:root {
  color-scheme: light;
  --page: #f5f6f3;
  --stage: #e5eae8;
  --panel: #fafbf8;
  --ink: #223333;
  --muted: #526361;
  --line: #cfd8d3;
  --soft: #e3e9e5;
  --accent: #365c59;
  --action: var(--accent);
  --action-text: #fff;
  --accent-hover: #294b49;
  --focus: #297a79;
  --error: #9a3532;
  --overlay: #17252770;
  --shadow: #29413720;
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--page);
  color: var(--ink);
}
:root[data-theme="graphite"] {
  color-scheme: dark;
  --page: #1c2328;
  --stage: #36444d;
  --panel: #242d32;
  --ink: #e4eae8;
  --muted: #b2c0c1;
  --line: #46545a;
  --soft: #39464b;
  --accent: #b0c9c4;
  --action: #3b5555;
  --action-text: #edf4f2;
  --accent-hover: #496463;
  --focus: #aad9d3;
  --error: #ffc0b7;
  --overlay: #090f15ae;
  --shadow: #0a121a4d;
}
* { box-sizing: border-box; }
body, h1, h2, h3, p, figure { margin: 0; }
button, input, select { font: inherit; }
button, select {
  color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 13px; font-size: .91rem; font-weight: 550; cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
@media (hover:hover) {
  button:not(:disabled):hover, select:hover { background: var(--soft); }
  button.primary:not(:disabled):hover { background: var(--accent-hover); }
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button.primary { color: var(--action-text); background: var(--action); border-color: transparent; }
button.quiet { background: transparent; color: var(--accent); border-color: transparent; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mast { border-bottom: 1px solid var(--line); }
.mast-inner, main { max-width: 1460px; margin: auto; padding-inline: clamp(18px, 4vw, 64px); }
.mast-inner { min-height: 66px; display: flex; align-items: center; gap: clamp(20px, 4vw, 68px); }
.wordmark { display: flex; align-items: center; gap: 10px; font-size: 1.25rem; font-weight: 680; letter-spacing: -.055em; white-space: nowrap; }
.app-nav, .utilities, .stage-tools { display: flex; align-items: center; }
.app-nav { gap: 4px; }
.app-nav button, .utilities button, .focus-button, .stage-tools button, .work-footer button {
  background: transparent; border-color: transparent; color: var(--muted);
}
.app-nav [aria-current="page"] { color: var(--ink); background: var(--soft); }
.utilities { margin-left: auto; gap: 4px; }
.utilities .mobile-menu { display: none; }
.menu-list { display: grid; gap: 7px; }
.menu-list button { text-align: left; }
.utilities button, .focus-button, .stage-tools button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.theme-icon { width: 17px; height: 17px; border: 1.5px solid currentColor; border-radius: 100%; overflow: hidden; }
.theme-icon::after { content: ""; display: block; width: 50%; height: 100%; background: currentColor; }
[data-theme="graphite"] .theme-icon::after { margin-left: auto; }
main { padding-top: clamp(18px, 3vh, 44px); padding-bottom: 20px; }
.workspace {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(280px, 3fr);
  gap: clamp(15px, 2.1vw, 32px); align-items: start;
}
.stage, .coach { min-width: 0; border-radius: 18px; }
.stage { background: var(--stage); overflow: hidden; position: relative; }
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 20px 24px 0; }
.chapter p { font-size: .84rem; color: var(--muted); }
.chapter h1 { font-size: clamp(1.5rem, 2.4vw, 2.4rem); line-height: 1.16; letter-spacing: -.05em; font-weight: 590; }
.focus-button { font-size: .85rem; padding: 7px 10px; white-space: nowrap; }
.stage figure { position: relative; text-align: center; }
.stage figure::before {
  content: ""; position: absolute; width: 44%; left: 28%; height: 9%; bottom: 11%; pointer-events: none;
  background: radial-gradient(ellipse, var(--shadow), transparent 69%);
}
.stage canvas {
  position: relative; display: block; width: 100%; height: clamp(280px, calc(100svh - 295px), 590px);
  touch-action: none; -webkit-user-select: none; user-select: none; cursor: grab;
}
.stage canvas.holding { cursor: grabbing; }
.stage figcaption { position: relative; color: var(--muted); padding: 3px 12px 10px; }
.stage figcaption small { font-size: .86rem; }
#swipe-tip {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%); width: max-content;
  max-width: 92%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 4px 10px; font-size: .84rem; border-radius: 6px; pointer-events: none;
}
.stage-tools { width: fit-content; max-width: 100%; margin: 0 auto 18px; padding: 2px; justify-content: center; flex-wrap: wrap; }
.stage-tools button { font-size: .86rem; padding: 7px 12px; }
.stage-tools .icon { width: 16px; height: 16px; }
#peek { touch-action: none; user-select: none; }
#peek[aria-pressed=true] { background: var(--soft); border-color: var(--line); }
.coach { background: var(--panel); border: 1px solid var(--line); padding: clamp(17px, 2vw, 31px); align-self: center; }
.coach-head { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; font-size: .87rem; font-weight: 650; color: var(--muted); }
.coach-head small { margin-left: auto; font-weight: 450; font-size: .8rem; }
#coach-content { margin: 22px 0; }
.coach h2 { font-size: clamp(1.35rem, 1.8vw, 1.78rem); line-height: 1.2; letter-spacing: -.035em; font-weight: 620; text-wrap: balance; }
.coach p { margin-top: 9px; color: var(--muted); }
.coach .feedback { border-left: 2px solid var(--accent); padding-left: 9px; }
.sample { display: flex; align-items: center; gap: 3px; margin-bottom: 11px; }
.sample i { border: 1px solid #202b3c38; width: 19px; height: 19px; border-radius: 5px; background: var(--swatch); }
.sample .shape { color: var(--muted); font-size: .81rem; margin-left: 4px; }
.coach .notation { font-family: ui-monospace, monospace; font-size: .87rem; color: var(--accent); }
#coach-actions, .player { display: grid; gap: 8px; }
.practice-tools { border-top: 1px solid var(--line); margin-top: 3px; }
.practice-tools summary { cursor: pointer; padding: 10px 0; font-size: .88rem; color: var(--muted); }
.practice-tools > div { display: grid; gap: 6px; }
.player label { color: var(--muted); font-size: .88rem; }
.player input { width: 100%; }
.row, .choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > button { flex: 1; }
.work-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; font-size: .86rem; color: var(--muted); }
.work-footer button { text-decoration: underline; text-underline-offset: 3px; flex: none; }
.focus-view .mast, .focus-view .coach, .focus-view .chapter, .focus-view .work-footer { display: none; }
.focus-view main { max-width: none; padding: 0; }
.focus-view .workspace { display: block; }
.focus-view .stage { border-radius: 0; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; }
.focus-view .stage-head { justify-content: flex-end; }
.focus-view .stage canvas { height: clamp(240px, calc(100svh - 182px), 820px); }
#focus-note { text-align: center; margin: 0 auto 14px; color: var(--muted); }
#focus-note button { margin-inline-start: 8px; }
dialog {
  color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 21px; width: min(520px, calc(100vw - 30px)); max-height: 88svh; overscroll-behavior: contain;
}
dialog::backdrop { background: var(--overlay); }
dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
dialog h2 { font-size: 1.35rem; line-height: 1.2; letter-spacing: -.035em; }
dialog header button { min-width: 38px; padding: 1px 9px; font-size: 1.4rem; background: transparent; }
dialog p { color: var(--muted); margin: 8px 0 14px; }
#dialog-body .path-step { display: flex; width: 100%; gap: 12px; align-items: center; text-align: left; padding: 10px 13px; margin: 5px 0; }
.path-step span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); }
.path-step[aria-current=step] span { background: var(--action); color: var(--action-text); }
.path-step small { margin-left: auto; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
input { accent-color: var(--accent); }
.check input { width: 18px; height: 18px; }
.paint-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; margin: 10px 0; }
.paint-face-selector { display: none; }
.paint-face { text-align: center; border: 1px solid var(--line); border-radius: 9px; padding: 5px 2px; }
.paint-face small { display: block; font-size: .75rem; color: var(--muted); }
.paint-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; max-width: 112px; margin: 5px auto; }
.paint-tiles button, .palette button { color: #14202a; border: 1px solid #26343855; }
.paint-tiles button { min-width: 0; padding: 4px; border-radius: 4px; }
.paint-tiles button:disabled { opacity: 1; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; }
.palette button { padding: 4px 7px; }
.palette [aria-pressed=true] { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { color: var(--error); }
.history-list { display: grid; }
.history-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 12px; align-items: baseline;
  background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  padding: 13px 4px; text-align: left;
}
.history-row strong { font-size: 1rem; font-weight: 620; }
.history-row small, .history-row time, .review-info time { font-size: .82rem; color: var(--muted); font-weight: 450; }
.history-row span { text-align: right; color: var(--accent); }
.empty-state { padding: 16px; border-radius: 10px; background: var(--soft); }
.review-info { display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 15px; }
.review-info strong { font-size: .87rem; font-weight: 600; }
.review-figure { text-align: center; border-radius: 12px; overflow: hidden; background: var(--stage); }
.review-figure canvas { display: block; width: 100%; height: clamp(150px, 29svh, 260px); touch-action: none; cursor: grab; }
.review-figure figcaption { padding: 0 7px 6px; color: var(--muted); }
.review-player { margin: 14px 0 8px; }
.review-player label, .review-player input { display: block; width: 100%; }
.review-player label { font-weight: 600; font-size: .89rem; }
.review-player input { margin: 6px 0; }
.review-player p { min-height: 1.5em; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .mast { padding-top: env(safe-area-inset-top); }
  .mast-inner { padding-inline: max(10px,env(safe-area-inset-left)); min-height: 52px; gap: 3px; }
  .wordmark { gap: 6px; font-size: 1.09rem; }
  .wordmark svg { width: 24px; height: 27px; }
  .app-nav { margin-left: auto; }
  .app-nav #learn-nav, .app-nav #practice-nav, .utilities .desktop-settings, .utility-name { display: none; }
  .utilities { margin-left: 0; gap: 0; }
  .utilities .mobile-menu { display: inline-flex; }
  .app-nav button, .utilities button { padding: 5px 8px; }
  button, select { min-height: 44px; }
  #theme-toggle { min-width: 44px; }
  main { padding: 10px max(10px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .workspace { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .stage, .coach { border-radius: 13px; }
  .stage-head { align-items: center; padding: 9px 13px 0; }
  .chapter p { font-size: .78rem; }
  .chapter h1 { font-size: 1.3rem; }
  .focus-button { padding-inline: 6px; }
  .stage canvas { height: clamp(198px, min(76vw, 38svh), 380px); }
  .stage figcaption { padding: 0 6px; }
  .stage-tools { margin: 0 auto 3px; padding: 0 3px; flex-wrap: nowrap; }
  .stage-tools button { padding: 3px 7px; font-size: .84rem; gap: 4px; }
  .stage-tools .icon { width: 15px; height: 15px; }
  .coach { padding: 13px 15px; }
  #coach-content { margin: 10px 0 12px; }
  .coach h2 { font-size: 1.25rem; }
  .sample { margin-bottom: 5px; }
  .sample i { width: 15px; height: 15px; }
  .coach p { margin-top: 6px; }
  #coach-actions:has(>button:nth-child(2):last-child) { grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); }
  .work-footer { align-items: flex-start; margin-top: 6px; }
  .work-footer p { padding-top: 8px; }
  .focus-view .stage { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
  .focus-view .stage canvas { height: clamp(188px, calc(100svh - 165px), 730px); }
  dialog { width: min(520px, calc(100vw - 16px)); max-height: calc(100dvh - 22px); padding: 15px; }
  dialog header { margin-bottom: 10px; }
  dialog header button { min-width: 44px; }
  .paint-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .paint-tiles { max-width: 140px; }
  .paint-tiles button { padding: 2px; }
  .review-player input { min-height: 32px; }
  .history-row { grid-template-columns: 1fr auto; }
  .history-row time { grid-area: 2 / 1; }
  .history-row small { grid-area: 3 / 1; }
  .history-row span { grid-area: 1 / 2 / span 3; align-self: center; }
}
@media (max-width: 359px) {
  .stage-tools .icon { display: none; }
  .work-footer { font-size: .8rem; }
}
@media (max-width: 520px) {
  .paint-face-selector { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
  .paint-grid { grid-template-columns: minmax(0,1fr); }
  .paint-face[data-current="false"] { display: none; }
  .paint-tiles { width: min(165px,100%); max-width: none; }
}
@media (max-width: 520px) and (max-height: 700px) {
  .stage canvas { height: clamp(185px, 34svh, 238px); }
}
@media (min-width: 560px) and (max-height: 520px) {
  .mast-inner { min-height: 46px; }
  main { padding: 8px max(10px,env(safe-area-inset-right)) 8px max(10px,env(safe-area-inset-left)); }
  .workspace { grid-template-columns: minmax(0, 1.35fr) minmax(220px, 1fr); align-items: start; gap: 10px; }
  .stage-head { padding: 6px 12px 0; }
  .chapter h1 { font-size: 1.2rem; }
  .stage-tools { margin-bottom: 0; }
  .stage canvas { height: clamp(170px, calc(100svh - 209px), 310px); }
  .focus-view .stage canvas { height: calc(100svh - 110px); }
}
