* { box-sizing: border-box; }

:root {
  /* Epoch Curated brand: warm cream + near-black, monochrome/editorial. */
  --brand-black: #14120d;
  --brand-cream: #ece8de;
  --bg: #f5f3ed;            /* warm paper */
  --bg-alt: #ece9e0;        /* deeper warm fill */
  --bg-raised: #fffefb;     /* cards */
  --card: var(--bg-raised); /* alias used by greeting/tour components */
  --border: #e4e0d4;
  --border-strong: #d3cdbe;
  --text: #14120d;
  --text-muted: #6c675b;
  --text-faint: #9c968a;
  --accent: #16130d;        /* brand black drives primary actions */
  --accent-hover: #322d24;
  --accent-soft: rgba(20, 18, 13, 0.06);
  --accent-ink: #f4f1e8;    /* cream text on black */
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --radius: 11px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-none: none;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08), 0 1px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --bg: #0c0b09;
  --bg-alt: #141310;
  --bg-raised: #1a1813;
  --border: #2b2822;
  --border-strong: #3b372f;
  --text: #ece8de;
  --text-muted: #a29c8e;
  --text-faint: #6f6a5e;
  --accent: #ece8de;        /* cream drives primary actions in the dark */
  --accent-hover: #fbf8ef;
  --accent-soft: rgba(236, 232, 222, 0.12);
  --accent-ink: #16130d;    /* black text on cream */
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0b09;
    --bg-alt: #141310;
    --bg-raised: #1a1813;
    --border: #2b2822;
    --border-strong: #3b372f;
    --text: #ece8de;
    --text-muted: #a29c8e;
    --text-faint: #6f6a5e;
    --accent: #ece8de;
    --accent-hover: #fbf8ef;
    --accent-soft: rgba(236, 232, 222, 0.12);
    --accent-ink: #16130d;
    --success: #22c55e;
    --success-soft: rgba(34, 197, 94, 0.14);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
  }
}

*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html { background: var(--bg); }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

svg.icon { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- shell: sidebar + content ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 220px;
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
}
.brand { display: flex; align-items: center; gap: 9px; margin: 0 0 22px 2px; }
.brand-logo {
  width: 27px; height: 27px; border-radius: 8px; flex: none; background: var(--brand-black);
  display: inline-flex; align-items: center; justify-content: center;
}
.app-title { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }

/* Epoch Curated logo mark: black squircle + cream glyph, upgraded to the real
   /logo.png if that file exists (the <img> removes itself on 404). */
.ec-logo { position: relative; overflow: hidden; }
.ec-logo .ec-logo-glyph { width: 60%; height: 60%; stroke: var(--brand-cream); stroke-width: 2.5; fill: none; }
.ec-logo .ec-logo-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.side-nav { position: relative; display: flex; flex-direction: column; gap: 2px; }
.nav-indicator {
  position: absolute; top: 0; left: 0; right: 0; background: var(--accent); border-radius: var(--radius-sm);
  z-index: 0; transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-btn {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 9px;
  background: none; border: none; border-radius: var(--radius-sm); text-align: left;
  padding: 9px 10px; font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--text-muted); cursor: pointer; transition: color 0.15s ease, background 0.15s ease;
}
.nav-btn:hover { color: var(--text); background: var(--border); }
.nav-btn.active { color: var(--accent-ink); }
.nav-btn.active:hover { background: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.theme-toggle {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--text); }

.content { flex: 1 1 auto; padding: 28px 32px 90px 32px; max-width: 1500px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel.panel-enter { animation: panel-in 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.panel-sub { font-size: 12.5px; color: var(--text-faint); margin: 3px 0 0 0; }

.hint { font-size: 12px; color: var(--text-faint); margin: 0 0 12px 0; line-height: 1.55; }
.hint code { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 11px; color: var(--text-muted); }
.hint-inline { color: var(--text-faint); font-size: 11px; margin-left: 6px; }

.card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 14px; }

/* ---------- forms ---------- */
form.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type="text"], input[type="number"], input[type="datetime-local"], input[type="date"], input[type="file"], select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* Keep Chrome autofill from painting inputs light in dark mode. */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
  caret-color: var(--text);
}
select { cursor: pointer; }
textarea { width: 100%; resize: vertical; font-family: 'Courier New', monospace; font-size: 12px; }

