/* ────────────────────────────────────────────────────────────────
   Student Planner — Design System
   Theming: CSS custom properties on :root, strictly black/white/gray.
   Dark mode (.dark class) inverts the same neutral palette — there
   is no other color option anywhere in the app.
──────────────────────────────────────────────────────────────── */
* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
html { background: var(--bg); }
html { -webkit-text-size-adjust: 100%; }

:root {
  --ink: #141414;          /* near-black, used for the floating selection toolbar */
  --cloud: #ffffff;        /* near-white text/hover on --ink surfaces (floating toolbar) */
  --badge: #ececec;        /* neutral badge fill (e.g. "AI" labels) */

  --accent: #141414;
  --accent-light: #efefef;
  --accent-dark: #000000;
  --accent-text: #ffffff; /* readable text/icon color on --accent fills */
  --bg: #fafafa;
  --bg-text: #000000;
  --bg-text-dim: color-mix(in srgb, var(--bg-text) 65%, var(--bg));
  --bg-text-faint: color-mix(in srgb, var(--bg-text) 42%, var(--bg));
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #e4e4e4;
  --text: #000000;
  --text-dim: rgba(0, 0, 0, 0.72);
  --text-faint: rgba(0, 0, 0, 0.46);
  --danger: #141414;
  --danger-light: #ececec;
  --success: #3d3d3d;
  --success-light: #f2f2f2;
  --warn: #5c5c5c;
  --warn-light: #f4f4f4;

  --radius: 16px;
  --radius-sm: 10px;
  /* Signature shape: one soft corner, three tight — sharpens on interaction. */
  --r-soft: 26px;
  --r-tight: 9px;
  --r-tight-active: 6px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.16);
  --font: 'General Sans', -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

html.dark {
  --accent: #f2f2f2;
  --accent-light: #2a2a2a;
  --accent-dark: #ffffff;
  --accent-text: #000000;
  --bg: #0f0f0f;
  --bg-text: #ffffff;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --border: #333333;
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.75);
  --text-faint: rgba(255, 255, 255, 0.5);
  --danger: #f5f5f5;
  --danger-light: #2a2a2a;
  --success: #cfcfcf;
  --success-light: #262626;
  --warn: #a8a8a8;
  --warn-light: #2a2a2a;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.45);
}

/* ── Signature shape: the one asymmetric corner ───────────────────
   Applied to every contained shape (cards, buttons, nav, modals,
   calendar cells, icon badges). Default state has one soft corner;
   on hover/focus/active that corner sharpens toward a point — a
   tactile response tied to real interaction, not decoration. */
.card, .stat-card, .btn, .modal, .cal-cell, .empty .ic, .avatar, .nav-item {
  border-radius: var(--r-soft) var(--r-tight) var(--r-tight) var(--r-tight);
  transition: border-radius .16s cubic-bezier(.4,0,.2,1), background .15s, box-shadow .15s, color .15s;
}
.card:hover, .stat-card:hover, .btn:hover, .btn:focus-visible, .btn:active,
.cal-cell:hover, .avatar:hover, .nav-item:hover, .nav-item.active {
  border-radius: var(--r-tight-active);
}

