:root {
  color-scheme: light;
  --bg: #fdfcf7;
  --ink: #151515;
  --muted: #69665f;
  --line: #c9c3b4;
  --accent: #2f6f4e;
  --accent-2: #225c7a;
  --soft: #f5f1e8;
  --warn: #8b3d22;
  --shadow: rgba(35, 31, 24, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --receipt: "Courier New", "Lucida Console", "Roboto Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11110f;
  --ink: #eeeeea;
  --muted: #aaa496;
  --line: #514c42;
  --accent: #86cfa3;
  --accent-2: #9cc7d9;
  --soft: #1a1915;
  --warn: #f0a37f;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 32px 18px 132px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.62;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(100%, 680px);
  margin: 0 auto;
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.brand:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nav-link,
.theme-toggle {
  min-height: 32px;
  padding: 3px 10px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-transform: lowercase;
}

.nav-link:hover,
.nav-link:focus-visible,
.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

.terminal {
  width: 100%;
}

.ascii {
  overflow: auto;
  margin: 0 0 26px;
  color: var(--accent-2);
  font-size: clamp(11px, 2.7vw, 14px);
  line-height: 1.2;
  white-space: pre;
}

.screen {
  min-height: 420px;
}

.block {
  margin: 0 0 24px;
}

.line {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.ok {
  color: var(--accent);
}

.warn {
  color: var(--warn);
}

.prompt {
  margin: 22px 0 14px;
  font-weight: 700;
}

.question {
  margin: 10px 0 18px;
}

.quiz-meta {
  display: grid;
  gap: 2px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.quiz-meta p {
  margin: 0;
}

.meta-label {
  font-weight: 700;
}

.meta-name {
  color: var(--accent-2);
}

.meta-status {
  color: var(--accent-2);
}

.meta-question {
  color: var(--accent-2);
}

.progress-bar {
  color: var(--accent-2);
  font-size: 13px;
  line-height: 1;
  white-space: pre;
}

.spinner::before {
  display: inline-block;
  width: 1.25ch;
  color: var(--accent-2);
  content: "⠋";
  animation: spinner-cycle 0.78s steps(10, end) infinite;
}

.options {
  display: grid;
  gap: 10px;
  margin: 18px 0 22px;
}

.option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px dotted var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  text-align: left;
}

.option:hover,
.option:focus-visible {
  color: var(--accent);
  outline: none;
}

.option.is-picked {
  color: var(--accent);
}

.option.is-uncertain {
  color: var(--muted);
}

.option.is-uncertain.is-picked {
  color: var(--accent-2);
}

.letter {
  color: var(--accent-2);
  font-weight: 700;
}

.option-text {
  min-width: 0;
}

[data-stream-text].is-streaming::after {
  display: inline-block;
  width: 0.58em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.14em;
  background: var(--ink);
  content: "";
  animation: cursor-blink 0.82s linear infinite;
}

.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.08em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--ink);
  will-change: opacity;
  animation: cursor-blink 1.16s linear infinite;
}

@keyframes cursor-blink {
  0%,
  46% {
    opacity: 1;
  }

  47%,
  100% {
    opacity: 0;
  }
}

@keyframes spinner-cycle {
  0% {
    content: "⠋";
  }
  10% {
    content: "⠙";
  }
  20% {
    content: "⠹";
  }
  30% {
    content: "⠸";
  }
  40% {
    content: "⠼";
  }
  50% {
    content: "⠴";
  }
  60% {
    content: "⠦";
  }
  70% {
    content: "⠧";
  }
  80% {
    content: "⠇";
  }
  90%,
  100% {
    content: "⠏";
  }
}

.input-line {
  margin: 20px 0 8px;
}

.input-marker {
  color: var(--accent-2);
  font-weight: 700;
}

.name-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 10px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--soft);
}

.name-input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.name-input:focus {
  outline: none;
}

