/* VOICE: calm coach — clear, warm, compact (Gọn).
   IDEA: a story studio — every lesson ends on the arc you build.
   PICTURE: the tension arc with tappable beats is the recurring visual.
   COLOUR and TYPE: Gọn tokens, violet app accent; Be Vietnam Pro.
   LAYOUT: bottom nav on phones, sidebar on desktop, 760px content column. */

:root, [data-theme="light"] {
  --surface-0:#f7f7f5;--surface-1:#ffffff;--surface-2:#efefec;--border:#e2e2de;--border-strong:#c9c9c3;
  --ink:#18191b;--ink-muted:#5c5f66;--ink-subtle:#6f737b;
  --primary:#6d28d9;--primary-hover:#5b21b6;--on-primary:#ffffff;--primary-soft:#efe9fc;--primary-ink:#5320a8;
  --highlight:#c2410c;--success:#17702f;--success-soft:#e3f4e8;--warning:#9a6700;--danger:#c62828;--danger-soft:#fdecec;
  --scrim:rgba(0,0,0,.40);--shadow-pop:0 12px 32px rgba(0,0,0,.14);
}
[data-theme="dark"] {
  --surface-0:#121314;--surface-1:#1b1c1e;--surface-2:#26272a;--border:#2e3034;--border-strong:#45484d;
  --ink:#ececea;--ink-muted:#a3a6ad;--ink-subtle:#8b8f97;
  --primary:#a78bfa;--primary-hover:#c4b5fd;--on-primary:#1b1035;--primary-soft:#251b3f;--primary-ink:#c9b8fd;
  --highlight:#fb923c;--success:#4ac26b;--success-soft:#13261a;--warning:#d4a72c;--danger:#f47067;--danger-soft:#2d1615;
  --scrim:rgba(0,0,0,.60);--shadow-pop:0 12px 32px rgba(0,0,0,.6);
}
[data-theme="hc-light"] {
  --surface-0:#ffffff;--surface-1:#ffffff;--surface-2:#ececec;--border:#6b6b6b;--border-strong:#1a1a1a;
  --ink:#000;--ink-muted:#262626;--ink-subtle:#383838;
  --primary:#4c1d95;--primary-hover:#3b1574;--on-primary:#fff;--primary-soft:#e2d8fa;--primary-ink:#3b1574;
  --highlight:#8f2d0a;--success:#0b5221;--success-soft:#d5ecdc;--warning:#5e3e00;--danger:#94120f;--danger-soft:#f8dcdc;
  --scrim:rgba(0,0,0,.65);--shadow-pop:0 12px 32px rgba(0,0,0,.14);
}
[data-theme="hc-dark"] {
  --surface-0:#000;--surface-1:#0a0a0a;--surface-2:#242424;--border:#8f8f8f;--border-strong:#e6e6e6;
  --ink:#fff;--ink-muted:#ebebeb;--ink-subtle:#d4d4d4;
  --primary:#c4b5fd;--primary-hover:#ddd3fe;--on-primary:#000;--primary-soft:#1f1538;--primary-ink:#e0d6ff;
  --highlight:#ffae7a;--success:#7be89a;--success-soft:#0b2a15;--warning:#ffd470;--danger:#ff9a91;--danger-soft:#2a0d0b;
  --scrim:rgba(0,0,0,.8);--shadow-pop:0 12px 32px rgba(0,0,0,.6);
}
:root{color-scheme:light}
[data-theme="dark"],[data-theme="hc-dark"]{color-scheme:dark}
:root{
  --space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-6:24px;--space-8:32px;
  --radius-sm:6px;--radius-md:8px;--radius-lg:12px;--radius-full:999px;
  --size-touch:44px;--size-control:40px;--size-topbar:48px;--size-nav-bottom:56px;--size-sidebar:232px;
  --font-sans:"Be Vietnam Pro",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",sans-serif;
}

*{box-sizing:border-box;min-width:0}
html,body{margin:0;height:100%}
body{font:15px/22px var(--font-sans);color:var(--ink);background:var(--surface-0);-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent;overflow-x:clip}
button,input,select,textarea{font:inherit;color:inherit}
a{color:var(--primary-ink)}
:focus-visible{outline:2px solid var(--primary);outline-offset:2px}

