/* ==========================================================================
   STUDY HUB: design system
   1. Tokens   2. Base   3. Layout   4. Components   5. Pages   6. Utilities
   ========================================================================== */

@font-face {
  font-family: "DM Sans";
  src: url("../fonts/dm-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Manrope", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f3f2ed;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --surface-3: #ecebe5;
  --surface-hover: #f6f5f0;
  --border: #e3e2dc;
  --border-strong: #d8d7d1;
  --text: #101111;
  --text-2: #5d5d59;
  --text-3: #686863;
  --primary: #0e766a;
  --primary-hover: #0a5c52;
  --primary-soft: #e5f4f1;
  --primary-soft-2: #cdebe5;
  --on-primary: #ffffff;
  --btn-bg: #101111;
  --btn-fg: #ffffff;
  --btn-hover-bg: #21c9b4;
  --btn-hover-fg: #101111;
  --teal: #21c9b4;
  --success: #1e7d47;
  --success-soft: #e6f3ea;
  --warning: #9a5b0b;
  --warning-soft: #fbf1df;
  --danger: #c4383d;
  --danger-soft: #fbe9e9;
  --info: #2c6a94;
  --info-soft: #e7f0f6;

  --sidebar-bg: #101111;
  --sidebar-bg-2: #1a1c1c;
  --sidebar-text: #aaa9a4;
  --sidebar-text-strong: #f3f2ed;
  --sidebar-active: rgba(33, 201, 180, .12);
  --sidebar-border: #2a2c2c;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 17, 17, .05);
  --shadow-sm: 0 1px 3px rgba(16, 17, 17, .06), 0 1px 2px rgba(16, 17, 17, .04);
  --shadow: 0 4px 16px -4px rgba(16, 17, 17, .10), 0 2px 4px rgba(16, 17, 17, .04);
  --shadow-lg: 0 20px 48px -12px rgba(16, 17, 17, .25);
  --ring: 0 0 0 3px rgba(33, 201, 180, .35);

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
  --content-max: 1280px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101111;
  --surface: #1a1c1c;
  --surface-2: #161818;
  --surface-3: #232525;
  --surface-hover: #202222;
  --border: #2a2c2c;
  --border-strong: #3a3c3c;
  --text: #f3f2ed;
  --text-2: #c7c8c5;
  --text-3: #8f8e89;
  --primary: #21c9b4;
  --primary-hover: #4fd7c6;
  --primary-soft: rgba(33, 201, 180, .12);
  --primary-soft-2: rgba(33, 201, 180, .2);
  --on-primary: #101111;
  --btn-bg: #21c9b4;
  --btn-fg: #101111;
  --btn-hover-bg: #f3f2ed;
  --btn-hover-fg: #101111;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .12);
  --warning: #e7b961;
  --warning-soft: rgba(231, 185, 97, .12);
  --danger: #ef6b6f;
  --danger-soft: rgba(229, 72, 77, .14);
  --info: #7cb8e0;
  --info-soft: rgba(124, 184, 224, .12);
  --sidebar-bg: #0b0c0c;
  --sidebar-bg-2: #1a1c1c;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow: 0 6px 20px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, .65);
  --ring: 0 0 0 3px rgba(33, 201, 180, .4);
  color-scheme: dark;
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-family: var(--font-head); font-weight: 650; letter-spacing: -.025em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
::selection { background: var(--primary-soft-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
mark { background: #f7e3a1; color: #101111; padding: 0 2px; border-radius: 3px; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-3); padding: .1em .35em; border-radius: 5px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
[hidden] { display: none !important; }

/* 3. Layout ---------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  transition: width .2s ease, transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 18px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  background: #21c9b4;
  color: #101111; box-shadow: none;
}
.brand-mark .icon { width: 19px; height: 19px; }
.brand-name { color: var(--sidebar-text-strong); font-weight: 700; letter-spacing: .04em; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 6px 12px 16px; scrollbar-width: thin; scrollbar-color: #2a3350 transparent; }
.nav-section { margin-top: 18px; }
.nav-label { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 6px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #67728a; }
.nav-label a { color: #67728a; display: grid; place-items: center; border-radius: 6px; padding: 2px; }
.nav-label a:hover { color: var(--sidebar-text-strong); background: var(--sidebar-bg-2); }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin: 1px 0; border-radius: 9px;
  color: var(--sidebar-text); font-weight: 500; font-size: .9rem;
  white-space: nowrap; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--sidebar-bg-2); color: var(--sidebar-text-strong); }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; }
.nav-link.is-active .icon { color: #21c9b4; }
.nav-link .nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-count { font-size: .72rem; background: rgba(255,255,255,.08); color: var(--sidebar-text); padding: 1px 7px; border-radius: 99px; }
.nav-count.is-alert { background: rgba(229, 72, 77, .2); color: #f4a3a5; }
.course-dot { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-size: .62rem; font-weight: 700; }
.course-dot .icon { width: 13px; height: 13px; }
.nav-course .nav-code { font-weight: 600; color: var(--sidebar-text-strong); font-size: .84rem; }
.nav-course .nav-title { color: #7d889f; font-size: .8rem; margin-left: 4px; }
.nav-empty { padding: 8px 10px; font-size: .82rem; color: #67728a; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }
.sidebar-collapse-btn { width: 100%; justify-content: flex-start; color: var(--sidebar-text); background: none; border: 0; cursor: pointer; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .2s ease; display: flex; flex-direction: column; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 28px 32px 64px; flex: 1; }

/* Collapsed sidebar (desktop) */
.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
.sidebar-collapsed .sidebar .brand-name,
.sidebar-collapsed .sidebar .nav-text,
.sidebar-collapsed .sidebar .nav-count,
.sidebar-collapsed .sidebar .nav-label span,
.sidebar-collapsed .sidebar .nav-label a,
.sidebar-collapsed .sidebar .nav-title,
.sidebar-collapsed .sidebar .nav-code,
.sidebar-collapsed .sidebar .nav-empty { display: none; }
.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding: 9px 0; }
.sidebar-collapsed .sidebar .nav-label { justify-content: center; padding: 0 0 6px; }
.sidebar-collapsed .sidebar .nav-label::after { content: ""; width: 20px; height: 1px; background: var(--sidebar-border); }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
.sidebar-collapsed .sidebar-collapse-btn .icon { transform: rotate(180deg); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-menu { display: none; }
.topbar-search { position: relative; flex: 1; max-width: 520px; }
.topbar-search .input { padding-left: 38px; height: 40px; background: var(--surface); border-radius: 10px; }
.topbar-search > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.topbar-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--font); font-size: .7rem; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow-y: auto;
}
.suggest-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.suggest-item:hover, .suggest-item.is-active { background: var(--surface-hover); color: var(--text); }
.suggest-item .icon { color: var(--text-3); }
.suggest-item .s-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.suggest-item .s-meta { font-size: .76rem; color: var(--text-3); white-space: nowrap; }
.suggest-head { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 8px 10px 4px; font-weight: 600; }
.suggest-foot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.backdrop { position: fixed; inset: 0; background: rgba(16, 17, 17, .5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: .82rem; color: var(--text-3); margin-bottom: 10px; }
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .icon { width: 14px; height: 14px; }

/* 4. Components ------------------------------------------------------------ */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 6px;
  border: 1px solid transparent; background: none;
  font-weight: 550; font-size: .88rem; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none; user-select: none;
}
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-hover-bg); color: var(--btn-hover-fg); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: var(--primary-soft-2); color: var(--primary); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .82rem; border-radius: 8px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: .95rem; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: .55; pointer-events: none; }
.btn.is-on { color: var(--primary); }
.btn.is-on .icon { fill: currentColor; }
.icon-btn-badge { position: relative; }
.icon-btn-badge .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-body { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { font-size: .98rem; display: flex; align-items: center; gap: 8px; }
.card-header .icon { color: var(--text-3); }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-link { font-size: .84rem; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }

/* Grid helpers */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-icon.is-green { background: var(--success-soft); color: var(--success); }
.stat-icon.is-amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.is-red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.is-blue { background: var(--info-soft); color: var(--info); }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-2); font-weight: 500; }
a.stat:hover { border-color: var(--border-strong); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group + .form-group { margin-top: 16px; }
.form-grid .form-group + .form-group { margin-top: 0; }
.label { font-size: .84rem; font-weight: 600; color: var(--text); }
.label .opt { font-weight: 400; color: var(--text-3); }
.hint { font-size: .78rem; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s; font-size: .9rem;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238391a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-sm, .select-sm { height: 34px; font-size: .84rem; border-radius: 8px; }
.is-invalid { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: .8rem; font-weight: 500; }
.input-group { position: relative; }
.input-group .input { padding-right: 42px; }
.input-group .input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .88rem; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); margin: 0; cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-section-title { font-size: .95rem; font-weight: 650; margin-bottom: 4px; }
.form-section-desc { color: var(--text-2); font-size: .85rem; margin-bottom: 16px; }

/* Colour & icon pickers */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input, .icon-picker input, .theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.swatch span { display: block; width: 30px; height: 30px; border-radius: 9px; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); transition: transform .12s; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; transform: scale(1.04); }
.swatch input:focus-visible + span { box-shadow: var(--ring); }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.icon-picker label { position: relative; }
.icon-picker span { display: grid; place-items: center; height: 42px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; color: var(--text-2); background: var(--surface); }
.icon-picker span:hover { border-color: var(--border-strong); color: var(--text); }
.icon-picker input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.icon-picker input:focus-visible + span { box-shadow: var(--ring); }

/* Badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge .icon { width: 12px; height: 12px; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.status-not_started { background: var(--surface-3); color: var(--text-2); }
.status-in_progress { background: var(--info-soft); color: var(--info); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-submitted { background: var(--primary-soft); color: var(--primary); }
.priority-high { background: var(--danger-soft); color: var(--danger); }
.priority-medium { background: var(--warning-soft); color: var(--warning); }
.priority-low { background: var(--surface-3); color: var(--text-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: .74rem; font-weight: 500; }
a.chip:hover { background: var(--primary-soft); color: var(--primary); }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.course-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; color: var(--text-2); }
.course-tag::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--c, var(--primary)); }

/* File-type badge */
.ft { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; position: relative; }
.ft .icon { width: 19px; height: 19px; }
.ft-pdf { background: #fdecec; color: #dc2626; }
.ft-presentation { background: #fff1e6; color: #ea580c; }
.ft-word { background: #e8f0fe; color: #2563eb; }
.ft-spreadsheet { background: #e7f7ee; color: #16a34a; }
.ft-image { background: #f3e8ff; color: #9333ea; }
.ft-text, .ft-ebook { background: #eef2f7; color: #475569; }
.ft-archive { background: #fef9c3; color: #a16207; }
.ft-link { background: #e0f2fe; color: #0284c7; }
.ft-other { background: var(--surface-3); color: var(--text-2); }
:root[data-theme="dark"] .ft-pdf { background: rgba(239,68,68,.14); color: #f87171; }
:root[data-theme="dark"] .ft-presentation { background: rgba(249,115,22,.14); color: #fb923c; }
:root[data-theme="dark"] .ft-word { background: rgba(59,130,246,.14); color: #60a5fa; }
:root[data-theme="dark"] .ft-spreadsheet { background: rgba(34,197,94,.14); color: #4ade80; }
:root[data-theme="dark"] .ft-image { background: rgba(168,85,247,.14); color: #c084fc; }
:root[data-theme="dark"] .ft-text, :root[data-theme="dark"] .ft-ebook { background: rgba(148,163,184,.14); color: #cbd5e1; }
:root[data-theme="dark"] .ft-archive { background: rgba(234,179,8,.14); color: #facc15; }
:root[data-theme="dark"] .ft-link { background: rgba(14,165,233,.14); color: #38bdf8; }
.ft-ext { position: absolute; bottom: -4px; right: -6px; font-size: .55rem; font-weight: 700; text-transform: uppercase; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); border-radius: 4px; padding: 0 3px; line-height: 13px; }

/* Avatars */
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: .8rem; overflow: hidden; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.2rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.6rem; }

/* Progress */
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.progress.is-green > span { background: var(--success); }
.progress-label { display: flex; justify-content: space-between; font-size: .74rem; color: var(--text-3); margin-bottom: 5px; }

/* Tabs / segmented */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 11px; color: var(--text-2); font-weight: 550; font-size: .87rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: .72rem; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 99px; font-weight: 600; }
.tab.is-active .count { background: var(--primary-soft); color: var(--primary); }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.segmented a, .segmented button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: .82rem; font-weight: 550; border: 0; background: none; cursor: pointer; }
.segmented a:hover, .segmented button:hover { color: var(--text); }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 550; }
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.is-active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pill .count { font-size: .72rem; opacity: .7; }
.pill.is-danger.is-active { background: var(--danger); border-color: var(--danger); color: #fff; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filter-bar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }
.filter-bar .select { width: auto; min-width: 140px; }

/* Lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
a.list-item, .list-item.is-link { color: var(--text); transition: background .12s; }
a.list-item:hover, .list-item.is-link:hover { background: var(--surface-hover); }
.list-item .li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
a.li-title:hover { color: var(--primary); }
.li-meta { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.li-meta .sep::before { content: "·"; }
.li-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* Material rows/tiles */
.material-list .list-item { padding: 12px 16px; }
.material-list .li-check { flex-shrink: 0; }
.material-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.tile { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.tile-thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; border-bottom: 1px solid var(--border); overflow: hidden; color: var(--text-3); }
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile-thumb .ft { width: 56px; height: 56px; border-radius: 14px; }
.tile-thumb .ft .icon { width: 26px; height: 26px; }
.tile-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.tile-title { font-weight: 600; font-size: .88rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: .75rem; color: var(--text-3); }
.tile-check { position: absolute; top: 10px; left: 10px; z-index: 2; background: var(--surface); border-radius: 6px; padding: 3px; line-height: 0; box-shadow: var(--shadow-sm); }
.tile-badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; z-index: 2; }
.tile .stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.picture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.picture-grid .tile-thumb { aspect-ratio: 1; }

/* Course cards */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.course-card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; transition: border-color .15s, box-shadow .2s, transform .2s; }
.course-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.course-card-top { height: 6px; background: var(--c); }
.course-card-body { padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.course-card-head { display: flex; align-items: flex-start; gap: 12px; }
.course-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.course-icon .icon { width: 22px; height: 22px; }
.course-icon-lg { width: 56px; height: 56px; border-radius: 15px; }
.course-icon-lg .icon { width: 28px; height: 28px; }
.course-code { font-size: .76rem; font-weight: 700; letter-spacing: .05em; color: var(--c); text-transform: uppercase; }
.course-title { font-size: 1rem; font-weight: 650; color: var(--text); line-height: 1.3; margin-top: 2px; }
.course-card .stretched::after { content: ""; position: absolute; inset: 0; }
.course-stats { display: flex; gap: 14px; font-size: .78rem; color: var(--text-2); flex-wrap: wrap; }
.course-stats span { display: inline-flex; align-items: center; gap: 5px; }
.course-stats .icon { width: 14px; height: 14px; color: var(--text-3); }
.course-card-foot { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; border-top: 1px solid var(--border); font-size: .76rem; color: var(--text-3); background: var(--surface-2); }
.course-card .menu-wrap { position: relative; z-index: 2; margin-left: auto; }
.course-add { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; min-height: 196px; border: 1.5px dashed var(--border-strong); border-radius: 16px; color: var(--text-2); font-weight: 600; background: transparent; transition: border-color .15s, color .15s, background .15s; }
.course-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.course-table .course-icon { width: 34px; height: 34px; border-radius: 9px; }
.course-table .course-icon .icon { width: 17px; height: 17px; }

/* Course workspace header */
.course-hero { position: relative; display: flex; align-items: center; gap: 18px; padding: 22px 24px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 18px; overflow: hidden; }
.course-hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.course-hero .hero-main { flex: 1; min-width: 0; }
.course-hero h1 { font-size: 1.45rem; }
.course-hero .hero-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-2); font-size: .84rem; margin-top: 6px; }
.course-hero .hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.course-hero .hero-meta .icon { width: 15px; height: 15px; color: var(--text-3); }
.course-nav { margin-bottom: 22px; }

/* Dropdowns */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; display: none;
}
.menu.is-open { display: block; animation: pop .12s ease-out; }
.menu.menu-up { top: auto; bottom: calc(100% + 6px); }
.menu.menu-left { right: auto; left: 0; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: .86rem; background: none; border: 0; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-hover); color: var(--text); }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.menu-head { padding: 10px 10px 8px; }
.menu form { margin: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 17, 17, .55); animation: fade .15s; }
.modal-dialog { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.modal-lg .modal-dialog { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.modal-head h2 { font-size: 1.08rem; }
.modal-head p { color: var(--text-2); font-size: .86rem; margin-top: 4px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }
.confirm-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: min(400px, calc(100vw - 40px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; font-size: .87rem; }
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: var(--success); }
.toast-error .icon { color: var(--danger); }
.toast-warning .icon { color: var(--warning); }
.toast-info .icon { color: var(--info); }
.toast-msg { flex: 1; }
.toast-close { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 0; line-height: 0; }
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Alerts */
.alert { display: flex; gap: 12px; padding: 13px 15px; border-radius: 12px; font-size: .87rem; border: 1px solid transparent; align-items: flex-start; }
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert p { color: var(--text); }
.alert strong { color: inherit; }

/* Empty states */
.empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 6px; }
.empty-icon .icon { width: 28px; height: 28px; }
.empty h3 { font-size: 1.02rem; }
.empty p { color: var(--text-2); max-width: 420px; font-size: .88rem; }
.empty .row { margin-top: 10px; justify-content: center; flex-wrap: wrap; }
.empty-sm { padding: 28px 16px; }
.empty-sm .empty-icon { width: 44px; height: 44px; border-radius: 13px; }
.empty-sm .empty-icon .icon { width: 21px; height: 21px; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; font-size: .84rem; color: var(--text-2); }
.pagination .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link { min-width: 34px; height: 34px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface); font-weight: 550; }
.page-link:hover { border-color: var(--border-strong); color: var(--text); }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.page-link.is-disabled { opacity: .45; pointer-events: none; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th { text-align: left; font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }

/* Dropzone & upload queue */
.dropzone { position: relative; border: 2px dashed var(--border-strong); border-radius: 16px; padding: 36px 20px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dropzone-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.dropzone-icon .icon { width: 25px; height: 25px; }
.dropzone h3 { font-size: .98rem; }
.dropzone p { color: var(--text-2); font-size: .84rem; margin-top: 4px; }
.dropzone-compact { padding: 20px 16px; }
.queue { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.queue-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.queue-item .q-main { flex: 1; min-width: 0; }
.queue-item .q-title { width: 100%; border: 0; background: none; font-weight: 600; font-size: .88rem; padding: 2px 4px; border-radius: 6px; }
.queue-item .q-title:focus { background: var(--surface-3); outline: none; }
.queue-item .q-meta { font-size: .75rem; color: var(--text-3); padding: 0 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.queue-item .progress { margin: 6px 4px 0; }
.queue-item.is-done { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.queue-item.is-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.q-status { font-size: .75rem; font-weight: 600; }
.q-status.ok { color: var(--success); }
.q-status.err { color: var(--danger); }

/* Activity timeline */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 11px 20px; position: relative; }
.tl-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.tl-icon .icon { width: 15px; height: 15px; }
.tl-main { flex: 1; min-width: 0; font-size: .86rem; }
.tl-main .tl-text { color: var(--text); }
.tl-main .tl-text b { font-weight: 600; }
.tl-main .tl-time { font-size: .75rem; color: var(--text-3); margin-top: 1px; }

/* Continue studying */
.continue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.continue-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s; position: relative; }
.continue-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.continue-card .cc-top { display: flex; gap: 12px; align-items: flex-start; }
.continue-card .cc-title { font-weight: 600; font-size: .9rem; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.continue-card .cc-meta { font-size: .76rem; color: var(--text-3); margin-top: 3px; }
.continue-card .cc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }

/* Welcome */
.welcome { display: flex; align-items: center; gap: 20px; padding: 24px 26px; border-radius: 20px; margin-bottom: 24px; color: #fff; position: relative; overflow: hidden;
  background: #101111; border: 1px solid #101111; }
:root[data-theme="dark"] .welcome { background: var(--surface); border-color: var(--border); }
.welcome .avatar { border: 3px solid rgba(255,255,255,.18); background: rgba(255,255,255,.12); color: #fff; }
.welcome h1 { font-size: 1.5rem; color: #fff; }
.welcome .w-date { color: #21c9b4; font-size: .85rem; font-weight: 500; }
.welcome .w-msg { color: #c7c8c5; margin-top: 4px; font-size: .9rem; }
.welcome .w-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.welcome .btn-secondary { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: #fff; box-shadow: none; }
.welcome .btn-secondary:hover { background: rgba(255,255,255,.18); color: #fff; }
.welcome .btn-primary { background: #21c9b4; color: #101111; }
.welcome .btn-primary:hover { background: #f3f2ed; color: #101111; }
.welcome .btn-primary:hover { background: #eef0ff; color: #1e1b4b; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.qa { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550; font-size: .86rem; transition: border-color .15s, background .15s; }
.qa:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.qa .icon { color: var(--primary); }

/* Section headings within pages */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.section-head h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.section-head h2 .icon { color: var(--text-3); }

/* Bulk bar */
.bulk-bar { position: sticky; bottom: 16px; z-index: 20; display: none; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-top: 16px; background: var(--text); color: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.bulk-bar.is-visible { display: flex; }
.bulk-bar .btn-ghost { color: var(--surface); }
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,.12); color: var(--surface); }
:root[data-theme="dark"] .bulk-bar .btn-ghost:hover { background: rgba(0,0,0,.1); }
.bulk-bar .select { width: auto; height: 32px; font-size: .82rem; background-color: var(--surface); color: var(--text); }

/* Notes */
.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.note-card { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); transition: border-color .15s, box-shadow .15s; min-height: 160px; }
.note-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.note-card .nc-title { font-weight: 650; color: var(--text); font-size: .95rem; }
.note-card .nc-excerpt { color: var(--text-2); font-size: .84rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.note-card .nc-foot { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--text-3); flex-wrap: wrap; }
.note-card .stretched::after { content: ""; position: absolute; inset: 0; }

/* Editor */
.editor-shell { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: var(--topbar-h); z-index: 5; border-radius: 16px 16px 0 0; }
.editor-toolbar .tb-sep { width: 1px; background: var(--border); margin: 4px 6px; }
.tb-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.tb-btn:hover { background: var(--surface-3); color: var(--text); }
.tb-btn.is-active { background: var(--primary-soft); color: var(--primary); }
.tb-btn .icon { width: 17px; height: 17px; }
.editor-title { width: 100%; border: 0; background: none; font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; padding: 26px 32px 6px; color: var(--text); }
.editor-title:focus { outline: none; }
.editor-title::placeholder { color: var(--text-3); }
.editor-area { min-height: 420px; padding: 8px 32px 40px; outline: none; font-size: 1rem; line-height: 1.75; }
.editor-area:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.prose h1 { font-size: 1.6rem; margin: 1.2em 0 .4em; }
.prose h2 { font-size: 1.3rem; margin: 1.1em 0 .4em; }
.prose h3 { font-size: 1.1rem; margin: 1em 0 .3em; }
.prose p, .prose div { margin: 0 0 .7em; }
.prose ul, .prose ol { margin: 0 0 .8em; padding-left: 1.5em; }
.prose li { margin: .2em 0; }
.prose blockquote { margin: 0 0 .8em; padding: .3em 1em; border-left: 3px solid var(--primary); color: var(--text-2); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.prose pre { background: var(--surface-3); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: .86rem; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose table { border-collapse: collapse; margin-bottom: 1em; }
.prose td, .prose th { border: 1px solid var(--border); padding: 6px 10px; }
.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-3); }
.save-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.save-status.is-saved .dot { background: var(--success); }
.save-status.is-dirty .dot { background: var(--warning); }
.save-status.is-saving .dot { background: var(--info); animation: pulse 1s infinite; }
.save-status.is-error { color: var(--danger); }
.save-status.is-error .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* Detail definition lists */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; font-size: .86rem; }
.dl dt { color: var(--text-3); font-weight: 500; }
.dl dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* Attachments */
.attach { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.attach + .attach { margin-top: 8px; }
.attach .a-main { flex: 1; min-width: 0; }
.attach .a-name { font-weight: 600; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; color: var(--text); }
.attach .a-meta { font-size: .75rem; color: var(--text-3); }
.attach-section-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: .92rem; margin-bottom: 10px; }
.attach-section-title .badge { margin-left: auto; }

/* Assignment rows */
.assign-row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); position: relative; }
.assign-row:last-child { border-bottom: 0; }
.assign-row:hover { background: var(--surface-hover); }
.assign-row .ar-main { flex: 1 1 220px; min-width: 0; }
.assign-row .ar-title { font-weight: 600; color: var(--text); }
.assign-row .ar-title::after { content: ""; position: absolute; inset: 0; }
.assign-row .ar-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; position: relative; z-index: 1; }
.due { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--text-2); font-weight: 500; }
.due .icon { width: 14px; height: 14px; }
.due.is-overdue { color: var(--danger); font-weight: 600; }
.due.is-soon { color: var(--warning); }
.assign-check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; color: transparent; }
.assign-check.is-done { background: var(--success); border-color: var(--success); color: #fff; }
.assign-check .icon { width: 14px; height: 14px; stroke-width: 3; }

/* Heatmap & bars (progress page) */
.heatmap { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-flow: column; grid-auto-columns: 13px; gap: 3px; }
.heatmap span { border-radius: 3px; background: var(--surface-3); }
.heatmap .l1 { background: color-mix(in srgb, var(--primary) 30%, var(--surface-3)); }
.heatmap .l2 { background: color-mix(in srgb, var(--primary) 55%, var(--surface-3)); }
.heatmap .l3 { background: color-mix(in srgb, var(--primary) 80%, var(--surface-3)); }
.heatmap .l4 { background: var(--primary); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar-fill { width: 100%; max-width: 38px; background: var(--primary); border-radius: 6px 6px 3px 3px; min-height: 2px; position: relative; }
.bars .bar-fill.is-zero { background: var(--surface-3); }
.bars .bar-val { font-size: .72rem; font-weight: 600; color: var(--text-2); }
.bars .bar-label { font-size: .7rem; color: var(--text-3); white-space: nowrap; }
.legend { display: flex; align-items: center; gap: 4px; font-size: .74rem; color: var(--text-3); }
.legend span { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Settings layout */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-weight: 550; font-size: .88rem; }
.settings-nav a:hover { background: var(--surface-3); color: var(--text); }
.settings-nav a.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-option { position: relative; cursor: pointer; }
.theme-option .to-card { border: 2px solid var(--border); border-radius: 14px; overflow: hidden; transition: border-color .15s; }
.theme-option input:checked + .to-card { border-color: var(--primary); }
.theme-option input:focus-visible + .to-card { box-shadow: var(--ring); }
.to-preview { height: 86px; display: flex; gap: 6px; padding: 10px; }
.to-preview i { display: block; border-radius: 5px; }
.to-light { background: #f3f2ed; } .to-light i:first-child { width: 26%; background: #101111; } .to-light i:last-child { flex: 1; background: #fff; border: 1px solid #d8d7d1; }
.to-dark { background: #101111; } .to-dark i:first-child { width: 26%; background: #0b0c0c; border: 1px solid #2a2c2c; } .to-dark i:last-child { flex: 1; background: #1a1c1c; border: 1px solid #2a2c2c; }
.to-system { background: linear-gradient(90deg, #f3f2ed 50%, #101111 50%); } .to-system i:first-child { width: 26%; background: #101111; } .to-system i:last-child { flex: 1; background: linear-gradient(90deg, #fff 50%, #1a1c1c 50%); }
.to-label { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; font-size: .86rem; border-top: 1px solid var(--border); }
.storage-bar { height: 12px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.storage-bar span { height: 100%; }

/* Auth & installer pages */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 44px; color: #fff;
  background: #101111; }
.auth-aside h2 { font-size: 2rem; line-height: 1.2; max-width: 440px; letter-spacing: -.02em; }
.auth-aside p { color: #aaa9a4; max-width: 420px; margin-top: 14px; font-size: .98rem; }
.auth-features { display: grid; gap: 14px; margin-top: 32px; max-width: 420px; }
.auth-feature { display: flex; gap: 12px; align-items: flex-start; color: #c7c8c5; font-size: .9rem; }
.auth-feature .f-icon { width: 34px; height: 34px; border-radius: 10px; background: rgba(33,201,180,.1); display: grid; place-items: center; flex-shrink: 0; color: #21c9b4; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .subtitle { color: var(--text-2); margin: 6px 0 26px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .04em; }
.minimal-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 20px; }
.minimal-card { width: 100%; max-width: 640px; }
.install-steps { display: flex; gap: 8px; margin: 18px 0 22px; }
.install-step { flex: 1; display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: var(--text-3); }
.install-step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: .78rem; }
.install-step.is-active { color: var(--text); }
.install-step.is-active .n { background: var(--primary); color: var(--on-primary); }
.install-step.is-done .n { background: var(--success); color: #fff; }
.req-list { display: grid; gap: 6px; font-size: .85rem; }
.req { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; background: var(--surface-2); }
.req .icon { width: 16px; height: 16px; }
.req.ok .icon { color: var(--success); }
.req.bad .icon { color: var(--danger); }
.req.warn .icon { color: var(--warning); }
.req .r-note { margin-left: auto; color: var(--text-3); font-size: .78rem; text-align: right; }
pre.config-source { background: var(--surface-3); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: .78rem; font-family: var(--mono); }

/* 5. Reader --------------------------------------------------------------- */
.reader-body { height: 100vh; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.reader-top { height: 58px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 10; }
.reader-title { min-width: 0; flex: 1; display: flex; align-items: center; gap: 12px; }
.reader-title .ft { width: 34px; height: 34px; border-radius: 9px; }
.reader-title .ft .icon { width: 17px; height: 17px; }
.reader-title .rt-name { font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title .rt-sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-title .rt-text { min-width: 0; }
.reader-tools { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.reader-bar { height: 50px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: nowrap; overflow-x: auto; }
.reader-bar .tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.page-input { width: 56px; height: 32px; text-align: center; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-size: .86rem; }
.page-total { font-size: .86rem; color: var(--text-2); white-space: nowrap; }
.zoom-label { min-width: 52px; text-align: center; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.reader-main { flex: 1; min-height: 0; display: flex; }
.reader-stage { flex: 1; min-width: 0; overflow: auto; position: relative; background: var(--surface-3); }
:root[data-theme="dark"] .reader-stage { background: #070a13; }
.reader-stage.is-dark-paper .pdf-page canvas { filter: invert(.9) hue-rotate(180deg); }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 16px 40px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(16,17,17,.15); flex-shrink: 0; }
.pdf-page canvas { display: block; }
.pdf-page .pdf-ph { position: absolute; inset: 0; display: grid; place-items: center; color: #94a3b8; font-size: .8rem; }
.reader-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; background: var(--surface-3); }
.reader-loading .box { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-2); font-size: .88rem; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader-fallback { max-width: 460px; margin: 60px auto; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; }
.reader-panel { width: 340px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.reader-panel .rp-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.reader-panel .rp-tabs { display: flex; gap: 2px; flex: 1; }
.reader-panel .rp-body { flex: 1; overflow-y: auto; padding: 16px; }
.quick-note .editor-area { min-height: 180px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; font-size: .9rem; }
.quick-note .editor-area:focus { border-color: var(--primary); box-shadow: var(--ring); }
.quick-note .mini-tools { display: flex; gap: 2px; margin-bottom: 6px; }
.quick-note .mini-tools .tb-btn { width: 30px; height: 30px; }
.pptx-stage { display: flex; justify-content: center; align-items: flex-start; padding: 24px 16px; min-height: 100%; }
.pptx-host { background: #fff; box-shadow: 0 4px 20px rgba(16,17,17,.18); transform-origin: top center; }
.pptx-host .pptx-preview-wrapper, .pptx-host > div { background: #fff !important; }
.pptx-host [class*="pptx-preview-wrapper-next"], .pptx-host [class*="pptx-preview-wrapper-prev"], .pptx-host [class*="pagination"] { display: none !important; }
.docx-stage { padding: 24px 12px; }
.docx-stage .docx-wrapper { background: transparent !important; padding: 0 !important; }
.docx-stage .docx-wrapper > section.docx { box-shadow: 0 2px 12px rgba(16,17,17,.15) !important; margin: 0 auto 20px !important; max-width: 100%; }
.text-stage { max-width: 860px; margin: 24px auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 32px; }
.text-stage pre { white-space: pre-wrap; word-wrap: break-word; font-family: var(--mono); font-size: .88rem; line-height: 1.65; margin: 0; color: var(--text); }
.image-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; background: #0b0f1a; }
.image-stage.is-dragging { cursor: grabbing; }
.image-stage img { position: absolute; top: 50%; left: 50%; max-width: none; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.image-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(16,17,17,.55); color: #fff; border: 1px solid rgba(255,255,255,.12); }
.image-nav:hover { background: rgba(16,17,17,.8); color: #fff; }
.image-nav.prev { left: 16px; } .image-nav.next { right: 16px; }
.image-counter { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 4; background: rgba(16,17,17,.65); color: #fff; font-size: .78rem; padding: 4px 12px; border-radius: 99px; }
.office-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.reader-progress-line { height: 3px; background: var(--surface-3); flex-shrink: 0; }
.reader-progress-line span { display: block; height: 100%; background: var(--primary); width: 0; transition: width .25s; }

/* PDF.js text layer (selectable text over the canvas) */
.textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-align: initial; -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; z-index: 2; opacity: 1; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgba(33, 201, 180, .35); }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: -1; cursor: default; user-select: none; }
.reader-stage.is-dark-paper .pdf-page { background: #111; }

/* Theme toggle shows the icon for the theme you would switch to */
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root:not([data-theme="dark"]) .theme-icon-light { display: none; }

/* 6. Utilities ------------------------------------------------------------- */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .82rem; }
.xs { font-size: .75rem; }
.bold { font-weight: 650; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 28px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.p-0 { padding: 0 !important; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.w-100 { width: 100%; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.desc-text { white-space: pre-line; color: var(--text-2); font-size: .9rem; }
.inline-form { display: inline; margin: 0; }
.only-mobile { display: none; }

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 1200px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr) 300px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: 280px !important; box-shadow: var(--shadow-lg); }
  .main, .sidebar-collapsed .main { margin-left: 0; }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .backdrop { opacity: 1; pointer-events: auto; }
  .sidebar-collapsed .sidebar .brand-name, .sidebar-collapsed .sidebar .nav-text, .sidebar-collapsed .sidebar .nav-count,
  .sidebar-collapsed .sidebar .nav-label span, .sidebar-collapsed .sidebar .nav-label a, .sidebar-collapsed .sidebar .nav-code,
  .sidebar-collapsed .sidebar .nav-title, .sidebar-collapsed .sidebar .nav-empty { display: revert; }
  .sidebar-collapsed .sidebar .nav-link { justify-content: flex-start; padding: 8px 10px; }
  .sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 18px; }
  .sidebar-collapse-btn { display: none; }
  .topbar-menu { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 22px 20px 56px; }
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-panel { position: fixed; right: 0; top: 58px; bottom: 0; z-index: 20; box-shadow: var(--shadow-lg); width: min(360px, 92vw); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .settings-nav a { white-space: nowrap; }
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  h1 { font-size: 1.35rem; }
  .content { padding: 18px 16px 48px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-search kbd { display: none; }
  .topbar-search { max-width: none; }
  .hide-mobile { display: none !important; }
  .only-mobile { display: revert; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .welcome { flex-wrap: wrap; padding: 20px; }
  .welcome .w-actions { margin-left: 0; width: 100%; }
  .welcome .avatar-lg { width: 52px; height: 52px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.35rem; }
  .course-grid { grid-template-columns: minmax(0, 1fr); }
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .picture-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .picture-grid .tile { border-radius: 10px; }
  .picture-grid .tile-body { display: none; }
  .list-item { padding: 12px 14px; gap: 12px; }
  .li-actions .btn-ghost.hide-mobile { display: none; }
  .filter-bar .input-icon { max-width: none; min-width: 100%; }
  .filter-bar .select { flex: 1; min-width: 0; }
  .page-header { margin-bottom: 18px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .course-hero { flex-wrap: wrap; padding: 18px; }
  .course-hero .page-actions .btn { flex: 0 0 auto; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-dialog { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .editor-title { padding: 20px 18px 4px; font-size: 1.4rem; }
  .editor-area { padding: 6px 18px 32px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .assign-row { flex-wrap: wrap; }
  .assign-row .ar-side { width: 100%; justify-content: flex-start; padding-left: 36px; }
  .theme-options { grid-template-columns: minmax(0, 1fr); }
  .reader-top { padding: 0 8px; gap: 4px; }
  .reader-tools .hide-mobile { display: none; }
  .reader-bar { justify-content: flex-start; }
  .text-stage { margin: 0; border-radius: 0; border: 0; padding: 20px 16px; }
  .toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .pagination { justify-content: center; }
  .table th, .table td { padding: 10px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .toasts { display: none !important; }
  .main { margin: 0 !important; }
}

.auth-credit { display: flex; align-items: center; gap: 8px; }
.auth-credit span { margin-left: auto; text-transform: uppercase; letter-spacing: .18em; font-size: .62rem; }
.auth-credit img { width: 58px; height: auto; opacity: .85; }

/* Welcome intro and feature tour (sign-in page), beAnt style ---------------- */
body.intro-open { overflow: hidden; }
.intro { position: fixed; inset: 0; z-index: 200; color: #f3f2ed; overflow: hidden; background-color: #101111;
  background-image: linear-gradient(rgba(243,242,237,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(243,242,237,.045) 1px, transparent 1px);
  background-size: 68px 68px; background-position: center center;
  opacity: 0; transition: opacity .45s cubic-bezier(.22,.61,.36,1); --teal: #21c9b4; --ease: cubic-bezier(.22,.61,.36,1); }
.intro.is-open { opacity: 1; }
.intro.is-closing { opacity: 0; pointer-events: none; }
.intro .btn { border-radius: 6px; }
.intro .btn-primary { background: #21c9b4; color: #101111; }
.intro .btn-primary:hover { background: #f3f2ed; color: #101111; }
.intro-ghost { background: transparent; color: #f3f2ed; border: 1px solid rgba(243,242,237,.28); }
.intro-ghost:hover { background: #21c9b4; border-color: #21c9b4; color: #101111; }
.intro-skip { position: absolute; top: 18px; right: 18px; z-index: 3; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid rgba(243,242,237,.22); background: transparent; color: #aaa9a4; font: inherit; font-size: .72rem;
  font-weight: 600; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.intro-skip:hover { color: #101111; background: #21c9b4; border-color: #21c9b4; }
.intro .btn:focus-visible, .intro-skip:focus-visible, .intro-dots button:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; box-shadow: none; }
.intro-kicker { font-size: .68rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #aaa9a4; display: inline-flex; align-items: center; gap: 10px; }
.intro-peak { width: 8px; height: 8px; border-left: 1.4px solid var(--teal); border-top: 1.4px solid var(--teal); transform: rotate(45deg) translate(1px, 1px); display: inline-block; }

/* All steps are stacked; only the active one shows. */
[data-intro-step] { position: absolute; inset: 0; z-index: 1; opacity: 0; visibility: hidden; transform: translateX(32px);
  transition: opacity .5s var(--ease), transform .5s var(--ease), visibility 0s linear .5s; }
[data-intro-step].is-before { transform: translateX(-32px); }
[data-intro-step].is-active { opacity: 1; visibility: visible; transform: none; transition: opacity .5s var(--ease), transform .5s var(--ease); z-index: 2; }

/* Splash */
.intro-splash { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 16px; transform: none; }
.intro-splash.is-before { transform: none; }
.intro-mark { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; background: #21c9b4; color: #101111; margin-bottom: 28px; opacity: 0; }
.intro-mark .icon { width: 32px; height: 32px; }
.intro-title { font-family: var(--font-head); font-size: clamp(3rem, 11vw, 6.4rem); font-weight: 600; letter-spacing: -.045em; line-height: .95; display: flex; flex-wrap: wrap; justify-content: center; color: #f3f2ed; }
.intro-title span { display: inline-block; opacity: 0; transform: translateY(20px); }
.intro-title .intro-hub { color: var(--teal); font-weight: 400; }
.intro-title .intro-gap { width: .28em; }
.intro-tagline { margin-top: 22px; color: #c7c8c5; font-size: clamp(1rem, 2.4vw, 1.15rem); max-width: 520px; opacity: 0; }
.intro-credit { margin-top: 44px; display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0; }
.intro-credit img { width: 132px; height: auto; }
.intro-cta { margin-top: 40px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; opacity: 0; }
.intro.is-open .intro-splash.is-active .intro-mark { animation: introFade .7s var(--ease) .1s forwards; }
.intro.is-open .intro-splash.is-active .intro-title span { animation: introRise .7s var(--ease) calc(.2s + var(--i) * 45ms) forwards; }
.intro.is-open .intro-splash.is-active .intro-tagline { animation: introFade .7s var(--ease) .8s forwards; }
.intro.is-open .intro-splash.is-active .intro-credit { animation: introFade .7s var(--ease) 1.05s forwards; }
.intro.is-open .intro-splash.is-active .intro-cta { animation: introFade .7s var(--ease) 1.3s forwards; }
@keyframes introRise { to { opacity: 1; transform: none; } }
@keyframes introFade { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* Feature slides */
.intro-slide { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); align-items: center; gap: 52px; padding: 76px 48px 104px; max-width: 1480px; margin: 0 auto; }
.intro-shot { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.intro-window { width: 100%; max-width: calc((100vh - 230px) * 1.6); border-radius: 14px; overflow: hidden; background: #1a1c1c;
  border: 1px solid #2a2c2c; box-shadow: 0 30px 70px -30px rgba(0,0,0,.7); }
.intro-window-bar { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; background: #161818; border-bottom: 1px solid #2a2c2c; }
.intro-window-bar i { width: 9px; height: 9px; border-radius: 50%; background: #3a3c3c; }
.intro-window-bar span { margin-left: 10px; font-size: .7rem; color: #8f8e89; }
.intro-window img { display: block; width: 100%; height: auto; aspect-ratio: 1440 / 900; background: #1a1c1c; }
.intro-phone { height: min(600px, calc(100vh - 230px)); aspect-ratio: 390 / 844; border-radius: 36px; padding: 9px; background: #1a1c1c;
  border: 1px solid #2a2c2c; box-shadow: 0 30px 70px -30px rgba(0,0,0,.7); }
.intro-phone img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 28px; background: #f3f2ed; }
.intro-caption { margin-top: 14px; font-size: .8rem; color: #8f8e89; text-align: center; max-width: 640px; }
.intro-copy { max-width: 440px; }
.intro-eyebrow { display: flex; align-items: center; gap: 10px; }
.intro-count { margin-left: auto; font-family: var(--font-head); font-weight: 600; color: var(--teal); font-size: .85rem; }
.intro-copy h2 { margin-top: 18px; font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.05; letter-spacing: -.04em; font-weight: 600; color: #fff; }
.intro-copy p { margin-top: 16px; color: #c7c8c5; font-size: 1rem; line-height: 1.65; }
.intro-copy ul { list-style: none; padding: 0; margin: 22px 0 0; border-top: 1px solid #2a2c2c; }
.intro-copy li { display: flex; gap: 12px; align-items: baseline; color: #f3f2ed; font-size: .92rem; padding: 10px 0; border-bottom: 1px solid #2a2c2c; }
.intro-copy li::before { content: "+"; color: var(--teal); font-weight: 600; flex-shrink: 0; }
.intro-slide.is-active .intro-window, .intro-slide.is-active .intro-phone { animation: introFade .7s var(--ease) both; }
.intro-slide.is-active .intro-copy > * { animation: introFade .6s var(--ease) both; }
.intro-slide.is-active .intro-copy > :nth-child(2) { animation-delay: .06s; }
.intro-slide.is-active .intro-copy > :nth-child(3) { animation-delay: .12s; }
.intro-slide.is-active .intro-copy > :nth-child(4) { animation-delay: .18s; }

.intro-nav { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 18px;
  transition: opacity .4s var(--ease), transform .4s var(--ease); }
.intro.on-splash .intro-nav { opacity: 0; pointer-events: none; transform: translate(-50%, 16px); }
.intro-dots { display: flex; gap: 8px; }
.intro-dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 99px; background: #3a3c3c; cursor: pointer; transition: width .3s var(--ease), background .3s var(--ease); }
.intro-dots button.is-active { width: 24px; background: var(--teal); }
.intro-foot { position: absolute; left: 24px; bottom: 30px; z-index: 3; display: flex; align-items: center; gap: 10px; color: #8f8e89; font-size: .66rem;
  font-weight: 600; letter-spacing: .14em; text-transform: uppercase; transition: opacity .4s var(--ease); }
.intro-foot a { display: flex; align-items: center; gap: 10px; color: inherit; }
.intro-foot img { width: 60px; height: auto; }
.intro.on-splash .intro-foot { opacity: 0; }
.auth-tour-link { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; font-weight: 500; }
.auth-tour-link:hover { text-decoration: underline; }

@media (max-width: 1100px) { .intro-foot { display: none; } }
@media (max-width: 900px) {
  .intro-slide { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 22px; padding: 64px 16px 96px; overflow-y: auto; }
  .intro-window { max-width: 640px; border-radius: 10px; }
  .intro-window-bar { height: 22px; }
  .intro-window-bar i { width: 7px; height: 7px; }
  .intro-phone { height: min(42vh, 420px); border-radius: 28px; padding: 7px; }
  .intro-phone img { border-radius: 21px; }
  .intro-caption { font-size: .74rem; margin-top: 10px; }
  .intro-copy { max-width: 640px; margin: 0 auto; width: 100%; }
  .intro-copy h2 { margin-top: 12px; }
  .intro-copy p { font-size: .95rem; margin-top: 10px; }
  .intro-copy ul { margin-top: 14px; }
  .intro-copy li { padding: 8px 0; }
  .intro-nav { bottom: 0; left: 0; right: 0; transform: none; justify-content: space-between; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: #101111; border-top: 1px solid #2a2c2c; }
  .intro.on-splash .intro-nav { transform: translateY(16px); }
  .intro-dots { gap: 6px; }
  .intro-dots button.is-active { width: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .intro-mark, .intro-title span, .intro-tagline, .intro-credit, .intro-cta { opacity: 1; transform: none; }
}

/* Sign up ------------------------------------------------------------------ */
.auth-card-wide { max-width: 460px; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { position: relative; display: flex; align-items: center; min-height: 42px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: .9rem; font-weight: 500; color: var(--text-2); transition: border-color .15s, background .15s, color .15s; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:hover { border-color: var(--text-3); color: var(--text); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--primary); }
.choice:has(input:focus-visible) { box-shadow: var(--ring); }
.auth-main { overflow-y: auto; }

/* People (owner) ----------------------------------------------------------- */
.presence { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.presence i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.presence.is-on { color: var(--success); }
.presence.is-on i { background: #21c9b4; box-shadow: 0 0 0 3px rgba(33, 201, 180, .2); }
.people-table td { vertical-align: top; }
.settings-nav-label { display: block; margin: 14px 12px 4px; font-size: .66rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); }
[data-register] .form-grid { margin-top: 16px; }
[data-register] .form-group > .hint { margin-top: 2px; }
.topbar-title { flex: 1; display: flex; align-items: center; }
.presence.is-paused { color: var(--warning); }
.presence.is-paused i { background: var(--warning); }
