/* =========================================================================
   SOLIDIUM — styles.css
   A single stylesheet for the whole app.

   How this file is organized (skim the section headers):
     1. Design tokens (CSS variables) — colors, spacing, etc.
     2. Base + resets
     3. Layout: the app shell (sidebar + main)
     4. Reusable components: buttons, cards, inputs, chips, modal, toast
     5. Feature-specific bits: calendar grid, task rows, notes, etc.
     6. Responsive: phone layout (bottom tab bar)

   TIP: "design tokens" are just variables. Change a value in section 1 and
   it updates everywhere. Try changing --accent to see the whole app reskin.
   ========================================================================= */

/* 1. DESIGN TOKENS ------------------------------------------------------- */
:root {
  --accent:        #0f766e;   /* teal — calm, clinical, not stressful */
  --accent-soft:   #d7f0ec;
  --accent-ink:    #0b544e;

  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #f0f3f7;
  --border:        #e2e8f0;
  --text:          #1f2933;
  --muted:         #64748b;
  --danger:        #dc2626;
  --warn:          #d97706;
  --ok:            #16a34a;

  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-sm:     0 1px 2px rgba(15,23,42,.08);

  --space:         16px;
  --sidebar-w:     232px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Dark mode: the browser tells us the user's preference and we swap tokens.
   Everything else in the file just uses the variables, so it "just works". */
@media (prefers-color-scheme: dark) {
  :root {
    --accent:      #2dd4bf;
    --accent-soft: #123a37;
    --accent-ink:  #99f6e4;
    --bg:          #0f141a;
    --surface:     #171d26;
    --surface-2:   #1e2530;
    --border:      #2a323d;
    --text:        #e6edf3;
    --muted:       #94a3b8;
    --shadow:      0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}

/* 2. BASE + RESET ------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
p  { margin: 0 0 .6em; }
a  { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* 3. APP SHELL ---------------------------------------------------------- */
.app { display: flex; min-height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand__mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700;
}
.brand__name { font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; font-size: .95rem;
  transition: background .12s, color .12s;
}
.nav__link:hover { background: var(--surface-2); color: var(--text); }
.nav__link.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav__ico { width: 18px; text-align: center; opacity: .9; }

.sidebar__foot { margin-top: auto; padding-top: 10px; }

.main {
  flex: 1 1 auto;
  min-width: 0;                     /* lets content shrink instead of overflow */
  padding: 28px clamp(16px, 4vw, 40px) 80px;
  max-width: 1080px;
}

/* The Notes app is a two-pane workspace (tree + editor), not prose — let it use
   the full desktop width instead of the comfortable 1080px reading column. */
body[data-route="notes"] .main { max-width: none; }

/* A standard page header used by every view */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); font-size: .95rem; }

/* 4. COMPONENTS --------------------------------------------------------- */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
  font-size: .92rem; font-weight: 600;
  background: var(--accent); color: #fff;
  transition: filter .12s, background .12s, border-color .12s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { filter: brightness(.96); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--sm { padding: 6px 11px; font-size: .85rem; }
.btn--danger { background: var(--danger); }
.btn--block { width: 100%; justify-content: center; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Section titles inside cards */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title h2 { margin: 0; }

/* Form controls */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: .95rem; font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* Chips (little colored labels — used for course tags, priorities) */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Empty states */
.empty { text-align: center; color: var(--muted); padding: 42px 20px; }
.empty .big { font-size: 2rem; margin-bottom: 8px; opacity: .7; }

/* Modal (pop-up dialog) */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); }
.modal__card {
  position: relative; z-index: 1;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(520px, 100%);
  max-height: 88vh; overflow: auto; padding: 24px;
}
.modal__x {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: var(--surface-2); color: var(--muted);
  cursor: pointer; font-size: .9rem;
}
.modal__x:hover { background: var(--border); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow); z-index: 60; animation: toast-in .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* 5. FEATURE-SPECIFIC --------------------------------------------------- */