/* Accent presets — applied by writing inline vars from JS, these are fallbacks */
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
button, input, textarea, select { font-family: var(--font); color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.i { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
button .i, .btn .i { vertical-align: -2.5px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn .22s ease; }
@keyframes popIn { 0% { opacity:0; transform: scale(.94); } 100% { opacity:1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ── App shell ─────────────────────────────────────────────── */
#app { display: flex; min-height: 100%; }
#app.sidebar-collapsed .sidebar { display: none; }
.btn.sidebar-expand-fab { display: none; position: fixed; top: 18px; left: 18px; z-index: 150; box-shadow: var(--shadow-lg); }
#app.sidebar-collapsed ~ .btn.sidebar-expand-fab { display: inline-flex; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--bg);
  border-right: 1px solid color-mix(in srgb, var(--border) 70%, transparent); display: flex; flex-direction: column;
  padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { padding: 4px 6px 22px 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.sidebar-brand .btn-icon { opacity: .55; flex-shrink: 0; color: var(--bg-text); }
.sidebar-brand .btn-icon:hover { opacity: 1; }
.sidebar-brand h1 {
  font-family: var(--font-serif); font-style: italic; font-size: 25px; font-weight: 400; letter-spacing: -.1px;
  color: var(--bg-text);
}
.sidebar-brand p { font-size: 11.5px; color: var(--bg-text-faint); margin-top: 2px; }
.nav-group { margin-bottom: 18px; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--bg-text-faint); padding: 6px 10px 8px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8.5px 10px; margin-bottom: 1px;
  font-size: 13.5px; color: var(--bg-text-dim); cursor: pointer; user-select: none;
}
.nav-item:hover { background: color-mix(in srgb, var(--bg-text) 10%, var(--bg)); color: var(--bg-text); }
.nav-item.active { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.nav-item .ic { width: 18px; display: flex; align-items: center; justify-content: center; opacity: .82; }
.nav-item.active .ic { opacity: 1; }
.nav-item .ic .i { vertical-align: 0; }
.empty .ic .i { vertical-align: 0; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 12.5px; cursor: pointer; color: var(--bg-text-dim); }
.user-chip:hover { background: color-mix(in srgb, var(--bg-text) 10%, var(--bg)); color: var(--bg-text); }
.avatar { width: 26px; height: 26px; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.content { flex: 1; min-width: 0; padding: 30px 38px 64px; max-width: 1180px; }
.content.content-notebook { padding: 0; max-width: none; height: 100vh; overflow: hidden; }
.content-notebook > .fade-in { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.content-notebook .page-head { margin: 0; padding: 22px 32px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--font-serif); font-size: 32px; font-weight: 400; letter-spacing: -.2px; color: var(--text); }
.page-head .sub { font-size: 13px; color: var(--text-faint); margin-top: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: none;
  padding: 9px 15px; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: transparent; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 38%, transparent); }
.btn-primary:hover { box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 48%, transparent); background: var(--accent); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: transparent; box-shadow: none; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards / surfaces ──────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }

/* ── Paywall ───────────────────────────────────────────────── */
.paywall-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.paywall-card { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: var(--r-soft); padding: 36px 32px; width: 420px; max-width: 100%; text-align: center; }
.paywall-card h2 { font-family: var(--font-serif); font-weight: 400; font-size: 26px; margin-bottom: 8px; }
.paywall-price { font-family: var(--font-serif); font-size: 44px; margin: 8px 0 18px; }
.paywall-price-period { font-size: 16px; color: var(--text-dim); }
.paywall-card a { color: var(--accent); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* Settings uses a masonry-style column flow instead of a strict grid — a
   CSS grid row locks its height to the tallest card in it, which left an
   awkward gap under short cards (e.g. Appearance next to the much taller
   Background card). Columns pack independently, so no wasted space. */
.settings-columns { column-count: 2; column-gap: 18px; }
.settings-columns .card { break-inside: avoid; margin-bottom: 18px; }
@media (max-width: 900px) { .settings-columns { column-count: 1; } }

.stat-card { padding: 17px 19px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card .num { font-family: var(--font-serif); font-style: italic; font-size: 30px; font-weight: 400; letter-spacing: -.2px; color: var(--text); }
.stat-card .lbl { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }

.empty { text-align: center; padding: 46px 20px; color: var(--text-faint); }
.empty .ic {
  font-size: 30px; margin: 0 auto 12px; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center; color: var(--accent-dark);
  background: var(--accent-light);
}
.empty p { font-size: 13px; }
.empty .empty-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; max-width: 280px; margin-left: auto; margin-right: auto; }
.stat-card .num.stat-dash, .stat-dash { color: var(--text-faint); font-style: normal; font-weight: 500; }

/* ── Form controls ─────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.input, .select, textarea.input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; font-size: 13.5px; color: var(--text); width: 100%;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 70px; font-family: var(--font); }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ── Badges/tags/pills ─────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; }
.course-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag { padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

/* ── Modal ─────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 200; }
.overlay.show { opacity: 1; pointer-events: auto; }
.modal-wrap { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 201; pointer-events: none; padding: 20px; }
.modal { background: var(--surface); box-shadow: var(--shadow-lg); width: 480px; max-width: 100%; max-height: 86vh; overflow-y: auto; opacity: 0; transform: scale(.96) translateY(8px); transition: opacity .18s, transform .18s; pointer-events: none; }
.overlay.show ~ .modal-wrap .modal, .modal-wrap.show .modal { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
.modal.wide { width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-family: var(--font-serif); font-size: 20px; font-weight: 400; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.close-x { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: none; font-size: 14px; color: var(--text-dim); }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13px; display: flex; align-items: center; gap: 9px; animation: popIn .2s ease; }
.toast .ic { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; flex-shrink: 0; }
.toast.success .ic { background: var(--success); }
.toast.error .ic { background: var(--danger); }
.toast.info .ic { background: var(--accent-dark); }

/* ── Tabs / segmented control ──────────────────────────────── */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; padding: 6px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.segmented button.active { background: var(--accent); color: var(--accent-text); }

/* ── Progress bars ─────────────────────────────────────────── */
.progress { height: 8px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress > div { height: 100%; border-radius: 6px; background: var(--accent); transition: width .3s ease; }

/* ── Tables/lists ──────────────────────────────────────────── */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; transition: background .12s; }
.list-row:hover { background: var(--surface-2); }
.row-check {
  width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--accent-text); transition: all .15s;
  /* .row-check is a <button> so it needs its own reset — it's not a plain div */
  background: transparent; padding: 0; margin: 0; font: inherit; cursor: pointer; appearance: none;
}
.row-check.checked { background: var(--accent); border-color: var(--accent); }
.row-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-title { flex: 1; min-width: 0; font-size: 13.5px; }
.row-title.done { text-decoration: line-through; color: var(--text-faint); }
.row-meta { font-size: 11.5px; color: var(--text-faint); }

/* ── Color swatches (theme customization) ─────────────────── */
.swatch-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; transition: transform .12s; }
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--text); }

/* ── Color wheel picker (course + event colors) ───────────────── */
.cw-wheel {
  width: 150px; height: 150px; border-radius: 50%; margin: 0 auto; position: relative; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle at center, #fff, transparent 70%), conic-gradient(from 90deg, red, yellow, lime, cyan, blue, magenta, red);
  box-shadow: 0 0 0 1px var(--border);
}
.cw-marker { position: absolute; width: 15px; height: 15px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); transform: translate(-50%,-50%); pointer-events: none; }
.cw-brightness { width: 100%; margin-top: 12px; }
.cw-hexrow { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.cw-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.bg-preview { height: 64px; border-radius: 12px; border: 1px solid var(--border); }
.bg-preset { width: 30px; height: 30px; border-radius: 9px; cursor: pointer; border: 2px solid var(--border); flex-shrink: 0; transition: transform .12s; }
.bg-preset:hover { transform: scale(1.08); }
.bg-preset.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }

