:root {
  color-scheme: light;
  --stage: #101e23;
  --outer: #0c1519;
  --night: #17292e;
  --night-line: #34454b;
  --lime: #d7f990;
  --paper: #f6f6f0;
  --cell: #fcfcf8;
  --ink: #16272a;
  --muted: #536565;
  --line: #d4dbd2;
  --accent: #285f53;
  --pad: clamp(14px, 5vw, 22px);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  font-family: "Inter", "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  background: var(--outer);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; font-size: 16px; line-height: 1.6; }
h1, h2, h3, p, figure, blockquote { margin: 0; }
button, input, output { font: inherit; }
button { color: inherit; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid #7d87e6; outline-offset: 2px; }
summary { cursor: pointer; }
.visually-hidden { display: block; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pocket-app {
  width: min(100%, 448px); margin-inline: auto; min-height: 100vh; min-height: 100svh;
  background: var(--stage); padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 0 0 1px #ffffff0e;
}
.shell, .app-header {
  padding-left: max(var(--pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--pad), env(safe-area-inset-right, 0px));
}
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: calc(62px + env(safe-area-inset-top, 0px));
  padding-top: calc(9px + env(safe-area-inset-top, 0px)); padding-bottom: 9px;
  color: #fbfdf8; background: var(--stage); border-bottom: 1px solid var(--night-line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; font-weight: 720; line-height: 1.23; letter-spacing: .045em; }
.brand small { color: #b7c5c2; font-size: 12px; line-height: 1.3; letter-spacing: .08em; margin-top: 2px; }
.brand-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--lime); }
.brand-icon i { position: relative; width: 19px; height: 18px; border: 1.5px solid #263e32; border-top-style: dashed; border-radius: 2px 2px 5px 5px; }
.brand-icon i::after { content: ""; position: absolute; width: 12px; height: 2px; left: 2px; top: 7px; background: #263e32; transform: rotate(-9deg); }
.attribution { color: #c8d2ce; font-size: 12px; white-space: nowrap; }
.attribution::before { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 6px 2px 0; background: var(--lime); border-radius: 50%; }
#capture-page { color: #f6f8f1; }
.capture-layout { display: flex; flex-direction: column; gap: 15px; padding-block: 19px 13px; }
.hero-copy .principle, .result-heading .principle { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 680; letter-spacing: .14em; }
.principle::before { content: ""; width: 17px; height: 1px; background: currentColor; }
.hero-copy .principle { color: var(--lime); }
.hero-copy h1 { display: flex; flex-wrap: wrap; margin: 6px 0 5px; font-size: clamp(25px, 7.35vw, 32px); font-weight: 720; letter-spacing: -.047em; line-height: 1.29; }
.hero-copy h1 span:last-child { color: #d5efa0; }
.hero-copy p { color: #c1ceca; font-size: clamp(12px, 3.6vw, 14px); }
.capture-stage {
  display: grid; grid-template-rows: 32px minmax(0, 1fr) 31px;
  position: relative; isolation: isolate; overflow: hidden; margin: 0;
  height: clamp(182px, 53vw, 220px); border: 1px solid #53646a; border-radius: 18px;
  background: radial-gradient(72% 120% at 46% 48%, #364953, #20343b 76%, #1b2b31);
}
.capture-stage::before {
  content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none;
  background: linear-gradient(#95c0bd12 1px,transparent 1px), linear-gradient(90deg,#95c0bd12 1px,transparent 1px);
  background-size: 18px 18px; mask-image: linear-gradient(to right, #0006, #000 22%, #000 78%, #0006);
}
.stage-bar, .stage-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; z-index: 1; padding-inline: 12px; }
.stage-bar { font-size: 11px; color: #dce7e1; }
.stage-bar > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.stage-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); }
#stage-counter, #stage-footnote { color: #c2cdcb; font-size: 11px; font-variant-numeric: tabular-nums; }
.stage-footer { border-top: 1px solid #c0d6d022; background: #0d1d2466; }
.stage-footer strong { font-size: 12px; font-weight: 590; }
.finder, .camera-view { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.finder { margin: 0 12% 7px; }
.finder::after, .guide-corners {
  --corner: #c7dea1;
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(var(--corner),var(--corner)) top left/14px 1px,
              linear-gradient(var(--corner),var(--corner)) top left/1px 14px,
              linear-gradient(var(--corner),var(--corner)) top right/14px 1px,
              linear-gradient(var(--corner),var(--corner)) top right/1px 14px,
              linear-gradient(var(--corner),var(--corner)) bottom left/14px 1px,
              linear-gradient(var(--corner),var(--corner)) bottom left/1px 14px,
              linear-gradient(var(--corner),var(--corner)) bottom right/14px 1px,
              linear-gradient(var(--corner),var(--corner)) bottom right/1px 14px;
  background-repeat: no-repeat;
}
.paper { height: 90%; aspect-ratio: 1; position: relative; padding: 6px; background: #fbf9ed; border-radius: 2px; box-shadow: 1px 8px 13px #08131782; transform: rotate(-3deg); }
.paper::before { content: ""; position: absolute; inset: 0; border-radius: 2px; background: #c3cabb; z-index: -1; transform: translate(4px,3px) rotate(4deg); }
.paper-crop { position: relative; width: 100%; height: 100%; overflow: hidden; background: white; }
.paper img { position: absolute; width: 222%; height: auto; max-width: none; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.camera-view { background: #0a1419; overflow: hidden; }
.camera-view video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.guide-corners { inset: 6%; }
#capture-page[data-live=true] .hero-copy, #capture-page[data-live=true] .examples { display: none; }
#capture-page[data-live=true] .capture-layout { padding-top: 13px; gap: 12px; }
#capture-page[data-live=true] .capture-stage { height: clamp(223px, 54vh, 560px); height: clamp(223px, 54svh, 560px); }
#capture-page[data-live=true] .input-card { position: sticky; bottom: 0; z-index: 3; background: var(--stage); padding-block: 3px max(6px, env(safe-area-inset-bottom, 0px)); }
#capture-stage[data-recording=true] .stage-dot { background: #ff766e; box-shadow: 0 0 0 3px #ff766e33; }
.input-card { min-width: 0; color: #f5f8f1; }
.mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid #3b4e52; border-radius: 14px; background: #192a30; }
.mode-options button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 10px; background: transparent; color: #b8c8c7; font-size: 15px; }
.mode-options button[aria-pressed=true] { background: #33474a; color: white; box-shadow: inset 0 0 0 1px #607679; font-weight: 650; }
.icon { display: inline-block; position: relative; flex: none; width: 18px; height: 14px; font-style: normal; }
.icon-photo { border: 1.5px solid currentColor; border-radius: 4px; }
.icon-photo::before { content: ""; position: absolute; left: 4px; top: -3px; width: 6px; height: 2px; background: currentColor; border-radius: 2px; }
.icon-photo::after { content: ""; position: absolute; width: 5px; height: 5px; left: 4px; top: 2px; border-radius: 50%; border: 1.5px solid currentColor; }
.icon-video { width: 14px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; margin-right: 3px; }
.icon-video::after { content: ""; position: absolute; left: 12px; top: 1px; border-block: 3.5px solid transparent; border-right: 4px solid currentColor; }
.icon-album { width: 16px; height: 15px; border: 1.5px solid currentColor; border-radius: 3px; overflow: hidden; }
.icon-album::before { content: ""; position: absolute; width: 8px; height: 8px; bottom: -4px; left: 4px; transform: rotate(45deg); border: 1px solid currentColor; }
.icon-album::after { content: ""; position: absolute; width: 3px; height: 3px; top: 2px; left: 2px; background: currentColor; border-radius: 50%; }
#mode-tip { margin: 9px 2px 14px; color: #cad4cf; font-size: 14px; line-height: 1.55; }
.capture-actions { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); gap: 5px 8px; }
.primary, .secondary { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 48px; border-radius: 13px; padding: 7px 8px; font-size: 15px; font-weight: 620; }
.primary { background: var(--lime); color: #203326; }
.primary:disabled { opacity: .66; }
.capture-actions .secondary:disabled { opacity: .47; }
.secondary { background: #25373b; color: #f0f3ed; border: 1px solid #45585c; }
.capture-actions .primary:active:not(:disabled) { background: #b5d878; }
.capture-actions .secondary:active { background: #354a4c; }
.capture-actions .shutter { display: inline-block; margin: 0; width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 50%; }
.capture-actions .shutter::before { content: ""; position: absolute; inset: 3px; width: auto; height: auto; background: currentColor; border: 0; border-radius: 50%; }
.capture-actions .shutter::after { display: none; }
#capture-page[data-phase=recording] .shutter::before { border-radius: 2px; }
.text-button { grid-column: 1 / -1; justify-self: center; min-height: 44px; padding: 5px 11px; color: #d9e3d2; background: transparent; text-decoration: underline; text-underline-offset: 4px; font-size: 13px; }
#input-status { margin: 8px 2px 0; font-size: 14px; color: #dae9e0; }
#input-status[data-error=true] { color: #ffc2ab; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; color: #aabcb7; font-size: 12px; border-top: 1px solid var(--night-line); }
.examples > span { margin-right: auto; }
.example-action { min-height: 44px; padding: 5px 0 5px 4px; font-weight: 600; color: #e3ede1; background: none; font-size: 13px; }

body[data-screen=results] .pocket-app { background: var(--paper); }
#result-page { padding-block: 20px max(22px, env(safe-area-inset-bottom, 0px)); }
.result-heading, .group-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.result-heading { margin-bottom: 13px; }
.result-heading .principle { color: var(--accent); }
.result-heading h1 { margin: 4px 0 2px; font-size: 29px; line-height: 1.4; letter-spacing: -.045em; }
#result-meta { color: var(--muted); font-size: 12px; }
.compact { min-height: 44px; padding: 5px 10px; border: 1px solid #bfcac1; border-radius: 12px; color: #25473d; background: var(--cell); font-size: 13px; white-space: nowrap; }
.compact .icon-photo { transform: scale(.9); }
.notices { border-left: 2px solid #59816e; padding: 7px 9px; margin: 10px 0 12px; background: #e9efe6; color: #425b50; border-radius: 0 6px 6px 0; font-size: 12px; }
.notices p + p { margin-top: 4px; }
.notices summary { align-content: center; min-height: 36px; font-weight: 620; }
.notices details[open] p { padding: 1px 0 5px; }
.group-bar { margin: 0 0 7px; }
h2 { font-size: 18px; line-height: 1.45; font-weight: 690; letter-spacing: -.035em; }
.navigation { display: flex; align-items: center; justify-content: end; flex: none; }
.navigation output { min-width: 39px; text-align: center; color: #566862; font: 12px/1.4 var(--mono); font-variant-numeric: tabular-nums; }
.arrow { width: 44px; height: 44px; display: grid; place-items: center; position: relative; z-index: 0; border-radius: 50%; color: #20463d; background: transparent; font: inherit; font-size: 12px; font-weight: 620; }
.arrow::before { content: ""; position: absolute; inset: 5px; z-index: -1; background: var(--cell); border: 1px solid #c3cfc4; border-radius: 50%; }
.arrow:disabled { color: #98a69f; }
.arrow:disabled::before { background: transparent; border-color: #d6ddd3; }
#results, .demo-view { touch-action: pan-y pinch-zoom; }
.three-col { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: clamp(5px, 1.8vw, 8px); align-items: stretch; }
.result-tile { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--cell); }
.result-crop { display: grid; place-items: center; aspect-ratio: 1.16; overflow: hidden; padding: 5px; background: #ebeee6; }
.result-crop img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.no-crop { color: var(--muted); font-size: 11px; }
.tile-meta { padding: 6px 7px 9px; line-height: 1.4; overflow-wrap: anywhere; }
.tile-label { display: block; color: #243c32; font-size: 14px; font-weight: 680; }
.tile-label .slot { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; font-weight: 450; }
.score { display: block; margin-top: 4px; font-size: 14px; line-height: 1.45; color: var(--accent); font-weight: 650; }
.score[data-ungraded=true] { color: var(--muted); font-weight: 520; }
.score b { color: #1d4f3c; font: 690 16px/1.4 var(--mono); letter-spacing: -.035em; }
.feedback { margin-top: 17px; }
.feedback h3 { margin-bottom: 5px; color: #22392e; font-size: 15px; line-height: 1.45; font-weight: 680; }
.feedback-cell { min-width: 0; padding: 7px 2px 0; border-top: 1px solid #bbc9bd; color: #33473e; font-size: 14px; line-height: 1.67; overflow-wrap: anywhere; }
.feedback-index { display: block; margin-bottom: 4px; color: #5b6f5e; font: 12px/1.5 var(--mono); }
.feedback-cell p + p { margin-top: 5px; }
.feedback-cell .unknown { color: #56685f; }
.node-practice { padding-block: 0 4px; scroll-margin-top: 12px; }
.node-practice + .node-practice { margin-top: 6px; padding-top: 8px; border-top: 1px dotted #bfccbf; }
.node-practice:focus { outline: 2px solid #50785e; outline-offset: 2px; border-radius: 4px; }
.node-label { display: block; color: #31563e; margin-bottom: 3px; font-size: 12px; line-height: 1.55; }
.other-lessons { margin-top: 3px; border-top: 1px dotted #c0c9bd; }
.other-lessons summary { padding: 10px 0; min-height: 40px; color: #486350; font-size: 12px; font-weight: 610; }
.comparison-only > .unknown { margin: 1px 0 6px; font-size: 12px; }
.practice-jump, .learn-link { min-height: 44px; width: 100%; text-align: left; color: #2b664e; font-size: 13px; line-height: 1.45; font-weight: 650; }
.practice-jump { background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.learn-link { border-radius: 6px; background: #e7eee2; padding: 4px 5px; margin-top: 5px; }
.demo-section { border-top: 1px solid #b9c8b9; padding-top: 12px; margin-top: 21px; }
.lesson-player { overflow: hidden; border: 1px solid #afbeb1; border-radius: 14px; background: var(--cell); }
.lesson-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 7px; padding: 7px 10px; color: #eef4ed; background: #1e3335; }
.lesson-toolbar strong { font-size: 12px; line-height: 1.45; }
.lesson-modes { display: inline-flex; gap: 4px; }
.lesson-modes button { min-height: 44px; padding: 4px 6px; border: 1px solid #5b706e; border-radius: 8px; color: #d8e3dd; background: transparent; font-size: 12px; }
.lesson-modes button[aria-pressed=true] { border-color: var(--lime); color: #243824; background: var(--lime); font-weight: 640; }
.player-context { padding: 5px 10px; background: #e8eee1; color: #435b49; font-size: 12px; }
.demo-view { position: relative; isolation: isolate; display: grid; place-items: center; overflow: hidden; width: 100%; aspect-ratio: 16/9; background: #14242a; color: white; }
.demo-view > img, .demo-view > video { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.play { position: relative; min-height: 44px; border: 1px solid #f2f5edbd; border-radius: 50px; padding: 6px 15px; background: #182c2be6; color: #f4f7eb; font-size: 14px; font-weight: 650; }
.demo-error { position: relative; padding: 5px 9px; background: #182c2be6; color: white; font-size: 13px; }
.lesson-source, .source-details, .demo-picker { font-size: 13px; color: #46604d; }
.lesson-source { border-top: 1px solid var(--line); padding-inline: 11px; }
.lesson-source > summary, .source-details > summary, .demo-picker > summary { min-height: 44px; align-content: center; padding-block: 9px; }
.lesson-source p { margin-block: 2px 6px; font: 11px/1.7 var(--mono); }
.lesson-source strong { font-size: 12px; }
.lesson-source blockquote { padding-left: 8px; border-left: 2px solid #98afa0; margin: 3px 0 9px; }
.demo-picker { margin-top: 6px; }
.demo-list { display: grid; gap: 4px; }
.demo-choice { display: flex; gap: 8px; align-items: center; text-align: left; width: 100%; min-height: 44px; padding: 6px 9px; color: #47614b; font-size: 13px; border-radius: 6px; background: transparent; }
.demo-choice span { white-space: nowrap; font: 11px/1.5 var(--mono); }
.demo-choice[aria-pressed=true] { background: #e2ebdf; color: #23563d; font-weight: 650; }
.demo-choice small { display: block; font-size: 11px; color: #526c58; font-weight: 460; }
.empty-demo { color: var(--muted); font-size: 13px; }
.source-details { margin: 14px 0 2px; border-top: 1px solid var(--line); }
#source-preview img, #source-preview video { display: block; max-width: 100%; max-height: 68vh; margin: 5px auto 0; object-fit: contain; background: white; }
@media (min-height: 700px) {
  #capture-page[data-live=false] .capture-stage { height: clamp(207px, calc(100vh - 490px), 344px); height: clamp(207px, calc(100svh - 490px), 344px); }
}
@media (max-height: 660px) {
  .capture-layout { gap: 11px; padding-top: 12px; }
  .capture-stage { height: 161px; }
  #capture-page[data-live=true] .capture-stage { height: 45vh; height: 45svh; min-height: 171px; }
  #mode-tip { margin-block: 6px 9px; }
}
@media (max-width: 345px) {
  .app-header { min-height: calc(56px + env(safe-area-inset-top, 0px)); }
  .brand strong { font-size: 16px; }
  .feedback-cell { padding-inline: 1px; }
  .primary, .secondary { font-size: 14px; gap: 6px; }
  .compact { font-size: 12px; }
}
