@font-face { font-family: 'Barlow XB'; src: url('../demo/assets/slice_v002/ui/barlow-xb.woff') format('woff'); font-display: swap; }
:root { --gold: #ffcf3a; --bad: #ff3b30; --ok: #34c759; --ink: #f5f6f7; --glass: rgba(12, 14, 18, 0.78); --line: rgba(255, 255, 255, 0.16);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #0b0d10; color: var(--ink); overflow: hidden; overscroll-behavior: none;
  font: 15px/1.35 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- the view (and what is drawn over it) */
#viewport { position: fixed; left: 0; top: 0; right: var(--panelW, 0px); bottom: var(--panelH, 0px); overflow: hidden; }
canvas#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.tag.num { font: 22px/1 'Barlow XB', system-ui, sans-serif; color: #1a1406; background: var(--gold); border-radius: 50%; min-width: 30px; height: 30px; display: grid; place-items: center; padding: 0 6px; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
.tag.num.bad { background: var(--bad); color: #fff; }
.tag.lbl { font-size: 13px; font-weight: 600; background: rgba(12,14,18,.8); padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line); }
.tag.lbl.small { font-size: 12px; font-weight: 500; }
.tag.lbl.dim { font-weight: 500; color: #d8dade; }
.tag.lbl.good { border-color: var(--ok); }
.tag.lbl.bad { background: var(--bad); }

#top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, var(--sat)); padding-left: max(10px, var(--sal));
  background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); pointer-events: none; }
#top > * { pointer-events: auto; }
#top .hsp { flex: 1; pointer-events: none; }
.hbtn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--glass); border-radius: 999px; height: 40px; padding: 0 14px; font-weight: 600; }
.hbtn.sq { width: 40px; padding: 0; justify-content: center; font-size: 22px; line-height: 1; }
#lessonName { font: 20px/1.1 'Barlow XB', system-ui, sans-serif; text-shadow: 0 1px 4px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

#hud { position: absolute; right: max(10px, var(--sar)); top: calc(max(8px, var(--sat)) + 52px); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
#counter, #clock { background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px 8px; text-align: right; min-width: 128px; }
#counter .lbl, #clock .lbl { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
#counter .n { font: 46px/1 'Barlow XB', system-ui, sans-serif; color: var(--gold); }
#counter .max { font: 22px/1 'Barlow XB', system-ui, sans-serif; opacity: .6; }
#counter.bad .n { color: var(--bad); }
#counter .dots { display: flex; gap: 5px; justify-content: flex-end; margin-top: 4px; }
#counter .dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); }
#counter .dots i.on { background: var(--gold); border-color: var(--gold); }
#counter .dots i.over { background: var(--bad); border-color: var(--bad); }
#counter .hold { display: block; font-size: 12px; opacity: .8; margin-top: 3px; }
#clock .n { font: 30px/1 'Barlow XB', system-ui, sans-serif; }
#clock .bar { display: block; position: relative; height: 6px; background: rgba(255,255,255,.18); border-radius: 3px; margin-top: 5px; overflow: hidden; }
#clock .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); }
#clock.bad .n { color: var(--bad); }
#clock.bad .bar i { background: var(--bad); }

#verdict { position: absolute; left: 50%; top: calc(max(8px, var(--sat)) + 54px); transform: translateX(-50%); text-align: center; padding: 8px 22px 10px; border-radius: 16px; background: var(--bad); box-shadow: 0 6px 24px rgba(0,0,0,.4); pointer-events: none; animation: pop .25s ease-out; max-width: min(420px, calc(100% - 300px)); }
#verdict.ok { background: var(--ok); }
#verdict.info { background: #3a4452; }
#verdict b { display: block; font: 30px/1.05 'Barlow XB', system-ui, sans-serif; text-transform: uppercase; letter-spacing: .02em; }
#verdict span { font-size: 13px; opacity: .95; }
@keyframes pop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* the foot-and-line inset (src/inset.js) */
#inset { position: absolute; right: max(12px, var(--sar)); bottom: 12px; width: clamp(200px, 26vw, 340px); aspect-ratio: 4 / 3.4; border-radius: 14px; overflow: hidden; border: 2px solid rgba(255,255,255,.75); box-shadow: 0 6px 20px rgba(0,0,0,.45); background: #4f7d36; pointer-events: none; }
#inset canvas { width: 100%; height: 100%; display: block; }
#inset .ttl { position: absolute; right: 6px; top: 6px; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; background: rgba(10,12,16,.7); border-radius: 6px; padding: 2px 6px; }
#inset .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px 6px; background: rgba(10,12,16,.75); font-size: 12px; line-height: 1.3; display: flex; flex-direction: column; }
#inset .cap .bad { color: #ff8a80; font-weight: 700; } #inset .cap .good { color: #7ee08f; font-weight: 700; }