/* ── Calendar ──────────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-faint); padding-bottom: 6px; text-transform: uppercase; }
.cal-cell { min-height: 96px; min-width: 0; background: var(--surface); border: 1px solid var(--border); padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.cal-cell.muted { opacity: .4; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-cell .d-num { font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
.cal-evt { font-size: 10px; padding: 2px 5px; border-radius: 5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-evt-ic { display: inline-block; vertical-align: -1px; margin-right: 2px; }
.cal-evt.kind-exam { border: 1px solid currentColor; font-weight: 700; }
.cal-evt.kind-deadline { border: 1px dashed currentColor; }
.cal-block.kind-exam { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.55); font-weight: 700; }
.cal-block.kind-deadline { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.16) 0 6px, transparent 6px 12px); }

/* ── Year view: 12 mini months, each a tiny click-through calendar ── */
.cal-year-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.cal-mini-month { background: var(--surface); border: 1px solid var(--border); padding: 10px; }
.cal-mini-month-head { font-family: var(--font-serif); font-style: italic; font-size: 15px; margin-bottom: 8px; cursor: pointer; }
.cal-mini-month-head:hover { color: var(--accent-dark); }
.cal-mini-dow { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.cal-mini-dow span { text-align: center; font-size: 8.5px; font-weight: 700; color: var(--text-faint); }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-mini-cell { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 9.5px; color: var(--text-dim); cursor: pointer; border-radius: 4px; gap: 1px; }
.cal-mini-cell:hover { background: var(--surface-2); }
.cal-mini-cell.muted { color: var(--text-faint); opacity: .35; }
.cal-mini-cell.today { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-mini-dot { width: 3.5px; height: 3.5px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.cal-mini-cell.today .cal-mini-dot { background: var(--accent-text); }
.cal-mini-dot.exam { border-radius: 1px; }
@media (max-width: 900px) {
  .cal-year-grid { grid-template-columns: repeat(2, 1fr); }
}
.cal-week-grid { display: grid; grid-template-columns: 52px repeat(7, 1fr); }
.cal-hour-label { font-size: 10px; color: var(--text-faint); text-align: right; padding-right: 6px; height: 48px; }
.cal-day-col { border-left: 1px solid var(--border); position: relative; }
.cal-hour-row { height: 48px; border-bottom: 1px solid var(--border); }
.cal-block { position: absolute; left: 3px; right: 3px; border-radius: 8px; padding: 4px 7px; font-size: 10.5px; color: #fff; font-weight: 600; overflow: hidden; }

/* ── Flashcards ────────────────────────────────────────────── */
.flip-card { perspective: 1200px; height: 220px; cursor: pointer; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 16px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 22px; font-size: 15px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.flip-face.back { transform: rotateY(180deg); background: var(--accent-light); }

/* ── Timer ─────────────────────────────────────────────────── */
.timer-ring { width: 220px; height: 220px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; }
.timer-display { font-family: var(--font-serif); font-style: italic; font-size: 46px; }


/* ── Rich text editor (notebook) ──────────────────────────────── */
.rich-editor { outline: none; line-height: 1.7; }
.rich-editor h1, .rich-editor h2 { font-family: var(--font-serif); font-weight: 400; color: var(--accent-dark); margin: 16px 0 6px; }
.rich-editor h3 { font-family: var(--font); font-weight: 600; color: var(--text); margin: 16px 0 6px; }
.rich-editor h1 { font-size: 27px; } .rich-editor h2 { font-size: 21px; } .rich-editor h3 { font-size: 15px; }
.rich-editor p { margin: 6px 0; }
.rich-editor ul, .rich-editor ol { padding-left: 22px; margin: 6px 0; }
.rich-editor li { margin: 3px 0; }
.rich-editor strong { color: var(--text); }
.rich-editor pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-family: 'Courier New', monospace; font-size: 13px; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; }
.rich-editor hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.rich-editor a { color: var(--accent); text-decoration: underline; }

/* ── Dashboard widgets ─────────────────────────────────────────── */
.dash-workload { display: flex; justify-content: space-between; gap: 6px; }
.dash-wl-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 6px 2px; border-radius: 10px; }
.dash-wl-col:hover { background: var(--surface-2); }
.dash-wl-col.today .dash-wl-day { color: var(--accent); font-weight: 700; }
.dash-wl-bar-wrap { height: 48px; display: flex; align-items: flex-end; }
.dash-wl-bar { width: 18px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 35%, var(--border)); transition: height .2s ease; }
.dash-wl-col.today .dash-wl-bar { background: var(--accent); }
.dash-wl-count { font-size: 10.5px; font-weight: 700; color: var(--text-dim); min-height: 13px; }
.dash-wl-day { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; }
.dash-overdue-row { box-shadow: inset 2px 0 0 var(--danger); background: var(--danger-light); border-radius: 10px; margin-bottom: 6px; }
.dash-overdue-row:last-child { margin-bottom: 0; }
.dash-overdue-row:hover { background: var(--danger-light); filter: brightness(0.98); }

.dash-note-row { flex-wrap: wrap; }
.sticky-note {
  background: var(--accent-light); padding: 14px 16px; box-shadow: var(--shadow);
  border-radius: var(--r-soft) var(--r-tight) var(--r-tight) var(--r-tight);
  transform: rotate(-1.2deg); transition: transform .15s ease;
  width: 220px; flex-shrink: 0;
}
.sticky-note.size-sm { width: 170px; }
.sticky-note.size-lg { width: 300px; }
.sticky-note:hover, .sticky-note:focus-within { transform: rotate(0deg); }
.sticky-note-input {
  width: 100%; min-height: 108px; margin-top: 8px; border: none; background: transparent; resize: vertical;
  font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--text); outline: none;
}
.sticky-note.size-lg .sticky-note-input { min-height: 150px; }
.sticky-note.size-sm .sticky-note-input { min-height: 80px; }
.sticky-note-input::placeholder { color: var(--text-faint); }

/* ── Notebook ──────────────────────────────────────────────────── */
.notebook-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.notebook-tree-panel { width: 264px; flex-shrink: 0; min-height: 0; padding: 18px 12px; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.notebook-search-wrap { position: relative; margin-bottom: 8px; flex-shrink: 0; padding: 0 4px; }
.notebook-search-ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.notebook-search { width: 100%; background: var(--surface-2); border: none; border-radius: 8px; padding: 7px 10px 7px 30px; font-size: 12.5px; color: var(--text); }
.notebook-search:focus { outline: none; border-color: var(--accent); }
.notebook-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nb-sort-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; }
.nb-sort-row .segmented { padding: 2px; }
.nb-sort-row .segmented button { padding: 4px 8px; font-size: 11px; }
.notebook-tree { overflow-y: auto; flex: 1; padding: 0 4px; }
.nb-branch { margin-bottom: 1px; }
.nb-folder-row { display: flex; align-items: center; gap: 6px; padding: 6px 6px; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .02em; }
.nb-folder-row:hover { background: var(--surface-2); }
.nb-chevron { display: flex; color: var(--text-faint); transition: transform .15s; flex-shrink: 0; }
.nb-chevron.open { transform: rotate(90deg); }
.nb-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-count { font-size: 9.5px; color: var(--text-faint); background: var(--surface-2); border-radius: 8px; padding: 1px 6px; flex-shrink: 0; font-weight: 600; text-transform: none; }
.nb-folder-row .btn-icon { opacity: 0; flex-shrink: 0; }
.nb-folder-row:hover .btn-icon { opacity: 1; }
.nb-children { margin-left: 8px; }
.nb-note-row { display: flex; align-items: center; gap: 8px; padding: 6px 7px; border-radius: 16px var(--r-tight) var(--r-tight) var(--r-tight); cursor: pointer; transition: border-radius .16s cubic-bezier(.4,0,.2,1), background .15s; }
.nb-note-row:hover { background: var(--surface-2); border-radius: var(--r-tight-active); }
.nb-note-row.selected { background: var(--accent-light); border-radius: var(--r-tight-active); }
.nb-note-ic { color: var(--text-faint); flex-shrink: 0; }
.nb-note-row.selected .nb-note-ic { color: var(--accent-dark); }
.nb-note-meta { flex: 1; min-width: 0; }
.nb-note-title { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-note-row.selected .nb-note-title { font-weight: 600; }
.nb-note-sub { font-size: 10.5px; color: var(--text-faint); display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.nb-note-del { opacity: 0; flex-shrink: 0; }
.nb-note-row:hover .nb-note-del { opacity: 1; }
.notebook-page { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; background: var(--surface); padding: 56px 40px 120px; }
.nb-blank { height: 100%; display: flex; align-items: center; justify-content: center; }
.nb-page-inner {
  max-width: 760px; margin: 0 auto; min-height: calc(100% - 1px);
}
.nb-breadcrumb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.nb-breadcrumb { font-size: 12px; color: var(--text-faint); }
.nb-page-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.nb-crumb-sep { margin: 0 6px; opacity: .6; }
.nb-icon-avatar { width: 46px; height: 46px; border-radius: var(--r-soft) var(--r-tight) var(--r-tight) var(--r-tight); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.nb-title-input { width: 100%; border: none; background: transparent; font-family: var(--font-serif); font-style: italic; font-size: 36px; font-weight: 400; color: var(--text); padding: 0; letter-spacing: -.2px; }
.nb-title-input:focus { outline: none; }
.nb-title-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.nb-title-input::placeholder { color: var(--text-faint); }
.nb-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.nb-course-select { max-width: 170px; padding: 5px 9px; font-size: 12px; background: var(--surface-2); border: none; }
.nb-hint { font-size: 11px; color: var(--text-faint); margin: 18px 0 6px; }
.nb-editor-body { min-height: 400px; font-size: 15.5px; line-height: 1.8; padding: 0; outline: none; }
.nb-editor-body:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }
.nb-editor-body:empty::before { content: attr(data-placeholder); color: var(--text-faint); }
.nb-editor-body blockquote { border-left: 3px solid var(--accent); padding-left: 14px; color: var(--text-dim); margin: 10px 0; }

/* Floating selection toolbar */
.nb-bubble { position: fixed; display: none; align-items: center; gap: 2px; background: var(--ink); padding: 4px; border-radius: var(--r-tight-active); box-shadow: var(--shadow-lg); z-index: 250; }
.nb-bubble button { background: transparent; border: none; color: var(--cloud); width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; cursor: pointer; }
.nb-bubble button:hover { background: color-mix(in srgb, var(--cloud) 18%, transparent); }
.nb-bubble button.active { background: var(--cloud); color: var(--ink); }
.nb-bubble-sep { width: 1px; height: 18px; background: color-mix(in srgb, var(--cloud) 22%, transparent); margin: 0 3px; flex-shrink: 0; }

/* Persistent formatting toolbar above the editor — an elevated card, not bare buttons */
.nb-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-soft) var(--r-tight) var(--r-tight) var(--r-tight); box-shadow: var(--shadow); padding: 5px; margin: 20px 0 6px; }
.nb-toolbar button { background: transparent; border: none; min-width: 30px; height: 30px; padding: 0 7px; border-radius: var(--r-tight); display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; font-weight: 700; color: var(--text-dim); cursor: pointer; transition: background .12s, color .12s; }
.nb-toolbar button:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.nb-toolbar button.active { background: var(--accent); color: var(--accent-text); }
.nb-toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* Slash-command block menu */
.nb-slash-menu { position: fixed; display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-soft) var(--r-tight) var(--r-tight) var(--r-tight); box-shadow: var(--shadow-lg); padding: 6px; z-index: 250; width: 240px; max-height: 320px; overflow-y: auto; }
.nb-slash-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-tight); cursor: pointer; }
.nb-slash-item:hover { background: var(--accent-light); }
.nb-slash-glyph { width: 28px; height: 28px; border-radius: var(--r-tight); background: var(--accent-light); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--accent-dark); flex-shrink: 0; }
.nb-slash-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.nb-slash-desc { font-size: 10.5px; color: var(--text-faint); margin-top: 1px; }

