:root {
  --bg: #fbf6ef; --fg: #3b2f2a; --muted: #75665c; --accent: #a8442b; --accent-soft: #e07a5f; --accent-2: #81b29a;
  --card: #ffffff; --line: #e6d9cb; --soft: #f4ebe1; --panel: rgba(255, 252, 247, 0.98);
  --ok: #3f8a64; --todo: #c9b8a8; --note: #fff4e6; --focus: #2f6fb5;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; }
body.live { overflow: hidden; height: 100%; }
a { color: var(--accent); }
button { font-weight: 700; font-size: 15px; font-family: inherit; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--fg); padding: 10px 18px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 1040px; margin: 0 auto; padding: 14px 16px 0; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 18px; text-decoration: none; color: var(--fg); }
.topbar nav { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a, .topbar nav button { font-weight: 700; font-size: 14px; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--fg); background: none; border: 0; }
.topbar nav a:hover, .topbar nav button:hover { background: var(--soft); }

/* ---------- home ---------- */
#home { max-width: 1040px; margin: 0 auto; padding: 18px 16px 40px; }
#home header { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
#home h1 { margin: 0; font-size: 34px; letter-spacing: -0.01em; }
.lede { color: var(--muted); max-width: 660px; line-height: 1.55; margin: 8px 0 0; }
.callout { background: var(--note); border: 1.5px solid #f1dcc0; border-radius: 16px; padding: 12px 14px; line-height: 1.5; margin: 16px 0 0; font-size: 15px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 20px 0 6px; }
.progress { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; }
.progress .track { flex: 1; height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--accent-2); border-radius: 999px; transition: width .4s; }
#home h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sign { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 12px 12px 10px; text-align: center; cursor: pointer; transition: transform .15s, border-color .15s; font: inherit; color: inherit; width: 100%; }
.sign:hover { transform: translateY(-2px); border-color: var(--accent-soft); }
.sign .e { font-size: 30px; }
.sign .w { font-weight: 800; font-size: 18px; margin-top: 2px; }
.sign svg.dia { width: 100%; height: 86px; }
.sign .done { position: absolute; top: 8px; right: 10px; color: var(--ok); font-weight: 900; }
footer.site { max-width: 1040px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 14px; line-height: 1.55; border-top: 1.5px solid var(--line); }
footer.site p { margin: 10px 0; }