/* ---------- buttons ---------- */
button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px var(--accent-soft); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); transform: translateY(-1px); box-shadow: 0 6px 16px var(--accent-soft); }
button.primary:active { transform: translateY(0) scale(0.98); }
.btn-plain { background: none; border: none; padding: 3px 6px; color: var(--text-muted); }
.btn-plain:hover { background: none; color: var(--accent); }

/* Escalating "+" hierarchy: module (loud) > topic (medium) > session (quiet) */
.btn-add-module {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  padding: 9px 18px; font-size: 13px; font-weight: 700; border-radius: var(--radius);
}
.btn-add-module:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-add-topic {
  background: var(--bg); border: 1.5px solid var(--accent); color: var(--accent);
  padding: 6px 12px; font-size: 12px; font-weight: 700;
}
.btn-add-topic:hover { background: var(--accent-soft); }
.btn-add-session {
  background: none; border: 1px dashed var(--border-strong); color: var(--text-faint);
  padding: 3px 9px; font-size: 11px; font-weight: 600;
}
.btn-add-session:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); border-style: solid; }

.status-line { font-size: 12px; color: var(--text-muted); min-height: 1em; margin: 10px 0 0 0; }

.output-types { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--text); margin: 6px 0 12px 0; }
.output-types label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.output-types input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; margin: 0; }
.field-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 12px 0 5px 0; }

.progress-track { display: inline-block; width: 60px; height: 4px; border-radius: 2px; background: var(--border); vertical-align: middle; overflow: hidden; margin-right: 6px; }
.progress-fill { display: block; height: 100%; border-radius: 2px; background: var(--accent); transform-origin: left; animation: fill-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes fill-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.pill {
  display: inline-block; font-size: 10px; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 1px 8px; margin-left: 6px;
  text-transform: uppercase; letter-spacing: 0.03em;
}

.module-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; flex: none; }

.kicker { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 4px 0; }

/* ---------- table toolbar (search + filter) ---------- */
.table-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 10px; background: var(--bg); }
.search-box .icon { color: var(--text-faint); }
.search-box input { border: none; padding: 8px 0; flex: 1; background: none; }
.search-box input:focus { box-shadow: none; }

/* ---------- Home: module -> topic -> session table ---------- */
.module-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; background: var(--bg-raised); box-shadow: var(--shadow-sm); transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease); }
.module-group:hover { box-shadow: var(--shadow-md); }
.module-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; cursor: pointer; background: var(--bg-alt);
}
.module-header:hover { background: var(--accent-soft); }
.module-header-left { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
.module-header-actions { display: flex; align-items: center; gap: 8px; }
.chevron { transition: transform 0.2s ease; color: var(--text-faint); }
.module-group.collapsed .chevron { transform: rotate(-90deg); }
.module-body { }
.module-group.collapsed .module-body { display: none; }

.topic-group { border-top: 1px solid var(--border); }
.topic-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px 9px 30px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--text-muted);
}
.topic-header:hover { background: var(--bg-alt); }
.topic-group.collapsed .chevron { transform: rotate(-90deg); }
.topic-group.collapsed .session-table { display: none; }