/* Todo checklist block inside notes */
.nb-todo-line { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; }
.nb-todo-line input[type="checkbox"] { margin-top: 4px; width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }

/* ── Misc ──────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.muted { color: var(--text-faint); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.priority-high { color: var(--danger); } .priority-med { color: var(--warn); } .priority-low { color: var(--text-faint); }
.upload-drop { border: 2px dashed var(--border); border-radius: 14px; padding: 30px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.upload-drop:hover, .upload-drop.drag { border-color: var(--accent); background: var(--accent-light); }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: var(--badge); color: var(--ink); }
.loading-dots::after { content: ''; animation: dots 1.2s steps(4, end) infinite; }
@keyframes dots { 0%, 20% { content: ''; } 40% { content: '.'; } 60% { content: '..'; } 80%, 100% { content: '...'; } }

/* ── FAQ accordion (Settings) ─────────────────────────────────── */
.faq-item { border-bottom: 1px solid var(--border); padding: 12px 2px; }
.faq-item:last-of-type { border-bottom: none; }
.faq-item summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text); list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 17px; font-weight: 400; color: var(--text-faint); transition: transform .15s ease; flex-shrink: 0; }
.faq-item[open] summary::after { transform: rotate(45deg); color: var(--accent-dark); }
.faq-item p { margin-top: 8px; line-height: 1.6; }