.name-line:focus-within {
  border-color: var(--accent-2);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.last-receipt {
  margin: 18px 0 0;
  padding: 12px 0 0;
  border-top: 1px dotted var(--line);
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.line-button {
  min-height: 30px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  text-transform: lowercase;
}

.line-button:hover,
.line-button:focus-visible {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

.result-title {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.25;
  text-align: center;
}

.result-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
}

.result-grid {
  display: grid;
  gap: 14px;
  margin: 16px 0 22px;
}

.result-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.result-section h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.printer-block {
  min-height: 300px;
}

.printer-art {
  overflow-x: auto;
  margin: 24px 0 20px;
  color: var(--accent-2);
  font-size: 14px;
  line-height: 1.2;
  white-space: pre;
}

.printer-dots::after {
  display: inline-block;
  width: 3ch;
  overflow: hidden;
  vertical-align: bottom;
  content: "...";
  animation: dot-cycle 1s steps(4, end) infinite;
}

@keyframes dot-cycle {
  0% {
    width: 0;
  }

  100% {
    width: 3ch;
  }
}

.receipt-paper {
  position: relative;
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 18px 18px 20px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, white);
  box-shadow: 0 8px 28px var(--shadow);
  font-family: var(--receipt);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

:root[data-theme="dark"] .receipt-paper {
  background: color-mix(in srgb, var(--bg) 90%, white 4%);
}

.receipt-paper::before,
.receipt-paper::after {
  display: block;
  width: 100%;
  overflow: hidden;
  color: var(--line);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  content: "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
}

.receipt-paper::before {
  margin: -8px 0 12px;
}

.receipt-paper::after {
  margin: 16px 0 -10px;
  transform: rotate(180deg);
}

.receipt-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.receipt-code {
  overflow-x: auto;
  margin: 0 auto 10px;
  color: var(--ink);
  font-size: clamp(16px, 4.8vw, 25px);
  font-weight: 700;
  line-height: 1.08;
  text-align: center;
  white-space: pre;
}

.receipt-face {
  overflow-x: auto;
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: clamp(15px, 4.4vw, 22px);
  line-height: 1.1;
  text-align: center;
  white-space: pre;
}

.receipt-stamp {
  width: max-content;
  max-width: 100%;
  margin: 0 auto 14px;
  padding: 3px 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  text-align: center;
  transform: rotate(-1deg);
}

.receipt-facts {
  display: grid;
  gap: 3px;
  margin: 0 0 18px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}

.receipt-facts div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: baseline;
}

.receipt-facts dt,
.receipt-facts dd {
  margin: 0;
}

.receipt-facts dt {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.receipt-facts dd {
  color: var(--ink);
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
}

.visualizer {
  overflow-x: auto;
  margin: 8px 0 0;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
}

.receipt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.receipt-tags span {
  padding: 2px 7px;
  border: 1px solid var(--line);
  color: var(--accent-2);
  font-size: 12px;
}

.receipt-footer {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.text-button {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.text-button:hover,
.text-button:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

.image-save-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

.image-save-panel {
  width: min(100%, 420px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 16px 50px var(--shadow);
}

.image-save-panel img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 12px;
  border: 1px solid var(--line);
}

.image-save-panel .text-button {
  width: 100%;
  margin-top: 12px;
}

.keypad {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 10;
  display: grid;
  width: min(calc(100% - 28px), 680px);
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 92%, white);
  box-shadow: 0 10px 32px var(--shadow);
  transform: translateX(-50%);
}

.keypad button {
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  text-transform: lowercase;
}

.keypad button[data-key="enter"] {
  color: var(--bg);
  background: var(--ink);
}

.keypad button.is-active {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
}

.keypad button.is-muted {
  opacity: 0.55;
}

.keypad button:hover,
.keypad button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.keypad button[data-key="enter"]:hover,
.keypad button[data-key="enter"]:focus-visible {
  color: var(--bg);
  background: var(--accent);
}

.keypad.is-hidden {
  display: none;
}

@media (min-width: 760px) {
  body {
    padding-top: 52px;
  }

  .keypad {
    position: static;
    margin: 12px auto 0;
    transform: none;
    box-shadow: none;
    background: transparent;
  }
}

@media (max-width: 520px) {
  body {
    padding: 22px 14px 132px;
    font-size: 15px;
  }

  .site-head {
    align-items: flex-start;
  }

  .screen {
    min-height: 360px;
  }

  .option {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .keypad {
    bottom: 10px;
    gap: 7px;
    padding: 8px;
  }

  .keypad button {
    min-height: 44px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor,
  .spinner::before,
  [data-stream-text].is-streaming::after,
  .printer-dots::after {
    animation: none;
  }
}

@media print {
  :root {
    --bg: #ffffff;
    --ink: #000000;
    --muted: #444444;
    --line: #000000;
    --accent: #000000;
    --accent-2: #000000;
    --shadow: transparent;
  }

  body {
    padding: 0;
    background: #ffffff;
  }

  .site-head,
  .ascii,
  .keypad,
  .actions,
  .image-save-modal,
  .hint {
    display: none;
  }

  .shell {
    width: 100%;
    margin: 0;
  }

  .screen {
    min-height: 0;
  }

  .receipt-paper {
    width: 72mm;
    margin: 0 auto;
    border: 0;
    box-shadow: none;
  }
}
