/* Hasaki Clinic — Mô phỏng cơ chế 3D. Frame-first design system. */
:root {
  --bg: #070D0B;
  --letterbox: #030605;
  --surface: rgba(14, 26, 22, 0.78);
  --surface-2: rgba(20, 36, 30, 0.9);
  --surface-solid: #0E1A16;
  --border: rgba(160, 220, 195, 0.14);
  --border-strong: rgba(160, 220, 195, 0.28);
  --text: #E8F2EE;
  --muted: #9DB4AB;
  --faint: #6F867D;
  --brand: #326E51;
  --brand-bright: #4FA37A;
  --accent: #FF6600;
  --accent-soft: rgba(255, 102, 0, 0.14);
  --wave: #7FE3C9;
  --c15: #37C6C0;
  --c30: #8FD14F;
  --c45: #FF6600;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --transport-h: 64px;
  --drawer-w: 380px;
  --gutter: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--wave); outline-offset: 2px; }
.noscript { padding: 24px; text-align: center; }

/* ---------------------------------------------------------------- app grid */
.app { position: fixed; inset: 0; display: grid; grid-template-rows: var(--topbar-h) 1fr var(--transport-h); height: 100dvh; }
.app[data-view="home"] { grid-template-rows: var(--topbar-h) 1fr 0; }
.app[data-view="home"] .studio, .app[data-view="home"] .transport { display: none; }
.app[data-view="studio"] .home { display: none; }