.i{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
.i-sm{width:16px;height:16px}

/* Shell */
.app{display:flex;min-height:100%}
.side{display:none}
.main{flex:1;display:flex;flex-direction:column;min-height:100vh;padding-bottom:calc(var(--size-nav-bottom) + env(safe-area-inset-bottom))}
.top{position:sticky;top:0;z-index:5;height:var(--size-topbar);display:flex;align-items:center;gap:var(--space-2);padding:0 var(--space-4);background:var(--surface-0);border-bottom:1px solid var(--border)}
.top h1{font-size:17px;line-height:24px;font-weight:600;margin:0;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand{display:flex;align-items:center;gap:8px;font-weight:700}
.logo{width:28px;height:28px;border-radius:8px;background:var(--primary);color:var(--on-primary);display:grid;place-items:center}
.content{width:100%;max-width:760px;margin:0 auto;padding:var(--space-4) var(--space-4) var(--space-8)}
.bnav{position:fixed;left:0;right:0;bottom:0;z-index:6;display:flex;background:var(--surface-1);border-top:1px solid var(--border);padding-bottom:env(safe-area-inset-bottom)}
.bnav a{flex:1;height:var(--size-nav-bottom);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:11px;font-weight:500;color:var(--ink-subtle);text-decoration:none}
.bnav a.on,.side a.on{color:var(--primary-ink)}
.bnav .dot{position:absolute;margin:-18px 0 0 22px;min-width:16px;height:16px;border-radius:8px;background:var(--highlight);color:#fff;font-size:10px;line-height:16px;text-align:center;padding:0 4px}
@media(min-width:900px){
  .side{display:flex;flex-direction:column;gap:2px;width:var(--size-sidebar);flex:none;position:sticky;top:0;height:100vh;padding:var(--space-4) var(--space-3);border-right:1px solid var(--border);background:var(--surface-1)}
  .side .brand{padding:4px 8px 16px}
  .side a{display:flex;align-items:center;gap:12px;height:40px;padding:0 12px;border-radius:var(--radius-md);color:var(--ink-muted);text-decoration:none;font-weight:500}
  .side a:hover{background:var(--surface-2)}
  .side a.on{background:var(--primary-soft)}
  .side .sp{flex:1}
  .bnav{display:none}
  .main{padding-bottom:0}
  .top .brand{display:none}
}

/* Type */
.h1{font-size:22px;line-height:28px;font-weight:600;margin:0 0 4px;text-wrap:balance}
.h2{font-size:17px;line-height:24px;font-weight:600;margin:var(--space-6) 0 var(--space-2)}
.sub{color:var(--ink-muted);margin:0}
.sm{font-size:13px;line-height:18px}
.cap{font-size:12px;line-height:16px;font-weight:500;color:var(--ink-subtle)}
.muted{color:var(--ink-muted)}

/* Components */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:var(--size-control);padding:0 16px;border-radius:var(--radius-md);border:1px solid var(--border-strong);background:var(--surface-1);font-weight:500;font-size:14px;cursor:pointer;white-space:nowrap;text-decoration:none;color:var(--ink)}
.btn:hover{background:var(--surface-2)}
.btn.pri{background:var(--primary);border-color:transparent;color:var(--on-primary)}
.btn.pri:hover{background:var(--primary-hover)}
.btn.ghost{border-color:transparent;background:transparent}
.btn.sm{height:32px;padding:0 12px;font-size:13px}
.btn.touch{height:var(--size-touch);font-size:15px}
.btn.block{width:100%}
.btn.icon{width:var(--size-control);padding:0}
.card{background:var(--surface-1);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-4)}
.card+.card{margin-top:var(--space-3)}
.soft{background:var(--primary-soft);border-color:transparent}
.soft .cap{color:var(--primary-ink)}
.row{display:flex;align-items:center;gap:var(--space-3)}
.wrap{flex-wrap:wrap}
.grow{flex:1}
.stack>*+*{margin-top:var(--space-3)}
.list{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface-1);overflow:hidden}
.li{display:flex;align-items:center;gap:var(--space-3);min-height:56px;padding:10px var(--space-4);text-decoration:none;color:inherit;border-top:1px solid var(--border);cursor:pointer;background:none;border-left:0;border-right:0;border-bottom:0;width:100%;text-align:left}
.li:first-child{border-top:0}
.li:hover{background:var(--surface-2)}
.ico{width:36px;height:36px;border-radius:10px;display:grid;place-items:center;background:var(--primary-soft);color:var(--primary-ink);flex:none}
.chip{display:inline-flex;align-items:center;height:24px;padding:0 10px;border-radius:var(--radius-full);background:var(--surface-2);font-size:12px;font-weight:500;color:var(--ink-muted)}
.chip.v{background:var(--primary-soft);color:var(--primary-ink)}
.chip.ok{background:var(--success-soft);color:var(--success)}
.bar{height:6px;border-radius:3px;background:var(--surface-2);overflow:hidden}
.bar>i{display:block;height:100%;background:var(--primary);border-radius:3px}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:var(--space-3)}
.stat{background:var(--surface-1);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4)}
.stat b{display:block;font-size:22px;line-height:28px;font-weight:600}
.seg{display:inline-flex;border:1px solid var(--border-strong);border-radius:var(--radius-md);overflow:hidden;flex-wrap:wrap}
.seg button{height:36px;padding:0 12px;border:0;background:var(--surface-1);cursor:pointer;font-size:13px;font-weight:500}
.seg button+button{border-left:1px solid var(--border)}
.seg button.on{background:var(--primary-soft);color:var(--primary-ink)}
select,input[type=text],textarea{width:100%;font-size:16px;border:1px solid var(--border-strong);border-radius:var(--radius-md);background:var(--surface-1);padding:8px 12px}
select{height:var(--size-control)}
textarea{resize:vertical;line-height:22px}
input[type=range]{width:100%;accent-color:var(--primary)}
label.f{display:block;font-size:13px;font-weight:500;margin:0 0 4px;color:var(--ink-muted)}

