:root {
  color-scheme: light;
  --bg: #f5f4fb;
  --surface: #fff;
  --subtle: #efedf7;
  --text: #201e2b;
  --muted: #5e596e;
  --line: #dcd7e8;
  --primary: #51429a;
  --on-primary: #fff;
  --lavender: #e5ddff;
  --on-lavender: #332270;
  --peach: #ffdfce;
  --on-peach: #672d1e;
  --green: #d8f0e4;
  --on-green: #20583e;
  --red: #ffdedf;
  --on-red: #822a3a;
  --blue: #e0e8ff;
  --on-blue: #284380;
  --hero: #e7dfff;
  --hero-text: #292049;
  --hero-muted: #514568;
  --code: #2c2250;
  --code-text: #f2eaff;
  --code-muted: #c4afd9;
  --shadow: 0 12px 28px #40336d16;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-exit: cubic-bezier(.3, 0, .8, .15);
  --spring: cubic-bezier(.2, 1.45, .43, 1);
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14131c; --surface: #201e2a; --subtle: #2b2738; --text: #f0ecfa;
    --muted: #c4bbd2; --line: #494259; --primary: #d2c1ff; --on-primary: #2d1c62;
    --lavender: #413567; --on-lavender: #ecdeff; --peach: #57392f; --on-peach: #ffdfce;
    --green: #253f35; --on-green: #c0f1d7; --red: #522c38; --on-red: #ffdce2;
    --blue: #2e385d; --on-blue: #dce6ff; --hero: #342955; --hero-text: #f2eaff;
    --hero-muted: #ddd0ef; --code: #211a39; --code-text: #f2eaff; --code-muted: #c4afd9;
    --shadow: 0 12px 28px #0004;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14131c; --surface: #201e2a; --subtle: #2b2738; --text: #f0ecfa;
  --muted: #c4bbd2; --line: #494259; --primary: #d2c1ff; --on-primary: #2d1c62;
  --lavender: #413567; --on-lavender: #ecdeff; --peach: #57392f; --on-peach: #ffdfce;
  --green: #253f35; --on-green: #c0f1d7; --red: #522c38; --on-red: #ffdce2;
  --blue: #2e385d; --on-blue: #dce6ff; --hero: #342955; --hero-text: #f2eaff;
  --hero-muted: #ddd0ef; --code: #211a39; --code-text: #f2eaff; --code-muted: #c4afd9;
  --shadow: 0 12px 28px #0004;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
html { scrollbar-gutter: stable; }
button, textarea, input { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
a { color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
[hidden] { display: none !important; }
.skip { position: fixed; z-index: 4; top: -100px; left: 16px; padding: 12px; background: var(--surface); border-radius: 12px; }
.skip:focus { top: 12px; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; vertical-align: middle; }
.top { border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-inner, main, footer { width: min(1168px, calc(100% - 64px)); margin-inline: auto; }
.top-inner { min-height: 76px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 780; letter-spacing: -.04em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 15px; color: var(--on-primary); background: var(--primary); font: 700 15px/1 Consolas, monospace; letter-spacing: -.08em; }
.top nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link, .icon-button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border: 0; border-radius: 999px; text-decoration: none; font-weight: 650; transition: background .2s, color .2s, border-radius .28s var(--ease), scale .32s var(--spring); }
.nav-link { padding: 0 15px; color: var(--muted); }
.nav-link[aria-current]:not([aria-current="false"]) { color: var(--on-lavender); background: var(--lavender); }
.icon-button { width: 46px; flex: 0 0 46px; background: var(--subtle); }
.icon-button .icon { color: var(--text); }
.button { padding: 11px 22px; background: var(--primary); color: var(--on-primary); text-align: center; }
.button.secondary { background: var(--lavender); color: var(--on-lavender); }
.button.quiet { background: var(--subtle); color: var(--text); }
.button:disabled { background: var(--subtle); color: var(--muted); cursor: default; opacity: .72; }
button:not(:disabled), .button, .nav-link, a.tile, summary { touch-action: manipulation; }
:is(.button, .nav-link, .icon-button, .option, .number):not(:disabled) {
  position: relative;
  isolation: isolate;
  overflow: clip;
}
:is(.button, .nav-link, .icon-button, .option, .number):not(:disabled)::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  transition: opacity .24s var(--ease);
}
@media (hover: hover) {
  :is(.button, .nav-link, .icon-button, .option, .number):not(:disabled):hover::after { opacity: .08; }
}
:is(.button, .nav-link, .icon-button, .option, .number):not(:disabled):active::after { opacity: .15; transition-duration: .08s; }
:is(.button, .nav-link, .icon-button):not(:disabled):active { border-radius: 16px; scale: .965; transition-duration: .12s; }
main { flex: 1; padding-block: 28px 44px; }
footer { display: flex; gap: 12px; justify-content: space-between; padding-block: 18px calc(24px + env(safe-area-inset-bottom)); color: var(--muted); border-top: 1px solid var(--line); font-size: .875rem; }
footer span:first-child { font-weight: 760; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.14; letter-spacing: -.035em; overflow-wrap: anywhere; }
h1 { font-size: clamp(2.25rem, 5vw, 4.15rem); font-weight: 810; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 770; }
h3 { font-size: 1.3rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.section { margin-top: 34px; }
.section-heading { margin-bottom: 16px; }
.section-heading p { margin-top: 5px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span[aria-current] { color: var(--text); font-weight: 680; }
.hero { position: relative; isolation: isolate; display: grid; grid-template-columns: 1.14fr .86fr; align-items: center; gap: 18px; min-height: 354px; padding: clamp(24px, 4.6vw, 58px); overflow: hidden; border-radius: 40px; background: var(--hero); color: var(--hero-text); }
.hero.compact { min-height: 274px; }
.hero-content { position: relative; z-index: 1; }
.hero h1 { margin-top: 14px; max-width: 11ch; }
.hero p { max-width: 43ch; margin-top: 14px; color: var(--hero-muted); font-size: 1.08rem; }
.hero .button { margin-top: 23px; }
.pill { display: inline-flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; border-radius: 999px; padding: 6px 12px; background: var(--lavender); color: var(--on-lavender); font-size: .875rem; font-weight: 680; }
.pill .icon { width: 17px; height: 17px; }
.hero .pill { background: var(--surface); color: var(--on-lavender); }
.art { position: relative; display: grid; place-items: center; min-width: 0; min-height: 235px; }
.art::before, .art::after { position: absolute; content: ""; pointer-events: none; }
.art::before { width: 204px; height: 204px; right: 0; top: -7px; border-radius: 37% 63% 65% 35% / 49% 37% 63% 51%; background: #a594e87d; transform: rotate(18deg); }
.art::after { width: 114px; height: 114px; left: 2px; bottom: -4px; background: var(--peach); border-radius: 35% 64% 38% 67%; transform: rotate(-19deg); }
.code-art { position: relative; z-index: 1; width: min(100%, 322px); background: var(--code); color: var(--code-text); padding: 15px 20px 20px; border: 1px solid #ffffff25; border-radius: 25px; box-shadow: 0 17px 30px #24154040; transform: rotate(-5deg); }
.code-bar { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-bottom: 1px solid #ffffff31; padding-bottom: 11px; font: .875rem/1.4 Consolas, monospace; color: var(--code-muted); }
.code-dots { display: flex; gap: 4px; }
.code-dots i { width: 7px; height: 7px; border-radius: 50%; background: #9d88bf; }
.code-dots i:first-child { background: #f6bcaa; }
.code-art pre { background: transparent; padding: 0; margin: 14px 0 0; color: inherit; font-size: .9rem; overflow: visible; }
.code-art .syntax { color: #f9bfab; }
.code-art .literal { color: #c9db9a; }
.spark { position: absolute; z-index: 2; top: 4px; right: 5px; font: 55px/1 system-ui; color: var(--on-lavender); }
.home-grid, .mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel, .tile { border: 1px solid var(--line); border-radius: 28px; background: var(--surface); padding: clamp(18px, 3vw, 30px); min-width: 0; }
.tile { display: flex; flex-direction: column; align-items: start; gap: 12px; text-decoration: none; color: var(--text); transition: translate .28s var(--ease), scale .32s var(--spring), border-radius .28s var(--ease), box-shadow .28s; }
.tile:focus-visible { box-shadow: var(--shadow); }
@media (hover: hover) {
  :is(a.tile, .mode-grid .tile):hover { translate: 0 -4px; border-radius: 34px; box-shadow: var(--shadow); }
  :is(a.tile, .mode-grid .tile):hover .tile-icon { rotate: -5deg; border-radius: 22px; }
}
a.tile:active { translate: 0 0; scale: .985; border-radius: 23px; }
.tile-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 18px; background: var(--lavender); color: var(--on-lavender); transition: rotate .32s var(--spring), border-radius .25s var(--ease); }
.tone-peach { background: var(--peach); color: var(--on-peach); }
.tone-green { background: var(--green); color: var(--on-green); }
.tone-blue { background: var(--blue); color: var(--on-blue); }
.tone-red { background: var(--red); color: var(--on-red); }
.tile p, .stack p { max-width: 65ch; }
.tile-action { display: inline-flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 3px; font-weight: 700; color: var(--primary); }
.stats { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 14px 0; }
.stats div { display: grid; }
.stats strong { font-size: 1.45rem; line-height: 1.25; }
.stats span { color: var(--muted); font-size: .875rem; }
.progress { height: 9px; width: 100%; background: var(--subtle); border-radius: 99px; overflow: hidden; }
.progress div { background: var(--primary); height: 100%; border-radius: inherit; transform: scaleX(var(--progress, 0)); transform-origin: left center; }
.progress-text { margin-top: 8px; }
.stack { display: grid; gap: 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.attempt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; align-items: start; gap: 16px; }
.attempt-layout > * { min-width: 0; }
.attempt-header { margin-bottom: 16px; }
.attempt-header h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); }
.attempt-header .progress { margin-top: 12px; }
.question-panel { display: grid; gap: 16px; }
.question-panel h2 { font-size: clamp(1.32rem, 3vw, 1.85rem); }
.key { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px; background: var(--surface); font-weight: 730; transition: background .22s, color .22s, border-radius .25s var(--ease); }
.options { display: grid; gap: 8px; }
.option { width: 100%; display: flex; gap: 12px; align-items: center; min-height: 54px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 17px; background: var(--subtle); transition: background .22s, color .22s, border-color .22s, scale .28s var(--spring); }
.option span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (hover: hover) {
  .option:not(:disabled):hover { border-color: var(--primary); }
}
.option:not(:disabled):active { scale: .986; transition-duration: .12s; }
.option:disabled { opacity: 1; cursor: default; }
.option.selected { background: var(--lavender); color: var(--on-lavender); border-color: var(--primary); }
.option.selected .key { background: var(--primary); color: var(--on-primary); border-radius: 50%; }
.option.correct, .feedback.correct { background: var(--green); color: var(--on-green); }
.option.wrong, .feedback.wrong { background: var(--red); color: var(--on-red); }
.feedback { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; font-weight: 680; }
details { border: 1px solid transparent; border-radius: 16px; background: var(--subtle); padding: 0 14px; transition: border-color .22s, background .22s; }
details[open] { border-color: var(--line); }
summary { display: flex; align-items: center; gap: 9px; min-height: 48px; padding-block: 10px; list-style: none; font-weight: 700; overflow-wrap: anywhere; }
summary::-webkit-details-marker { display: none; }
summary::before { content: ""; flex: 0 0 8px; width: 8px; height: 8px; margin-inline: 1px 4px; border-right: 2px solid; border-bottom: 2px solid; rotate: -45deg; transition: rotate .25s var(--ease); }
details[open] > summary::before { rotate: 45deg; }
details:not([open]) > summary .when-open,
details[open] > summary .when-closed { display: none; }
details > div { padding-bottom: 15px; }
@supports (interpolate-size: allow-keywords) and selector(::details-content) {
  details::details-content { interpolate-size: allow-keywords; block-size: 0; overflow: clip; contain: layout; opacity: 0; }
  details[open]::details-content { block-size: auto; opacity: 1; }
  details[data-interactive]::details-content {
    transition: block-size .28s var(--ease), opacity .19s var(--ease), content-visibility .28s allow-discrete, display .28s allow-discrete;
  }
}
@supports not ((interpolate-size: allow-keywords) and selector(::details-content)) {
  details[data-interactive][open] > div { animation: study-enter .24s var(--ease) both; }
}
.number-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 5px; margin-top: 12px; }
.number { min-height: 44px; border: 1px solid transparent; border-radius: 12px; background: var(--subtle); font-size: .9rem; font-weight: 650; transition: background .22s, scale .26s var(--spring); }
.number:not(:disabled):active { scale: .9; transition-duration: .12s; }
.number[aria-current] { border-color: var(--primary); outline: 1px solid var(--primary); }
.number.ok { background: var(--green); color: var(--on-green); }
.number.no { background: var(--red); color: var(--on-red); }
.number:disabled { opacity: .55; cursor: default; }
pre, .code-field { padding: 12px 14px; border-radius: 13px; background: var(--subtle); margin: 0; overflow: auto; font: .94rem/1.55 Consolas, "Courier New", monospace; tab-size: 4; }
.cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cases div, .case-check { min-width: 0; }
.field { display: grid; gap: 6px; font-weight: 650; }
.field textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--subtle); }
.field .case-output { min-height: 54px; }
.draft-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.case-check { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.grade-list { display: grid; gap: 6px; }
.radio-card { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.radio-card input { width: 21px; height: 21px; accent-color: var(--primary); flex: 0 0 auto; }
.result-number { color: var(--primary); font-size: clamp(2.4rem, 8vw, 4.2rem); font-weight: 800; line-height: 1; }
.result-list { display: grid; gap: 8px; }
.split { justify-content: space-between; }

[data-motion="page"] #main,
[data-motion="result"] #main { view-transition-name: study-page; }
[data-motion="step"] .question-panel { view-transition-name: study-step; }
:root[data-motion] { --entry-x: 16px; --exit-x: -9px; --entry-y: 0px; --exit-y: 0px; }
:root[data-motion="page"] { --entry-x: 0px; --exit-x: 0px; --entry-y: 12px; --exit-y: -7px; }
:root[data-motion="result"] { --entry-x: 0px; --exit-x: 0px; --entry-y: 19px; --exit-y: -9px; }
:root[data-motion="step"][data-direction="back"] { --entry-x: -16px; --exit-x: 9px; }
:root[data-motion="page"][data-direction="back"] { --entry-y: -9px; --exit-y: 7px; }
::view-transition { pointer-events: none; }
::view-transition-group(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(root) { display: none; }
::view-transition-group(study-page), ::view-transition-group(study-step) { animation: none; }
::view-transition-old(study-page), ::view-transition-old(study-step) { animation: study-exit .14s var(--ease-exit) both; }
::view-transition-new(study-page), ::view-transition-new(study-step) { animation: study-enter .28s var(--ease) both; }
::view-transition-old(study-page), ::view-transition-new(study-page),
::view-transition-old(study-step), ::view-transition-new(study-step) { mix-blend-mode: normal; }
@keyframes study-enter {
  from { opacity: 0; translate: var(--entry-x, 0px) var(--entry-y, 8px); }
  to { opacity: 1; translate: 0 0; }
}
@keyframes study-exit {
  to { opacity: 0; translate: var(--exit-x) var(--exit-y); }
}
@media (max-width: 820px) {
  .top-inner, main, footer { width: calc(100% - 40px); }
  .attempt-layout { grid-template-columns: minmax(0, 1fr); }
  .attempt-layout aside { padding: 18px; }
}
@media (max-width: 600px) {
  .top-inner, main, footer { width: calc(100% - 28px); }
  .top-inner { gap: 5px; min-height: 64px; }
  .brand { font-size: 18px; gap: 6px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 12px; }
  .nav-link { padding: 0 8px; font-size: .875rem; }
  .icon-button { width: 44px; flex-basis: 44px; }
  main { padding-top: 16px; }
  .hero { grid-template-columns: 1fr; padding: 22px; border-radius: 28px; gap: 8px; }
  .hero.compact { min-height: 0; }
  .hero.compact .art { display: none; }
  .hero h1 { max-width: 13ch; }
  .hero p { font-size: 1rem; }
  .art { min-height: 180px; margin: 6px 5px 4px; }
  .art::before { width: 146px; height: 146px; }
  .art::after { width: 77px; height: 77px; }
  .spark { font-size: 42px; }
  .code-art { width: min(93%, 300px); padding: 10px 14px 12px; }
  .code-art pre { font-size: clamp(.69rem, 3.5vw, .9rem); }
  .home-grid, .mode-grid { grid-template-columns: minmax(0, 1fr); }
  footer { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  details[data-interactive]::details-content { transition: none; }
  :is(.button, .nav-link, .icon-button, .option, .number, a.tile):active,
  :is(a.tile, .mode-grid .tile):hover,
  :is(a.tile, .mode-grid .tile):hover .tile-icon { scale: none; translate: none; rotate: none; }
}
