:root {
  color-scheme: dark;
  --bg: #303034;
  --panel: #414146;
  --panel-dark: #26262b;
  --ink: #ffae54;
  --bright: #ffe0ad;
  --muted: #d2a276;
  --border: #a1836b;
  --green: #b9e3aa;
  --red: #ff9a94;
  --shadow: #17171a;
  --focus: #fff1c7;
  font-family: "Courier New", Courier, monospace;
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button {
  min-height: 44px;
  padding: .66rem .85rem;
  border: 2px outset #c4a081;
  border-radius: 2px;
  background: #6b5849;
  color: #ffe8c5;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .02em;
}
button:hover { filter: brightness(1.12); }
button:active { border-style: inset; transform: translate(1px, 1px); }
button:disabled { cursor: not-allowed; opacity: .52; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.secondary { background: #38383c; }
.danger { color: var(--red); }
.compact { min-height: 40px; padding: .45rem .7rem; }
.selected { border-style: inset; background: #b87536; color: #181818; }
.screen { width: min(100% - 1.25rem, 1080px); margin-inline: auto; padding: 1rem 0 3.5rem; }
.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 10; transform: translateY(-150%); background: #fff1c7; color: #17171a; padding: .65rem; }
.skip-link:focus { transform: translateY(0); }
.top {
  margin-bottom: 1.15rem;
  padding: 1rem;
  border: 3px solid #ad896d;
  background: linear-gradient(150deg, #47474c, #303034);
  box-shadow: 5px 5px 0 var(--shadow);
}
.brand { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.2rem); letter-spacing: .1em; line-height: 1; text-shadow: 2px 2px #0f0e0d; }
.apple {
  font-size: 2rem;
  background: linear-gradient(180deg, #74c6fa 0 20%, #a5db9b 20% 40%, #f8dc6d 40% 60%, #f4a359 60% 80%, #d989b1 80%);
  background-clip: text;
  color: transparent;
}
.cursor { animation: blink 1.1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.tagline { margin: .42rem 0 0; color: var(--bright); font-size: clamp(.73rem, 2vw, .9rem); letter-spacing: .04em; }
.toolbar, .actions, .chips, .row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.toolbar { justify-content: space-between; margin-top: .9rem; }
.row { justify-content: space-between; }
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; margin-bottom: .9rem; }
.tabs button { min-width: 0; }
.panel { margin: .75rem 0; padding: clamp(.9rem, 3vw, 1.35rem); border: 2px solid #9f816c; background: var(--panel); box-shadow: 4px 4px 0 #1b1b1d; }
.panel h2 { margin: 0 0 .8rem; color: var(--bright); font-size: clamp(1.25rem, 4vw, 1.55rem); }
.panel h3 { margin: .6rem 0; color: var(--bright); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.eyebrow { margin: 0 0 .2rem; color: var(--muted); font-size: .78rem; }
.disk { display: grid; place-items: center; width: 3.2rem; aspect-ratio: 1; flex: 0 0 auto; border: 3px solid var(--bright); border-radius: 5px; color: var(--bright); font-size: 1.5rem; font-weight: 700; box-shadow: inset 0 0 0 5px var(--panel-dark); }
.tiny { font-size: .78rem; color: var(--muted); }
.small { font-size: .9rem; }
.lead { color: var(--bright); font-size: 1.05rem; }
.stats, .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lesson-manager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .8rem; align-items: end; }
.lesson-actions { grid-column: 1 / -1; }
label { display: block; margin: .75rem 0 .35rem; color: var(--bright); font-size: .86rem; font-weight: 700; }
input, textarea, select { width: 100%; min-height: 44px; padding: .65rem; border: 2px inset #826d5b; border-radius: 0; background: #252529; color: #ffd092; }
textarea { min-height: 6rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: #b98c6b; opacity: 1; }
.form-actions { margin-top: .75rem; }
.flash { display: flex; min-height: 8.7rem; flex-direction: column; justify-content: center; gap: .4rem; padding: 1.15rem; border: 2px solid #9f816c; background: #29292e; overflow-wrap: anywhere; }
.question-flash { margin: .7rem 0 1rem; }
.prompt { color: #ffe0ac; font-size: clamp(1.3rem, 4vw, 2rem); }
.pill { padding: .2rem .5rem; border: 1px solid #997c63; font-size: .78rem; }
.correct { color: var(--green); }
.wrong { color: var(--red); }
.card-list { margin-top: .7rem; }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .7rem; align-items: center; padding: .75rem .1rem; border-bottom: 1px dotted #8c7463; }
.entry span { overflow-wrap: anywhere; }
.progress { height: .9rem; margin: .8rem 0; border: 1px solid #997c63; background: #232329; }
.progress > div { width: 0; height: 100%; background: #f5a457; transition: width .2s; }
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; margin: .8rem 0; }
.options button { min-height: 4rem; text-align: left; overflow-wrap: anywhere; }
.results { margin-top: .8rem; }
.review-list { margin: 1rem 0; }
.review-item { padding: .65rem; border-bottom: 1px dotted var(--border); }
.review-item p { margin: .2rem 0; }
.chatlog { min-height: 12rem; max-height: 24rem; padding: .7rem; overflow: auto; border: 2px inset #826d5b; background: #252529; }
.bubble { margin: .6rem 0; padding: .65rem .75rem; border-left: 3px solid #d89c5f; background: #36363b; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { border-color: #f3dc9b; background: #454039; }
.privacy-note { display: grid; gap: .25rem; margin: .8rem 0; padding: .75rem; border: 1px dashed var(--border); color: var(--muted); font-size: .82rem; }
.privacy-note strong { color: var(--bright); }
.foot { display: flex; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-top: 1.8rem; color: #b59275; font-size: .75rem; }
.noscript { max-width: 40rem; margin: 2rem auto; padding: 1rem; border: 2px solid var(--red); }
hr { margin: 1.15rem 0; border: 0; border-top: 1px dotted var(--border); }
.hide { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .grid, .stats, .lesson-manager { grid-template-columns: 1fr; }
  .entry { grid-template-columns: minmax(0, 1fr) auto; }
  .entry .entry-answer { grid-column: 1; }
  .entry .actions { grid-column: 2; grid-row: 1 / span 2; flex-direction: column; align-items: stretch; }
  .options { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .screen { width: min(100% - .75rem, 1080px); padding-top: .4rem; }
  .top, .panel { box-shadow: 2px 2px 0 var(--shadow); }
  .brand h1 { letter-spacing: .04em; }
  .tabs button { padding-inline: .35rem; font-size: .78rem; }
  .actions > button { flex: 1 1 100%; }
  .entry .actions > button { flex-basis: auto; }
  .disk { width: 2.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  button, input, textarea, select, .panel, .top, .flash { border: 2px solid ButtonText; }
}