.inline-add { padding: 10px 14px; background: var(--bg-alt); border-top: 1px solid var(--border); }
.inline-add.hidden { display: none; }
.inline-add form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* session rows: CSS grid "table" that collapses to labeled stacked cards on mobile */
.session-table-head, .session-row {
  display: grid;
  grid-template-columns: 1.5fr 84px 104px 84px 92px 92px 60px 58px 92px;
  gap: 8px;
  align-items: center;
  padding: 8px 14px 8px 44px;
  font-size: 12.5px;
}
.session-table-head {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
  border-top: 1px solid var(--border); padding-top: 10px; padding-bottom: 6px;
}
.session-row { border-top: 1px solid var(--border); color: var(--text); }
.session-row:hover { background: var(--bg-alt); }
.session-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-cell a { color: var(--accent); text-decoration: none; font-weight: 600; }
.session-cell a:hover { text-decoration: underline; }
.session-title { font-weight: 600; }
.session-feeling { display: flex; gap: 4px; }
.feeling-dot {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong); cursor: pointer; padding: 0; background: none;
}
.feeling-dot.red { border-color: var(--danger); }
.feeling-dot.red.active { background: var(--danger); }
.feeling-dot.yellow { border-color: var(--warning); }
.feeling-dot.yellow.active { background: var(--warning); }
.feeling-dot.green { border-color: var(--success); }
.feeling-dot.green.active { background: var(--success); }
.score-badge { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
.session-empty { padding: 10px 14px 14px 44px; color: var(--text-faint); font-size: 12px; }

/* ---------- CALENDAR ---------- */
.calendar-nav { display: flex; gap: 6px; align-items: center; }
.calendar-grid { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.week-grid { grid-template-columns: repeat(5, 1fr); }
.cal-weekday { background: var(--bg-alt); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); padding: 10px; text-align: center; }
.cal-weekday-date { display: block; font-size: 10px; color: var(--text-faint); margin-top: 2px; text-transform: none; letter-spacing: 0; }
.cal-cell { background: var(--bg-raised); min-height: 100px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.week-cell { min-height: 280px; align-items: stretch; }
.cal-empty { font-size: 11px; margin: 0; color: var(--text-faint); }
.cal-cell-today { background: var(--accent-soft); }
.cal-tile {
  display: flex; flex-direction: column; align-items: flex-start;
  border: 1px solid; border-radius: var(--radius-sm); padding: 4px 7px;
  font-size: 10.5px; font-weight: 700; cursor: pointer; width: 100%;
  transition: transform 0.15s ease;
}
.cal-tile { transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease); }
.cal-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cal-tile-time { font-size: 9px; opacity: 0.75; }
.cal-tile-module { font-weight: 400; opacity: 0.85; font-size: 9.5px; }

/* Google Calendar events not yet imported: dashed outline, no fill, so they
   read as "ghost" tiles next to real session tiles. */
.cal-tile-gcal { border-style: dashed; background: transparent; }
.cal-tile-gcal:hover { background: var(--accent-soft); }
.gcal-connect { color: var(--accent); border-color: var(--accent); }
.cal-sub-error { color: var(--danger); }

/* ---------- Master Library ---------- */
.lib-module-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.lib-module-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-raised);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.lib-module-tab { transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s var(--ease); }
.lib-module-tab:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.lib-module-tab.active { font-weight: 700; }
.lib-count { font-size: 10.5px; font-weight: 700; color: var(--text-faint); background: var(--bg-alt); border-radius: 999px; padding: 1px 7px; }
.lib-add-card { margin-bottom: 16px; }
.lib-add-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.lib-add-form input[type="text"], .lib-add-form input[type="url"] { flex: 1 1 200px; }
.lib-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.lib-group { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.lib-group-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.lib-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.lib-item:last-child { border-bottom: none; }
.lib-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-item-name { font-size: 12.5px; font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
a.lib-item-name:hover { color: var(--accent); text-decoration: underline; }
.lib-item-date { font-size: 10.5px; color: var(--text-faint); }
.lib-empty { margin: 0; font-size: 11.5px; }

/* ---------- Notes tab (structured notes + grouped images) ---------- */
.nt-style { width: 100%; resize: vertical; font-family: var(--sans); font-size: 12.5px; }
.notes-outputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.notes-outputs a.btn-plain { text-decoration: none; }
a.fc-apkg { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); border-radius: var(--radius-sm); padding: 5px 11px; font-weight: 700; }
a.fc-apkg:hover { background: var(--accent); color: var(--accent-ink); }
.notes-doc { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 16px; }
.notes-section {
  margin-bottom: 14px; padding: 12px 16px; background: var(--bg-alt);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.notes-section h4 { font-size: 14px; font-weight: 700; margin: 0 0 8px 0; color: var(--text); letter-spacing: -0.01em; }
.notes-section ul { margin: 0; padding-left: 18px; }
.notes-section li { font-size: 12.5px; line-height: 1.55; margin-bottom: 4px; }
.notes-section li strong, .notes-section li b { color: var(--accent); }
.notes-figures { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.notes-figure { margin: 0; max-width: 220px; }
.notes-figure img { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.18s var(--ease); }
.notes-figure img:hover { transform: scale(1.02); }
.notes-figure figcaption { font-size: 10.5px; color: var(--text-muted); margin-top: 5px; font-style: italic; }
.onenote-area { margin: 6px 0 4px; }
.onenote-picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.onenote-picker label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.onenote-picker select { min-width: 150px; }

/* Import-from-Google modal */
#gcalImportForm select, #gcalImportForm input[type="text"] { width: 100%; }
.gi-new-input { margin-top: 6px; }
.gi-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 17, 21, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: overlay-in 0.18s ease;
}
.modal {
  background: var(--bg-raised); border-radius: var(--radius-lg); border: 1px solid var(--border);
  padding: 26px 28px; width: 440px; max-width: 92vw; max-height: 86vh; overflow-y: auto; position: relative;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.28s var(--ease);
}
.modal-close { position: absolute; top: 12px; right: 12px; border: none; background: none; font-size: 18px; padding: 4px 8px; color: var(--text-faint); }
.modal-section { margin-top: 14px; }
.modal h3 { font-size: 17px; font-weight: 700; margin: 4px 0 14px 0; }

/* source chips */
.source-chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); border: 1px solid var(--accent); color: var(--text);
  border-radius: 999px; padding: 5px 6px 5px 11px; font-size: 12px; width: fit-content; max-width: 100%;
}
.source-chip .icon { color: var(--accent); }
.chip-pages { color: var(--text-muted); font-size: 11px; }
.chip-x {
  border: none; background: none; color: var(--text-muted); font-size: 16px; line-height: 1;
  padding: 0 4px; cursor: pointer; border-radius: 50%;
}
.chip-x:hover { color: var(--danger); background: var(--danger-soft); }
.add-source-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.page-input { width: 78px; }

