/* =====================================================================
   TutorHub — Design System
   Premium, calm, pastel learning app. Light-first, dark-aware.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Brand */
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-050: #eef0ff;
  --on-primary: #ffffff;

  /* Pastel surface tints (used for category cards & status) */
  --tint-mint:    #e7f6ee;  --tint-mint-ink:   #147a52;
  --tint-sky:     #e6f0fd;  --tint-sky-ink:    #1f5fbf;
  --tint-lav:     #eeebfb;  --tint-lav-ink:    #6244c5;
  --tint-rose:    #fce9f0;  --tint-rose-ink:   #c0396f;
  --tint-amber:   #fbf0d9;  --tint-amber-ink:  #a9700c;
  --tint-peach:   #fde9e2;  --tint-peach-ink:  #c1512c;

  /* Status semantics */
  --ok:        #16a34a;  --ok-bg:   #e7f6ee;
  --warn:      #d97706;  --warn-bg: #fbf0d9;
  --danger:    #dc2626;  --danger-bg:#fbe4e4;
  --info:      #2563eb;  --info-bg: #e6f0fd;

  /* Neutrals */
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --surface-2: #f9fafc;
  --ink:       #171a2b;
  --ink-2:     #3b3f52;
  --muted:     #6b7189;
  --faint:     #9aa0b4;
  --border:    #e9ebf2;
  --border-2:  #dfe2ec;
  --ring:      #4f46e5;

  /* Radii */
  --r-sm: 10px;  --r-md: 14px;  --r-lg: 20px;  --r-xl: 28px;  --r-pill: 999px;

  /* Shadows — soft, layered */
  --sh-sm: 0 1px 2px rgba(23,26,43,.05), 0 1px 3px rgba(23,26,43,.04);
  --sh-md: 0 2px 4px rgba(23,26,43,.04), 0 8px 20px rgba(23,26,43,.06);
  --sh-lg: 0 8px 30px rgba(23,26,43,.10), 0 2px 8px rgba(23,26,43,.05);
  --sh-focus: 0 0 0 4px rgba(79,70,229,.18);

  /* Spacing scale (8pt) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px;
  --s7: 32px; --s8: 40px; --s9: 56px; --s10: 72px;

  --sidebar-w: 264px;
  --topbar-h: 72px;

  --font-head: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  --primary: #8b8bf5;
  --primary-600: #a5a5f8;
  --primary-050: #23233a;
  --on-primary: #10101c;

  --tint-mint:  #16332a;  --tint-mint-ink:  #6ee7b0;
  --tint-sky:   #14283f;  --tint-sky-ink:   #8bc0ff;
  --tint-lav:   #262148;  --tint-lav-ink:   #c3b4ff;
  --tint-rose:  #3a1f2c;  --tint-rose-ink:  #ff9dc2;
  --tint-amber: #352b16;  --tint-amber-ink: #f2c977;
  --tint-peach: #3a251c;  --tint-peach-ink: #ffab8f;

  --ok-bg:#16332a; --warn-bg:#352b16; --danger-bg:#3a1f22; --info-bg:#14283f;

  --bg:        #0e0f17;
  --surface:   #171826;
  --surface-2: #1e2030;
  --ink:       #eef0f6;
  --ink-2:     #cdd0dd;
  --muted:     #9aa0b6;
  --faint:     #727892;
  --border:    #262838;
  --border-2:  #313349;
  --ring:      #8b8bf5;

  --sh-sm: 0 1px 2px rgba(0,0,0,.4);
  --sh-md: 0 2px 6px rgba(0,0,0,.4), 0 10px 24px rgba(0,0,0,.35);
  --sh-lg: 0 12px 40px rgba(0,0,0,.5);
  --sh-focus: 0 0 0 4px rgba(139,139,245,.28);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: 8px; }
img { max-width: 100%; display: block; }

/* ---------- Buttons ---------- */
.btn {
  --_bg: var(--surface); --_fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; min-height: 44px;
  border: 1px solid var(--border-2); border-radius: var(--r-pill);
  background: var(--_bg); color: var(--_fg);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.btn:hover { box-shadow: var(--sh-sm); }
.btn:active { transform: scale(.97); }
.btn--primary { --_bg: var(--primary); --_fg: var(--on-primary); border-color: transparent; box-shadow: 0 4px 14px rgba(79,70,229,.28); }
.btn--primary:hover { background: var(--primary-600); box-shadow: 0 6px 20px rgba(79,70,229,.36); }
.btn--ghost { --_bg: transparent; border-color: transparent; }
.btn--ghost:hover { --_bg: var(--surface-2); }
.btn--soft { --_bg: var(--primary-050); --_fg: var(--primary); border-color: transparent; }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: 15px; padding: 14px 20px; }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.btn--danger { --_bg: var(--danger-bg); --_fg: var(--danger); border-color: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .spinner { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; }

.linklike { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }
.linklike:hover { text-decoration: underline; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark { width: 30px; height: 30px; border-radius: 9px; background:
  conic-gradient(from 140deg, #6366f1, #8b5cf6, #ec4899, #f59e0b, #6366f1);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), var(--sh-sm); }
.brand__name { font-family: var(--font-head); font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand--lg .brand__mark { width: 38px; height: 38px; border-radius: 11px; }
.brand--lg .brand__name { font-size: 23px; }

/* =====================================================================
   AUTH
   ===================================================================== */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth[hidden] { display: none; }
.auth__art { position: relative; overflow: hidden; background:
  linear-gradient(160deg, #4f46e5 0%, #6d5cf0 42%, #a855f7 100%); display: grid; place-items: end start; padding: var(--s9); }
.auth__blob { position: absolute; border-radius: 50%; filter: blur(6px); opacity: .55; mix-blend-mode: screen; }
.auth__blob--a { width: 360px; height: 360px; background: #f0abfc; top: -80px; right: -60px; }
.auth__blob--b { width: 300px; height: 300px; background: #fbbf24; bottom: -40px; left: -70px; opacity: .4; }
.auth__blob--c { width: 240px; height: 240px; background: #38bdf8; top: 40%; left: 45%; opacity: .45; }
.auth__quote { position: relative; color: #fff; max-width: 430px; }
.auth__quote-text { font-family: var(--font-head); font-size: clamp(22px, 2.4vw, 30px); font-weight: 700; line-height: 1.28; }
.auth__quote-by { display: inline-block; margin-top: 14px; color: rgba(255,255,255,.82); font-weight: 500; }
.auth__panel { display: grid; align-content: center; justify-items: center; padding: var(--s6); gap: 14px; }
.auth__card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-lg); padding: clamp(24px, 4vw, 40px); }
.auth__card .brand { margin-bottom: var(--s7); }
.auth__title { font-size: 28px; margin-bottom: 8px; }
.auth__subtitle { color: var(--muted); margin-bottom: var(--s6); }
.auth__form { display: grid; gap: var(--s4); }
.auth__hint { margin-top: var(--s5); color: var(--muted); font-size: 14px; text-align: center; }
.auth__legal { color: var(--faint); font-size: 12.5px; }
.auth__sent-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--tint-mint); color: var(--tint-mint-ink); display: grid; place-items: center; margin-bottom: var(--s5); }
.auth__sent-icon::after { content: ""; width: 26px; height: 26px; background: currentColor;
  -webkit-mask: var(--ico-mail) center/contain no-repeat; mask: var(--ico-mail) center/contain no-repeat; }
.auth__mock-mail { margin-top: var(--s6); padding: var(--s4); border: 1px dashed var(--border-2); border-radius: var(--r-md); background: var(--surface-2); }
.auth__mock-label { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.auth__back { margin-top: var(--s5); }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth__art { display: none; } }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field__label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field__input, .field__select, .field__textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1.5px solid var(--border-2); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font-size: 15px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field__textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field__input:focus, .field__select:focus, .field__textarea:focus { border-color: var(--primary); box-shadow: var(--sh-focus); outline: none; }
.field__input::placeholder { color: var(--faint); }
.field--invalid .field__input { border-color: var(--danger); }
.field__error { color: var(--danger); font-size: 13px; min-height: 0; }
.field__error:empty { display: none; }
.field__hint { color: var(--muted); font-size: 13px; }

/* =====================================================================
   APP SHELL
   ===================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }
.app[hidden] { display: none; }

.sidebar {
  grid-row: 1; position: sticky; top: 0; height: 100dvh; z-index: 60;
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s5) var(--s4); background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar__top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px var(--s4); }
.sidebar__close { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.nav__group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: var(--s4) 12px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-weight: 600; font-size: 14.5px; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; transition: background .14s ease, color .14s ease; position: relative;
}
.nav__item:hover { background: var(--surface-2); color: var(--ink); }
.nav__item.is-active { background: var(--primary-050); color: var(--primary); }
.nav__item svg { width: 20px; height: 20px; flex: none; }
.nav__badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.nav__item.is-active .nav__badge { background: var(--primary); }

.sidebar__foot { display: flex; align-items: center; gap: 8px; padding: var(--s3) 6px 0; border-top: 1px solid var(--border); margin-top: var(--s2); }
.usercard { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.usercard__meta { display: grid; min-width: 0; }
.usercard__name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usercard__role { font-size: 12px; color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); font-family: var(--font-head); }
.avatar--sm { width: 30px; height: 30px; font-size: 12px; }
.avatar--lg { width: 60px; height: 60px; font-size: 22px; }

.scrim { position: fixed; inset: 0; background: rgba(10,12,24,.42); z-index: 55; backdrop-filter: blur(2px); }
.scrim[hidden] { display: none; }

.main { grid-column: 2; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 clamp(16px, 3vw, 32px); background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar__menu { display: none; }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: clamp(19px, 2.4vw, 24px); }
.topbar__sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.streak-pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--r-pill);
  background: var(--tint-amber); color: var(--tint-amber-ink); font-weight: 700; font-size: 14px; }
.streak-pill__flame { width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--ico-flame) center/contain no-repeat; mask: var(--ico-flame) center/contain no-repeat; }

.view { padding: clamp(16px, 3vw, 32px); flex: 1; max-width: 1240px; width: 100%; margin: 0 auto; }
.view:focus { outline: none; }

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { display: none; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: clamp(16px, 3vw, 28px); bottom: clamp(16px, 3vw, 28px); z-index: 45;
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px 12px 14px;
  border: none; border-radius: var(--r-pill); cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #a855f7); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 24px rgba(79,70,229,.4); transition: transform .15s ease, box-shadow .2s ease;
}
.fab[hidden] { display: none; }
.fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(79,70,229,.5); }
.fab__icon { width: 22px; height: 22px; background: #fff;
  -webkit-mask: var(--ico-sparkles) center/contain no-repeat; mask: var(--ico-sparkles) center/contain no-repeat; }

/* =====================================================================
   COMPONENTS
   ===================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.card--pad { padding: var(--s6); }
.card--flat { box-shadow: none; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--s5); }
.card__title { font-size: 17px; font-weight: 700; }
.card__hint { font-size: 13px; color: var(--muted); }

.section-title { font-size: 15px; font-weight: 700; color: var(--ink); margin: var(--s7) 0 var(--s4); display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-title .count { color: var(--muted); font-weight: 600; }

.grid { display: grid; gap: var(--s5); }
.grid--dash { grid-template-columns: 1.6fr 1fr; align-items: start; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (max-width: 1000px) { .grid--dash, .grid--3, .grid--4 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid--2 { grid-template-columns: 1fr; } }

.stack { display: grid; gap: var(--s5); }
.stack--sm { gap: var(--s3); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; }
.strong { font-weight: 700; }
.center { text-align: center; }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.badge svg { width: 13px; height: 13px; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { 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--lav { background: var(--tint-lav); color: var(--tint-lav-ink); }
.badge--dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-pill);
  border: 1.5px solid var(--border-2); background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: all .14s ease; min-height: 40px; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Progress bar */
.pbar { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.pbar__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #a855f7);
  transition: width .8s cubic-bezier(.2,.8,.2,1); }
.pbar--thin { height: 7px; }
.pbar--ok .pbar__fill { background: linear-gradient(90deg, #22c55e, #16a34a); }
.pbar--warn .pbar__fill { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* Stat tile */
.stat { padding: var(--s5); border-radius: var(--r-lg); position: relative; overflow: hidden; }
.stat__label { font-size: 13px; font-weight: 600; opacity: .85; }
.stat__value { font-family: var(--font-head); font-size: 30px; font-weight: 800; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat__sub { font-size: 12.5px; opacity: .8; margin-top: 2px; }
.stat__icon { position: absolute; top: 16px; right: 16px; width: 22px; height: 22px; opacity: .8; }
.stat--mint { background: var(--tint-mint); color: var(--tint-mint-ink); }
.stat--sky  { background: var(--tint-sky);  color: var(--tint-sky-ink); }
.stat--lav  { background: var(--tint-lav);  color: var(--tint-lav-ink); }
.stat--amber{ background: var(--tint-amber);color: var(--tint-amber-ink); }
.stat--rose { background: var(--tint-rose); color: var(--tint-rose-ink); }
.stat--peach{ background: var(--tint-peach);color: var(--tint-peach-ink); }

/* Next-action cards (dashboard hero) */
.actions { display: grid; gap: var(--s3); }
.action {
  display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5);
  border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; text-align: left; width: 100%; transition: transform .14s ease, box-shadow .18s ease, border-color .18s ease;
}
.action:hover { transform: translateY(-2px); box-shadow: var(--sh-md); border-color: var(--border-2); }
.action__ico { width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center; }
.action__ico svg { width: 24px; height: 24px; }
.action__body { flex: 1; min-width: 0; }
.action__kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.action__title { font-weight: 700; font-size: 15.5px; color: var(--ink); margin-top: 1px; }
.action__meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.action__go { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--ink-2); }
.action:hover .action__go { background: var(--primary); color: #fff; }
.action__go svg { width: 18px; height: 18px; }

/* List rows */
.lrow { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--border); }
.lrow:last-child { border-bottom: none; }
.lrow__ico { width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.lrow__ico svg { width: 20px; height: 20px; }
.lrow__body { flex: 1; min-width: 0; }
.lrow__title { font-weight: 600; font-size: 14.5px; }
.lrow__sub { font-size: 13px; color: var(--muted); }

/* Timeline (calendar/agenda) */
.agenda { display: grid; gap: 2px; }
.agenda__item { display: grid; grid-template-columns: 64px 1fr; gap: var(--s4); padding: var(--s3) 0; align-items: start; }
.agenda__time { font-size: 13px; color: var(--muted); font-weight: 600; padding-top: 14px; font-variant-numeric: tabular-nums; }
.agenda__card { border-radius: var(--r-md); padding: var(--s4); border: 1px solid var(--border); }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 560px; background: var(--surface); }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: 14px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* Roadmap / program */
.roadmap { display: grid; gap: var(--s4); }
.rm-unit { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.rm-unit__head { display: flex; align-items: center; gap: var(--s4); padding: var(--s5); }
.rm-unit__num { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-family: var(--font-head); flex: none; }
.rm-topics { display: grid; gap: 1px; background: var(--border); }
.rm-topic { display: flex; align-items: center; gap: var(--s4); padding: 14px var(--s5); background: var(--surface); cursor: pointer; transition: background .12s ease; }
.rm-topic:hover { background: var(--surface-2); }
.rm-topic__dot { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.rm-topic__dot svg { width: 16px; height: 16px; }
.rm-topic__name { font-weight: 600; font-size: 14.5px; flex: 1; }

/* Status color helpers */
.st-mastered { background: var(--ok-bg); color: var(--ok); }
.st-studying { background: var(--info-bg); color: var(--info); }
.st-struggling { background: var(--danger-bg); color: var(--danger); }
.st-notstarted { background: var(--surface-2); color: var(--faint); }
.st-locked { background: var(--surface-2); color: var(--faint); }

/* Video card */
.vid { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); cursor: pointer; transition: transform .15s ease, box-shadow .2s ease; }
.vid:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.vid__thumb { aspect-ratio: 16/9; position: relative; display: grid; place-items: center; }
.vid__play { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; box-shadow: var(--sh-md); }
.vid__play svg { width: 22px; height: 22px; color: var(--primary); margin-left: 3px; }
.vid__dur { position: absolute; bottom: 8px; right: 8px; background: rgba(10,12,24,.78); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 7px; }
.vid__done { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; }
.vid__done svg { width: 14px; height: 14px; }
.vid__meta { padding: var(--s4); }
.vid__title { font-weight: 700; font-size: 14.5px; }
.vid__sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* Donut wrap */
.donut-wrap { display: grid; place-items: center; position: relative; }
.donut-center { position: absolute; text-align: center; }
.donut-center__val { font-family: var(--font-head); font-size: 30px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.donut-center__lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Achievement */
.ach { text-align: center; padding: var(--s5); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); position: relative; }
.ach--locked { opacity: .55; }
.ach__medal { width: 64px; height: 64px; margin: 0 auto var(--s3); border-radius: 50%; display: grid; place-items: center; }
.ach__medal svg { width: 32px; height: 32px; }
.ach__name { font-weight: 700; font-size: 14.5px; }
.ach__desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.ach__lock { position: absolute; top: 12px; right: 12px; color: var(--faint); }
.ach__lock svg { width: 16px; height: 16px; }

/* Mistake card */
.mistake { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.mistake__head { display: flex; align-items: center; gap: 12px; padding: var(--s4) var(--s5); cursor: pointer; }
.mistake__q { flex: 1; font-weight: 600; font-size: 14.5px; }
.mistake__body { padding: 0 var(--s5) var(--s5); display: grid; gap: var(--s3); }
.ans { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); font-size: 14px; }
.ans--wrong { background: var(--danger-bg); color: var(--danger); }
.ans--right { background: var(--ok-bg); color: var(--ok); }
.ans__ico { flex: none; width: 20px; height: 20px; }
.explain { background: var(--surface-2); border-radius: var(--r-md); padding: 14px; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.explain strong { color: var(--ink); }

/* Quiz runner */
.quiz-q { font-family: var(--font-head); font-size: clamp(19px, 3vw, 24px); font-weight: 700; margin-bottom: var(--s6); }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 16px 18px; border-radius: var(--r-md);
  border: 1.5px solid var(--border-2); background: var(--surface); cursor: pointer; font-size: 15px; font-weight: 600; color: var(--ink);
  transition: all .14s ease; min-height: 56px; }
.opt:hover { border-color: var(--primary); background: var(--primary-050); }
.opt__key { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
.opt.is-correct .opt__key { background: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.opt.is-wrong .opt__key { background: var(--danger); color: #fff; }
.opt:disabled { cursor: default; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-h) - 2 * clamp(16px,3vw,32px)); min-height: 420px; }
.chat__scroll { flex: 1; overflow-y: auto; padding: var(--s5); display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: min(80%, 520px); padding: 11px 15px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; }
.msg--in { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.msg--out { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 6px; }
.msg__time { display: block; font-size: 11px; opacity: .7; margin-top: 4px; }
.chat__day { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0; }
.chat__compose { display: flex; gap: 10px; padding: var(--s4); border-top: 1px solid var(--border); }
.chat__compose .field__input { min-height: 46px; }

/* AI Tutor panel */
.ai-suggest { display: flex; gap: 8px; flex-wrap: wrap; padding: var(--s3) var(--s4) 0; }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 16px; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.ai-typing span:nth-child(2){ animation-delay:.2s } .ai-typing span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,60%,100%{opacity:.3} 30%{opacity:1} }

/* Empty state */
.empty { text-align: center; padding: var(--s9) var(--s5); color: var(--muted); }
.empty__ico { width: 56px; height: 56px; margin: 0 auto var(--s4); border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); }
.empty__ico svg { width: 26px; height: 26px; }
.empty__title { font-family: var(--font-head); font-weight: 700; font-size: 17px; color: var(--ink); }

/* Modal */
.modal-host { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s4); }
.modal-host[hidden] { display: none; }
.modal-host__scrim { position: absolute; inset: 0; background: rgba(10,12,24,.5); backdrop-filter: blur(4px); animation: fade .2s ease; }
.modal { position: relative; width: min(560px, 100%); max-height: 90dvh; overflow: auto; background: var(--surface);
  border-radius: var(--r-xl); box-shadow: var(--sh-lg); animation: pop .24s cubic-bezier(.2,.9,.3,1.2); }
.modal--wide { width: min(760px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: var(--s5) var(--s6); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__body { padding: var(--s6); }
.modal__foot { padding: var(--s5) var(--s6); border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Toast */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 10px; width: min(420px, calc(100% - 32px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--ink); color: #fff;
  box-shadow: var(--sh-lg); animation: toastIn .28s cubic-bezier(.2,.9,.3,1.2); font-size: 14px; font-weight: 500; }
.toast__ico { width: 22px; height: 22px; flex: none; display: grid; place-items: center; }
.toast--ok .toast__ico { color: #4ade80; } .toast--info .toast__ico { color: #60a5fa; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Spinner */
.spinner { display: inline-block; border: 2.5px solid rgba(255,255,255,.35); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Heatmap (streak calendar) */
.heat { display: grid; grid-template-columns: repeat(auto-fill, 14px); gap: 4px; }
.heat__cell { width: 14px; height: 14px; border-radius: 4px; background: var(--surface-2); }
.heat__l1 { background: #c7d2fe; } .heat__l2 { background: #a5b4fc; } .heat__l3 { background: #818cf8; } .heat__l4 { background: #4f46e5; }
:root[data-theme="dark"] .heat__l1{background:#312e6b} :root[data-theme="dark"] .heat__l2{background:#43409c}
:root[data-theme="dark"] .heat__l3{background:#5b57c9} :root[data-theme="dark"] .heat__l4{background:#8b8bf5}

/* Calendar grid */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 0; }
.cal__day { aspect-ratio: 1; border-radius: var(--r-md); border: 1px solid transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px; font-size: 14px; font-weight: 600; cursor: pointer; position: relative; transition: background .12s ease; }
.cal__day:hover { background: var(--surface-2); }
.cal__day--out { color: var(--faint); }
.cal__day--today { border-color: var(--primary); color: var(--primary); }
.cal__day--sel { background: var(--primary); color: #fff; }
.cal__dots { display: flex; gap: 3px; }
.cal__dot { width: 5px; height: 5px; border-radius: 50%; }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; background: var(--surface-2); border-radius: var(--r-pill); gap: 2px; }
.seg__btn { border: none; background: none; padding: 7px 14px; border-radius: var(--r-pill); font-weight: 600; font-size: 13.5px; color: var(--muted); cursor: pointer; min-height: 36px; }
.seg__btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(10px); animation: reveal .5s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .main { grid-column: 1; padding-bottom: 76px; }
  .sidebar {
    position: fixed; left: 0; top: 0; width: min(300px, 84vw); transform: translateX(-102%);
    transition: transform .28s cubic-bezier(.2,.8,.2,1); box-shadow: var(--sh-lg);
  }
  .sidebar.is-open { transform: none; }
  .sidebar__close { display: inline-grid; }
  .topbar__menu { display: inline-grid; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottomnav__item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 8px; border: none; background: none;
    color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer; border-radius: 10px; min-width: 56px; position: relative; }
  .bottomnav__item svg { width: 22px; height: 22px; }
  .bottomnav__item.is-active { color: var(--primary); }
  .bottomnav__badge { position: absolute; top: 2px; right: 12px; min-width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .fab__label { display: none; }
  .fab { padding: 14px; }
}
@media (max-width: 560px) {
  .view { padding: 16px 16px 24px; }
  .stat__value { font-size: 26px; }
  .grid { gap: 14px; }
  .modal__body, .modal__head, .modal__foot { padding-left: var(--s5); padding-right: var(--s5); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .pbar__fill { transition: none; }
}

/* Print helpers hidden */
.hide { display: none !important; }
@media (max-width: 900px) { .desktop-only { display: none !important; } }
@media (min-width: 901px) { .mobile-only { display: none !important; } }