/* ---------------------------------------------------------------- top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter); border-bottom: 1px solid var(--border); background: linear-gradient(180deg, rgba(16, 30, 25, 0.96), rgba(10, 19, 16, 0.96)); z-index: 30; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; text-decoration: none; color: inherit; background: none; border: 0; padding: 0; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-word { font-weight: 800; letter-spacing: 0.2em; font-size: 15px; white-space: nowrap; }
.brand-word::after { content: ''; display: block; height: 2px; margin-top: 3px; width: 100%; background: linear-gradient(90deg, var(--accent) 0 26%, var(--brand-bright) 26% 100%); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumbs strong { color: var(--text); font-weight: 600; }
.crumbs .sep { opacity: 0.5; }
.topbar .spacer { flex: 1; }
.tb-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-studio { overflow-x: auto; scrollbar-width: none; }
.tb-studio::-webkit-scrollbar { display: none; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; box-shadow: 0 2px 10px rgba(50, 110, 81, 0.45); }
.seg button:hover:not([aria-pressed="true"]) { color: var(--text); }

.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.04); font-size: 13px; font-weight: 600; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #ff7a22; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn[aria-pressed="true"] { border-color: var(--wave); color: var(--wave); }

/* ---------------------------------------------------------------- home */
.home { overflow-y: auto; padding: clamp(24px, 5vw, 64px) var(--gutter) 48px; background: radial-gradient(1200px 600px at 70% -10%, rgba(50, 110, 81, 0.28), transparent 60%), radial-gradient(900px 500px at 0% 110%, rgba(255, 102, 0, 0.08), transparent 60%); }
.home-inner { max-width: 1120px; margin: 0 auto; }
.home-kicker { color: var(--accent); font-weight: 700; letter-spacing: 0.18em; font-size: 12px; text-transform: uppercase; }
.home h1 { font-size: clamp(30px, 5vw, 54px); line-height: 1.08; margin: 12px 0 14px; font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; }
.home .lead { color: var(--muted); font-size: clamp(15px, 1.6vw, 18px); max-width: 720px; line-height: 1.6; margin: 0 0 32px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); min-height: 300px; overflow: hidden; text-align: left; transition: transform 0.2s, border-color 0.2s; }
.card[data-status="ready"] { cursor: pointer; }
.card[data-status="ready"]:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.card .art { height: 140px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); display: grid; place-items: center; overflow: hidden; }
.card .art svg { width: 100%; height: 100%; }
.card h2 { margin: 4px 0 0; font-size: 20px; font-weight: 750; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.tag { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.badge { position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.badge-ready { background: var(--accent); color: #fff; }
.badge-soon { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.card[data-status="soon"] { opacity: 0.66; }
.home-foot { margin-top: 36px; color: var(--faint); font-size: 12px; line-height: 1.6; max-width: 780px; }

/* ---------------------------------------------------------------- studio */
.studio { position: relative; min-height: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; background: var(--letterbox); }
.frame { position: absolute; overflow: hidden; background: #050A08; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 20px 60px rgba(0, 0, 0, 0.55); }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layer-gl { touch-action: none; }
.layer-inset { inset: auto; clip-path: circle(50% at 50% 50%); }
.layer-inset, .layer-overlay, .layer-guides { pointer-events: none; }
.guide { position: absolute; border: 1px dashed rgba(127, 227, 201, 0.55); border-radius: 4px; }
.guide-safe { border-color: rgba(255, 102, 0, 0.7); }
.stage-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: rgba(0, 0, 0, 0.45); padding: 6px 12px; border-radius: 999px; pointer-events: none; transition: opacity 0.3s; }
.stage-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; z-index: 5; }

/* ---------------------------------------------------------------- drawer */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: var(--drawer-w); max-width: 100%; overflow-y: auto; background: rgba(9, 17, 14, 0.94); border-left: 1px solid var(--border); backdrop-filter: blur(14px); transform: translateX(100%); transition: transform 0.28s ease; z-index: 20; padding: 16px 16px 28px; }
.drawer[data-open="true"] { transform: none; box-shadow: var(--shadow); }
.drawer h3 { margin: 18px 0 10px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.drawer h3:first-child { margin-top: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-handle { display: none; }

.chapter-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.chapter-list button { width: 100%; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; text-align: left; border: 1px solid transparent; background: transparent; padding: 8px 10px; border-radius: 10px; color: var(--muted); }
.chapter-list button:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.chapter-list button[aria-current="true"] { background: rgba(50, 110, 81, 0.22); border-color: rgba(79, 163, 122, 0.5); color: var(--text); }
.chapter-list .num { font-size: 12px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.chapter-list .ttl { font-size: 13px; font-weight: 600; line-height: 1.3; }
.chapter-list .bar { grid-column: 2; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.chapter-list .bar i { display: block; height: 100%; width: 0; background: var(--accent); }

.info-kicker { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.info-title { font-size: 20px; font-weight: 750; margin: 6px 0 10px; line-height: 1.25; }
.info-text p { margin: 0 0 10px; color: #CFE0D9; font-size: 14px; line-height: 1.65; }
.facts { display: grid; gap: 8px; margin-top: 8px; }
.fact { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.fact .k { font-size: 13px; color: var(--muted); }
.fact .v { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.fact .n { grid-column: 1 / -1; font-size: 12px; color: var(--faint); line-height: 1.5; }

.readouts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.readout { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); min-width: 0; }
.readout .k { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout .v { font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; margin-top: 2px; }
.readout .u { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 3px; }
.readout[data-tone="hot"] .v { color: #FFB066; }
.readout[data-tone="cool"] .v { color: #9FD8FF; }
.readout[data-tone="brand"] .v { color: var(--brand-bright); }
.readout[data-tone="wave"] .v { color: var(--wave); }
.chart { width: 100%; height: 170px; display: block; border-radius: 10px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--border); }
.bmode { width: 100%; aspect-ratio: 3 / 2; display: block; border-radius: 10px; background: #000; border: 1px solid var(--border); }
.face-map { width: 100%; height: auto; display: block; border-radius: 10px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); }

.params { display: grid; gap: 12px; }
.param label, .param .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.param .val { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.param .seg { display: flex; width: 100%; }
.param .seg button { flex: 1; }
.param input[type="range"] { width: 100%; accent-color: var(--accent); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--text); padding: 6px 0; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background 0.15s; flex: none; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--brand-bright); }
.switch input:checked::after { transform: translateX(16px); }
.sources { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.sources a { color: var(--wave); }
.disclaimer { margin-top: 18px; font-size: 12px; color: var(--faint); line-height: 1.6; }

/* ---------------------------------------------------------------- transport */
.transport { display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter); border-top: 1px solid var(--border); background: rgba(9, 17, 14, 0.96); z-index: 25; min-width: 0; }
.transport .ctl { display: flex; align-items: center; gap: 6px; }
.tbtn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.04); display: grid; place-items: center; padding: 0; }
.tbtn svg { width: 18px; height: 18px; }
.tbtn-play { width: 44px; height: 44px; background: var(--accent); border-color: var(--accent); color: #fff; }
.scrub { position: relative; flex: 1; height: 36px; display: flex; align-items: center; cursor: pointer; touch-action: none; min-width: 80px; }
.scrub-track { position: relative; width: 100%; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.scrub-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--brand-bright), var(--accent)); }
.scrub-tick { position: absolute; top: 50%; width: 2px; height: 12px; margin-top: -6px; background: rgba(7, 13, 11, 0.95); }
.scrub-knob { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 102, 0, 0.35); pointer-events: none; }
.scrub-tip { position: absolute; bottom: 34px; transform: translateX(-50%); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
.time { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.time strong { color: var(--text); }
.simclock { font-size: 12px; color: var(--wave); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.speed { height: 32px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; padding: 0 10px; font-size: 13px; }
.speed option { background: var(--surface-solid); }
.chapter-select { display: none; height: 32px; max-width: 46vw; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; padding: 0 10px; font-size: 13px; }
.chapter-select option { background: var(--surface-solid); }
.transport[data-mode="lab"] .scrub, .transport[data-mode="lab"] .ctl, .transport[data-mode="lab"] .time, .transport[data-mode="lab"] .speed { display: none; }
.lab-bar { display: none; align-items: center; gap: 10px; flex: 1; }
.transport[data-mode="lab"] .lab-bar { display: flex; }

/* ---------------------------------------------------------------- overlays */
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(4, 8, 7, 0.92); z-index: 60; transition: opacity 0.35s; }
.loading[data-state="done"] { opacity: 0; pointer-events: none; }
.loading-card { width: min(420px, calc(100vw - 32px)); padding: 28px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow); text-align: center; }
.loading-card .brand-word { display: inline-block; font-size: 16px; }
.loading-title { margin: 16px 0 6px; font-weight: 700; }
.loading-step { color: var(--muted); font-size: 13px; min-height: 20px; }
.loading-bar { margin-top: 16px; height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-bright), var(--accent)); transition: width 0.3s; }
.loading-error { color: #FFB4A0; font-size: 14px; line-height: 1.6; }
.toast { position: fixed; left: 50%; bottom: calc(var(--transport-h) + 16px); transform: translate(-50%, 20px); opacity: 0; background: var(--surface-2); border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 70; transition: opacity 0.25s, transform 0.25s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; line-height: 1.5; }
.modal .row { display: grid; gap: 6px; margin-bottom: 14px; }
.modal .row > span { font-size: 13px; color: var(--muted); }
.modal select { height: 38px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); padding: 0 10px; }
.modal .range-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.modal .est { font-size: 13px; color: var(--muted); margin: 6px 0 16px; line-height: 1.5; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.progress { height: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin: 12px 0 8px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-bright), var(--accent)); }
.modal video { width: 100%; max-height: 46vh; border-radius: 12px; background: #000; margin: 8px 0 14px; }
.note { font-size: 12px; color: var(--faint); line-height: 1.5; }
.debug { position: fixed; left: 8px; bottom: calc(var(--transport-h) + 8px); z-index: 90; font: 12px/1.4 ui-monospace, monospace; background: rgba(0, 0, 0, 0.6); padding: 6px 8px; border-radius: 6px; color: #9FD8FF; pointer-events: none; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .crumbs { display: none; }
}
@media (max-width: 900px) {
  .btn .lbl { display: none; }
  .btn { width: 36px; padding: 0; justify-content: center; }
  .btn-primary { width: auto; padding: 0 12px; }
  .simclock { display: none; }
}
@media (max-width: 760px) {
  :root { --topbar-h: 52px; --transport-h: 60px; --gutter: 10px; }
  .brand-word { font-size: 13px; letter-spacing: 0.16em; }
  .seg button { padding: 5px 9px; font-size: 12px; }
  .tb-mode { display: none; }
  .btn-primary .lbl { display: none; }
  .btn-primary { width: 36px; padding: 0; }
  .time { display: none; }
  .transport .tbtn:not(.tbtn-play) { display: none; }
  .chapter-select { display: block; }
  .drawer { top: auto; left: 0; width: 100%; height: 62%; border-left: 0; border-top: 1px solid var(--border-strong); border-radius: 18px 18px 0 0; transform: translateY(100%); padding-top: 6px; }
  .drawer[data-open="true"] { transform: none; }
  .sheet-handle { display: block; width: 44px; height: 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.25); margin: 4px auto 10px; }
  .cards { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
