/* CubeX LMS — Adaptive Playful Minimalism
   Flat Design 2.0 + age-gated modular theming.
   Brand: CubeX Turquoise #00E5BC, Pure Black #000000, Pure White #FFFFFF.
   Turquoise is used as a fill/indicator; text on white uses the darker
   --accent-ink (#00775F, 5.3:1 on white) to meet WCAG AA. */

:root {
  --cubex-turquoise: #00E5BC;
  --cubex-black: #000000;
  --cubex-white: #FFFFFF;

  /* Neutrals (subordinate to the brand colours) */
  --graphite-950: #0A0C0D;
  --graphite-900: #111416;
  --graphite-800: #1A1E21;
  --graphite-700: #2A3034;
  --graphite-500: #5B656C;
  --graphite-400: #808A91;
  --graphite-200: #D9DEE1;
  --graphite-100: #EDF0F2;
  --graphite-50: #F6F8F9;

  /* Semantic (used sparingly, always with an icon + label) */
  --ok: #0E7A4F;
  --warn: #8A5A00;
  --danger: #B42318;
  --info: #1F5F8B;

  /* Light theme tokens */
  --bg: var(--graphite-50);
  --surface: var(--cubex-white);
  --surface-2: var(--graphite-100);
  --border: var(--graphite-200);
  --text: #0B0F11;
  --text-2: #3F484E;
  --muted: #5B656C;
  --accent: var(--cubex-turquoise);
  --accent-ink: #00775F;
  --accent-soft: #E3FBF5;
  --on-accent: var(--cubex-black);
  --focus: #00A688;
  --ok-bg: #E7F6EE; --warn-bg: #FFF4DC; --danger-bg: #FDECEA; --info-bg: #E8F1F8;
  --shadow-1: 0 1px 2px rgba(10, 12, 13, .06), 0 1px 1px rgba(10, 12, 13, .04);
  --shadow-2: 0 8px 24px rgba(10, 12, 13, .08), 0 2px 6px rgba(10, 12, 13, .05);
  --chart-mark: #00927A;
  --chart-grid: #E3E7EA;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --gap: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Nastaliq Urdu", sans-serif;
  --font-display: "Poppins", var(--font);
  --fs: 15px;
  --control-h: 40px;
  --sidebar-w: 248px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--cubex-black); --surface: var(--graphite-900); --surface-2: var(--graphite-800); --border: var(--graphite-700);
    --text: #F2F5F6; --text-2: #C5CDD2; --muted: #98A3AA; --accent-ink: var(--cubex-turquoise); --accent-soft: rgba(0, 229, 188, .12);
    --focus: var(--cubex-turquoise); --ok: #4CD597; --warn: #F5C451; --danger: #FF8A80; --info: #8CC4EE;
    --ok-bg: rgba(76, 213, 151, .12); --warn-bg: rgba(245, 196, 81, .12); --danger-bg: rgba(255, 138, 128, .12); --info-bg: rgba(140, 196, 238, .12);
    --shadow-1: none; --shadow-2: 0 8px 28px rgba(0, 0, 0, .5); --chart-mark: var(--cubex-turquoise); --chart-grid: #262C30;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--cubex-black); --surface: var(--graphite-900); --surface-2: var(--graphite-800); --border: var(--graphite-700);
  --text: #F2F5F6; --text-2: #C5CDD2; --muted: #98A3AA; --accent-ink: var(--cubex-turquoise); --accent-soft: rgba(0, 229, 188, .12);
  --focus: var(--cubex-turquoise); --ok: #4CD597; --warn: #F5C451; --danger: #FF8A80; --info: #8CC4EE;
  --ok-bg: rgba(76, 213, 151, .12); --warn-bg: rgba(245, 196, 81, .12); --danger-bg: rgba(255, 138, 128, .12); --info-bg: rgba(140, 196, 238, .12);
  --shadow-1: none; --shadow-2: 0 8px 28px rgba(0, 0, 0, .5); --chart-mark: var(--cubex-turquoise); --chart-grid: #262C30;
  color-scheme: dark;
}

:root[data-text="large"] { --fs: 17px; }
:root[data-text="xlarge"] { --fs: 19px; }

/* ---------- Age-gated themes (student views only) ---------- */
body[data-age="g1_3"] { --fs: 18px; --radius: 18px; --radius-lg: 24px; --control-h: 52px; --font-display: "Baloo 2", "Poppins", var(--font); }
body[data-age="g1_3"] .content { background-image: radial-gradient(circle at 12px 12px, var(--accent-soft) 2px, transparent 2.5px); background-size: 28px 28px; }
body[data-age="g1_3"] .btn { font-size: 1.05rem; padding-inline: 22px; }
body[data-age="g1_3"] .hero-task { border-width: 3px; }
body[data-age="g1_3"] .tile, body[data-age="g1_3"] .card { border-width: 2px; }
body[data-age="g4_5"] { --fs: 16.5px; --radius: 14px; --radius-lg: 18px; --control-h: 46px; }
body[data-age="g6_8"] { --fs: 15.5px; }
body[data-age="g6_8"] .hero-task { background-image: linear-gradient(var(--chart-grid) 1px, transparent 1px), linear-gradient(90deg, var(--chart-grid) 1px, transparent 1px); background-size: 22px 22px; }
body[data-age="g9_10"], body[data-age="g11_12"] { --radius: 8px; --radius-lg: 10px; }
body[data-age="g11_12"] .page-header h1 { letter-spacing: -.02em; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; margin: 0 0 .4em; font-weight: 650; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
img { max-width: 100%; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }
code.block { display: block; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); word-break: break-all; user-select: all; }
blockquote { margin: 0; padding: 12px 14px; border-inline-start: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.error-text { color: var(--danger); font-weight: 600; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 700; }
.skip:focus { top: 8px; }
.icon { flex-shrink: 0; vertical-align: middle; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--gap); }
.section-title { margin-top: 8px; }