/* ---- the panel: the caption, the beat buttons, the time bar */
#panel { position: fixed; left: max(12px, var(--sal)); bottom: max(12px, var(--sab)); width: min(580px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px;
  background: rgba(12, 14, 18, 0.86); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px 10px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
#caption .head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
#beatNo { font: 13px/1 'Barlow XB', system-ui, sans-serif; color: #1a1406; background: var(--gold); border-radius: 6px; padding: 3px 6px 2px; }
#beatTitle { font-weight: 700; font-size: 15px; }
#caption .rule { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin-left: auto; }
#caption .text { font-size: 17px; line-height: 1.4; min-height: 2.8em; }
#caption .text b { color: var(--gold); }
#steer { display: flex; gap: 8px; }
.sbtn { flex: 1; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #232831; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; }
.sbtn span { font-size: 18px; line-height: 1; }
.sbtn.main { flex: 1.6; background: var(--gold); color: #1a1406; border: 0; }
.sbtn.main.ready { animation: ready 1.4s ease-in-out infinite; }
@keyframes ready { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,207,58,.55); } 50% { box-shadow: 0 0 0 7px rgba(255,207,58,0); } }
#bar { display: flex; align-items: center; gap: 8px; }
#bar .icon { border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 17px; flex: none; background: #232831; }
#bar .chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; height: 44px; min-width: 48px; padding: 0 10px; flex: none; }
#bar .chip.manual { border-color: var(--gold); color: var(--gold); }
#time { font-variant-numeric: tabular-nums; font-size: 12px; opacity: .8; flex: none; min-width: 70px; text-align: center; }
#prep { position: absolute; right: 14px; top: 8px; font-size: 10px; opacity: .5; }
#track { position: relative; flex: 1; height: 44px; display: flex; align-items: center; min-width: 60px; }
#scrub { width: 100%; margin: 0; accent-color: var(--gold); height: 44px; background: transparent; position: relative; z-index: 2; touch-action: none; }
#marks { position: absolute; left: 0; right: 0; top: 50%; height: 16px; transform: translateY(-50%); pointer-events: none; z-index: 1; }
#marks i { position: absolute; top: 2px; width: 2px; height: 12px; background: rgba(255,255,255,.45); }
#marks i.quiz { background: var(--gold); width: 3px; }