.result-block { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.result-block h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin: 0 0 6px 0; }
.result-body { font-size: 13px; color: var(--text-muted); white-space: pre-wrap; line-height: 1.5; }
.result-body a { color: var(--accent); }
.card-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 12px; margin-top: 12px; }
.preview-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--bg-raised);
  box-shadow: var(--shadow-sm); transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  display: flex; flex-direction: column;
}
.preview-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.preview-card-img { width: 100%; max-height: 168px; object-fit: contain; border-radius: var(--radius-sm); margin-bottom: 9px; background: #fff; border: 1px solid var(--border); }
.preview-card-q { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.4; }
.preview-card-a { font-size: 11.5px; color: var(--success); margin-top: auto; padding-top: 8px; font-weight: 700; }

.muted { color: var(--text-faint); }

/* delete / icon-only buttons */
.btn-icon-del {
  border: none; background: none; padding: 4px; color: var(--text-faint); border-radius: var(--radius-sm);
}
.btn-icon-del:hover { background: var(--danger-soft); color: var(--danger); border: none; transform: none; }
.btn-icon-del .icon { width: 14px; height: 14px; }
.topic-header-actions, .module-header-actions { display: flex; align-items: center; gap: 6px; }
.session-del { padding: 2px; margin-left: 4px; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- QUIZZES (overview, unchanged mechanics from before) ---------- */
.module-block + .module-block { margin-top: 16px; }
.module-block > h3 { font-size: 15px; font-weight: 700; margin: 0 0 14px 0; display: flex; align-items: center; }

/* Quizzes tab: collapsible module cards */
.quiz-module-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.quiz-module-head h3 { font-size: 15px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 4px; }
.quiz-module .quiz-module-body { margin-top: 14px; }
.quiz-module.collapsed .quiz-module-body { display: none; }
.quiz-module.collapsed .chevron { transform: rotate(-90deg); }

.quiz-topic { margin-bottom: 12px; }
.quiz-topic h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 8px 0; }
.lecture-block { margin: 0 0 10px 14px; padding-left: 12px; border-left: 2px solid var(--border); }
.lecture-block h5 { font-size: 13px; font-weight: 700; margin: 0 0 6px 0; }
.attempt-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; cursor: pointer; border-radius: var(--radius-sm); }
.attempt-row:hover { background: var(--bg-alt); }
.attempt-detail { padding: 14px 10px 4px 10px; }
.attempt-question { margin-bottom: 14px; }
.attempt-question .q { font-weight: 700; margin-bottom: 8px; font-size: 13px; }
.attempt-option { display: block; font-size: 12.5px; color: var(--text-muted); padding: 4px 0; cursor: pointer; }
.attempt-option input { margin-right: 8px; accent-color: var(--accent); }
.attempt-option.correct { color: var(--success); font-weight: 700; }
.attempt-option.incorrect { color: var(--danger); text-decoration: line-through; }
.attempt-question .source-tag { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
#quizRunner .card { animation: panel-in 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
#quizRunner .q { font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.runner-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.runner-explain { margin: 12px 0; padding: 12px 14px; background: var(--bg-alt); border-radius: var(--radius); }
.runner-correct-label { color: var(--success); font-weight: 700; font-size: 13px; margin: 0 0 4px 0; }
.runner-incorrect-label { color: var(--danger); font-weight: 700; font-size: 13px; margin: 0 0 4px 0; }
.runner-summary { text-align: center; padding: 36px 24px; }
.runner-summary h3 { font-size: 32px; font-weight: 800; margin: 6px 0 12px 0; }

/* multi-format question inputs */
.runner-fill, .runner-dropdown { width: 100%; margin-bottom: 14px; }
.runner-typed { width: 100%; margin-bottom: 14px; min-height: 70px; resize: vertical; }
.match-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.match-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.match-left { font-weight: 600; font-size: 13px; }
.match-select { min-width: 150px; }
.match-answer { display: none; font-size: 12px; color: var(--success); font-weight: 600; }
.match-row.match-correct { border-color: var(--success); }
.match-row.match-wrong { border-color: var(--danger); }
.match-row.match-wrong .match-answer, .match-row.match-correct .match-answer { display: inline; }
.match-row.match-wrong .match-answer { color: var(--danger); }

/* Quiz question navigator: numbered pills, jump to any question */
.quiz-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quiz-nav-pill {
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg); color: var(--text-muted);
  font-size: 12.5px; font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: 0;
}
.quiz-nav-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.quiz-nav-pill.picked { border-color: var(--accent); color: var(--accent); }
.quiz-nav-pill.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quiz-nav-pill.correct { background: var(--success); border-color: var(--success); color: #fff; }
.quiz-nav-pill.incorrect { background: var(--danger); border-color: var(--danger); color: #fff; }
.quiz-nav-pill.current { outline: 2px solid var(--accent); outline-offset: 2px; }
.quiz-progress-line { font-size: 12px; color: var(--text-muted); margin: 0 0 10px 0; }
.runner-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.runner-controls .btn-add-module { margin-left: auto; }

/* Sidebar "Sync to Anki" button; glows when cards are waiting */
.anki-sync {
  display: flex; align-items: center; gap: 8px; width: 100%; justify-content: flex-start;
  background: var(--bg-alt); border: 1px solid var(--border); color: var(--text-muted);
  padding: 9px 12px; text-transform: none; letter-spacing: 0; font-weight: 600;
}
.anki-sync:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.anki-sync.has-pending { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.btn-new-attempt {
  margin-top: 8px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; padding: 7px 14px; text-transform: none; letter-spacing: 0;
}
.btn-new-attempt:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-new-attempt:disabled { opacity: 0.6; cursor: default; }
.quiz-new-link { margin-left: 8px; font-size: 11px; color: var(--accent); text-decoration: none; }
.quiz-new-link:hover { text-decoration: underline; }

/* ---------- mode-driven session modal ---------- */
.modal-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 16px; }
.modal-tab {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; letter-spacing: 0;
}
.modal-tab:hover { color: var(--text); background: none; }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.qz-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.session-cell .cell-link { cursor: pointer; }

/* generation preference dropdowns (difficulty / depth / format / style) */
.gen-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; }
.gen-opt { display: flex; flex-direction: column; gap: 3px; flex: 1 1 130px; min-width: 120px; }
.gen-opt > span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); }
.gen-opt select { width: 100%; }