/* Options (quiz / drills) */
.opt{display:block;width:100%;text-align:left;padding:12px 14px;border:1px solid var(--border-strong);border-radius:var(--radius-md);background:var(--surface-1);cursor:pointer;line-height:21px;min-height:var(--size-touch)}
.opt+.opt{margin-top:8px}
.opt:hover{background:var(--surface-2)}
.opt.sel{border-color:var(--primary);background:var(--primary-soft)}
.opt.ok{border-color:var(--success);background:var(--success-soft)}
.opt.bad{border-color:var(--danger);background:var(--danger-soft)}
.fb{margin-top:var(--space-3);padding:12px 14px;border-radius:var(--radius-md);background:var(--surface-2);line-height:21px}
.fb b.ok{color:var(--success)}.fb b.bad{color:var(--danger)}
.conf{display:flex;gap:6px;flex-wrap:wrap}
.conf button{flex:1;min-width:52px;height:40px;border-radius:var(--radius-md);border:1px solid var(--border-strong);background:var(--surface-1);cursor:pointer;font-size:13px;font-weight:500}
.conf button.on{background:var(--primary);color:var(--on-primary);border-color:transparent}

/* Arc */
.arc{width:100%;height:auto;display:block}
.arc .curve{fill:none;stroke:var(--border-strong);stroke-width:2.5}
.arc .fillc{fill:var(--primary-soft);stroke:none}
.arc circle{fill:var(--surface-1);stroke:var(--primary);stroke-width:2.5;cursor:pointer}
.arc circle.done{fill:var(--primary)}
.arc circle.cur{stroke-width:4}
.arc text{fill:var(--ink-muted);font-size:12px;font-weight:500;font-family:var(--font-sans)}
.beat{border:1px solid var(--border);border-radius:var(--radius-lg);padding:12px;background:var(--surface-1)}
.beat.cur{border-color:var(--primary)}
.beat .tip{font-size:13px;line-height:18px;color:var(--ink-muted);margin:2px 0 8px}
.n{display:inline-grid;place-items:center;width:22px;height:22px;border-radius:11px;background:var(--primary-soft);color:var(--primary-ink);font-size:12px;font-weight:600;margin-right:6px}
.timebar{position:relative;height:10px;border-radius:5px;background:var(--surface-2);overflow:hidden}
.timebar>i{position:absolute;inset:0 auto 0 0;background:var(--primary);border-radius:5px;transition:width .2s}
.timebar>i.over{background:var(--highlight)}

/* Charts */
.hbars .r{display:grid;grid-template-columns:44px 1fr 48px;align-items:center;gap:8px;margin:6px 0;font-size:13px}
.hbars .t{height:18px;border-radius:4px;background:var(--surface-2);overflow:hidden}
.hbars .t>i{display:block;height:100%;background:var(--primary)}
.hbars .t>i.hi{background:var(--highlight)}
.hbars .v{text-align:right;font-variant-numeric:tabular-nums}

.toast{position:fixed;left:50%;bottom:calc(var(--size-nav-bottom) + 16px);transform:translateX(-50%);background:var(--ink);color:var(--surface-1);padding:10px 16px;border-radius:var(--radius-md);font-size:14px;z-index:20;box-shadow:var(--shadow-pop)}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.hide{display:none!important}
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