/* Stat tiles (dashboard) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat__num { font-size: 1.8rem; font-weight: 700; letter-spacing: -.02em; }
.stat__label { color: var(--muted); font-size: .85rem; }

/* Generic list rows (tasks, events, study sessions) */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.item__main { flex: 1; min-width: 0; }
.item__title { font-weight: 600; }
.item__meta { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.item.is-done .item__title { text-decoration: line-through; color: var(--muted); }
.item__actions { display: flex; gap: 6px; }

/* A round checkbox for tasks */
.check {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer; flex: none;
  display: grid; place-items: center; transition: .12s;
}
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: "✓"; color: #fff; font-size: .8rem; font-weight: 700; }

/* Icon button (small square, e.g. delete/edit) */
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; font-size: .85rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn--danger:hover { color: var(--danger); border-color: var(--danger); }

/* Calendar grid */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-head h2 { min-width: 190px; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px;
}
.cal-dow { text-align: center; font-size: .74rem; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-cell {
  min-height: 84px; border-radius: var(--radius-sm);
  border: 1px solid transparent; padding: 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface-2); transition: border-color .12s;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.is-out { opacity: .4; }
.cal-cell.is-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell__num { font-size: .82rem; font-weight: 600; color: var(--muted); }
.cal-cell.is-today .cal-cell__num { color: var(--accent-ink); }
.cal-ev {
  font-size: .72rem; font-weight: 600; color: #fff;
  padding: 2px 6px; border-radius: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-more { font-size: .7rem; color: var(--muted); font-weight: 600; }

/* Study sessions on the calendar: outlined (not filled) so they read as a
   different layer from classes, with a 📚 marker. Colour comes from inline style. */
.cal-ev--study {
  color: var(--accent); background: transparent;
  border: 1px dashed currentColor; font-weight: 600;
}
/* Calendar toolbar: the Classes/Study/All toggle sits beside "+ Class". */
.cal-tools { display: flex; align-items: center; gap: 10px; }

/* Review reminders (Study Planner) + the "time to review" nudge (Today). */
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reminder { align-items: center; }
.reminder__dot { font-size: 1.1rem; width: 1.4rem; text-align: center; flex: 0 0 auto; }
.reminder.is-fresh    { border-left: 3px solid var(--ok); }
.reminder.is-fresh    .reminder__dot { color: var(--ok); }
.reminder.is-overdue  { border-left: 3px solid var(--danger); }
.reminder.is-overdue  .reminder__dot { color: var(--danger); }
.reminder.is-stale    { border-left: 3px solid var(--warn); }
.reminder.is-stale    .reminder__dot { color: var(--warn); }
.review-nudge { border-left: 4px solid var(--warn); }

/* Notes: two-pane (list + editor) */
.notes { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.note-list { display: flex; flex-direction: column; gap: 6px; }
.note-list__item { padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.note-list__item:hover { border-color: var(--accent); }
.note-list__item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.note-list__item .t { font-weight: 600; font-size: .92rem; }
.note-list__item .d { font-size: .76rem; color: var(--muted); }

/* Notebook cards (the top level of the Notebooks view) */
.nb-card { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.nb-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.nb-card .section-title { align-items: flex-start; }
.nb-head { display: flex; align-items: center; gap: 12px; }
.nb-head h1 { margin: 0; }

/* Note editor */
.note-editor__head { display: flex; align-items: center; gap: 8px; }
.note-title { font-weight: 700; font-size: 1.05rem; border: none; padding-left: 0; background: transparent; }
.note-title:focus { box-shadow: none; }
.note-editor__meta { margin-top: 10px; }
.note-editor__body { margin-top: 12px; }
.note-body { min-height: 340px; font-size: .95rem; line-height: 1.55; }
.note-editor__foot { font-size: .8rem; margin-top: 8px; }
.note-editor__tags { margin-top: 10px; }

/* Reusable tag editor (chips + type-to-add) */
.tagin {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px;
  background: var(--surface); min-height: 40px;
}
.tagin:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tagin__chips { display: contents; }
.tagin__input {
  flex: 1; min-width: 90px; border: none; outline: none; background: transparent;
  color: var(--text); font-size: .9rem; font-family: inherit; padding: 2px;
}
.tagchip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .8rem; font-weight: 600;
  background: var(--surface-2); border-radius: 999px; padding: 2px 4px 2px 9px;
}
.tagchip__x {
  border: none; background: none; cursor: pointer; color: inherit; opacity: .55;
  font-size: .7rem; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.tagchip__x:hover { opacity: 1; background: color-mix(in srgb, currentColor 18%, transparent); }

/* Search + tag filter (Notebooks landing) */
.search { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.search__meta { font-size: .82rem; margin-bottom: 10px; }
.tagfilter { display: flex; flex-wrap: wrap; gap: 6px; }
.tagfilter__chip {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 3px 11px; cursor: pointer;
  font-size: .8rem; font-weight: 600; color: var(--muted); font-family: inherit;
  transition: border-color .12s, color .12s, background .12s;
}
.tagfilter__chip:hover { border-color: var(--tc); color: var(--text); }
.tagfilter__chip.is-active { background: var(--tc); border-color: var(--tc); color: #fff; }
.search-result { cursor: pointer; }
.search-result:hover { border-color: var(--accent); }
.search-result__snippet { font-size: .84rem; margin-top: 5px; line-height: 1.45; }

/* ---- Obsidian-style Notebooks: tree panel + editor -------------------- */
.noteapp { display: flex; align-items: stretch; gap: 16px; min-height: calc(100vh - 108px); }
.noteapp__tree {
  width: 300px; flex: 0 0 300px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; position: sticky; top: 28px; max-height: calc(100vh - 108px);
}
.noteapp__main { flex: 1 1 auto; min-width: 0; }
.noteapp__empty {
  display: grid; place-content: center; justify-items: center; gap: 8px;
  height: 100%; min-height: 320px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 24px;
}
.noteapp__empty .big { font-size: 2.4rem; opacity: .5; }
.noteapp__empty p { max-width: 34ch; }
.noteapp__back { display: none; }

.tree__head { display: flex; align-items: center; justify-content: space-between; }
.tree__title { font-weight: 700; font-size: .92rem; }
.tree__actions { display: flex; gap: 4px; }
.tree__search { font-size: .88rem; }
.tree__tags { max-height: 70px; overflow-y: auto; }
.tree__filters { display: flex; gap: 6px; }
.tree__filters .select { flex: 1 1 0; min-width: 0; font-size: .8rem; padding: 6px 8px; }
.tree__filters[hidden] { display: none; }
.tree { flex: 1 1 auto; overflow-y: auto; margin: 0 -6px; padding: 2px 6px; }
.tree__group { margin-bottom: 1px; }
.tree__nb { display: flex; align-items: center; gap: 7px; padding: 7px 6px; border-radius: 8px; cursor: pointer; }
.tree__nb:hover { background: var(--surface-2); }
.tree__chev { font-size: .68rem; color: var(--muted); width: 12px; text-align: center; transition: transform .12s; flex: none; }
.tree__chev.is-open { transform: rotate(90deg); }
.tree__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tree__nbname { flex: 1; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree__count { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tree__nbactions { display: none; gap: 1px; }
.tree__nb:hover .tree__nbactions { display: flex; }
.tree__nb:hover .tree__count { display: none; }
.tree__mini { border: none; background: none; cursor: pointer; color: var(--muted); font-size: .8rem; padding: 2px 4px; border-radius: 5px; line-height: 1; }
.tree__mini:hover { background: var(--border); color: var(--text); }
.tree__notes { margin-left: 15px; border-left: 1px solid var(--border); padding-left: 5px; }
.tree__note { padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.tree__note:hover { background: var(--surface-2); }
.tree__note.is-active { background: var(--accent-soft); }
.tree__notetitle { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree__note.is-active .tree__notetitle { color: var(--accent-ink); }
.tree__notemeta { display: flex; flex-wrap: nowrap; gap: 2px 8px; font-size: .74rem; margin-top: 2px; color: var(--muted); overflow: hidden; }
.tree__notemeta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree__tag { font-weight: 600; }
.tree__empty, .tree__searchmeta { font-size: .8rem; padding: 6px 8px; }

/* Collapsible sidebar (desktop only — on phones it's already a bottom bar) */
.nav-collapse {
  margin-left: auto; border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 1rem; line-height: 1; padding: 4px 7px; border-radius: 7px;
}
.nav-collapse:hover { background: var(--surface-2); color: var(--text); }
@media (min-width: 721px) {
  body.is-nav-collapsed .sidebar { width: 66px; flex-basis: 66px; }
  body.is-nav-collapsed .brand { flex-direction: column; gap: 8px; padding: 8px 0 14px; }
  body.is-nav-collapsed .brand__name { display: none; }
  body.is-nav-collapsed .nav-collapse { margin: 0; transform: rotate(180deg); }
  body.is-nav-collapsed .nav__label { display: none; }
  body.is-nav-collapsed .nav__link { justify-content: center; padding: 11px 0; gap: 0; }
  body.is-nav-collapsed .sidebar__foot { display: none; }
}
@media (max-width: 720px) {
  .noteapp { flex-direction: column; min-height: 0; }
  .noteapp__tree { width: auto; flex: none; position: static; max-height: none; }
  .noteapp.has-note .noteapp__tree { display: none; }
  .noteapp:not(.has-note) .noteapp__main { display: none; }
  .noteapp__back { display: inline-flex; margin-bottom: 10px; }
}

/* Formatting toolbar + Write/Preview toggle */
.md-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-top: 14px;
  padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
}
.md-toolbar__hint { font-size: .82rem; font-weight: 600; padding-left: 6px; }
.md-tools { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.md-tool {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text); cursor: pointer;
  font-size: .85rem; font-weight: 600;
}
.md-tool:hover { background: var(--surface); border-color: var(--border); }
.md-tools__sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg__btn {
  padding: 5px 12px; border: none; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: .85rem; font-weight: 600;
}
.seg__btn.is-active { background: var(--accent); color: #fff; }

/* Rendered Markdown ("prose") */
.prose { min-height: 340px; font-size: .96rem; line-height: 1.6; word-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.1em 0 .4em; line-height: 1.25; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.08rem; }
.prose p { margin: 0 0 .8em; }
.prose ul, .prose ol { margin: 0 0 .8em; padding-left: 1.4em; }
.prose li { margin: .2em 0; }
.prose blockquote {
  margin: 0 0 .8em; padding: 4px 14px;
  border-left: 3px solid var(--accent); color: var(--muted);
  background: var(--surface-2); border-radius: 0 8px 8px 0;
}
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .88em; background: var(--surface-2);
  padding: 1px 5px; border-radius: 5px;
}
.prose pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0 0 .8em;
}
.prose pre code { background: none; padding: 0; font-size: .85rem; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.prose img { max-width: 100%; border-radius: 8px; }

/* Tables (scroll horizontally on their own so the page never does) */
.prose .table-wrap { overflow-x: auto; margin: 0 0 .9em; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.prose thead th { background: var(--surface-2); font-weight: 700; }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.prose .ta-center { text-align: center; }
.prose .ta-right { text-align: right; }
.prose .ta-left { text-align: left; }

/* -------------------------------------------------------------------------
   Test mode: fill-in-the-blank quiz built from a note's table.
   ------------------------------------------------------------------------- */
.testmode__hint { font-size: .88rem; margin: 0 0 12px; }
.testmode__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.testmode__cols { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.testmode__col {
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.testmode__col.is-hidden { background: var(--accent); border-color: var(--accent); color: #fff; }
.testmode__table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.testmode__table th, .testmode__table td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; vertical-align: top; }
.testmode__table thead th { background: var(--surface-2); font-weight: 700; }
.testmode__table thead th.is-blank { color: var(--accent-ink); }
.testmode__input { width: 100%; min-width: 90px; padding: 5px 8px; }
.testmode__cell.is-correct { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.testmode__cell.is-close   { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.testmode__cell.is-wrong   { background: color-mix(in srgb, var(--danger) 14%, transparent); }
.testmode__cell.is-correct .testmode__input { border-color: var(--ok); }
.testmode__cell.is-close   .testmode__input { border-color: var(--warn); }
.testmode__cell.is-wrong   .testmode__input { border-color: var(--danger); }
.testmode__answer { display: block; margin-top: 4px; font-size: .85rem; font-weight: 600; color: var(--ok); }
.testmode__cell.is-close .testmode__answer { color: var(--warn); }
.testmode__foot { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.testmode__score { font-weight: 700; }
.testmode__score.is-perfect { color: var(--ok); }
.testmode__score.is-ok { color: var(--warn); }
.testmode__score.is-low { color: var(--danger); }

/* Alignment blocks ( ::: center … ::: ) */
.prose .align-center { text-align: center; }
.prose .align-right { text-align: right; }
.prose .align-left { text-align: left; }

/* Inline #tags */
.prose a.tag {
  color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 5px; padding: 0 5px; font-weight: 600; font-size: .9em; text-decoration: none;
}
.prose a.tag:hover { filter: brightness(.97); }

/* Highlight + font colours. These class names are the ONLY ones markdown.js will
   emit from a [text]{.class} span, so notes can't inject arbitrary styling. */
:root {
  --hl-yellow: #fde68a; --hl-green: #bbf7d0; --hl-blue: #bfdbfe; --hl-pink: #fbcfe8;
  --fg-red: #e5484d; --fg-orange: #e5731b; --fg-green: #22a06b; --fg-blue: #3b82f6; --fg-purple: #8b5cf6;
}
.prose mark, .hl-yellow, .hl-green, .hl-blue, .hl-pink { color: #1e293b; border-radius: 3px; padding: 0 2px; }
.prose mark, .hl-yellow { background: var(--hl-yellow); }
.hl-green { background: var(--hl-green); }
.hl-blue  { background: var(--hl-blue); }
.hl-pink  { background: var(--hl-pink); }
.fg-red { color: var(--fg-red); } .fg-orange { color: var(--fg-orange); }
.fg-green { color: var(--fg-green); } .fg-blue { color: var(--fg-blue); } .fg-purple { color: var(--fg-purple); }

/* Toolbar dropdown menus (highlight/colour/align) + swatches */
.md-tool-wrap { position: relative; display: inline-flex; }
.md-menu {
  position: absolute; top: 100%; left: 0; margin-top: 5px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow); padding: 5px; display: flex; gap: 4px;
}
.md-menu[hidden] { display: none; }
.md-menu__item {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  cursor: pointer; font-size: .82rem; color: var(--text); white-space: nowrap;
}
.md-menu__item:hover { background: var(--surface-2); border-color: var(--border); }
.md-swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,.18); display: inline-block; }

/* Colour picker (swatches + native "any colour") */
.colorpick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.color-swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; padding: 0; }
.color-swatch.is-chosen { border-color: var(--text); }
.color-custom { width: 36px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.color-custom::-webkit-color-swatch-wrapper { padding: 0; }
.color-custom::-webkit-color-swatch { border: none; border-radius: 5px; }

/* Wikilinks: a note link, plus special colors for class / event links.
   "is-missing" = the target doesn't exist yet (Obsidian greys these out). */
.wikilink {
  cursor: pointer; text-decoration: none;
  border-radius: 5px; padding: 1px 5px;
  font-weight: 600; background: var(--accent-soft); color: var(--accent-ink);
}
.wikilink:hover { filter: brightness(.97); text-decoration: underline; }
.wikilink:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wikilink.is-missing { background: transparent; color: var(--muted); border: 1px dashed var(--border); }
.wikilink--course::before { content: "◈ "; opacity: .8; }
.wikilink--event::before { content: "▦ "; opacity: .8; }
.wikilink--course { background: var(--surface-2); color: var(--text); }
.wikilink--event { background: var(--surface-2); color: var(--text); }

/* Backlinks panel */
.backlinks { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.backlinks__title { font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.backlinks__list { display: flex; flex-wrap: wrap; gap: 6px; }
.backlinks__item {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
  font-size: .84rem; font-weight: 600; color: var(--text);
}
.backlinks__item:hover { border-color: var(--accent); color: var(--accent-ink); }

/* The link-picker list items shouldn't be centered like normal block buttons */
.picker__item { justify-content: flex-start; text-align: left; }

/* Study planner progress bar */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Sync status pill (bottom-right; created by js/sync.js) */
.sync-pill {
  position: fixed; bottom: 16px; right: 16px; z-index: 45;
  display: flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: .74rem; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 999px; box-shadow: var(--shadow-sm);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.sync-pill:hover { border-color: var(--muted); color: var(--text); }
.sync-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background .2s; }
.sync-pill.is-ok .sync-pill__dot { background: var(--ok); }
.sync-pill.is-off .sync-pill__dot { background: var(--danger); }
.sync-pill.is-paused .sync-pill__dot { background: var(--warn); }
@media (max-width: 720px) { .sync-pill { bottom: 78px; } }  /* clear the mobile tab bar */

/* Login / register gate */
body.is-auth .sidebar { display: none; }
body.is-auth .main { max-width: none; padding: 0; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth__card {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 28px;
}
.auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth__title { font-size: 1.4rem; margin: 0 0 4px; }
.auth__sub { margin: 0 0 20px; font-size: .92rem; }
.auth__err {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 9px; padding: 9px 12px; font-size: .86rem; font-weight: 500;
}
.auth__err[hidden] { display: none; }
.auth__or {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: .8rem; margin: 18px 0;
}
.auth__or::before, .auth__or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth__g {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; color: #4285f4; font-weight: 800; font-size: .8rem;
  border: 1px solid var(--border);
}
.auth__switch { margin-top: 18px; text-align: center; font-size: .88rem; }
.auth__switch a { color: var(--accent-ink); font-weight: 600; }

/* Signed-in user chip in the sidebar foot */
.user-chip { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.user-chip__email { font-size: .74rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .user-chip { display: none; } }

/* Utility helpers */
.stack { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted); }
.right { margin-left: auto; }
.mt { margin-top: 16px; }
.hidden { display: none !important; }
.badge-danger { color: var(--danger); }
.badge-warn { color: var(--warn); }

/* 6. RESPONSIVE (phones) ------------------------------------------------ */
@media (max-width: 720px) {
  .app { flex-direction: column; }

  /* Sidebar becomes a fixed bottom tab bar */
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; height: auto; flex: none;
    flex-direction: row; align-items: center;
    border-right: none; border-top: 1px solid var(--border);
    padding: 8px; gap: 2px; z-index: 40;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .brand, .sidebar__foot { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav__link { flex-direction: column; gap: 2px; font-size: .68rem; padding: 6px 4px; flex: 1; text-align: center; }
  .nav__ico { font-size: 1.1rem; }

  .main { padding: 20px 16px 90px; }
  .notes { grid-template-columns: 1fr; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .cal-cell { min-height: 58px; }
}