/* ---------- Shibli avatar (flat cartoon: curly hair, stubble, blue crewneck) ---------- */
.shibli { display: block; }
.sh-shadow { fill: rgba(0,0,0,0.12); }
.sh-body { fill: #a9c3e0; }            /* his light-blue knit sweater */
.sh-neckline { stroke: #8aa8ca; }
.sh-sleeve { stroke: #a9c3e0; }
.sh-skin, .sh-hand { fill: #a9713f; }  /* warm brown skin */
.sh-hair { fill: #17110b; }            /* black curls */
.sh-brow { stroke: #17110b; fill: none; }
.sh-nose { stroke: #7a4a26; fill: none; }
.sh-cheek { fill: #e08a8a; opacity: 0.5; }
.sh-beardshadow { fill: #2a1a10; opacity: 0.3; }
.sh-stubble circle { fill: #241812; opacity: 0.6; }
.sh-smile { stroke: #5a2f1a; fill: none; }
.sh-spark { fill: #fff; }
.sh-eye { fill: #17110b; }
.sh-eyes { animation: sh-blink 4.2s infinite; transform-origin: 60px 60px; }
.sh-arm { transform-origin: 82px 116px; animation: sh-wave 1.6s ease-in-out infinite; }
@keyframes sh-wave { 0%,100% { transform: rotate(0deg); } 25% { transform: rotate(-18deg); } 60% { transform: rotate(6deg); } }
@keyframes sh-blink { 0%,92%,100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
.shibli-bob { animation: sh-bob 2.4s ease-in-out infinite; }
@keyframes sh-bob { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-5px) scale(1.02); } }
/* if a real photo is dropped at public/shibli.png it's used instead */
.shibli-photo { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid var(--card); box-shadow: 0 4px 14px rgba(0,0,0,0.18); }
.tour-avatar .shibli-photo { width: 54px; height: 54px; }

/* ---------- welcome greeting ---------- */
.welcome-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(3px); animation: overlay-fade 0.3s ease; }
@keyframes overlay-fade { from { opacity: 0; } to { opacity: 1; } }
.welcome-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 32px 34px 28px;
  width: 420px; max-width: 92vw; text-align: center; animation: welcome-pop 0.4s cubic-bezier(0.22,1,0.36,1); }
@keyframes welcome-pop { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
.welcome-avatar { display: flex; justify-content: center; margin-bottom: 6px; }
.welcome-card h2 { font-size: 22px; margin: 6px 0 8px; }
.welcome-card p { color: var(--text-muted); font-size: 14px; margin: 0 0 22px; line-height: 1.6; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- guided tutorial ---------- */
.tour-layer { position: fixed; inset: 0; z-index: 310; pointer-events: none; }
.tour-layer::before { content: ''; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); pointer-events: auto; }
.tour-spotlight { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(15,23,42,0.5); transition: all 0.35s cubic-bezier(0.22,1,0.36,1);
  border: 2px solid var(--accent); pointer-events: none; z-index: 311; }
.tour-bubble { position: fixed; z-index: 312; width: 320px; max-width: 90vw; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 16px 14px; display: flex; gap: 12px; pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25); transition: top 0.35s ease, left 0.35s ease; }
.tour-avatar { flex: 0 0 auto; }
.tour-avatar .shibli { width: 54px; height: 64px; }
.tour-bubble-body { flex: 1; }
.tour-bubble-body p { font-size: 13.5px; line-height: 1.55; margin: 2px 0 12px; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-progress { font-size: 11px; color: var(--text-faint); }
.tour-nav-btns { display: flex; gap: 6px; }
.tour-nav-btns button { padding: 6px 12px; font-size: 11px; }

.hidden { display: none !important; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { position: static; height: auto; flex: none; border-right: none; border-bottom: 1px solid var(--border); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-indicator { display: none; }
  .content { padding: 18px 16px 70px 16px; }
  .sidebar-foot { margin-top: 14px; flex-direction: row; }

  .session-table-head { display: none; }
  .session-row {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    padding: 12px 14px; border-radius: var(--radius-sm);
  }
  .session-cell { display: flex; justify-content: space-between; align-items: center; white-space: normal; }
  .session-cell::before { content: attr(data-label); font-weight: 700; color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
  .week-grid { grid-template-columns: 1fr; }
}

/* The 9-column session table needs room; below ~1150px stack it into cards
   (keeps the sidebar layout intact — that only stacks under 860px). */
@media (min-width: 861px) and (max-width: 1150px) {
  .session-table-head { display: none; }
  .session-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
    padding: 12px 14px 12px 44px; border-radius: var(--radius-sm);
  }
  .session-cell { white-space: normal; }
  .session-cell::before { content: attr(data-label) ": "; font-weight: 700; color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
  .session-cell.session-title::before { content: ""; }
  .session-cell.session-title { flex-basis: 100%; font-weight: 700; }
}

/* ======================================================================
   AUTH SCREEN (/login) — clean, on-brand, single blue accent
   ====================================================================== */
.auth-body { display: block; }
.auth-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 24px;
  background:
    radial-gradient(1100px 620px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 400px; max-width: 100%;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px 30px 26px;
  box-shadow: 0 18px 50px rgba(15, 17, 21, 0.10), 0 2px 8px rgba(15, 17, 21, 0.04);
  animation: auth-pop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
:root[data-theme="dark"] .auth-card { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); }
@keyframes auth-pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.auth-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand-black); color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.auth-logo svg { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.auth-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.auth-title { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 5px; }
.auth-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 20px; line-height: 1.5; }
.auth-error {
  font-size: 12.5px; color: var(--danger); background: var(--danger-soft);
  border: 1px solid var(--danger); border-radius: var(--radius);
  padding: 9px 12px; margin-bottom: 16px; line-height: 1.45;
}
.auth-google {
  width: 100%; justify-content: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border-strong); color: var(--text);
  padding: 11px; font-size: 13.5px; font-weight: 600; border-radius: var(--radius);
}
.auth-google:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.auth-divider { display: flex; align-items: center; text-align: center; margin: 16px 0; color: var(--text-faint); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { padding: 0 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.auth-field input { width: 100%; padding: 11px 12px; font-size: 14px; border-radius: var(--radius); }
.auth-submit { width: 100%; justify-content: center; padding: 12px; font-size: 14px; font-weight: 700; border-radius: var(--radius); margin-top: 2px; }
.auth-toggle { text-align: center; font-size: 12.5px; color: var(--text-muted); margin: 18px 0 0; }
.auth-toggle a { color: var(--accent); font-weight: 700; text-decoration: none; margin-left: 5px; }
.auth-toggle a:hover { text-decoration: underline; }
.auth-foot { font-size: 11px; color: var(--text-faint); margin: 0; }

/* ---------- sidebar account chip ---------- */
.account-row { display: flex; align-items: center; gap: 6px; }
.account-chip {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 9px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px 9px; text-align: left; cursor: pointer;
}
.account-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.account-avatar {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700;
}
.account-avatar.lg { width: 42px; height: 42px; font-size: 17px; }
.account-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account-name { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-email { font-size: 10.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-logout {
  flex: none; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text-muted);
}
.account-logout:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* ---------- Settings tab ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.settings-card:empty { display: none; }
.settings-h { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.settings-account { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.settings-name { font-size: 15px; font-weight: 700; }
.settings-logout { margin-top: 4px; }
.conn-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.conn-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.conn-row:last-child { border-bottom: none; }
.conn-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.conn-dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.conn-actions { display: flex; align-items: center; gap: 8px; }
.conn-status { font-size: 11.5px; font-weight: 700; }
.conn-status.on { color: var(--success); }
.conn-connect { color: var(--accent); }
.settings-steps { margin: 8px 0 10px; padding-left: 20px; font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.settings-steps li { margin-bottom: 4px; }
.settings-steps code { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; font-size: 11px; }
.settings-steps a { color: var(--accent); }
.settings-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.settings-field > span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.settings-field input { width: 100%; }
