/* ==========================================================================
   Học Tốt Hóa Học — Design system (light / dark)
   ========================================================================== */
:root {
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  --brand: #0ea5a4;
  --brand-strong: #0f766e;
  --brand-soft: #d6f5f3;
  --violet: #7c3aed;
  --violet-soft: #ede4ff;
  --orange: #f97316;
  --orange-soft: #ffe8d6;
  --sun: #f5b400;
  --sun-soft: #fff4cc;
  --pink: #e8479a;
  --pink-soft: #ffe0ef;
  --blue: #2f7cf6;
  --blue-soft: #dde9ff;
  --ok: #16a34a;
  --ok-soft: #dcf7e5;
  --bad: #dc2626;
  --bad-soft: #fde2e2;

  --bg: #f3f7fb;
  --bg-dots: rgba(14, 165, 164, .09);
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #edf2f8;
  --text: #102037;
  --text-2: #3b4c66;
  --muted: #5e6f88;
  --border: #e1e8f1;
  --border-strong: #cad5e3;
  --shadow-sm: 0 1px 2px rgba(16, 32, 55, .06), 0 1px 3px rgba(16, 32, 55, .05);
  --shadow: 0 6px 24px -8px rgba(16, 32, 55, .16), 0 2px 6px rgba(16, 32, 55, .05);
  --shadow-lg: 0 24px 48px -16px rgba(16, 32, 55, .25);
  --ring: 0 0 0 3px rgba(14, 165, 164, .35);
  --glass: rgba(255, 255, 255, .78);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-w: 248px;
  --topbar-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #2dd4bf;
  --brand-strong: #5eead4;
  --brand-soft: rgba(45, 212, 191, .14);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, .15);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, .15);
  --sun: #facc15;
  --sun-soft: rgba(250, 204, 21, .14);
  --pink: #f472b6;
  --pink-soft: rgba(244, 114, 182, .15);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, .15);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, .14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .15);

  --bg: #0a1120;
  --bg-dots: rgba(45, 212, 191, .07);
  --surface: #111a2c;
  --surface-2: #152036;
  --surface-3: #1b2842;
  --text: #e8eefb;
  --text-2: #c3cee2;
  --muted: #93a2bd;
  --border: #22314d;
  --border-strong: #2f4166;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 8px 28px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(45, 212, 191, .4);
  --glass: rgba(17, 26, 44, .8);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --brand: #2dd4bf; --brand-strong: #5eead4; --brand-soft: rgba(45, 212, 191, .14);
    --bg: #0a1120; --surface: #111a2c; --surface-2: #152036; --surface-3: #1b2842;
    --text: #e8eefb; --text-2: #c3cee2; --muted: #93a2bd; --border: #22314d; --border-strong: #2f4166;
    --glass: rgba(17, 26, 44, .8); color-scheme: dark;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-body); font-size: 16px; line-height: 1.6; color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(var(--bg-dots) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color .25s, color .25s;
}
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="dark"] a:not(.btn) { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; color: var(--text); }
h1, .h1 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); font-weight: 800; }
h2, .h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); font-weight: 700; }
h3, .h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-3); padding: .1em .4em; border-radius: 6px; }
code.chem { font-family: var(--font-body); font-weight: 600; color: var(--violet); background: var(--violet-soft); }
sub { font-size: .72em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 999; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--surface); --c: var(--text); --bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px;
  padding: .55em 1.15em; border-radius: 999px; border: 1.5px solid var(--bd); background: var(--b); color: var(--c);
  font-weight: 600; font-size: .95rem; line-height: 1.2; cursor: pointer; text-decoration: none !important;
  transition: transform .15s, box-shadow .15s, background-color .15s, border-color .15s; white-space: nowrap; user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { --b: var(--brand-strong); --c: #fff; --bd: var(--brand-strong); box-shadow: 0 6px 16px -6px rgba(14, 165, 164, .7); }
:root[data-theme="dark"] .btn-primary { --b: var(--brand); --bd: var(--brand); }
:root[data-theme="dark"] .btn-primary { --c: #062421; }
.btn-primary:hover { --b: #115e59; --bd: #115e59; }
:root[data-theme="dark"] .btn-primary:hover { --b: var(--brand-strong); --bd: var(--brand-strong); }
.btn-violet { --b: var(--violet); --c: #fff; --bd: var(--violet); }
.btn-orange { --b: var(--orange); --c: #fff; --bd: var(--orange); }
.btn-danger { --b: var(--bad); --c: #fff; --bd: var(--bad); }
.btn-ghost { --b: transparent; --bd: var(--border-strong); }
.btn-soft { --b: var(--brand-soft); --c: var(--brand-strong); --bd: transparent; }
:root[data-theme="dark"] .btn-soft { --c: var(--brand); }
.btn-sm { min-height: 34px; padding: .35em .85em; font-size: .85rem; }
.btn-lg { min-height: 52px; padding: .7em 1.6em; font-size: 1.05rem; }
.btn-icon { width: 44px; padding: 0; }
.btn-block { width: 100%; }
.row-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field > span, .field-label { font-weight: 600; font-size: .9rem; color: var(--text-2); }
.field small { color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input[type="search"], input[type="url"], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: .6em .9em; background: var(--surface); border: 1.5px solid var(--border-strong);
  border-radius: 12px; transition: border-color .15s, box-shadow .15s; color: var(--text);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2em; }
.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; margin: .3rem 0 1rem; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem .4rem; margin: 0 0 1.2rem; }
legend { font-weight: 700; padding: 0 .5rem; font-family: var(--font-display); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
.input-group { position: relative; }
.input-group .toggle-pw { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; padding: 8px; color: var(--muted); border-radius: 8px; }
.form-grid { margin-top: 1rem; }

/* ---------- Alerts / chips / badges ---------- */
.alert { padding: .8rem 1rem; border-radius: 12px; margin: 0 0 1rem; border: 1px solid transparent; font-size: .95rem; }
.alert-info { background: var(--blue-soft); border-color: rgba(47, 124, 246, .25); }
.alert-success { background: var(--ok-soft); border-color: rgba(22, 163, 74, .25); }
.alert-error { background: var(--bad-soft); border-color: rgba(220, 38, 38, .25); }
.alert-warn { background: var(--sun-soft); border-color: rgba(245, 180, 0, .35); }
.chip { display: inline-flex; align-items: center; gap: .35em; padding: .25em .7em; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: .8rem; font-weight: 600; border: 1px solid var(--border); white-space: nowrap; }
.chip-brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }
.chip-violet { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.chip-orange { background: var(--orange-soft); color: var(--orange); border-color: transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip-sun { background: var(--sun-soft); color: #9a6b00; border-color: transparent; }
:root[data-theme="dark"] .chip-brand { color: var(--brand); }
:root[data-theme="dark"] .chip-sun { color: var(--sun); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.card-lg { padding: 1.75rem; border-radius: var(--radius-lg); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-link { display: block; color: inherit; transition: transform .18s, box-shadow .18s, border-color .18s; }
.card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); text-decoration: none; }
.grid { display: grid; gap: 1.25rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.stack > * + * { margin-top: 1.25rem; }
.container { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 30;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--text) !important; text-decoration: none !important; line-height: 1; }
.brand b { color: var(--brand); font-weight: 800; }
.brand img { width: 38px; height: 38px; }
.brand-lg { font-size: 1.5rem; margin-bottom: 1.25rem; }
.sidebar .brand { padding: 6px 8px 18px; font-size: 1.12rem; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 12px; color: var(--text-2); font-weight: 600; font-size: .8rem; text-decoration: none; transition: background-color .15s, color .15s; }
.nav a .ico { font-size: 1.2rem; width: 26px; text-align: center; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-strong); }
:root[data-theme="dark"] .nav a.active { color: var(--brand); }
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.mini-profile { display: flex; align-items: center; gap: .7rem; padding: .7rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 1.4rem; background: linear-gradient(135deg, var(--brand-soft), var(--violet-soft)); flex: none; }
.avatar-lg { width: 84px; height: 84px; font-size: 2.6rem; }
.mini-profile .who { min-width: 0; }
.mini-profile .who b { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-profile .who span { font-size: .78rem; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 25; height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 24px; background: var(--glass); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.topbar .page-h { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .brand { display: none; }
.xp-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .8rem; border-radius: 999px; background: var(--sun-soft); font-weight: 700; font-size: .88rem; color: #8a5f00; }
:root[data-theme="dark"] .xp-pill { color: var(--sun); }
.streak-pill { background: var(--orange-soft); color: var(--orange); }
.content { padding: 24px; flex: 1; width: 100%; max-width: 1480px; }
.page-intro { margin-bottom: 1.25rem; }
.page-intro p { color: var(--muted); max-width: 70ch; }

.theme-toggle { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; display: grid; place-items: center; transition: transform .2s; }
.theme-toggle:hover { transform: rotate(-12deg); }
.theme-toggle svg { width: 22px; height: 22px; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

.bottom-nav { display: none; }
.menu-btn { display: none; }

/* ---------- Public header / landing ---------- */
.site-header { position: sticky; top: 0; z-index: 40; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 1rem; height: 70px; }
.site-header nav { display: flex; gap: 1.4rem; margin-left: auto; align-items: center; }
.site-header nav a.lnk { color: var(--text-2); font-weight: 600; }
.hero { padding: clamp(40px, 7vw, 90px) 0 50px; position: relative; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); }
.hero h1 .hl { background: linear-gradient(100deg, var(--brand), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: 1.15rem; color: var(--text-2); max-width: 54ch; }
.hero-art { position: relative; aspect-ratio: 1; max-width: 460px; margin-inline: auto; width: 100%; }
.hero-blob { position: absolute; inset: 6%; border-radius: 42% 58% 55% 45% / 48% 42% 58% 52%; background: linear-gradient(140deg, var(--brand-soft), var(--violet-soft)); animation: blob 12s ease-in-out infinite; }
.hero-art .robot-hero { position: absolute; inset: 10%; }
.float-tag { position: absolute; padding: .45rem .8rem; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: .9rem; animation: bob 4s ease-in-out infinite; }
.float-tag.t1 { top: 8%; left: -2%; } .float-tag.t2 { bottom: 14%; right: -4%; animation-delay: -1.5s; } .float-tag.t3 { bottom: 2%; left: 8%; animation-delay: -2.6s; }
.section { padding: 56px 0; }
.section-h { text-align: center; max-width: 640px; margin: 0 auto 2rem; }
.section-h p { color: var(--muted); }
.feature { padding: 1.5rem; }
.feature .f-ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 1.8rem; margin-bottom: .9rem; }
.f-teal { background: var(--brand-soft); } .f-violet { background: var(--violet-soft); } .f-orange { background: var(--orange-soft); } .f-pink { background: var(--pink-soft); } .f-sun { background: var(--sun-soft); } .f-blue { background: var(--blue-soft); }
.feature ul { padding-left: 1.1rem; margin: 0; color: var(--text-2); font-size: .95rem; }
.cta-band { background: linear-gradient(120deg, var(--brand), var(--violet)); color: #fff; border-radius: var(--radius-lg); padding: clamp(28px, 5vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.cta-band h2 { color: #fff; margin: 0 0 .3rem; }
.cta-band .btn { --b: #fff; --c: #0b3b3a; --bd: #fff; }
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: .9rem; margin-top: 30px; }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-wrap { width: min(460px, 100%); }
.auth-wide { width: min(760px, 100%); }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(22px, 4vw, 36px); box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.7rem; }
.auth-foot { text-align: center; margin-top: 1rem; color: var(--muted); font-size: .92rem; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.auth-top .brand-lg { margin: 0; }
.req-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .3rem 1rem; font-size: .9rem; margin: 0 0 1rem; }
.req-list .ok { color: var(--ok); } .req-list .bad { color: var(--bad); font-weight: 700; }
.tabs-seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 1rem; }
.tabs-seg button, .tabs-seg a { border: 0; background: none; padding: .45rem 1rem; border-radius: 999px; font-weight: 600; cursor: pointer; color: var(--text-2); font-size: .9rem; text-decoration: none; }
.tabs-seg .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Dashboard ---------- */
.welcome { display: grid; grid-template-columns: 1fr auto; gap: 1.5rem; align-items: center; background: linear-gradient(120deg, var(--brand-soft), var(--violet-soft)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(18px, 3vw, 28px); position: relative; overflow: hidden; }
.welcome h1, .welcome .h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: .2rem; }
.level-bar { margin-top: .9rem; max-width: 460px; }
.progress { height: 12px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--violet)); transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.progress.sm { height: 8px; }
.progress.ok > span { background: var(--ok); } .progress.warn > span { background: var(--orange); } .progress.bad > span { background: var(--bad); }
.stat { display: flex; align-items: center; gap: .9rem; }
.stat .s-ico { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 1.5rem; flex: none; }
.stat b { font-family: var(--font-display); font-size: 1.6rem; line-height: 1; display: block; }
.stat span { color: var(--muted); font-size: .85rem; }
.quick { display: flex; flex-direction: column; gap: .4rem; padding: 1.25rem; min-height: 150px; position: relative; overflow: hidden; }
.quick .q-ico { font-size: 2rem; }
.quick h3 { margin: .2rem 0 0; }
.quick p { color: var(--muted); font-size: .9rem; margin: 0; }
.quick::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 110px; height: 110px; border-radius: 50%; background: var(--q, var(--brand-soft)); opacity: .9; z-index: 0; }
.quick > * { position: relative; z-index: 1; }
.quick[data-q="violet"] { --q: var(--violet-soft); } .quick[data-q="orange"] { --q: var(--orange-soft); } .quick[data-q="pink"] { --q: var(--pink-soft); }
.w-art { width: 130px; height: 150px; animation: bob 4s ease-in-out infinite; }
.rec-list { display: flex; flex-direction: column; gap: .75rem; }
.rec { display: grid; grid-template-columns: 44px 1fr; gap: .8rem; align-items: start; padding: .9rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.rec .r-ico { font-size: 1.5rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface); }
.rec h4, .rec .rec-h { margin: 0 0 .15rem; font-family: var(--font-body); font-size: .98rem; }
.rec p { margin: 0 0 .4rem; font-size: .88rem; color: var(--muted); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .75rem; }
.badge-item { text-align: center; padding: .8rem .4rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: .78rem; font-weight: 600; }
.badge-item .b-ico { font-size: 1.9rem; display: block; margin-bottom: .2rem; }
.badge-item.locked { opacity: .45; filter: grayscale(1); }
.topic-row { display: grid; grid-template-columns: 1fr 120px 44px; gap: .75rem; align-items: center; padding: .4rem 0; font-size: .92rem; }
.topic-row b { font-weight: 600; }

/* ---------- Lessons / path ---------- */
.grade-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.grade-tabs a { padding: .5rem 1.1rem; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--border); font-weight: 700; color: var(--text-2); text-decoration: none; }
.grade-tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .grade-tabs a.on { color: #062421; }
.path { position: relative; display: flex; flex-direction: column; gap: 1.25rem; }
.chapter { display: grid; grid-template-columns: 64px 1fr; gap: 1rem; }
.chapter-node { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 1.9rem; background: var(--surface); border: 2px solid var(--border-strong); box-shadow: var(--shadow-sm); position: relative; z-index: 1; }
.chapter.done .chapter-node { border-color: var(--ok); background: var(--ok-soft); }
.chapter.current .chapter-node { border-color: var(--brand); background: var(--brand-soft); animation: pulse 2.4s ease-in-out infinite; }
.path::before { content: ""; position: absolute; left: 31px; top: 30px; bottom: 30px; width: 3px; border-radius: 3px; background: repeating-linear-gradient(var(--border-strong) 0 8px, transparent 8px 16px); }
.lesson-list { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.lesson-list a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.lesson-list a:hover { border-color: var(--brand); text-decoration: none; }
.lesson-list .tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; border: 2px solid var(--border-strong); flex: none; }
.lesson-list .done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.prose { font-size: 1.04rem; color: var(--text-2); max-width: 72ch; }
.prose h2, .prose h3 { margin-top: 1.4em; color: var(--text); }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .25em 0; }
.prose blockquote { margin: 1em 0; padding: .8rem 1rem; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 12px 12px 0; color: var(--text); }
.prose strong { color: var(--text); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: .75rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 700; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td .row-actions { flex-wrap: nowrap; gap: .35rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Leaderboard ---------- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.podium .p { text-align: center; padding: 1rem .5rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.podium .p .avatar { margin: 0 auto .4rem; width: 64px; height: 64px; font-size: 2rem; }
.podium .p1 { padding-top: 1.8rem; border-color: var(--sun); box-shadow: 0 10px 30px -14px var(--sun); }
.podium .medal { font-size: 1.8rem; }
.rank-me td { background: var(--brand-soft) !important; font-weight: 700; }

/* ---------- Chat (tutor) ---------- */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.25rem; height: calc(100vh - var(--topbar-h) - 48px); min-height: 520px; }
.chat-sessions { display: flex; flex-direction: column; gap: .5rem; overflow: hidden; }
.chat-sessions .list { overflow-y: auto; display: flex; flex-direction: column; gap: .3rem; }
.chat-sessions .list a { display: block; padding: .6rem .75rem; border-radius: 12px; color: var(--text-2); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid transparent; }
.chat-sessions .list a.on, .chat-sessions .list a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.chat-box { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.chat-head .avatar { background: linear-gradient(135deg, #b9f4ee, #e3d7ff); }
.chat-log { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .9rem; scroll-behavior: smooth; }
.msg { display: flex; gap: .6rem; max-width: 88%; animation: pop .25s ease-out; }
.msg .bubble { padding: .75rem 1rem; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); font-size: .97rem; line-height: 1.55; overflow-wrap: anywhere; }
.msg .bubble p:last-child, .msg .bubble ul:last-child, .msg .bubble ol:last-child { margin-bottom: 0; }
.msg .bubble ul, .msg .bubble ol { padding-left: 1.2rem; margin: .4rem 0; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bubble { background: var(--brand); color: #fff; border-color: transparent; border-bottom-right-radius: 6px; }
:root[data-theme="dark"] .msg.me .bubble { color: #052522; }
.msg.bot .bubble { border-bottom-left-radius: 6px; }
.msg .mini-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); flex: none; font-size: 1.1rem; }
.msg .meta { font-size: .74rem; color: var(--muted); margin-top: .3rem; }
.typing { display: inline-flex; gap: 4px; padding: .2rem 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.chat-form { display: flex; gap: .6rem; padding: .9rem; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.chat-form textarea { min-height: 46px; max-height: 160px; border-radius: 16px; resize: none; }
.suggest { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0 1.1rem .8rem; }
.suggest button { border: 1px dashed var(--border-strong); background: var(--surface); border-radius: 999px; padding: .35rem .8rem; font-size: .84rem; cursor: pointer; color: var(--text-2); }
.suggest button:hover { border-color: var(--brand); color: var(--brand-strong); }
.ctx-card { margin: 0 1.1rem .8rem; padding: .7rem .9rem; border-radius: 12px; background: var(--violet-soft); font-size: .88rem; }

/* ---------- Lab ---------- */
.lab { display: grid; grid-template-columns: 270px minmax(0, 1fr) 300px; gap: 1.25rem; align-items: start; }
.shelf { padding: 1rem; max-height: calc(100vh - var(--topbar-h) - 48px); display: flex; flex-direction: column; position: sticky; top: calc(var(--topbar-h) + 24px); }
.shelf-filter { display: flex; gap: .3rem; flex-wrap: wrap; margin: .6rem 0; }
.shelf-filter button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: .25rem .65rem; font-size: .78rem; cursor: pointer; font-weight: 600; color: var(--text-2); }
.shelf-filter button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chem-list { overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; padding-right: 4px; margin-top: .3rem; }
.chem-item { display: grid; grid-template-columns: 38px 1fr; gap: .65rem; align-items: center; padding: .5rem .6rem; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, transform .15s; }
.chem-item:hover { border-color: var(--brand); transform: translateX(2px); }
.chem-item.sel-a { border-color: var(--brand); background: var(--brand-soft); }
.chem-item.sel-b { border-color: var(--violet); background: var(--violet-soft); }
.chem-item .bottle { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; position: relative; background: var(--surface-3); }
.chem-item .bottle i { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 18px; border-radius: 3px 3px 7px 7px; border: 2px solid rgba(0, 0, 0, .12); }
.chem-item .c-name { font-size: .86rem; font-weight: 600; line-height: 1.25; }
.chem-item .c-f { font-size: .78rem; color: var(--violet); font-weight: 700; }
.bench { padding: 0; overflow: hidden; }
.bench-stage { position: relative; aspect-ratio: 16 / 11; background: radial-gradient(ellipse at 50% 120%, var(--surface-3), var(--surface) 70%); border-bottom: 1px solid var(--border); }
.bench-stage canvas { width: 100%; height: 100%; }
.slots { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: .5rem; flex-wrap: wrap; pointer-events: none; }
.slot { pointer-events: auto; display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border-radius: 999px; background: var(--glass); border: 1.5px dashed var(--border-strong); font-size: .84rem; font-weight: 600; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.slot.filled { border-style: solid; }
.slot.a.filled { border-color: var(--brand); } .slot.b.filled { border-color: var(--violet); }
.slot button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 0 0 .2rem; font-size: 1rem; line-height: 1; }
.bench-tools { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 600; font-size: .92rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1.5px solid var(--border-strong); position: relative; transition: background-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--orange); border-color: var(--orange); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.panel-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.panel-steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: .5rem; font-size: .9rem; color: var(--text-2); }
.panel-steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; font-size: .8rem; }
.predict { display: grid; grid-template-columns: 1fr; gap: .4rem; }
.predict label { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; font-size: .9rem; background: var(--surface); transition: border-color .15s, background-color .15s; }
.predict label:hover { border-color: var(--brand); }
.predict input { accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
.predict label.is-on { border-color: var(--brand); background: var(--brand-soft); }
.predict label.right { border-color: var(--ok); background: var(--ok-soft); }
.predict label.wrong { border-color: var(--bad); background: var(--bad-soft); }
.result-card { border-radius: var(--radius); padding: 1rem; background: var(--surface-2); border: 1px solid var(--border); animation: pop .3s ease-out; }
.eq-display { font-size: 1.12rem; font-weight: 700; padding: .7rem .9rem; border-radius: 12px; background: var(--violet-soft); color: var(--text); margin: .6rem 0; overflow-x: auto; white-space: nowrap; }
.verified { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 700; color: var(--ok); }
.featured-exp { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.exp-btn { text-align: left; border: 1.5px solid var(--border); background: var(--surface); border-radius: 14px; padding: .75rem .85rem; cursor: pointer; transition: border-color .15s, transform .15s; }
.exp-btn:hover { border-color: var(--brand); transform: translateY(-2px); }
.exp-btn b { display: block; font-size: .9rem; margin-bottom: .2rem; }
.exp-btn span { font-size: .78rem; color: var(--muted); }

/* ---------- Equation ---------- */
.eq-input { font-size: 1.25rem; font-weight: 600; letter-spacing: .02em; min-height: 58px !important; }
.eq-preview { font-size: 1.5rem; font-weight: 700; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border-strong); min-height: 70px; display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .5rem; overflow-x: auto; }
.eq-preview .term { display: inline-flex; align-items: baseline; gap: .1rem; padding: .1rem .35rem; border-radius: 8px; }
.eq-preview .coef { color: var(--orange); font-size: 1.1em; }
.eq-preview .op { color: var(--muted); }
.atom-table td, .atom-table th { text-align: center; }
.atom-table .ok { color: var(--ok); font-weight: 700; } .atom-table .bad { color: var(--bad); font-weight: 700; }
.balance-scale { display: flex; justify-content: center; margin: .5rem 0 1rem; }
.balance-scale svg { width: 220px; height: 110px; }
.balance-scale .beam { transition: transform .6s cubic-bezier(.3, 1.6, .5, 1); transform-origin: 110px 40px; }
.hint-box { border-left: 4px solid var(--sun); background: var(--sun-soft); padding: .8rem 1rem; border-radius: 0 12px 12px 0; margin-top: .75rem; animation: pop .3s ease-out; }
.diff-pick { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- Quiz ---------- */
.quiz-wrap { max-width: 820px; margin-inline: auto; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.q-dots { display: flex; gap: .3rem; flex-wrap: wrap; }
.q-dots span { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); }
.q-dots span.cur { background: var(--brand); border-color: var(--brand); transform: scale(1.25); }
.q-dots span.ans { background: var(--violet); border-color: var(--violet); }
.q-text { font-size: 1.2rem; font-weight: 600; margin-bottom: 1.1rem; }
.opts { display: grid; gap: .6rem; }
.opt { display: grid; grid-template-columns: 40px 1fr; gap: .7rem; align-items: center; padding: .8rem 1rem; border: 2px solid var(--border); border-radius: 16px; background: var(--surface); cursor: pointer; text-align: left; font-size: 1rem; transition: border-color .15s, background-color .15s, transform .12s; width: 100%; }
.opt:hover { border-color: var(--brand); transform: translateX(3px); }
.opt .k { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); font-weight: 800; font-family: var(--font-display); }
.opt.sel { border-color: var(--violet); background: var(--violet-soft); }
.opt.sel .k { background: var(--violet); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; transform: none; }
.score-ring { width: 150px; height: 150px; margin: 0 auto 1rem; position: relative; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 2.2rem; }
.review-item { padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.review-item.ok { border-left: 5px solid var(--ok); } .review-item.no { border-left: 5px solid var(--bad); }

/* ---------- Robot widget ---------- */
.robot-dock { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; }
.robot-dock > * { pointer-events: auto; }
.robot-btn { width: 108px; height: 120px; border: 0; background: none; padding: 0; cursor: pointer; position: relative; animation: bob 3.6s ease-in-out infinite; filter: drop-shadow(0 12px 18px rgba(16, 32, 55, .28)); }
.robot-btn:focus-visible { box-shadow: none; outline: 3px solid var(--brand); outline-offset: 4px; border-radius: 30px; }
.robot-btn svg { width: 100%; height: 100%; overflow: visible; }
.robot-bubble { max-width: 260px; background: var(--surface); border: 1px solid var(--border); padding: .7rem .9rem; border-radius: 18px 18px 6px 18px; box-shadow: var(--shadow); font-size: .9rem; line-height: 1.45; position: relative; animation: pop .3s ease-out; }
.robot-bubble .x { position: absolute; top: 4px; right: 6px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 4px; }
.robot-panel { width: min(380px, calc(100vw - 32px)); height: min(540px, calc(100vh - 170px)); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .25s ease-out; transform-origin: bottom right; }
.robot-panel .chat-head { padding: .75rem .9rem; background: linear-gradient(120deg, var(--brand-soft), var(--violet-soft)); }
.robot-panel .chat-log { padding: .9rem; }
.robot-panel .chat-form { padding: .7rem; }
.robot-panel .msg { max-width: 94%; }
.r-eye { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.r-arm-r { transform-box: fill-box; transform-origin: 10% 10%; }
.r-head { transform-box: fill-box; transform-origin: 50% 90%; }
.r-antenna { animation: glow 2s ease-in-out infinite; }
.robot-svg.wave .r-arm-r { animation: wave 1.2s ease-in-out 2; }
.robot-svg.tilt .r-head { animation: tilt 1.6s ease-in-out; }
.robot-svg.happy .r-mouth-n { display: none; }
.robot-svg:not(.happy) .r-mouth-h { display: none; }
.robot-svg.jump { animation: jump .7s cubic-bezier(.3, 1.5, .6, 1) 2; }
.robot-svg.spin .r-flask { animation: swirl 1.4s ease-in-out; transform-box: fill-box; transform-origin: center; }
.robot-svg.think .r-eye { animation: look 1.8s ease-in-out; }

/* ---------- Toast & modal ---------- */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast { pointer-events: auto; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); padding: .75rem 1rem; border-radius: 14px; font-weight: 600; font-size: .93rem; animation: drop .35s cubic-bezier(.2, 1.4, .4, 1); display: flex; align-items: center; gap: .6rem; width: 100%; }
.toast.ok { border-left: 5px solid var(--ok); } .toast.bad { border-left: 5px solid var(--bad); } .toast.xp { border-left: 5px solid var(--sun); }
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(8, 15, 30, .55); backdrop-filter: blur(3px); }
.dlg-body { padding: 1.4rem; }
.dlg-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 120; }

/* ---------- Pager / empty ---------- */
.pager { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1rem; }
.pager a, .pager span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .9rem; padding: 0 .5rem; }
.pager .is-current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager-gap { border: 0 !important; background: none !important; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .e-ico { font-size: 3rem; display: block; margin-bottom: .5rem; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis { stroke: var(--border-strong); }
.chart .grid-l { stroke: var(--border); stroke-dasharray: 3 4; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .bar { fill: var(--brand); transition: opacity .15s; }
.chart .bar:hover { opacity: .8; }
.chart .bar.alt { fill: var(--violet); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--brand-soft); }
.chart .dot { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.heat { display: grid; gap: 3px; font-size: .78rem; }
.heat .cell { padding: .45rem .3rem; border-radius: 6px; text-align: center; font-weight: 700; color: #102037; }
.heat .h-head { font-weight: 700; color: var(--muted); padding: .3rem; font-size: .74rem; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: .5rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* ---------- Admin ---------- */
.admin .sidebar { background: #0f1b2f; border-right-color: #0f1b2f; }
.admin .sidebar .brand { color: #fff !important; }
.admin .sidebar .nav a { color: #b6c3d9; }
.admin .sidebar .nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.admin .sidebar .nav a.active { background: rgba(45, 212, 191, .16); color: #5eead4; }
.admin .sidebar .nav-label { color: #6c7d99; }
.admin .mini-profile { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .08); }
.admin .mini-profile .who b { color: #fff; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; min-height: 40px; }
.toolbar input[type="search"] { min-width: 220px; flex: 1; max-width: 340px; }
.kpi { padding: 1.1rem 1.2rem; }
.kpi .k-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.kpi .k-val { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1.1; margin: .2rem 0; }
.kpi .k-sub { font-size: .8rem; color: var(--muted); }
.cred-card { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 1rem 1.2rem; background: var(--surface-2); }
.cred-card dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.cred-card dt { color: var(--muted); }
.cred-card dd { margin: 0; font-weight: 700; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .35rem; }
.status-dot.on { background: var(--ok); } .status-dot.off { background: var(--bad); }
.key-mask { font-family: ui-monospace, Menlo, monospace; letter-spacing: .1em; }

/* ---------- Animations ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes glow { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-35deg); } 75% { transform: rotate(10deg); } }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-9deg); } 70% { transform: rotate(7deg); } }
@keyframes jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-26px) scale(1.03, .97); } }
@keyframes swirl { 0% { transform: rotate(0); } 50% { transform: rotate(18deg); } 100% { transform: rotate(0); } }
@keyframes look { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 164, .45); } 50% { box-shadow: 0 0 0 10px rgba(14, 165, 164, 0); } }
@keyframes blob { 0%, 100% { border-radius: 42% 58% 55% 45% / 48% 42% 58% 52%; transform: rotate(0); } 50% { border-radius: 56% 44% 42% 58% / 52% 58% 42% 48%; transform: rotate(8deg); } }
/* Lab — bước, dự đoán trong bàn, trạng thái, popup */
.bench { border: 0; box-shadow: var(--shadow); overflow: clip; }
.bench .bench-tools { position: sticky; bottom: 0; z-index: 2; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.bench-stage { aspect-ratio: 16 / 10; background: var(--surface-2); }
.lab-steps { list-style: none; margin: 0; padding: .7rem .9rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; background: linear-gradient(90deg, var(--brand-soft), var(--violet-soft)); border-bottom: 1px solid var(--border); }
.lab-steps li { display: flex; align-items: center; justify-content: center; gap: .4rem; font-size: .8rem; font-weight: 700; color: var(--muted); padding: .3rem .4rem; border-radius: 999px; transition: background-color .2s, color .2s; white-space: nowrap; }
.lab-steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--border-strong); font-size: .74rem; flex: none; }
.lab-steps li.done { color: var(--brand-strong); }
.lab-steps li.done span { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 0; }
.lab-steps li.done span::after { content: "✓"; font-size: .74rem; }
.lab-steps li.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.lab-steps li.on span { background: var(--brand); border-color: var(--brand); color: #fff; animation: glow 1.6s ease-in-out infinite; }
.stage-status { text-align: center; padding: .5rem 1rem; font-weight: 700; font-size: .9rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.stage-status.run { background: var(--violet-soft); color: var(--violet); }
.stage-status.ok { background: var(--ok-soft); color: var(--ok); }
.predict-box { padding: .75rem 1rem .25rem; border-bottom: 1px solid var(--border); border-radius: 0; }
.predict-box.pulse { animation: predPulse 1.2s ease-out 2; }
@keyframes predPulse { 0% { box-shadow: inset 0 0 0 3px var(--violet); background: var(--violet-soft); } 100% { box-shadow: inset 0 0 0 3px transparent; background: transparent; } }
.predict-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .45rem; }
.predict-head .h3 { font-size: 1.02rem; }
.predict { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .45rem; }
.predict label { padding: .38rem .55rem; font-size: .84rem; line-height: 1.2; position: relative; min-height: 40px; }
.predict label .p-ico { font-size: 1.1rem; flex: none; }
.predict label.missed { border-color: var(--sun); background: var(--sun-soft); border-style: dashed; }
.is-busy .predict label { cursor: not-allowed; opacity: .75; }
.btn-run:not(:disabled) { box-shadow: 0 8px 20px -8px var(--brand); }
.btn-run:not(:disabled):hover { transform: translateY(-1px); }
.chem-item .bottle i { transition: transform .2s; }
.chem-item:hover .bottle i { transform: translateY(-2px); }
.chem-item.sel-a .bottle, .chem-item.sel-b .bottle { box-shadow: 0 0 0 2px var(--brand) inset; }
.chem-item.sel-b .bottle { box-shadow: 0 0 0 2px var(--violet) inset; }

dialog.lab-modal { width: min(440px, calc(100% - 32px)); overflow: visible; margin: auto; padding-top: 0; text-align: center; animation: modalIn .28s cubic-bezier(.2, .9, .3, 1.3); }
dialog.lab-modal-lg { width: min(620px, calc(100% - 32px)); text-align: left; }
dialog.lab-modal[open] { display: block; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.94); } to { opacity: 1; transform: none; } }
.lm-hero { width: 84px; height: 84px; margin: -42px auto 0; border-radius: 50%; display: grid; place-items: center; font-size: 2.6rem; background: var(--brand); box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .35), 0 0 0 6px var(--surface); animation: jump .9s ease-out 1 .15s; }
.lm-ok { background: linear-gradient(135deg, #34d399, #0ea5a4); }
.lm-sun { background: linear-gradient(135deg, #fde047, #f59e0b); }
.lm-violet { background: linear-gradient(135deg, #c4b5fd, #7c3aed); }
.lm-blue { background: linear-gradient(135deg, #93c5fd, #2f7cf6); }
.lm-body { padding: 1rem 1.4rem 1.3rem; max-height: calc(100vh - 140px); overflow-y: auto; }
.lab-modal-lg .lm-body { padding-top: .6rem; }
.lm-x { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--text-2); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.lm-x:hover { background: var(--border-strong); }
.lm-score { text-align: center; font-weight: 700; padding: .65rem .9rem; border-radius: 14px; margin: .2rem 0 .9rem; }
.lm-score.ok { background: var(--ok-soft); color: var(--ok); }
.lm-score.warn { background: var(--sun-soft); color: #8a5a00; }
.lm-score.info { background: var(--blue-soft); color: var(--blue); }
:root[data-theme="dark"] .lm-score.warn { color: var(--sun); }
.lm-obs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0 .3rem; }
.obs-chip { font-size: .8rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; border: 1.5px solid; }
.obs-chip.right { border-color: var(--ok); background: var(--ok-soft); }
.obs-chip.wrong { border-color: var(--bad); background: var(--bad-soft); text-decoration: line-through; }
.obs-chip.missed { border-color: var(--sun); background: var(--sun-soft); border-style: dashed; }
.obs-legend { width: 100%; margin: .2rem 0 0; font-size: .74rem; }
.lm-sec { margin-top: .7rem; padding: .7rem .85rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.lm-sec b { display: block; font-size: .88rem; margin-bottom: .2rem; }
.lm-sec p { margin: 0; color: var(--text-2); font-size: .93rem; }
.lm-actions { justify-content: center; margin-top: 1rem; }
.lab-modal-lg .lm-actions { justify-content: flex-end; }
.lab-modal .verified { margin-bottom: .2rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .lab { grid-template-columns: 260px minmax(0, 1fr); }
  .lab .lab-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; align-items: start; }
  .lab .lab-side > * + * { margin-top: 0; }
  .lab .lab-side { grid-column: 1 / -1; }
}
@media (max-width: 1080px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 340px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; padding-bottom: 96px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; font-weight: 600; color: var(--muted); padding: 4px 0; text-decoration: none; border-radius: 10px; }
  .bottom-nav a .ico { font-size: 1.3rem; }
  .bottom-nav a.active { color: var(--brand-strong); }
  :root[data-theme="dark"] .bottom-nav a.active { color: var(--brand); }
  .admin .bottom-nav { display: none; }
  .admin .content { padding-bottom: 24px; }
  .robot-dock { bottom: 84px; right: 10px; }
  .robot-btn { width: 78px; height: 88px; }
  .lab { grid-template-columns: 1fr; }
  .bench .bench-tools { bottom: calc(62px + env(safe-area-inset-bottom)); }
  .shelf { position: static; max-height: 360px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-sessions { display: none; }
  .chat-box { height: calc(100vh - var(--topbar-h) - 130px); min-height: 460px; }
  .site-header nav a.lnk { display: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8, 15, 30, .45); z-index: 29; }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .welcome { grid-template-columns: 1fr; }
  .welcome .w-art { display: none; }
  .topbar .page-h { font-size: 1.05rem; }
  .xp-pill .lbl { display: none; }
  .card { padding: 1rem; }
  .podium { gap: .5rem; }
  .podium .p .avatar { width: 48px; height: 48px; font-size: 1.5rem; }
  .podium .p { font-size: .82rem; }
  .q-text { font-size: 1.08rem; }
  .eq-preview { font-size: 1.15rem; }
  .topic-row { grid-template-columns: 1fr 80px 40px; }
  .toolbar input[type="search"] { min-width: 0; max-width: none; }
  th, td { padding: .6rem; }
  .hide-sm { display: none; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .robot-dock, .no-print, .toasts { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; }
}
.pt-0 { padding-top: 0 !important; }
.w-100 { width: 100%; }
details summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
details summary:hover { color: var(--text); }
.sc-base { fill: var(--border-strong); } .sc-v { fill: var(--violet); } .sc-line { fill: none; stroke: var(--violet); stroke-width: 2; }
.sc-l { fill: var(--brand); } .sc-r { fill: var(--orange); } .sc-pin { fill: var(--sun); }
.eq-preview .stepper { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.eq-preview .stepper button { width: 26px; height: 20px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: .8rem; line-height: 1; color: var(--text-2); padding: 0; }
.eq-preview .stepper button:hover { border-color: var(--brand); color: var(--brand-strong); }
.eq-preview .term.bad-el { background: var(--bad-soft); }
.eq-preview .formula { font-size: 1.05em; }
tbody th { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); background: transparent; }
.eq-preview .term { align-items: center; gap: .35rem; }
.row-center { justify-content: center; }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--brand); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 1.2s ease; }
.ring-fg.ok { stroke: var(--ok); } .ring-fg.warn { stroke: var(--orange); } .ring-fg.bad { stroke: var(--bad); }
.avatar-sm { width: 32px; height: 32px; font-size: 1.05rem; display: inline-grid; vertical-align: middle; margin-right: .35rem; }
.badge-item.is-current { border-color: var(--brand); background: var(--brand-soft); }
button.badge-item { cursor: pointer; font: inherit; color: inherit; }
.inline-form { display: inline; margin: 0; }
.link-btn { border: 0; background: none; color: var(--bad); cursor: pointer; padding: 0 .15rem; font-size: 1rem; line-height: 1; font-weight: 700; }
.span-2 { grid-column: 1 / -1; }
.md-preview { max-height: 520px; overflow: auto; }
.heat-table td, .heat-table th { text-align: center; }
.heat-table tbody th { text-align: left; }
.heat-cell { font-weight: 700; font-size: .85rem; color: #102037; }
.h-1 { background: #fca5a5 !important; } .h-2 { background: #fdba74 !important; } .h-3 { background: #fde68a !important; } .h-4 { background: #bef264 !important; } .h-5 { background: #86efac !important; } .h-none { color: var(--muted); }
.legend i.h-1, .legend i.h-2, .legend i.h-3, .legend i.h-4, .legend i.h-5 { display: inline-block; }
.field > .btn { align-self: flex-start; }
.auth-card .w-art { margin: 0 auto 1rem; }
p a:not(.btn), li a:not(.btn), .auth-foot a { text-decoration: underline; text-underline-offset: 3px; }
.nav a, .lesson-list a, .chat-sessions a, .card-link, .grade-tabs a, .tabs-seg a, .pager a { text-decoration: none !important; }
.grade-tabs a.on, .pager .is-current { background: var(--brand-strong); border-color: var(--brand-strong); }
:root[data-theme="dark"] .grade-tabs a.on { background: var(--brand); border-color: var(--brand); }
.shelf-filter button.on { background: var(--brand-strong); border-color: var(--brand-strong); }
/* Độ tương phản chữ (WCAG AA) cho giao diện sáng */
.chip-orange, .streak-pill { color: #b23c0a; }
.chip-ok { color: #157a3a; }
.chip-bad { color: #b42318; }
.chip-violet { color: #6227d1; }
.btn-orange { --b: #c2410c; --bd: #c2410c; }
:root[data-theme="dark"] .chip-orange, :root[data-theme="dark"] .streak-pill { color: var(--orange); }
:root[data-theme="dark"] .chip-ok { color: var(--ok); }
:root[data-theme="dark"] .chip-bad { color: var(--bad); }
:root[data-theme="dark"] .chip-violet { color: var(--violet); }
:root[data-theme="dark"] .btn-orange { --b: var(--orange); --bd: var(--orange); --c: #2a1204; }

@media (max-width: 640px) {
  .streak-pill { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .stats-grid .stat { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .stats-grid .stat b { font-size: 1.35rem; }
  .stats-grid .quick { min-height: 128px; padding: 1rem; }
  .stats-grid .quick p { display: none; }
  .bench-stage { aspect-ratio: 4 / 3; }
  .lab-steps { gap: .2rem; padding: .5rem; }
  .lab-steps li { font-size: 0; gap: 0; padding: .2rem; }
  .lab-steps li span { font-size: .74rem; }
  .lab-steps li.on { font-size: .72rem; gap: .3rem; padding: .2rem .5rem; }
  .predict { grid-template-columns: 1fr 1fr; }
  .predict label { font-size: .78rem; padding: .4rem .45rem; gap: .35rem; }
  .lab-modal-lg .lm-actions .btn { flex: 1 1 auto; }
  .slot { font-size: .75rem; padding: .25rem .55rem; }
  .chat-head .small, .chat-head .chip { display: none; }
  .site-header .brand { font-size: 1.05rem; }
  .site-header .brand span { white-space: nowrap; }
  .site-header nav { gap: .5rem; }
  .welcome h1, .welcome .h1 { font-size: 1.4rem; }
}
a.mini-profile { color: inherit; text-decoration: none !important; transition: border-color .15s; }
a.mini-profile:hover { border-color: var(--brand); }

.diag-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .35rem; font-size: .92rem; }
.diag-list li span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .75rem; font-weight: 700; margin-right: .3rem; color: #fff; }
.diag-list li.ok span { background: var(--ok); } .diag-list li.bad span { background: var(--bad); } .diag-list li.warn span { background: var(--orange); }
.diag-list li.bad { color: var(--bad); font-weight: 600; } .diag-list li.warn { color: #b23c0a; font-weight: 600; }
:root[data-theme="dark"] .diag-list li.warn { color: var(--orange); }
.ai-status code { font-size: .85em; }