/* ── Collapsible sub-sections elsewhere in Settings — same accordion
   language as the FAQ, used to keep long option grids out of the way
   until asked for (e.g. background presets, Recently Deleted). ────── */
.settings-collapse { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.settings-collapse summary {
  cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-dim); list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px;
}
.settings-collapse summary::-webkit-details-marker { display: none; }
.settings-collapse summary::after { content: '+'; font-size: 16px; font-weight: 400; color: var(--text-faint); transition: transform .15s ease; flex-shrink: 0; }
.settings-collapse[open] summary::after { transform: rotate(45deg); color: var(--accent-dark); }
.settings-collapse .settings-collapse-body { margin-top: 10px; }
.settings-collapse-scroll { max-height: 320px; overflow-y: auto; }

/* ── Print / PDF export (notebook notes) ──────────────────────── */
#print-area { display: none; }
.print-title { font-family: var(--font); font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.print-meta { font-size: 12px; color: #666; margin-bottom: 20px; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; padding: 30px 40px; color: #000; }
  #print-area .rich-editor { font-size: 13px; line-height: 1.6; color: #000; }
  #print-area .rich-editor h1, #print-area .rich-editor h2, #print-area .rich-editor h3 { color: #000; }
  #print-area .rich-editor pre { border: 1px solid #ccc; }
}

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar-brand { display: none; }
  .sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; top: auto; left: 0; right: 0; z-index: 120;
    flex-direction: row; align-items: center; padding: 6px 8px; gap: 6px;
    border-right: none; border-top: 1px solid var(--border);
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.06);
  }
  .sidebar > div:nth-child(2) {
    flex: 1; min-width: 0; display: flex; overflow-x: auto; gap: 10px;
    scrollbar-width: none;
  }
  .sidebar > div:nth-child(2)::-webkit-scrollbar { display: none; }
  .nav-group { display: flex; align-items: center; gap: 6px; margin-bottom: 0; flex-shrink: 0; }
  .nav-group-label { display: none; }
  .nav-item { flex-direction: column; gap: 3px; white-space: nowrap; flex-shrink: 0; padding: 7px 12px; font-size: 10px; }
  .nav-item .ic { width: auto; }
  .sidebar-foot { margin-top: 0; padding-top: 0; border-top: none; flex-shrink: 0; }
  .sidebar-foot .user-chip { display: none; }
  .content { padding: 16px; padding-bottom: 88px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content.content-notebook { height: auto; overflow: visible; padding-bottom: 88px; }
  .content-notebook .page-head { padding: 16px; }
  .notebook-layout { flex-direction: column; overflow: visible; }
  .notebook-tree-panel { width: auto; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
  .notebook-page { height: auto; overflow: visible; padding: 20px 12px 60px; }
  .nb-page-inner { max-width: none; min-height: auto; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-dow { font-size: 9.5px; padding-bottom: 3px; }
  .cal-evt { font-size: 8.5px; padding: 1px 3px; }
  .cal-evt-ic { display: none; }
  .cal-week-grid { grid-template-columns: 40px repeat(7, 1fr); }
  .cal-hour-label { font-size: 8.5px; padding-right: 3px; }
  .modal, .modal.wide { width: calc(100vw - 24px); }
  .dash-note-row { flex-direction: column; }
  .sticky-note, .sticky-note.size-sm, .sticky-note.size-lg { width: 100%; transform: none; }
  .btn.sidebar-expand-fab { top: auto; bottom: 18px; left: 18px; }
}