/* ---- the screens over the view: the contents, a lesson's card, the end, the quiz */
#home, #card, #done { position: fixed; inset: 0; z-index: 6; background: rgba(8, 10, 13, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#home { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
#home .page { max-width: 760px; margin: 0 auto; padding: max(28px, calc(var(--sat) + 16px)) max(20px, var(--sar)) max(36px, calc(var(--sab) + 24px)) max(20px, var(--sal)); position: relative; }
#home h1 { font: 44px/1.02 'Barlow XB', system-ui, sans-serif; margin: 6px 0 12px; color: var(--gold); }
#home .lead { font-size: 18px; line-height: 1.45; margin: 0 0 14px; max-width: 620px; }
#home .how { margin: 0 0 20px; padding-left: 20px; color: #cfd3d8; font-size: 14px; line-height: 1.5; }
#home .how b { color: var(--gold); }
#home h2 { font: 22px/1.1 'Barlow XB', system-ui, sans-serif; margin: 30px 0 8px; letter-spacing: .02em; }
#home .foot { color: #9aa1a9; font-size: 13px; margin-top: 26px; }
.lang { position: absolute; right: max(20px, var(--sar)); top: max(24px, calc(var(--sat) + 12px)); display: flex; gap: 4px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.lang button { border: 0; background: transparent; border-radius: 999px; min-width: 44px; height: 36px; font-weight: 700; font-size: 13px; }
.lang button[aria-pressed="true"] { background: var(--gold); color: #1a1406; }
.primary { border: 0; background: var(--gold); color: #1a1406; font-weight: 700; border-radius: 14px; min-height: 52px; padding: 0 22px; font-size: 17px; }
#toc .chap { margin: 0 0 14px; }
#toc h3 { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; font-size: 16px; }
#toc h3 span { font: 15px/1 'Barlow XB', system-ui, sans-serif; color: var(--gold); min-width: 14px; }
#toc h3 small { font-weight: 400; font-size: 12px; color: #8d949c; margin-left: auto; white-space: nowrap; }
#toc .les { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: #171a20; border-radius: 14px; padding: 12px 14px; margin: 0 0 8px; }
#toc .les b { display: flex; align-items: center; gap: 8px; font-size: 17px; }
#toc .les span { display: block; color: #b9bec5; font-size: 13.5px; margin-top: 3px; line-height: 1.4; }
#toc button.les:hover { border-color: var(--gold); }
#toc .les .tick { font-style: normal; color: #1a1406; background: var(--ok); border-radius: 50%; width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 12px; }
#toc .les.soon { opacity: .45; background: transparent; border-style: dashed; }
#toc .les.soon span { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
#card, #done { display: grid; place-items: center; padding: 16px; }
#card .box, #done .box { width: min(520px, 100%); background: #15181d; border: 1px solid var(--line); border-radius: 20px; padding: 22px 22px 18px; box-shadow: 0 12px 50px rgba(0,0,0,.5); }
#card .chap { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
#card h1, #done h1 { font: 38px/1.05 'Barlow XB', system-ui, sans-serif; margin: 6px 0 10px; }
#done h1 { font-size: 30px; }
#card .sum, #done p { font-size: 17px; line-height: 1.45; margin: 0 0 10px; }
#card .facts { color: #aab0b7; font-size: 14px; margin-bottom: 18px; }
#card .btns, #done .btns { display: flex; gap: 10px; flex-wrap: wrap; }
#card .btns button, #done .btns button { flex: 1; min-height: 50px; border-radius: 14px; }
#card .btns .toc, #done .btns .toc, #done .btns .again { border: 1px solid var(--line); background: #232831; font-weight: 600; }
#card .btns .go, #done .btns .go { flex: 2; }

#quiz { position: fixed; inset: 0; display: grid; place-items: end center; padding: 16px; padding-bottom: max(16px, var(--sab)); background: rgba(0,0,0,.3); z-index: 5; }
#quiz .card { background: #15181d; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; width: min(460px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.5); margin-bottom: 4vh; }
#quiz .qt { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
#quiz .qq { font: 26px/1.15 'Barlow XB', system-ui, sans-serif; margin: 6px 0 14px; }
#quiz .qa, #quiz .qb { display: flex; gap: 10px; flex-wrap: wrap; }
#quiz button { flex: 1; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #232831; font-weight: 600; padding: 8px 12px; }
#quiz button[data-kind="yes"] { background: #4a1d1a; border-color: #8a2e27; }
#quiz button[data-kind="no"] { background: #183a22; border-color: #2c6b3c; }
#quiz button.next { background: var(--gold); color: #1a1406; border: 0; }
#quiz .qr b { font: 22px/1.1 'Barlow XB', system-ui, sans-serif; display: block; margin-bottom: 4px; }
#quiz .qr b.right { color: var(--ok); } #quiz .qr b.wrong { color: var(--bad); }
#quiz .qr p { margin: 0 0 14px; font-size: 16px; }

#loading { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: #0b0d10; z-index: 9; transition: opacity .4s; }
#loading.gone { opacity: 0; pointer-events: none; }
.spin { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--gold); border-radius: 50%; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* off the lesson, the lesson's chrome hides */
body:not([data-view="lesson"]) #panel, body:not([data-view="lesson"]) #top, body:not([data-view="lesson"]) #hud, body:not([data-view="lesson"]) #verdict, body:not([data-view="lesson"]) #inset, body:not([data-view="lesson"]) #tags { visibility: hidden; }

/* ---- a phone upright: the view on top, the panel docked below it (not over the scene) */
body[data-mode="port"] #panel { left: 0; right: 0; bottom: 0; width: auto; border-radius: 0; border-width: 1px 0 0; box-shadow: none; background: #101318;
  padding: 10px max(12px, var(--sar)) max(8px, var(--sab)) max(12px, var(--sal)); gap: 6px; }
body[data-mode="port"] #caption .text { font-size: 15.5px; min-height: 4.2em; }
body[data-mode="port"] #lessonName { font-size: 17px; }
body[data-mode="port"] .hbtn .txt { display: none; }
body[data-mode="port"] .hbtn { padding: 0 12px; }
body[data-mode="port"] #counter .n { font-size: 32px; } body[data-mode="port"] #counter .max { font-size: 18px; }
body[data-mode="port"] #counter, body[data-mode="port"] #clock { min-width: 96px; padding: 4px 10px 6px; }
body[data-mode="port"] #counter .lbl, body[data-mode="port"] #clock .lbl { font-size: 10px; }
body[data-mode="port"] #clock .n { font-size: 22px; }
body[data-mode="port"] #inset { top: calc(max(8px, var(--sat)) + 52px); left: max(8px, var(--sal)); right: auto; bottom: auto; width: min(46vw, 210px); }
body[data-mode="port"] #inset .cap { font-size: 10.5px; }
body[data-mode="port"] #verdict { top: auto; bottom: 10px; max-width: calc(100% - 24px); padding: 6px 16px 8px; }
body[data-mode="port"] #verdict b { font-size: 22px; }
body[data-mode="port"] #time { display: none; }
body[data-mode="port"] #home h1 { font-size: 36px; margin-top: 48px; }
body[data-mode="port"] #home .lead { font-size: 16px; }
body[data-mode="port"] #card h1 { font-size: 32px; }

/* ---- a phone on its side: the panel in a column on the right */
body[data-mode="land"] #panel { left: auto; right: 0; top: 0; bottom: 0; width: min(330px, 42vw); border-radius: 0; border-width: 0 0 0 1px; box-shadow: none; background: #101318;
  padding: max(8px, var(--sat)) max(10px, var(--sar)) max(6px, var(--sab)) 12px; gap: 6px; overflow-y: auto; }
body[data-mode="land"] #caption { flex: 1; min-height: 0; overflow-y: auto; }
body[data-mode="land"] #caption .text { font-size: 14px; line-height: 1.35; min-height: 0; }
body[data-mode="land"] #beatTitle { font-size: 13.5px; }
body[data-mode="land"] #caption .rule { margin-left: 0; width: 100%; }
body[data-mode="land"] .sbtn { min-height: 44px; font-size: 14px; }
body[data-mode="land"] #steer .sbtn b { display: none; } body[data-mode="land"] #steer .sbtn.main b { display: inline; }
body[data-mode="land"] #time { display: none; }
body[data-mode="land"] #top { padding-top: max(4px, var(--sat)); padding-bottom: 4px; }
body[data-mode="land"] .hbtn { height: 36px; } body[data-mode="land"] .hbtn.sq { width: 36px; }
body[data-mode="land"] .hbtn .txt { display: none; }
body[data-mode="land"] #lessonName { font-size: 16px; }
body[data-mode="land"] #hud { top: calc(max(4px, var(--sat)) + 44px); }
body[data-mode="land"] #counter .n { font-size: 26px; } body[data-mode="land"] #counter .max { font-size: 15px; }
body[data-mode="land"] #counter, body[data-mode="land"] #clock { min-width: 86px; padding: 3px 9px 5px; }
body[data-mode="land"] #counter .lbl, body[data-mode="land"] #clock .lbl { font-size: 9.5px; }
body[data-mode="land"] #counter .dots i { width: 9px; height: 9px; }
body[data-mode="land"] #clock .n { font-size: 20px; }
body[data-mode="land"] #viewport { z-index: 2; }   /* (its verdict, below, is drawn over the panel column) */
/* (on its side the verdict sits in the panel column, under the text: over the view it would cover the feet) */
body[data-mode="land"] #verdict { position: fixed; left: auto; right: max(10px, var(--sar)); top: auto; bottom: calc(max(6px, var(--sab)) + 104px); width: calc(var(--panelW) - 24px); max-width: none; transform: none; animation: none; padding: 5px 12px 7px; z-index: 2; }
body[data-mode="land"] #verdict b { font-size: 19px; } body[data-mode="land"] #verdict span { font-size: 11px; }
body[data-mode="land"] #inset { top: calc(max(4px, var(--sat)) + 46px); bottom: auto; left: max(8px, var(--sal)); right: auto; width: auto; height: min(48vh, 180px); }
body[data-mode="land"] #inset .cap { font-size: 10.5px; }
body[data-mode="land"] #home h1 { font-size: 32px; }
body[data-mode="land"] #card h1 { font-size: 28px; } body[data-mode="land"] #card .box { padding: 16px; }
body[data-mode="land"] #quiz .card { margin-bottom: 0; }
body[data-mode="land"] #quiz .qq { font-size: 20px; margin-bottom: 10px; }
