/* ==========================================================================
   Ledger — Components
   Stat tiles, focus dashboard, theme picker, buttons, quick actions, forms,
   item rows, modals, color swatches, filter/sort bar, and related media
   queries (kept alongside their components to preserve exact cascade order).
   ========================================================================== */

  /* ---------- Stat tiles ---------- */
  .stat-tile{
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    position:relative;
    overflow:hidden;
  }
  .stat-tile > *:not(.aesthetic-art){ position:relative; z-index:1; }
  .stat-num{
    font-family: 'Space Grotesk', sans-serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
  }
  .stat-label{
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-top: 6px;
  }
  .stat-sub{
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: 4px;
  }

  /* ---------- V3 focus dashboard ---------- */
  .focus-hero{
    display: grid;
    grid-template-columns: minmax(0,1.45fr) minmax(280px,0.85fr);
    gap: 20px;
    margin-bottom: 20px;
  }
  .focus-card{
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    position:relative;
    overflow:hidden;
  }
  /* card1 (the big "today's focus" card) reserves a right-hand margin so
     the hero illustration always has its own space and can never sit
     under the task list, however many rows it has */
  .focus-card:not(.today-panel){ padding-right: 168px; }
  .focus-card > *:not(.aesthetic-art){ position:relative; z-index:1; }
  .aesthetic-art{
    position:absolute;
    pointer-events:none;
    color:var(--warn);
    z-index:0;
  }
  .aesthetic-art svg{ width:100%; height:100%; display:block; }

  /* hero: soft decorative illustration, tucked bottom-right in its own
     reserved margin */
  .art-hero{ right:20px; bottom:16px; width:132px; height:88px; opacity:0.55; }
  .art-modern.art-hero{ width:150px; height:90px; right:8px; bottom:6px; opacity:0.52; }
  .art-business.art-hero{ width:150px; height:90px; right:8px; bottom:6px; opacity:0.34; }
  .art-girly.art-hero{ width:112px; height:128px; right:20px; bottom:6px; top:auto; opacity:0.85; }
  .art-creative.art-hero{ width:112px; height:128px; right:22px; bottom:2px; opacity:0.95; }

  /* panel icon: small, solid, top-right corner of the "next class" card,
     clear of the kicker label and title beneath it */
  .art-panel{ right:20px; top:20px; width:26px; height:26px; opacity:0.9; }

  /* stat-tile icons: top-right corner, well above the number/label so
     they never sit on top of the data */
  /* Refinement Phase 5 §7 (Dashboard redesign): .art-tile-progress added
     to this selector — the Dashboard's new "Modules graded" tile calls
     renderCurrentThemeArt('tileProgress') (themes.js already has a real
     per-theme icon for this slot, used elsewhere for Study's weekly-
     target framing), which resolves to this exact class name via
     renderThemeArt()'s slot->class kebab-casing. Before this rule, that
     slot had no positioning CSS: the only prior consumer of THEME_ART's
     tileProgress icon was renderProgressRingArt() (themes.js), a
     different function that draws its own dynamic ring markup directly
     under a hand-written class (.art-tile-progress-ring, styled just
     below) and never went through renderThemeArt()/this class at all.
     Same top-right-corner treatment as the other two stat-tile icons
     immediately to the left in this selector — reusing their exact
     values rather than inventing a new size/position for what is
     visually the same kind of decorative corner icon. */
  .art-tile-overdue, .art-tile-average, .art-tile-progress{ right:16px; top:16px; width:22px; height:22px; opacity:0.85; }
  .art-tile-progress-ring{ right:15px; top:15px; width:26px; height:26px; opacity:1; }

  .art-dark-pro{ color:var(--warn); }
  .art-dark-pro.art-hero{ opacity:0.85; filter:drop-shadow(0 0 10px rgba(23,107,255,0.22)); }
  .art-girly{ color:#F06F97; }
  .art-creative{ color:#EA7D82; }
  .art-classic{ color:#B98A47; }
  body[data-theme="girly"] .page-title::after,
  body[data-theme="creative"] .page-title::after{
    content:"";
    display:inline-block;
    width:44px;
    height:8px;
    margin-left:10px;
    vertical-align:middle;
    border-bottom:3px solid var(--warn);
    border-radius:50%;
    opacity:0.65;
  }
  body[data-theme="business"] .focus-card::after,
  body[data-theme="modern"] .focus-card::after{
    content:"";
    position:absolute;
    inset:auto 0 0 auto;
    width:42%;
    height:50%;
    background:linear-gradient(135deg, transparent 0%, color-mix(in srgb, var(--warn) 18%, transparent) 100%);
    clip-path:polygon(25% 100%, 100% 12%, 100% 100%);
    opacity:0.45;
    pointer-events:none;
  }
  .focus-kicker{
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 8px;
  }
  .focus-greeting{
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 30px;
    line-height: 1.1;
    margin-bottom: 8px;
  }
  .focus-line{
    color: var(--ink-soft);
    font-size: 15px;
    line-height: 1.45;
    max-width: 680px;
  }
  .focus-list{ display: grid; gap: 10px; margin-top: 18px; }
  .focus-item{
    display: grid;
    grid-template-columns: 10px minmax(0,1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--rule);
  }
  .focus-item:first-child{ border-top: none; }
  .focus-title{
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14.5px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .focus-meta{
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: 2px;
  }
  .focus-time{
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--ink-soft);
    white-space: nowrap;
  }
  .today-panel{ display: grid; gap: 12px; }
  .next-class{
    border-left: 3px solid var(--ink);
    padding-left: 12px;
  }
  .next-class-title{
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.25;
  }
  .today-classes{ display:grid; gap:10px; }
  .today-class-row{
    display:grid;
    grid-template-columns: 64px minmax(0,1fr);
    gap:12px;
    padding:10px 0;
    border-top:1px solid var(--rule);
  }
  .today-class-row:first-child{ border-top:none; }
  .today-class-time{
    font-family:'JetBrains Mono', monospace;
    font-size:11px;
    color:var(--ink-soft);
  }
  .metric-strip{
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 12px;
    margin-bottom: 20px;
  }
  .quick-actions, .safety-actions{
    display: flex;
    flex-wrap: nowrap;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .quick-actions::-webkit-scrollbar, .safety-actions::-webkit-scrollbar{ display: none; }
  .quick-actions .btn, .safety-actions .btn{ flex: none; white-space: nowrap; }
  .safety-status{
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 12px;
    margin-bottom: 18px;
  }
  .theme-grid{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:12px;
  }
  .theme-card{
    border:1px solid var(--rule);
    background:var(--paper-raised);
    color:var(--ink);
    border-radius:var(--radius);
    padding:12px;
    text-align:left;
    box-shadow:var(--shadow);
    display:grid;
    gap:10px;
    min-height:190px;
  }
  .theme-card:hover{ border-color:var(--rule-strong); transform:translateY(-1px); }
  .theme-card.active{
    border-color:var(--ink);
    box-shadow:0 0 0 2px color-mix(in srgb, var(--ink) 16%, transparent), var(--shadow);
  }
  .theme-preview{
    height:92px;
    border-radius:8px;
    overflow:hidden;
    border:1px solid var(--preview-rule);
    background:var(--preview-paper);
    display:grid;
    grid-template-columns:30% 70%;
  }
  .theme-preview-side{
    background:var(--preview-sidebar);
    padding:9px 7px;
    display:grid;
    align-content:start;
    gap:5px;
  }
  .theme-preview-brand{
    width:42px;
    height:6px;
    border-radius:99px;
    background:var(--preview-strong);
    margin-bottom:5px;
  }
  .theme-preview-nav{
    height:7px;
    border-radius:99px;
    background:color-mix(in srgb, var(--preview-side-fg) 34%, transparent);
  }
  .theme-preview-nav.active{ background:var(--preview-accent); }
  .theme-preview-main{
    padding:9px;
    display:grid;
    gap:6px;
    position:relative;
    overflow:hidden;
  }
  .theme-preview-art{
    position:absolute;
    right:8px;
    bottom:7px;
    width:46px;
    height:34px;
    color:var(--preview-accent);
    opacity:0.72;
    pointer-events:none;
  }
  .theme-preview-art svg{ width:100%; height:100%; display:block; }
  .theme-preview-hero{
    height:24px;
    border:1px solid var(--preview-rule);
    border-radius:6px;
    background:var(--preview-card);
  }
  .theme-preview-row{
    display:grid;
    grid-template-columns:1fr 1fr 1fr;
    gap:5px;
  }
  .theme-preview-tile{
    height:20px;
    border:1px solid var(--preview-rule);
    border-radius:5px;
    background:var(--preview-card);
  }
  .theme-meta{
    display:flex;
    justify-content:space-between;
    gap:10px;
    align-items:flex-start;
  }
  .theme-name{
    font-family:var(--font-heading);
    font-weight:700;
    font-size:14px;
    line-height:1.2;
  }
  .theme-tag{
    font-family:var(--font-mono);
    color:var(--ink-soft);
    font-size:10px;
    text-transform:uppercase;
    letter-spacing:0.04em;
    white-space:nowrap;
  }
  .theme-desc{
    color:var(--ink-soft);
    font-size:12.5px;
    line-height:1.35;
  }
  .theme-swatches{
    display:flex;
    gap:5px;
  }
  .theme-swatch{
    width:16px;
    height:16px;
    border-radius:4px;
    border:1px solid var(--rule);
  }
  @media (max-width: 1180px){
    .theme-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  }
  @media (max-width: 700px){
    .theme-grid{ grid-template-columns:1fr; }
  }
  .week-calendar{
    display:grid;
    grid-template-columns: repeat(7, minmax(130px,1fr));
    gap:1px;
    background:var(--rule);
    border:1px solid var(--rule);
    border-radius:var(--radius);
    overflow:hidden;
    box-shadow:var(--shadow);
    margin-bottom:24px;
  }
  .day-column{
    background:var(--paper-raised);
    min-height:420px;
    padding:14px;
  }
  .day-column.today{
    background:var(--today-tint);
  }
  .day-head{
    display:flex;
    align-items:baseline;
    justify-content:space-between;
    gap:8px;
    margin-bottom:14px;
  }
  .day-name{
    font-family:'Space Grotesk', sans-serif;
    font-weight:700;
    font-size:15px;
  }
  .class-block{
    border-left:3px solid var(--ink-soft);
    background:var(--paper);
    border-radius:7px;
    padding:10px 10px 10px 12px;
    margin-bottom:10px;
  }
  .class-block-title{
    font-family:'Space Grotesk', sans-serif;
    font-size:13px;
    font-weight:700;
    line-height:1.25;
  }
  .class-block-meta{
    font-size:12px;
    color:var(--ink-soft);
    line-height:1.35;
    margin-top:4px;
  }
  .schedule-table-wrap{ overflow-x:auto; }
  @media (max-width: 1180px){
    .week-calendar{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  }
  @media (max-width: 700px){
    .week-calendar{ grid-template-columns: 1fr; }
    .day-column{ min-height:auto; }
  }
  @media (max-width: 980px){
    .focus-hero, .metric-strip, .safety-status{ grid-template-columns: 1fr; }
    .focus-greeting{ font-size: 24px; }
  }

  /* ---------- Timetable grid (pre-existing) ----------
     schedule.js's renderTimetableTab()/layoutDayBlocks() already emit this
     exact markup (.timetable-wrap/.timetable-hours/.timetable-day-col/
     .class-chip etc. with inline top/height/left/width percentages), but
     no CSS for these classes existed anywhere in the project, so the grid
     rendered as unstyled, unpositioned divs. Added here as a prerequisite
     for "preserve existing Schedule functionality" — the Timetable tab
     needs to actually work before Week (Feature 2 Phase 2) can be built
     alongside it. No JS or markup changed for this tab. */
  .timetable-wrap{ margin-bottom:24px; }
  .timetable{
    display:flex;
    border:1px solid var(--rule);
    border-radius:var(--radius);
    overflow:hidden;
    background:var(--paper-raised);
    box-shadow:var(--shadow);
  }
  /* Phase 1 (Navigation & visual polish) §1: the vertical rule between
     the time axis and the day grid, strengthened from --rule to
     --rule-strong so the separation reads as clearly intentional rather
     than blending in with the same faint tone used for the horizontal
     hour lines inside the grid itself. */
  .timetable-hours{ display:flex; flex-direction:column; width:52px; flex:none; border-right:1px solid var(--rule-strong); }
  .timetable-corner{ height:32px; border-bottom:1px solid var(--rule); }
  /* Phase 1 §1: this column previously carried the EXACT SAME repeating
     horizontal-line background-image as .timetable-day-body below —
     meaning the hour grid lines were being drawn a second time, directly
     behind the time labels, independently of the real grid lines in the
     day columns. Because both used identical line spacing, this looked
     like one continuous grid running straight through the time axis
     (the bug this phase calls out), when the labels were only ever meant
     to sit in their own clean column to the left of it. Removing the
     background-image here (labels no longer have anything drawn behind
     them) plus the strengthened border-right above is what actually
     "begins the grid at the first day column" rather than papering over
     it with an overlay — the real day-column grid lines are completely
     untouched below. Layout/height/spacing of this column is unaffected,
     since background-image never participated in box sizing. */
  .timetable-hours-body{
    position:relative; flex:1;
  }
  .timetable-hour-label{
    position:absolute; left:0; right:6px; text-align:right;
    font-family:'JetBrains Mono',monospace; font-size:10px; color:var(--ink-soft);
  }
  .timetable-days{ display:flex; flex:1; min-width:0; }
  .timetable-day-col{ flex:1; min-width:0; display:flex; flex-direction:column; border-right:1px solid var(--rule); }
  .timetable-day-col:last-child{ border-right:none; }
  .timetable-day-head{
    height:32px; display:flex; align-items:center; justify-content:center;
    font-family:'Space Grotesk',sans-serif; font-weight:600; font-size:12.5px;
    border-bottom:1px solid var(--rule); background:var(--paper);
  }
  .timetable-day-body{
    position:relative; flex:1;
    background-image:linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
    background-repeat:repeat; background-position:top;
  }
  .class-chip{
    position:absolute; border-left:3px solid var(--rule-strong); border-radius:6px;
    padding:4px 6px; overflow:hidden; cursor:pointer; background:var(--paper);
  }
  .class-chip-title{
    font-family:'Space Grotesk',sans-serif; font-weight:700; font-size:11px; line-height:1.25;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .class-chip-meta{
    font-family:'JetBrains Mono',monospace; font-size:9.5px; color:var(--ink-soft); margin-top:2px;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  /* ---------- Month Calendar grid (Calendar phase) ----------
     schedule.js's renderCalendarTab()/renderCalendarCell() already emit
     this exact markup (.calendar-nav/.calendar-grid/.calendar-cell/
     .calendar-chip etc.), but — unlike the Timetable grid just above,
     which already had CSS before this phase — no rules for these classes
     existed anywhere in the project. Without them every cell/header just
     falls back to default block/inline flow, which is why the month view
     rendered as an unstyled vertical stack of weekday labels followed by
     one long horizontal row of day cells instead of an actual 7-column
     grid. Mirrors the Timetable grid's existing conventions (--rule
     borders, --paper-raised surface, --today-tint for today) rather than
     inventing a new visual language. */
  .calendar-nav{ display:flex; align-items:center; gap:10px; margin-bottom:16px; flex-wrap:wrap; }
  .calendar-month-label{ font-family:'Space Grotesk', sans-serif; font-weight:700; font-size:17px; min-width:150px; }
  .calendar-grid{
    display:grid;
    grid-template-columns: repeat(7, minmax(0,1fr));
    border:1px solid var(--rule);
    border-radius:var(--radius);
    overflow:hidden;
    background:var(--paper-raised);
    box-shadow:var(--shadow);
  }
  .calendar-weekday-head{
    padding:8px 6px;
    text-align:center;
    font-family:'JetBrains Mono', monospace;
    font-size:10.5px;
    text-transform:uppercase;
    letter-spacing:0.05em;
    color:var(--ink-soft);
    background:var(--paper);
    border-bottom:1px solid var(--rule);
    border-right:1px solid var(--rule);
  }
  .calendar-weekday-head:last-child{ border-right:none; }
  .calendar-cell{
    display:flex;
    flex-direction:column;
    align-items:stretch;
    min-height:96px;
    padding:6px;
    margin:0;
    background:var(--paper-raised);
    border:none;
    border-right:1px solid var(--rule);
    border-bottom:1px solid var(--rule);
    text-align:left;
    cursor:pointer;
    font:inherit;
    color:inherit;
  }
  .calendar-cell:nth-child(7n){ border-right:none; }
  .calendar-cell:hover{ background:var(--rule); }
  .calendar-cell.outside{ background:var(--paper); color:var(--ink-soft); opacity:0.6; }
  .calendar-cell.today{ background:var(--today-tint); }
  .calendar-cell.today:hover{ background:color-mix(in srgb, var(--warn) 12%, var(--today-tint)); }
  .calendar-cell-num{ font-family:'JetBrains Mono', monospace; font-size:12px; color:var(--ink-soft); margin-bottom:4px; }
  .calendar-cell.today .calendar-cell-num{ color:var(--ink); font-weight:700; }
  .calendar-cell-items{ display:flex; flex-direction:column; gap:3px; flex:1; min-height:0; overflow:hidden; }
  .calendar-chip{
    font-size:10.5px;
    line-height:1.3;
    padding:2px 5px;
    border-radius:4px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    color:var(--ink);
  }
  .calendar-chip-more{ font-size:10px; color:var(--ink-soft); padding:1px 5px; }
  @media (max-width: 780px){
    .calendar-cell{ min-height:60px; padding:4px; }
    .calendar-cell-num{ font-size:10.5px; margin-bottom:2px; }
    .calendar-chip{ font-size:9.5px; padding:1px 4px; }
    .calendar-weekday-head{ font-size:9px; padding:6px 2px; }
  }

  /* Calendar phase: the Timetable grid is now a fixed 5 (Mon-Fri) day
     columns, down from up to 7 previously, so the horizontal-scroll
     fallback for narrow screens can kick in at a smaller min-width than
     before — still a fallback only (per the phase's "do not solve the
     layout by simply adding horizontal scrolling" note for desktop),
     desktop widths comfortably fit 5 columns without it. */
  @media (max-width: 780px){
    .timetable-wrap{ overflow-x:auto; }
    .timetable{ min-width:520px; }
  }

  /* Calendar phase: "clearly indicate today" on the Timetable grid — the
     day column matching today's weekday, using the same semantic
     --today-tint token the month Calendar cell and (formerly) the Week
     grid already used, so it stays visually consistent with the rest of
     the app rather than inventing a new highlight treatment. */
  .timetable-day-head.today{ background:var(--today-tint); }
  .timetable-day-col.today .timetable-day-body{ background-color:var(--today-tint); }

  /* ---------- Calendar phase: day-detail modal ----------
     Opened by clicking a month-grid day cell — lists everything
     happening that date (classes read-only, due tasks/exams deep-linking
     into Tasks, one-off events with real edit/delete). Reuses the
     existing .dot indicator (already used for exactly this "leading
     color swatch" role in Dashboard/Notification rows) and .icon-btn
     (already used for the module/task/note edit-delete pairs) rather
     than inventing new atoms — only the row layout itself is new. */
  .day-detail-list{ display:flex; flex-direction:column; max-height:360px; overflow-y:auto; margin:0 -4px; }
  .day-detail-row{ display:flex; align-items:center; gap:10px; padding:9px 4px; border-bottom:1px solid var(--rule); }
  .day-detail-row:last-child{ border-bottom:none; }
  .day-detail-text{ flex:1; min-width:0; }
  .day-detail-title{ font-family:'Space Grotesk',sans-serif; font-size:13.5px; font-weight:600; }
  button.day-detail-title{ display:block; width:100%; background:none; border:none; padding:0; margin:0; text-align:left; color:inherit; cursor:pointer; font:inherit; font-weight:600; }
  button.day-detail-title:hover{ text-decoration:underline; }
  .day-detail-meta{ font-size:11.5px; color:var(--ink-soft); margin-top:2px; }
  .day-detail-actions{ display:flex; gap:2px; flex-shrink:0; }

  /* ---------- Lists / rows (overview) ---------- */
  .row{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }
  .row:last-child{ border-bottom: none; }

  .row-title{ font-size: 14.5px; flex: 1; line-height: 1.3; }
  .row-meta{ font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--ink-soft); white-space: nowrap; }

  .pill{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 100px;
    white-space: nowrap;
  }
  .pill.urgent{ background: var(--urgent-bg); color: var(--urgent); }
  .pill.warn{ background: var(--warn-bg); color: var(--warn); }
  .pill.done{ background: var(--done-bg); color: var(--done); }
  .pill.neutral{ background: var(--rule); color: var(--ink-soft); }

  .dot{ width: 8px; height: 8px; border-radius: 50%; flex: none; }

  .empty{
    font-size: 13.5px;
    color: var(--ink-soft);
    padding: 18px 4px;
    line-height: 1.5;
  }

  /* ---------- Buttons ---------- */
  .btn{
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 7px;
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
  }
  .btn:hover{ background: var(--ink-soft); }
  .btn:disabled{
    opacity: 0.45;
    cursor: not-allowed;
  }
  .btn.ghost{
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--rule-strong);
  }
  .btn.ghost:hover{ background: var(--rule); }
  .btn.small{ padding: 5px 10px; font-size: 12px; }
  /* ---------- Quick action pills ---------- */
  .quick-actions .btn.small, .safety-actions .btn.small{
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(20,16,12,0.08);
    border-width: 1px;
  }
  /* Business & Modern: Task = blue, rest = neutral */
  body[data-theme="modern"] .quick-actions .btn.small:not(.ghost),
  body[data-theme="business"] .quick-actions .btn.small:not(.ghost){
    background: var(--warn); border-color: var(--warn); color:#fff;
  }
  body[data-theme="modern"] .quick-actions .btn.small.ghost,
  body[data-theme="business"] .quick-actions .btn.small.ghost{
    background: var(--paper); border-color: var(--rule-strong); color: var(--ink-soft);
  }
  /* Classic: Task = burgundy (already var(--ink)), rest = cream fill */
  body[data-theme="classic"] .quick-actions .btn.small.ghost{
    background: var(--paper); border-color: var(--rule-strong); color: var(--ink);
  }
  /* Dark Pro: Task = electric blue, rest = dark grey */
  body[data-theme="dark-pro"] .quick-actions .btn.small:not(.ghost){
    background: var(--warn); border-color: var(--warn); color:#04101F; font-weight:700;
  }
  body[data-theme="dark-pro"] .quick-actions .btn.small.ghost{
    background:#1B2330; border-color:#2B3644; color: var(--ink-soft);
  }
  /* Phase 1 (Navigation & visual polish) §1 — Dark Pro readability audit:
     the base .btn rule a few lines below (`background: var(--ink); color:
     #fff;`) assumes --ink is a dark color, which is true in every other
     theme (a legitimate dark solid fill behind white text). Dark Pro
     deliberately inverts --ink to a near-white (#E7EDF6), since --ink
     doubles as this theme's own primary TEXT color against a dark page —
     but that inversion means every OTHER "fill with --ink, write white
     text on top" component silently breaks into near-white-on-near-white
     here. The quick-action pills above already got a narrow fix for
     exactly this; this extends the same fix (reusing --warn, the theme's
     existing accent, and the same #04101F dark-navy text already proven
     legible against it above) to the base .btn used everywhere else —
     every "Save changes" / "+ Add module" / "+ Add task" button in every
     modal across the app. */
  body[data-theme="dark-pro"] .btn:not(.ghost):not(.danger-solid){
    background: var(--warn); border-color: var(--warn); color:#04101F; font-weight:700;
  }
  body[data-theme="dark-pro"] .btn:not(.ghost):not(.danger-solid):hover{
    background: color-mix(in srgb, var(--warn) 78%, white);
    border-color: color-mix(in srgb, var(--warn) 78%, white);
  }
  /* The quick-action pills above are a more specific selector
     (.quick-actions .btn.small:not(.ghost)) than the general rule just
     added, so they continue to win the cascade unchanged — this doesn't
     alter their appearance, only extends the same fix to every button
     that ISN'T one of those pills. */
  /* Creative: each pill its own pastel */
  body[data-theme="creative"] .quick-actions [data-action="add-task"]{ background:#F2A6AE; border-color:#F2A6AE; color:#63232F; }
  body[data-theme="creative"] .quick-actions [data-action="add-grade"]{ background:#CBB8F0; border-color:#CBB8F0; color:#3D2E63; }
  body[data-theme="creative"] .quick-actions [data-action="goto-study"]{ background:#FFCFA0; border-color:#FFCFA0; color:#6B4419; }
  body[data-theme="creative"] .quick-actions [data-action="add-course"]{ background:#AFCDB4; border-color:#AFCDB4; color:#2E4A34; }
  body[data-theme="creative"] .quick-actions [data-action="goto-safety"]{ background:#FFCFA0; border-color:#FFCFA0; color:#6B4419; }
  /* Girly: same idea, softer pastel */
  body[data-theme="girly"] .quick-actions [data-action="add-task"]{ background:#F6A9C3; border-color:#F6A9C3; color:#7A1F42; }
  body[data-theme="girly"] .quick-actions [data-action="add-grade"]{ background:#DCC8F7; border-color:#DCC8F7; color:#4B2E74; }
  body[data-theme="girly"] .quick-actions [data-action="goto-study"]{ background:#FBEAD8; border-color:#F1D9C0; color:#7A5230; }
  body[data-theme="girly"] .quick-actions [data-action="add-course"]{ background:#FBD7C4; border-color:#FBD7C4; color:#7A3F1E; }
  body[data-theme="girly"] .quick-actions [data-action="goto-safety"]{ background:#FBEAD8; border-color:#F1D9C0; color:#7A5230; }
  .btn.danger-solid{ background: var(--urgent); border-color: var(--urgent); color: #fff; }
  .btn.danger-solid:hover{ background: #b04f33; }
  /* Phase 1 §1 — Dark Pro readability: Dark Pro's --urgent (#FF7066) is a
     notably lighter, brighter coral than every other theme's --urgent
     (all are deep/muted reds) — the hardcoded white text above reads
     fine against those darker reds but is genuinely hard to read against
     Dark Pro's lighter one. Keeping --urgent as the fill (unchanged,
     still Dark Pro's own accent red) and switching only the text to a
     dark navy — the same contrast approach used for the .btn fix above —
     fixes this without touching any other theme's danger button. */
  body[data-theme="dark-pro"] .btn.danger-solid{ color:#1A0605; }
  body[data-theme="dark-pro"] .btn.danger-solid:hover{ background: color-mix(in srgb, var(--urgent) 82%, black); }

  .icon-btn{
    background: none; border: none; color: var(--ink-soft);
    font-size: 16px; padding: 4px; line-height: 1; border-radius: 5px;
  }
  .icon-btn:hover{ background: var(--rule); color: var(--ink); }

  /* ---------- Forms ---------- */
  .field-row{ display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
  .field{ flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 5px; }
  .field label{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-soft);
  }
  .field input, .field select, .field textarea{
    border: 1px solid var(--rule-strong);
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 14px;
    background: var(--paper-raised);
    color: var(--ink);
  }
  .field textarea{ resize: vertical; min-height: 56px; }

  .modal-backdrop{
    position: fixed; inset: 0;
    background: rgba(26,34,56,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
    padding: 20px;
  }
  .modal{
    background: var(--paper-raised);
    border-radius: 12px;
    padding: 24px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(26,34,56,0.25);
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-head{
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
  }
  .modal-actions{
    display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px;
  }

  table{ width: 100%; border-collapse: collapse; font-size: 14px; }
  th{
    text-align: left;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    padding: 8px 10px;
    border-bottom: 1px solid var(--rule-strong);
  }
  td{
    padding: 10px 10px;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
  }
  tr:last-child td{ border-bottom: none; }

  .course-swatch{
    width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px;
    flex: none;
  }

  .section-title{
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-soft);
    margin: 30px 0 12px;
  }
  .section-title:first-child{ margin-top: 0; }

  .progress-track{
    height: 7px; background: var(--rule); border-radius: 100px; overflow: hidden;
  }
  .progress-fill{ height: 100%; border-radius: 100px; }

  .toast{
    position: fixed;
    bottom: 22px; left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
  }
  /* Phase 1 §1 — Dark Pro readability: same --ink-as-a-dark-solid-fill
     assumption as .btn above (background: var(--ink); color: #fff;),
     breaking the same way once --ink is Dark Pro's light text color
     instead. Unlike .btn (an action the person clicks, where an accent
     color makes sense), a toast is a neutral passive notice — the
     correct fix here is the theme's own dark surface pair
     (--paper-raised/--ink), the exact same tokens every modal in this
     theme already uses correctly, rather than an accent color. */
  body[data-theme="dark-pro"] .toast{
    background: var(--paper-raised);
    color: var(--ink);
    border: 1px solid var(--rule-strong);
  }
  .toast.show{ opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ---------- Unified item row (modules + tasks) ---------- */
  /* base = task row: tick | name | note | due | dots  (5 tracks) */
  .item-row{
    display: grid;
    grid-template-columns: 28px minmax(160px, 1.4fr) minmax(160px, 1.8fr) 92px 30px;
    align-items: center;
    gap: 14px;
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 10px;
    position: relative;
  }
  /* module row adds a progress column: tick | name | note | progress | due | dots (6 tracks) */
  .item-row.has-progress{
    grid-template-columns: 28px minmax(150px,1.2fr) minmax(140px,1.4fr) 130px 92px 30px;
  }
  @media (max-width: 900px){
    .item-row, .item-row.has-progress{ grid-template-columns: 1fr; gap: 8px; }
  }

  .item-tick{
    width: 24px; height: 24px;
    border-radius: 7px;
    border: 1.5px solid var(--rule-strong);
    flex: none;
    display: flex; align-items: center; justify-content: center;
    background: var(--paper);
    color: #fff;
    font-size: 13px;
  }
  .item-tick.checked{ background: var(--done); border-color: var(--done); }
  .item-tick.placeholder{ visibility: hidden; }

  .item-name-btn{
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; text-align: left;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14.5px; font-weight: 600;
    color: var(--ink);
    min-width: 0;
  }
  .item-name-btn span.label-text{
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .item-name-btn.clickable:hover{ text-decoration: underline; }
  .item-name-btn.struck span.label-text{ text-decoration: line-through; opacity: 0.55; }
  .item-subcode{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--ink-soft);
    margin-left: 18px;
  }

  .item-note-btn{
    background: var(--paper); border: 1px solid var(--rule);
    border-radius: 7px; padding: 7px 10px;
    font-size: 12.5px; color: var(--ink-soft);
    text-align: left; line-height: 1.35;
    min-width: 0;
    max-height: 52px;
    overflow: hidden;
  }
  .item-note-btn:hover{ border-color: var(--rule-strong); background: var(--rule); }

  .item-progress{ display:flex; align-items:center; gap:8px; }
  .item-progress .progress-track{ flex:1; }
  .item-progress-pct{ font-family:'JetBrains Mono',monospace; font-size:11px; color: var(--ink-soft); white-space:nowrap; }

  .item-due{ font-family: 'JetBrains Mono', monospace; font-size: 12px; }
  .item-due .l{ display:block; font-size: 9.5px; text-transform:uppercase; letter-spacing:0.05em; color: var(--ink-soft); margin-bottom:2px; }

  .dots-btn{
    background: none; border: none; color: var(--ink-soft);
    font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px;
    letter-spacing: 1px;
  }
  .dots-btn:hover{ background: var(--rule); color: var(--ink); }
  .dots-menu{
    position: absolute;
    top: 44px; right: 14px;
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(26,34,56,0.15);
    overflow: hidden;
    z-index: 10;
    min-width: 130px;
  }
  .dots-menu button{
    display: block; width: 100%; text-align: left;
    background: none; border: none; padding: 9px 14px;
    font-size: 13px; font-family: 'Space Grotesk', sans-serif;
    color: var(--ink);
  }
  .dots-menu button:hover{ background: var(--rule); }
  .dots-menu button.danger{ color: var(--urgent); }

  /* timeline modal */
  .timeline-add{ margin-bottom: 18px; }
  .timeline-item{
    border-left: 2px solid var(--rule-strong);
    padding: 2px 54px 14px 14px;
    margin-left: 4px;
    position: relative;
  }
  .timeline-item::before{
    content:""; position:absolute; left:-5px; top:4px;
    width:8px; height:8px; border-radius:50%; background: var(--ink-soft);
  }
  .timeline-item:last-child{ padding-bottom: 0; }
  .timeline-date{
    font-family: 'JetBrains Mono', monospace; font-size: 10.5px;
    color: var(--ink-soft); margin-bottom: 3px;
  }
  .timeline-text{ font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
  .timeline-list{ max-height: 320px; overflow-y: auto; padding-right: 4px; }

  /* per-note edit/delete affordance: quiet by default, revealed on hover/focus
     so the timeline still reads as a clean scannable log rather than a form —
     focus-within (not just hover) so keyboard users can reach it too */
  .note-actions{
    position: absolute;
    top: 2px;
    right: 0;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  .timeline-item:hover .note-actions,
  .timeline-item:focus-within .note-actions{
    opacity: 1;
  }
  .note-action-btn.icon-btn{ padding: 3px; font-size: 14px; }
  .timeline-item-editing{ padding-right: 14px; }

  /* "(edited)" marker — same muted mono treatment as the date it sits beside,
     a transparency signal rather than something needing visual emphasis */
  .timeline-edited{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    color: var(--ink-soft);
  }

  .confirm-box p{ font-size: 14px; line-height: 1.5; margin: 0 0 4px; }

  .breadcrumb{
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--ink-soft);
    margin-bottom: 4px;
  }
  .breadcrumb button{
    background:none; border:none; color: var(--ink-soft); font-family: inherit; font-size: inherit;
    padding: 0; text-decoration: underline;
  }
  .breadcrumb button:hover{ color: var(--ink); }

  /* ---------- Color swatch palette picker ---------- */
  .swatch-picker{ display: flex; gap: 8px; flex-wrap: wrap; }
  .swatch-option{
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    position: relative;
  }
  .swatch-option.selected{
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--paper-raised) inset;
  }
  .swatch-option.selected::after{
    content: "✓";
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 13px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  }

  /* ---------- Filter / sort bar ---------- */
  .toolbar{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
  }
  .toolbar-label{
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin-right: 2px;
  }
  .toolbar select{
    border: 1px solid var(--rule-strong);
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--paper-raised);
    color: var(--ink);
    font-family: 'Space Grotesk', sans-serif;
  }
  .toolbar-divider{
    width: 1px; height: 18px;
    background: var(--rule-strong);
    margin: 0 4px;
  }

  .field input.field-error, .field select.field-error, .field textarea.field-error{
    border-color: var(--urgent);
    background: var(--urgent-bg);
  }
  .field-error-msg{
    color: var(--urgent);
    font-size: 11.5px;
    margin-top: -2px;
  }

  /* credits custom input */
  .credits-custom{ margin-top: 6px; }

  /* ---------- Toggle switch (Feature 1) ---------- */
  .toggle-row{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--rule);
  }
  .toggle-row:last-child{ border-bottom: none; }
  .toggle-row-label{
    font-size: 13.5px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    line-height: 1.35;
  }
  .toggle-row-sub{
    font-size: 11.5px;
    color: var(--ink-soft);
    margin-top: 2px;
    line-height: 1.4;
  }
  .toggle-switch{
    position: relative;
    width: 40px;
    height: 22px;
    flex: none;
    border-radius: 999px;
    border: 1px solid var(--rule-strong);
    background: var(--rule);
    padding: 0;
    transition: background 0.18s ease, border-color 0.18s ease;
  }
  .toggle-switch .toggle-thumb{
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
    transition: transform 0.18s ease;
  }
  .toggle-switch.on{
    background: var(--ink);
    border-color: var(--ink);
  }
  .toggle-switch.on .toggle-thumb{
    transform: translateX(18px);
  }