/* ---------- Brand ---------- */
.logo-tile { background: var(--cubex-black); border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; }
.logo-tile img { display: block; height: 100%; width: auto; object-fit: contain; }
.logo-full { height: 168px; padding: 16px 24px; }
.logo-sidebar { height: 76px; padding: 8px 18px; }
.logo-fallback { display: flex; flex-direction: column; align-items: center; color: var(--cubex-white); font-family: var(--font-display); font-weight: 800; line-height: 1; }
.logo-fallback .wm-cubex { font-size: 1.6em; } .logo-fallback .wm-lms { font-size: 1em; letter-spacing: .08em; margin-top: 4px; }
.logo-full .logo-fallback { font-size: 1.6rem; }

/* ---------- Buttons & controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s; text-decoration: none; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: #00CFAA; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn-lg { min-height: calc(var(--control-h) + 8px); font-size: 1.05rem; padding: 0 22px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; text-align: start; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; min-height: var(--control-h); width: 100%; }
textarea { min-height: auto; resize: vertical; }
select[multiple] { min-height: 110px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent-ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .92rem; }
.req { color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check small { display: block; flex-basis: 100%; margin-inline-start: 28px; margin-top: -6px; }
.check { flex-wrap: wrap; }
.check-inline { align-items: center; flex-wrap: nowrap; font-size: .9rem; }
.check-pill { border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; align-items: center; }
.check-pill:has(input:checked) { border-color: var(--accent-ink); background: var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.form-grid .span-2, .form-grid fieldset, .form-grid .form-errors { grid-column: 1 / -1; }
.form-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-inline .field { flex: 1 1 240px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0; }
fieldset.grade-pick, fieldset.checks { display: flex; flex-wrap: wrap; gap: 10px; }
legend { font-weight: 600; padding: 0 6px; }
.form-errors { border: 1px solid var(--danger); background: var(--danger-bg); color: var(--text); padding: 12px 14px; border-radius: var(--radius-sm); }
.form-errors ul { margin: 6px 0 0; padding-inline-start: 20px; }
.weight-input { width: 90px; text-align: end; }
.wizard-actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wizard-actions { justify-content: space-between; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: var(--gap); }
.filters select, .filters input { width: auto; flex: 1 1 200px; }

/* ---------- Layout shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.sidebar-brand { padding: 4px 6px 18px; display: flex; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar a, .sidebar .linklike { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 550; width: 100%; }
.sidebar a:hover, .sidebar .linklike:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
[dir="rtl"] .sidebar a.active { box-shadow: inset -3px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.menu-btn { display: none; }
.ctx-select { width: auto; max-width: min(420px, 60vw); min-height: 36px; font-weight: 600; }
.ctx-label { font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 4px; }
.bell .dot { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.profile { position: relative; }
.profile summary { list-style: none; cursor: pointer; border-radius: 50%; }
.profile summary::-webkit-details-marker { display: none; }
.profile .menu { position: absolute; inset-inline-end: 0; top: 46px; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--cubex-black); color: var(--cubex-turquoise); display: grid; place-items: center; font-weight: 700; font-family: var(--font-display); flex-shrink: 0; }
.avatar.sm { width: 34px; height: 34px; font-size: .9rem; }
.content { padding: 24px; width: 100%; max-width: 1320px; margin: 0 auto; flex: 1; }
.content:focus { outline: none; }
.demo-banner { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 6px 16px; background: var(--cubex-black); color: var(--cubex-white); font-size: .82rem; text-align: center; }
.demo-banner .icon { color: var(--cubex-turquoise); }
.scrim { display: none; }

.page-header { margin-bottom: 20px; }
.page-header-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header h1:focus { outline: none; }
.page-header p { margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions select { width: auto; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 8px; font-size: .85rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-inline-end: 6px; color: var(--border); }

/* ---------- Cards, tiles, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-header h2 { margin: 0; font-size: 1.02rem; }
.card-body { padding: 16px 20px 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: var(--gap); }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); color: inherit; text-decoration: none; transition: border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s; }
a.tile:hover { border-color: var(--accent-ink); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.tile h3 { margin: 4px 0 0; }
.tile p { margin: 0; }
.tile-icon { width: 44px; height: 44px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; }
.grade-badge { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; min-width: 0; }
.stat-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 550; }
.stat-icon { color: var(--accent-ink); display: inline-flex; }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.stat-value .badge { font-size: .85rem; }
.stat-hint { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stat-warning { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.stat-danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.big-number { font-family: var(--font-display); font-size: 2.4rem; font-weight: 800; line-height: 1; }
.big-number.sm { font-size: 1.5rem; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.notice .icon { color: var(--info); margin-top: 2px; }
.notice-danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.notice-danger .icon { color: var(--danger); }
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: var(--radius); padding: 14px 16px; }
.danger-zone h3 { display: flex; gap: 8px; align-items: center; color: var(--danger); }
.notice-success { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice-success .icon { color: var(--ok); }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge-success { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: .75rem; font-weight: 600; margin-inline-start: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips .chip { margin: 0; }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-observed { background: var(--ok-bg); color: var(--ok); margin: 0 6px; }
.chip-inferred { background: var(--surface-2); color: var(--muted); margin: 0 6px; }

/* ---------- Tables (become cards on narrow screens) ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
.table tbody tr:hover { background: var(--surface-2); }
.table .t-right { text-align: end; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.th-sort { background: none; border: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; align-items: center; cursor: pointer; padding: 0; }
th[aria-sort="descending"] .th-sort .icon { transform: rotate(180deg); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 12px; }
.inline-progress { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.inline-progress .progress { flex: 1; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--chart-mark); border-radius: 4px; transition: width .3s var(--ease); }

/* ---------- Charts ---------- */
.chart { margin: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.chart-title { font-size: .85rem; color: var(--text-2); font-weight: 600; }
.chart-note { font-size: .78rem; margin: 10px 0 0; }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr 48px; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; font-size: .88rem; }
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-2); }
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; display: block; position: relative; }
.bar-fill { display: block; height: 100%; background: var(--chart-mark); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-suppressed { font-size: .75rem; color: var(--muted); font-style: italic; }
.bar-value { text-align: end; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.line-wrap { width: 100%; }
.line-chart { width: 100%; height: auto; display: block; }
.line-chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.line-chart .axis { fill: var(--muted); font-size: 11px; }
.line-chart .line { fill: none; stroke: var(--chart-mark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .dot { fill: var(--chart-mark); stroke: var(--surface); stroke-width: 2; }
.line-chart .hit { fill: transparent; }
.line-chart .pt:focus-visible .dot, .line-chart .pt:hover .dot { r: 6; }
.line-chart .direct-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart-tip { position: fixed; z-index: 200; display: none; pointer-events: none; background: var(--cubex-black); color: var(--cubex-white); padding: 6px 10px; border-radius: 6px; font-size: .8rem; box-shadow: var(--shadow-2); max-width: 260px; }

/* ---------- Tabs ---------- */
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--gap); overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel:focus { outline: none; }

/* ---------- Dialogs & toasts ---------- */
.modal { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: var(--shadow-2); }
.modal-lg { width: min(860px, calc(100vw - 32px)); }
.modal-sm { width: min(420px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, .45); }
.modal[open] { display: flex; flex-direction: column; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; inset-inline-end: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); animation: rise .2s var(--ease); }
.toast span { flex: 1; }
.toast-success .icon:first-child { color: var(--ok); } .toast-error .icon:first-child { color: var(--danger); } .toast-warning .icon:first-child { color: var(--warn); } .toast-info .icon:first-child { color: var(--accent-ink); }
.toast .icon-btn { width: 28px; height: 28px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty / loading / error ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 6px; }
.empty h3 { margin: 0; }
.empty p { max-width: 460px; }
.error-state .empty-icon { background: var(--danger-bg); color: var(--danger); }
.skeleton-block { display: flex; flex-direction: column; gap: 12px; padding: 12px 0; }
.skeleton-line { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Stepper ---------- */
.stepper { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 var(--gap); flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: .85rem; font-weight: 600; }
.stepper li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: .78rem; }
.stepper li.current { color: var(--text); border-color: var(--accent-ink); }
.stepper li.current span, .stepper li.done span { background: var(--accent); color: var(--on-accent); }
.summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.summary dt { color: var(--muted); font-weight: 600; } .summary dd { margin: 0; }

/* ---------- Upload ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-2); cursor: pointer; color: var(--text-2); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag, .dropzone:focus-within { border-color: var(--accent-ink); background: var(--accent-soft); }
.dropzone .icon { color: var(--accent-ink); }
.upload-task { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.upload-title { display: flex; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.upload-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-task.done { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.upload-task.failed { border-color: var(--danger); }
.upload-task.failed .progress-fill { background: var(--danger); }

/* ---------- Video & segment editor ---------- */
.player { display: flex; flex-direction: column; gap: 8px; }
.video { width: 100%; max-height: 60vh; background: #000; border-radius: var(--radius); }
.timeline { position: relative; height: 28px; background: var(--surface-2); border-radius: 6px; cursor: pointer; overflow: hidden; }
.timeline .seg { position: absolute; top: 4px; bottom: 4px; border: 0; border-radius: 4px; background: var(--chart-mark); opacity: .85; cursor: pointer; padding: 0; box-shadow: 0 0 0 2px var(--surface); }
.timeline .seg-needs_identity { background: repeating-linear-gradient(135deg, var(--warn) 0 4px, transparent 4px 8px); opacity: 1; }
.timeline .seg:hover, .timeline .seg:focus-visible { opacity: 1; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); z-index: 2; pointer-events: none; }
.seg-list { display: flex; flex-direction: column; gap: 8px; }
.seg-row { display: grid; grid-template-columns: 28px minmax(160px, 2fr) repeat(2, minmax(120px, 1fr)) auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.seg-row.warn { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); background: var(--warn-bg); }
.seg-num { font-weight: 700; color: var(--muted); text-align: center; }
.time-field { display: flex; align-items: center; gap: 4px; }
.time-field span { font-size: .78rem; color: var(--muted); }
.time-field input { width: 84px; min-height: 34px; padding: 4px 8px; }

/* ---------- Review workspace ---------- */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.review-grid > .stack:first-child { position: sticky; top: 76px; }
.student-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.student-head .badge { margin-inline-start: auto; }
.criterion { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.criterion-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.score-scale { display: flex; gap: 6px; flex-wrap: wrap; }
.score-scale.disabled { opacity: .5; }
.score-opt { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 56px; min-height: 48px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 700; }
.score-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.score-opt small { font-weight: 500; font-size: .68rem; color: var(--muted); }
.score-opt.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.score-opt.on small { color: var(--on-accent); }
.score-opt.ai:not(.on) { border-style: dashed; border-color: var(--accent-ink); }
.score-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.ai-note { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .9rem; }
.ai-note p { margin: 6px 0; }
.ai-note-head { display: flex; align-items: center; gap: 6px; font-weight: 600; flex-wrap: wrap; }
.ai-note-head .chip { margin: 0; background: var(--cubex-black); color: var(--cubex-turquoise); }
.evidence { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 4px; }
.evidence li { display: flex; align-items: baseline; flex-wrap: wrap; }
.ts { font: inherit; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-ink); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: underline; }
.overall { padding: 10px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.history { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Student ---------- */
.hero-task { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--accent-ink); flex-wrap: wrap; }
.hero-task h2 { font-size: 1.4rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--accent-ink); }
.task-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.task-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.task-list a:hover { border-color: var(--accent-ink); }
.task-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.task-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.task-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.task-brief { padding: 20px 24px; }
.task-brief h3 { margin-top: 1.1em; color: var(--text-2); }
.checklist, .criteria-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: flex-start; }
.checklist .icon { color: var(--accent-ink); margin-top: 3px; }
.criteria-list li { display: flex; justify-content: space-between; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.stars { display: flex; gap: 4px; color: var(--border); }
.stars .on { color: var(--cubex-turquoise); }
.stars .on .icon { fill: currentColor; }
.celebrate { text-align: center; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.celebrate > .icon { color: var(--accent-ink); animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
.skill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.skill-list li { display: flex; flex-direction: column; gap: 6px; }
.skill-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 600; }
.result-list { display: flex; flex-direction: column; gap: 12px; }
.result { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.result header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.result h3 { margin: 0; }
.crit-scores { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; font-size: .9rem; }
.crit-scores li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 2px 0; }
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.notif-list li { border-bottom: 1px solid var(--border); }
.notif-list .linklike { flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 4px; width: 100%; }
.notif-list li.unread .linklike strong::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-inline-end: 8px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; width: min(1040px, 100%); align-items: center; }
.login-brand { background: var(--cubex-black); color: var(--cubex-white); border-radius: var(--radius-lg); padding: 40px; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; min-height: 420px; justify-content: center; }
.login-brand p { color: #C5CDD2; max-width: 360px; }
.login-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 14px; }
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.persona { text-align: start; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.persona:hover, .persona:focus-visible { border-color: var(--accent-ink); background: var(--accent-soft); }

/* ---------- Report / print ---------- */
.report-head { display: flex; gap: 20px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.report-head .logo-full { height: 96px; padding: 10px 16px; }
.report h3 { margin-top: 1.4em; }
@media print {
  .sidebar, .topbar, .demo-banner, .page-actions, .chart-head button, .review-actions, .toasts, .skip { display: none !important; }
  body, .card { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; }
  .logo-tile { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .review-grid, .task-layout { grid-template-columns: 1fr; }
  .review-grid > .stack:first-child { position: static; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: var(--shadow-2); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }
  .topbar { padding: 8px 16px; }
  .content { padding: 16px; }
  .login-grid { grid-template-columns: 1fr; }
  .login-brand { min-height: 0; padding: 24px; }
  .logo-full { height: 120px; }
  .seg-row { grid-template-columns: 28px 1fr; }
  .seg-row > :nth-child(n+3) { grid-column: 2; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 4px; }
  .table td { border: 0; display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; text-align: end; }
  .table td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: start; }
  .table td[data-label=""]::before { content: none; }
  .table td .row-actions { justify-content: flex-end; }
  .table-compact thead { display: table-header-group; }
  .table-compact, .table-compact tbody { display: table; } .table-compact tr { display: table-row; border: 0; } .table-compact td { display: table-cell; text-align: start; }
  .table-compact td::before { content: none; }
  .bar-row { grid-template-columns: 1fr 48px; }
  .bar-label { grid-column: 1 / -1; }
  .ctx-select { max-width: 52vw; }
  .summary { grid-template-columns: 1fr; }
  .modal-footer .btn { flex: 1; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
:root[data-reduced-motion] *, :root[data-reduced-motion] *::before, :root[data-reduced-motion] *::after { animation: none !important; transition: none !important; }

/* ---------- Forced colours ---------- */
@media (forced-colors: active) {
  .bar-fill, .progress-fill, .timeline .seg { background: Highlight; forced-color-adjust: none; }
  .badge, .chip { border: 1px solid CanvasText; }
}

/* =====================================================================
   v2 — Professional polish & motion layer
   Brand surfaces stay black / white / #00E5BC. Motion is short (≤ 450 ms),
   eased, and fully disabled by prefers-reduced-motion or the in-app setting.
   ===================================================================== */
:root {
  --sidebar-bg: var(--cubex-black);
  --sidebar-text: #B9C3C9;
  --sidebar-muted: #7D8890;
  --sidebar-hover: #12171A;
  --sidebar-active: rgba(0, 229, 188, .12);
  --line-soft: color-mix(in srgb, var(--border) 70%, transparent);
  --dur-1: 160ms; --dur-2: 280ms; --dur-3: 450ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --shadow-hover: 0 10px 30px rgba(10, 12, 13, .10), 0 2px 8px rgba(10, 12, 13, .06);
}
:root:not([data-theme="dark"]) { --bg: #F4F6F7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #050607; --shadow-hover: 0 10px 30px rgba(0, 0, 0, .55); } }
:root[data-theme="dark"] { --bg: #050607; --shadow-hover: 0 10px 30px rgba(0, 0, 0, .55); }

body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1 { letter-spacing: -.015em; font-weight: 700; }
::selection { background: var(--cubex-turquoise); color: var(--cubex-black); }

/* ---------- Cube mark & logo ---------- */
.cube-mark { color: var(--cubex-turquoise); display: block; overflow: visible; }
.cube-mark path { fill: none; stroke: currentColor; stroke-width: 11; stroke-linejoin: round; stroke-linecap: round; }
.logo-tile { background: var(--cubex-black); overflow: hidden; }
.logo-tile img { width: 100%; height: 100%; object-fit: contain; }
.logo-full { width: 220px; height: 220px; padding: 0; border-radius: var(--radius-lg); }
.logo-sidebar { width: 124px; height: 124px; padding: 0; background: transparent; }
.logo-fallback { gap: 2px; }
.logo-fallback .cube-mark { margin-bottom: 10px; }
.logo-sidebar .logo-fallback { font-size: .78rem; }
.logo-sidebar .logo-fallback .cube-mark { margin-bottom: 6px; }
.logo-mark { display: inline-flex; padding: 6px; border-radius: 10px; background: var(--cubex-black); }
.report-head .logo-full { width: 110px; height: 110px; }

/* ---------- Splash (first paint, before JS) ---------- */
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--cubex-black); color: #9AA5AC; font: 500 .9rem system-ui, sans-serif; }
.splash-cube path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: cx-draw 1.1s var(--ease-out) forwards, cx-pulse 1.6s 1.1s ease-in-out infinite; }
.splash-cube path:nth-child(2) { animation-delay: .25s, 1.1s; }
.splash-cube path:nth-child(3) { animation-delay: .45s, 1.1s; }
@keyframes cx-draw { to { stroke-dashoffset: 0; } }
@keyframes cx-pulse { 50% { opacity: .55; } }

/* ---------- Sidebar: premium black brand surface in both themes ---------- */
.sidebar { background: var(--sidebar-bg); border-inline-end: 1px solid #14191C; padding: 18px 14px; color: var(--sidebar-text); }
.sidebar-brand { justify-content: center; padding: 0 0 14px; margin-bottom: 10px; border-bottom: 1px solid #161B1E; }
.sidebar a, .sidebar .linklike { color: var(--sidebar-text); position: relative; transition: background var(--dur-1), color var(--dur-1); }
.sidebar a:hover, .sidebar .linklike:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar a.active { background: var(--sidebar-active); color: #fff; box-shadow: none; }
.sidebar a.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cubex-turquoise); }
.sidebar a.active .icon { color: var(--cubex-turquoise); }
.sidebar-foot { border-top-color: #161B1E; }
.sidebar :focus-visible { outline-color: var(--cubex-turquoise); }
.user-card { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px; border-radius: var(--radius); background: #0C1013; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-meta strong { color: #fff; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { color: var(--sidebar-muted); font-size: .75rem; }
.avatar { background: #0E2A25; color: var(--cubex-turquoise); border: 1px solid rgba(0, 229, 188, .35); }

/* ---------- Topbar ---------- */
.topbar { background: color-mix(in srgb, var(--surface) 82%, transparent); transition: box-shadow var(--dur-2); }
body.scrolled .topbar { box-shadow: 0 1px 0 var(--border), 0 6px 18px rgba(0, 0, 0, .06); }
.top-mark { display: none; }
.ctx-select { border-radius: 999px; padding-inline: 14px 32px; background-color: var(--surface-2); border-color: transparent; }
.ctx-select:hover { border-color: var(--border); }

/* ---------- Page & view transitions ---------- */
.view { animation: cx-enter var(--dur-3) var(--ease-out) both; }
@keyframes cx-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stats > *, .card-grid > *, .stack > .card, .grid-2 > .card { animation: cx-enter var(--dur-3) var(--ease-out) both; }
.stats > :nth-child(2), .card-grid > :nth-child(2), .grid-2 > :nth-child(2) { animation-delay: 40ms; }
.stats > :nth-child(3), .card-grid > :nth-child(3) { animation-delay: 80ms; }
.stats > :nth-child(4), .card-grid > :nth-child(4) { animation-delay: 120ms; }
.stats > :nth-child(5), .card-grid > :nth-child(5) { animation-delay: 160ms; }
.stats > :nth-child(n+6), .card-grid > :nth-child(n+6) { animation-delay: 200ms; }
.page-header h1 { font-size: 1.75rem; }

/* ---------- Cards & stats ---------- */
.card { border-color: var(--line-soft); transition: box-shadow var(--dur-2), border-color var(--dur-2); }
.card-header { padding: 18px 22px 0; }
.card-header h2 { font-size: .98rem; letter-spacing: .005em; }
.card-body { padding: 16px 22px 22px; }
.stat { position: relative; overflow: hidden; border-color: var(--line-soft); box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2), border-color var(--dur-2); }
.stat::after { content: ""; position: absolute; inset-inline: 0; top: 0; height: 3px; background: var(--cubex-turquoise); transform: scaleX(0); transform-origin: left; transition: transform var(--dur-3) var(--ease-out); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat:hover::after { transform: scaleX(1); }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); display: inline-grid; place-items: center; }
.stat-value { font-size: 1.65rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-warning::after, .stat-danger::after { transform: scaleX(1); }
.stat-warning::after { background: var(--warn); } .stat-danger::after { background: var(--danger); }
a.tile { transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2), border-color var(--dur-2); }
a.tile:hover { box-shadow: var(--shadow-hover); }
a.tile .tile-icon { transition: background var(--dur-2), color var(--dur-2); }
a.tile:hover .tile-icon { background: var(--cubex-turquoise); color: var(--cubex-black); }

/* ---------- Buttons ---------- */
.btn { transition: background var(--dur-1), border-color var(--dur-1), box-shadow var(--dur-2), transform var(--dur-1); }
.btn-primary { box-shadow: 0 1px 0 rgba(0, 0, 0, .08), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(0, 229, 188, .28); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

/* ---------- Charts animate in ---------- */
.bar-fill { transform-origin: left center; animation: cx-grow 700ms var(--ease-out) both; }
[dir="rtl"] .bar-fill { transform-origin: right center; }
.bar-row:nth-child(2) .bar-fill { animation-delay: 50ms; } .bar-row:nth-child(3) .bar-fill { animation-delay: 100ms; }
.bar-row:nth-child(4) .bar-fill { animation-delay: 150ms; } .bar-row:nth-child(n+5) .bar-fill { animation-delay: 200ms; }
@keyframes cx-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.line-chart .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: cx-draw 900ms var(--ease-out) 120ms forwards; }
.line-chart .dot { animation: cx-fade 300ms ease 700ms both; }
@keyframes cx-fade { from { opacity: 0; } }
.progress-fill { animation: cx-grow 700ms var(--ease-out) both; transform-origin: left center; }

/* ---------- Login ---------- */
.login { background: radial-gradient(1200px 600px at 80% -10%, rgba(0, 229, 188, .07), transparent 60%), var(--bg); }
.login-grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; }
.login-brand { position: relative; overflow: hidden; gap: 18px; padding: 44px 36px; border: 1px solid #14191C; background-color: var(--cubex-black);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='64' viewBox='0 0 56 64'%3E%3Cg fill='none' stroke='%2300E5BC' stroke-opacity='.07' stroke-width='1'%3E%3Cpath d='M28 2 52 16v28L28 58 4 44V16z'/%3E%3Cpath d='M4 16l24 14 24-14M28 30v28'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 56px 64px; }
.login-brand::after { content: ""; position: absolute; inset: auto -30% -40% -30%; height: 60%; background: radial-gradient(closest-side, rgba(0, 229, 188, .14), transparent); pointer-events: none; }
.login-brand > * { position: relative; z-index: 1; }
.login-brand .logo-full { animation: cx-enter 600ms var(--ease-out) both; }
.login-brand p.login-tagline { font-size: 1.02rem; color: #D3DADE; max-width: 380px; margin: 0; }
.login-points { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 10px; text-align: start; }
.login-points li { display: flex; gap: 10px; align-items: center; color: #AEB8BE; font-size: .92rem; }
.login-points .icon { color: var(--cubex-turquoise); }
.login-panel { animation: cx-enter 500ms var(--ease-out) 80ms both; }
.persona { transition: border-color var(--dur-1), background var(--dur-1), transform var(--dur-2) var(--ease-out); }
.persona:hover { transform: translateY(-2px); }

/* ---------- Student hero ---------- */
.hero-task { position: relative; overflow: hidden; border-color: color-mix(in srgb, var(--cubex-turquoise) 55%, var(--border)); }
.hero-task > :not(.hero-deco) { position: relative; z-index: 1; }
.hero-deco { position: absolute; inset-inline-end: -18px; bottom: -26px; opacity: .18; animation: cx-float 6s ease-in-out infinite; pointer-events: none; }
@keyframes cx-float { 50% { transform: translateY(-8px) rotate(-3deg); } }
.hero-task .btn { margin-inline-end: 90px; }

/* ---------- Age-gated polish ---------- */
body[data-age="g1_3"] .hero-task { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%); }
body[data-age="g1_3"] .hero-deco { opacity: .35; }
body[data-age="g1_3"] .task-list a { padding: 14px 16px; border-width: 2px; }
body[data-age="g1_3"] .task-icon { width: 48px; height: 48px; border-radius: 14px; }
body[data-age="g1_3"] .stars .on .icon { animation: cx-pop 420ms var(--ease-out) both; }
body[data-age="g1_3"] .stars span:nth-child(2) .icon { animation-delay: 80ms; }
body[data-age="g1_3"] .stars span:nth-child(3) .icon { animation-delay: 160ms; }
body[data-age="g1_3"] .stars span:nth-child(4) .icon { animation-delay: 240ms; }
body[data-age="g1_3"] .stars span:nth-child(5) .icon { animation-delay: 320ms; }
@keyframes cx-pop { 0% { transform: scale(.3); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
body[data-age="g4_5"] .hero-task { background: linear-gradient(120deg, var(--accent-soft), var(--surface) 55%); }
body[data-age="g4_5"] .tile, body[data-age="g4_5"] .card { border-width: 1.5px; }
body[data-age="g9_10"] .card, body[data-age="g11_12"] .card { box-shadow: none; }
body[data-age="g11_12"] .hero-task { border-color: var(--border); border-inline-start: 3px solid var(--cubex-turquoise); }
body[data-age="g11_12"] .hero-deco { opacity: .1; }

/* ---------- Responsive additions ---------- */
@media (max-width: 860px) {
  .top-mark { display: inline-flex; }
  .logo-full { width: 160px; height: 160px; }
  .hero-task .btn { margin-inline-end: 0; }
}

/* =====================================================================
   Sign-in — premium split layout
   ===================================================================== */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 46%) 1fr; background: var(--surface); }

/* Brand side */
.auth-brand { position: relative; overflow: hidden; background: var(--cubex-black); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 56px clamp(32px, 5vw, 80px) 32px; isolation: isolate; }
.auth-brand::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='64' viewBox='0 0 56 64'%3E%3Cg fill='none' stroke='%2300E5BC' stroke-opacity='.06' stroke-width='1'%3E%3Cpath d='M28 2 52 16v28L28 58 4 44V16z'/%3E%3Cpath d='M4 16l24 14 24-14M28 30v28'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 56px 64px; -webkit-mask-image: radial-gradient(120% 90% at 30% 40%, #000 30%, transparent 85%); mask-image: radial-gradient(120% 90% at 30% 40%, #000 30%, transparent 85%); }
.auth-brand::after { content: ""; position: absolute; z-index: -1; width: 720px; height: 720px; right: -260px; bottom: -320px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 229, 188, .16), transparent 70%); pointer-events: none; }
.auth-ghost-cube { position: absolute; z-index: -1; right: -150px; top: 50%; translate: 0 -50%; width: 560px; height: auto; color: var(--cubex-turquoise); opacity: .07; animation: auth-drift 18s ease-in-out infinite; pointer-events: none; }
.auth-ghost-cube path { stroke-width: 4; }
@keyframes auth-drift { 50% { transform: translateY(-14px) rotate(-2deg); } }
.auth-brand-inner { max-width: 480px; display: flex; flex-direction: column; gap: 22px; animation: cx-enter 700ms var(--ease-out) both; }
.auth-brand .logo-full { width: 168px; height: 168px; margin-inline-start: -18px; background: transparent; }
.auth-headline { font-family: var(--font-display); font-size: clamp(1.9rem, 2.6vw, 2.6rem); line-height: 1.12; letter-spacing: -.025em; font-weight: 700; margin: 0; color: #fff; }
.auth-headline span { color: var(--cubex-turquoise); }
.auth-sub { color: #A9B4BA; font-size: 1rem; line-height: 1.6; margin: 0; max-width: 420px; }
.auth-proof { list-style: none; padding: 22px 0 0; margin: 6px 0 0; display: grid; grid-template-columns: repeat(3, auto); gap: 28px; border-top: 1px solid #1B2124; justify-content: start; }
.auth-proof li { display: flex; flex-direction: column; gap: 2px; }
.auth-proof strong { font-family: var(--font-display); font-size: 1.15rem; color: #fff; letter-spacing: -.01em; }
.auth-proof span { font-size: .78rem; color: #7F8A91; }
.auth-legal { position: absolute; bottom: 24px; inset-inline-start: clamp(32px, 5vw, 80px); margin: 0; font-size: .75rem; color: #5D676D; }

/* Form side */
.auth-main { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px 72px; background:
  radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--cubex-turquoise) 6%, transparent), transparent 60%), var(--surface); }
.auth-top { display: none; }
.auth-column { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; animation: cx-enter 600ms var(--ease-out) 80ms both; }
.auth-pill { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: .76rem; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.auth-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cubex-turquoise); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cubex-turquoise) 22%, transparent); }
.auth-column h1 { font-size: 2rem; letter-spacing: -.025em; margin: 6px 0 0; }
.auth-lead { color: var(--muted); margin: 0 0 10px; line-height: 1.6; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 7px; }
.auth-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.auth-label-row label { font-size: .86rem; font-weight: 600; color: var(--text); }
.auth-input { position: relative; }
.auth-input input { min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 1rem; transition: border-color var(--dur-1), box-shadow var(--dur-2); }
.auth-input input:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.auth-input input:focus { border-color: var(--accent-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cubex-turquoise) 22%, transparent); }
.auth-input input[type="password"], .auth-input input[name="password"] { padding-inline-end: 64px; }
.auth-reveal { position: absolute; inset-inline-end: 8px; top: 50%; translate: 0 -50%; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.auth-reveal:hover { color: var(--text); background: var(--surface-2); }
.auth-link { border: 0; background: none; padding: 0; font: inherit; font-size: .82rem; font-weight: 600; color: var(--accent-ink); cursor: pointer; }
.auth-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: .9rem; font-weight: 550; }
.auth-switch small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.auth-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.auth-switch-track { flex-shrink: 0; width: 38px; height: 22px; border-radius: 999px; background: var(--border); position: relative; transition: background var(--dur-2); }
.auth-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--dur-2) var(--ease-out); }
.auth-switch input:checked + .auth-switch-track { background: var(--cubex-turquoise); }
.auth-switch input:checked + .auth-switch-track::after { transform: translateX(16px); }
.auth-switch input:focus-visible + .auth-switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.auth-submit { min-height: 52px; border-radius: 12px; font-size: 1rem; justify-content: center; gap: 6px; margin-top: 4px; }
.auth-submit .icon { transition: transform var(--dur-2) var(--ease-out); }
.auth-submit:hover .icon { transform: translateX(3px); }
.auth-submit.loading span { opacity: .6; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-google { min-height: 50px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); gap: 10px; }
.auth-google:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--border)); background: var(--surface-2); }
.auth-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: .88rem; font-weight: 550; }
.auth-foot { margin: 12px 0 0; font-size: .82rem; color: var(--muted); line-height: 1.6; }
.auth-foot code { font-size: .8em; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); }
.auth-trust { position: absolute; bottom: 22px; margin: 0; display: flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.auth-trust .icon { color: var(--accent-ink); }

/* Demo role picker */
.auth-group { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.auth-group-title { margin: 0; font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.auth-roles { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.auth-roles li + li { border-top: 1px solid var(--border); }
.auth-role { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: transparent; border: 0; font: inherit; color: var(--text); text-align: start; cursor: pointer; transition: background var(--dur-1); }
.auth-role:hover, .auth-role:focus-visible { background: var(--surface-2); }
.auth-role:focus-visible { outline-offset: -3px; }
.auth-role-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center; background: var(--cubex-black); color: var(--cubex-turquoise); transition: transform var(--dur-2) var(--ease-out); }
.auth-role:hover .auth-role-icon { transform: scale(1.06); }
.auth-role-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.auth-role-text strong { font-size: .93rem; font-weight: 600; }
.auth-role-text span { font-size: .8rem; color: var(--muted); }
.auth-role > .icon { color: var(--muted); transition: transform var(--dur-2) var(--ease-out), color var(--dur-1); }
.auth-role:hover > .icon { color: var(--accent-ink); transform: translateX(3px); }

/* Demo grade picker (Grades 1–12 grouped by age theme) */
.auth-grades { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; }
.auth-grades-head { display: flex; align-items: center; gap: 14px; }
.auth-grade-hint { font-size: .8rem; color: var(--muted); }
.auth-bands { display: grid; grid-template-columns: 3fr 2fr 3fr 2fr 2fr; gap: 8px; }
.auth-band { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.auth-band-chips { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.auth-band-name { font-size: .66rem; line-height: 1.25; color: var(--muted); text-align: center; letter-spacing: .01em; }
.auth-grade { min-height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1), transform var(--dur-2) var(--ease-out); }
.auth-grade:hover, .auth-grade:focus-visible { background: var(--cubex-black); border-color: var(--cubex-black); color: var(--cubex-turquoise); transform: translateY(-2px); }
@media (max-width: 520px) {
  .auth-bands { grid-template-columns: repeat(2, 1fr); }
  .auth-band:last-child { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-main { justify-content: flex-start; padding-top: 28px; }
  .auth-top { display: flex; justify-content: center; margin-bottom: 18px; }
  .auth-top .logo-sidebar { width: 96px; height: 96px; background: var(--cubex-black); border-radius: 20px; }
  .auth-trust { position: static; margin-top: 28px; }
}

.add-student fieldset { gap: 14px; }
.add-student legend { font-size: .9rem; }
.result-part { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.result-part h3 { font-size: .9rem; margin-bottom: 8px; }
.steps-list { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Reduced motion (re-asserted after the motion layer) ---------- */
@media (prefers-reduced-motion: reduce) {
  .view, .stats > *, .card-grid > *, .stack > .card, .grid-2 > .card, .bar-fill, .progress-fill, .hero-deco, .login-panel, .login-brand .logo-full,
  .auth-ghost-cube, .auth-brand-inner, .auth-column { animation: none !important; }
  .line-chart .line, .splash-cube path { animation: none !important; stroke-dashoffset: 0; }
}
:root[data-reduced-motion] .line-chart .line, :root[data-reduced-motion] .splash-cube path { stroke-dashoffset: 0; }