/* ---------- lesson ---------- */
#lesson { position: fixed; inset: 0; display: none; background: #2b231f; }
body.live #lesson { display: block; }
body.live #home, body.live .topbar, body.live footer.site { display: none; }
#lesson video, #lesson canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#lesson video { transform: scaleX(-1); }
#coach { position: absolute; top: 14px; left: 16px; right: 436px; z-index: 3; display: flex; justify-content: center; pointer-events: none; }
#coach div { background: rgba(255, 252, 247, 0.95); color: var(--fg); padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 18px; box-shadow: 0 4px 18px rgba(0,0,0,.18); max-width: 100%; text-align: center; }
#camchip { position: absolute; left: 16px; bottom: 16px; z-index: 3; display: flex; gap: 8px; align-items: center; background: rgba(43, 35, 31, 0.75); color: #fff; padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
#camchip .dot { width: 9px; height: 9px; border-radius: 50%; background: #5fd38d; }
#camchip button { padding: 4px 10px; font-size: 13px; }
#camchip[hidden] { display: none; }
#panel { position: absolute; top: 0; right: 0; bottom: 0; width: 420px; z-index: 4; background: var(--panel); border-left: 1.5px solid var(--line); overflow-y: auto; padding: 16px 18px 24px; }
#panel .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#panel .grp { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
#panel .title { display: flex; align-items: center; gap: 12px; margin: 10px 0 0; }
#panel .title .e { font-size: 44px; }
#panel .title h2 { margin: 0; font-size: 34px; }
#panel .gloss { color: var(--muted); font-size: 13px; font-weight: 700; margin: 2px 0 6px; }
#panel .visual { display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--soft); border-radius: 18px; padding: 8px; margin: 8px 0; flex-wrap: wrap; }
#panel .visual svg.dia { width: 160px; height: 150px; }
#panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 0 8px; }
#panel ol { margin: 0; padding-left: 20px; line-height: 1.5; }
.videos { display: grid; gap: 6px; }
.videos a { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-decoration: none; color: var(--fg); background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 9px 12px; font-weight: 700; }
.videos a:hover { border-color: var(--accent-soft); }
.videos small { color: var(--muted); font-weight: 600; }
.ext-note { color: var(--muted); font-size: 12px; margin-top: 4px; }
.tip { background: var(--note); border-radius: 14px; padding: 10px 12px; line-height: 1.45; font-size: 14px; }
.checks { display: grid; gap: 8px; }
.check { display: grid; grid-template-columns: 26px 1fr; gap: 2px 10px; align-items: center; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 9px 12px; }
.check .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--todo); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 900; }
.check.ok { border-color: #bfe0cd; }
.check.ok .dot { background: var(--ok); }
.check .k { font-weight: 800; }
.check .h { grid-column: 2; color: var(--muted); font-size: 14px; }
.nav { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.quizbar { display: flex; justify-content: space-between; font-weight: 800; color: var(--muted); margin-top: 8px; }
#celebrate { position: absolute; inset: 0; z-index: 5; display: none; align-items: center; justify-content: center; pointer-events: none; }
#celebrate div { background: rgba(255, 252, 247, 0.97); padding: 18px 28px; border-radius: 28px; font-size: 30px; font-weight: 900; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; }
#celebrate small { display: block; font-size: 15px; color: var(--muted); font-weight: 700; margin-top: 4px; }
#celebrate.show { display: flex; animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#status { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 19px; background: rgba(43, 35, 31, .86); text-align: center; padding: 24px; padding-right: 436px; line-height: 1.5; }
#status[hidden] { display: none; }
#status p { max-width: 520px; margin: 0; }
#status .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- dialogs ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; max-width: min(620px, calc(100% - 32px)); width: 100%; color: var(--fg); background: var(--bg); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(43, 35, 31, .55); }
dialog .inner { padding: 22px 22px 18px; max-height: calc(100vh - 64px); overflow-y: auto; }
dialog h2 { margin: 0 0 8px; font-size: 24px; }
dialog ul { padding-left: 20px; line-height: 1.55; margin: 8px 0; }
dialog li { margin: 6px 0; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1.5px solid var(--line); }
.setting small { display: block; color: var(--muted); }

@media (max-width: 760px) {
  #panel { top: auto; left: 0; width: auto; height: 50vh; border-left: 0; border-top: 1.5px solid var(--line); border-radius: 22px 22px 0 0; }
  #coach { right: 16px; }
  #coach div { font-size: 15px; }
  #camchip { bottom: calc(50vh + 12px); }
  #status { padding-right: 24px; padding-bottom: 52vh; }
  #panel .visual svg.dia { width: 120px; height: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- fingerspelling ---------- */
.sign .letter { font-size: 34px; font-weight: 900; color: var(--accent); line-height: 1; }
#panel .title .letter-badge { display: grid; place-items: center; min-width: 58px; height: 58px; padding: 0 10px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 36px; font-weight: 900; }
#panel .visual .letter-shape svg { width: 170px; height: 170px; }
@media (max-width: 760px) {
  #panel .visual .letter-shape svg { width: 130px; height: 130px; }
}

/* Offline proof panel */
.proof-panel { position: fixed; inset: auto 12px 12px auto; width: min(480px, calc(100vw - 24px)); max-height: min(640px, calc(100vh - 24px)); overflow-y: auto; z-index: 60; background: #fff; border: 1px solid #ddd7cc; border-radius: 12px; padding: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.25); color: #23211d; }
.proof-panel h2 { font-size: 14px; margin: 14px 0 6px; }
.proof-panel h2:first-child { margin-top: 0; }
.proof-panel .muted { color: #6e6960; font-size: 13px; line-height: 1.5; }
.proof-panel .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proof-panel .note { background: #fff4e3; border: 1px solid #f0d9b5; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; margin: 8px 0; }
.proof-panel code { font: 12px ui-monospace, Menlo, monospace; background: #efebe4; padding: 1px 4px; border-radius: 4px; }
#proofLog { font: 11px ui-monospace, Menlo, monospace; max-height: 180px; overflow-y: auto; background: #f7f5f1; border-radius: 8px; padding: 6px 8px; margin: 6px 0; list-style: none; }
#proofLog li { padding: 3px 0; border-bottom: 1px solid #ddd7cc; overflow-wrap: anywhere; }
.proof-origin { font-weight: 700; color: #2f7d5b; }
.proof-origin.remote { color: #c0392b; }
#proofStore ul { font-size: 13px; padding-left: 18px; }

/* ---------- shadow puppets ---------- */
.dashboard { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 16px 0 0; }
.dash-line { font-weight: 800; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge { background: var(--note); border: 1px solid #f1dcc0; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700; }
.sign .times { color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 2px; }
#panel .title .emoji-badge { display: grid; place-items: center; min-width: 58px; height: 58px; padding: 0 10px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 36px; }
#panel .visual .shadow-shape svg { width: 190px; height: 142px; }
#panel .visual .hand-shape svg { width: 130px; height: 130px; }
#panel .visual .hand-pair { display: flex; gap: 2px; }
#panel .visual .hand-pair.stacked { flex-direction: column; gap: 0; }
#panel .visual .hand-pair .hand-shape svg { width: 120px; height: 120px; }
#panel .visual .hand-shape.flip svg { transform: scaleX(-1); }
.hands-need { color: var(--muted); font-size: 14px; font-weight: 600; margin: 6px 0; line-height: 1.45; }
.story-text { background: var(--note); border-radius: 14px; padding: 10px 12px; line-height: 1.5; font-size: 14px; margin: 10px 0 0; }
@media (max-width: 760px) {
  #panel .visual .shadow-shape svg { width: 150px; height: 112px; }
  #panel .visual .hand-shape svg { width: 110px; height: 110px; }
}

/* ---------- tone trainer ---------- */
#micchip { position: absolute; left: 16px; bottom: 16px; z-index: 3; display: flex; gap: 8px; align-items: center; background: rgba(43, 35, 31, 0.75); color: #fff; padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
#micchip .dot { width: 9px; height: 9px; border-radius: 50%; background: #5fd38d; }
#micchip button { padding: 4px 10px; font-size: 13px; }
#micchip[hidden] { display: none; }
.tone-name { color: var(--muted); font-size: 14px; font-weight: 700; margin: 2px 0 6px; }
.curve-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.mic-controls { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
#lesson canvas#fx { background: #2b231f; }
@media (max-width: 760px) {
  #micchip { bottom: calc(50vh + 12px); }
}

/* ---------- screenshot scrubber ---------- */
.dropzone { background: var(--card); border: 2px dashed var(--line); border-radius: 18px; padding: 22px 18px; text-align: center; margin: 20px 0 6px; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent-soft); background: var(--soft); }
.dropzone p { margin: 4px 0; }
.status { font-weight: 700; line-height: 1.5; }
.test-results { background: var(--note); border-radius: 12px; padding: 10px 12px; line-height: 1.5; font-size: 14px; }
.test-results:empty { display: none; }
.canvas-wrap { background: var(--card); border: 1.5px solid var(--line); border-radius: 18px; padding: 10px; margin: 12px 0; overflow-x: auto; }
#viewCanvas { display: block; max-width: 100%; height: auto; background: #f4ebe1; border-radius: 10px; }
#viewCanvas.drawing { cursor: crosshair; touch-action: none; }
.findings { list-style: none; padding: 0; display: grid; gap: 10px; }
.finding { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.finding label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.finding input[type="checkbox"] { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.finding-head { overflow-wrap: anywhere; }
.finding-head code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.finding-exp { color: var(--muted); font-size: 14px; margin: 6px 0 0 28px; line-height: 1.5; }
.sev { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800; }
.sev-high { background: #fde8e2; color: #8f2a16; }
.sev-medium { background: #fff0d6; color: #7a5200; }
.redact-style { border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 14px 0; display: flex; gap: 18px; flex-wrap: wrap; }
.redact-style legend { font-weight: 800; padding: 0 6px; }
.confirm { display: flex; gap: 10px; align-items: center; font-weight: 800; margin: 12px 0; cursor: pointer; }
.confirm input { width: 18px; height: 18px; }
#celebrate { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; pointer-events: none; }
#celebrate div { background: rgba(255, 252, 247, 0.97); padding: 18px 28px; border-radius: 28px; font-size: 26px; font-weight: 900; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; }
#celebrate.show { display: flex; animation: pop .35s ease-out; }
@media (max-width: 760px) {
  #home h1 { font-size: 28px; }
}
