:root {
  /* Ledger palette (Kylan, 2026-11-09): petrol #165A72, olive #3C431B,
     parchment #F3EEE1, mist #D5E5EC, sage #A3AE8A; terracotta #B5552F is a
     back-up highlight only. Dark mode redefines these tokens below. */
  color-scheme: light;
  --ink: #1b2629;
  --ink-soft: #3b4a4f;
  --muted: #56635f;            /* 4.8:1 or better on every light surface (WCAG 1.4.3), 2026-11-18 */
  --slate: #94a0a0;
  --border: #e4ddcc;
  --border-strong: #cdc6b0;
  --bg: #F3EEE1;
  --paper: #fffdf8;
  --field: #ffffff;
  --surface: #f9f6ee;
  --surface-2: #efe9dc;
  --editor-ink: #161d20;
  --topbar-bg: rgba(255, 253, 248, 0.88);
  --glow: rgba(22, 90, 114, 0.06);
  --accent: #165A72;
  --accent-bright: #1f6f8b;
  --accent-deep: #0f4456;
  --accent-ink: #12485c;
  --accent-mid: #5c95a8;
  --accent-line: #a9cad6;
  --accent-soft: #D5E5EC;
  --accent-tint: #ecf3f6;
  --accent-shadow: rgba(15, 68, 86, 0.3);
  --focus-ring: rgba(22, 90, 114, 0.65);   /* 3:1 against the page (WCAG 1.4.11) */
  --field-line: #857f6f;       /* a form field's edge: 3.4:1 or better (WCAG 1.4.11) */
  --on-accent: #ffffff;
  --olive: #3C431B;
  --olive-soft: #e7e9dc;
  --sage: #A3AE8A;
  --sage-soft: #e9ecdf;
  --highlight: #B5552F;
  --highlight-soft: #f6e4da;
  --highlight-ink: #8f3f1f;    /* terracotta text on --highlight-soft: 5.9:1 */
  --danger: #b42318;
  --danger-soft: #fdf0ee;
  --danger-line: #f0bcb5;
  --warn: #a35a08;
  --warn-soft: #fcf4e2;
  --warn-line: #ecd29a;
  --good: #2f7a4d;
  --good-soft: #edf6ef;
  --good-line: #b9dcc5;
  --violet: #6d28d9;
  --violet-soft: #f3efff;
  --sky: #0369a1;
  --sky-soft: #eff8ff;
  /* provenance highlights (record views, swatches) */
  --p-ext: #fde7c8;
  --p-ai: #ebe0ff;
  --p-tr: #fff4bf;
  --p-typed: #e6f7ec;
  --p-moved: #e8edf3;
  --p-retyped: #f3e8ff;
  --p-nokey: #e0f2fe;
  --paste-bg: #fffaf3;
  --paste-line: #f5d9b4;
  --paste-ai-bg: #f7f2ff;
  --paste-ai-line: #dccdff;
  --shadow-sm: 0 1px 2px rgba(40, 36, 20, 0.06), 0 1px 1px rgba(40, 36, 20, 0.03);
  --shadow-md: 0 6px 20px rgba(40, 36, 20, 0.08), 0 1px 2px rgba(40, 36, 20, 0.05);
  --radius: 12px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8e3d6;
  --ink-soft: #c5c9c0;
  --muted: #94a19c;
  --slate: #6d7c80;
  --border: #2a383d;
  --border-strong: #3c4d53;
  --bg: #0f1719;
  --paper: #162024;
  --field: #1b272b;
  --surface: #192428;
  --surface-2: #213036;
  --editor-ink: #e6e1d4;
  --topbar-bg: rgba(22, 32, 36, 0.9);
  --glow: rgba(95, 168, 194, 0.05);
  --accent: #5ba5c0;
  --accent-bright: #73b7cf;
  --accent-deep: #7cbcd3;      /* text on --accent-soft / --accent-tint: 5.8:1+ (was 3.5:1) */
  --accent-ink: #a8d2e1;
  --accent-mid: #6fa9bd;
  --accent-line: #2f5a6a;
  --accent-soft: #1d3944;
  --accent-tint: #182d35;
  --accent-shadow: rgba(0, 0, 0, 0.45);
  --focus-ring: rgba(91, 165, 192, 0.7);
  --field-line: #6b8087;
  --on-accent: #0a1518;
  --olive: #c2ca97;
  --olive-soft: #272c1c;
  --sage: #8d9875;
  --sage-soft: #252b20;
  --highlight: #e08a63;
  --highlight-soft: #3a2319;
  --highlight-ink: #f0a888;
  --danger: #f2948c;
  --danger-soft: #361b1a;
  --danger-line: #6a2d29;
  --warn: #e6b862;
  --warn-soft: #30271a;
  --warn-line: #66512a;
  --good: #79c99a;
  --good-soft: #172b20;
  --good-line: #2c5a3f;
  --violet: #b9a3f6;
  --violet-soft: #251f3a;
  --sky: #7dc3ee;
  --sky-soft: #142735;
  --p-ext: rgba(234, 124, 26, 0.24);
  --p-ai: rgba(124, 58, 237, 0.32);
  --p-tr: rgba(217, 164, 6, 0.24);
  --p-typed: rgba(47, 160, 100, 0.22);
  --p-moved: rgba(120, 136, 160, 0.26);
  --p-retyped: rgba(168, 85, 247, 0.26);
  --p-nokey: rgba(14, 165, 233, 0.22);
  --paste-bg: rgba(234, 124, 26, 0.08);
  --paste-line: rgba(234, 124, 26, 0.32);
  --paste-ai-bg: rgba(124, 58, 237, 0.1);
  --paste-ai-line: rgba(124, 58, 237, 0.38);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* components below set display; hidden must still win */

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 10% -10%, var(--glow), transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
html { background: var(--bg); }

a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.3rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--accent-tint); padding: 0.05rem 0.35rem; border-radius: 4px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.5rem;
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand-link { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); }
.brand-logo { width: 32px; height: 32px; border-radius: 7px; box-shadow: var(--shadow-sm); }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1.45rem; letter-spacing: -0.01em; }
.demo-badge {
  background: var(--highlight-soft); color: var(--highlight-ink); font-size: 0.62rem; font-weight: 800;
  letter-spacing: 0.08em; padding: 0.15rem 0.45rem; border-radius: 4px; margin-left: 0.2rem;
}
.tagline { color: var(--muted); font-size: 0.85rem; margin-left: 0.25rem; }
.nav { margin-left: auto; display: flex; gap: 0.25rem; }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 0.88rem; font-weight: 500;
  padding: 0.4rem 0.75rem; border-radius: 8px;
}
.nav a:hover { background: var(--accent-soft); color: var(--accent-deep); }
@media (max-width: 760px) { .tagline { display: none; } }

.content { max-width: 980px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.content.wide { max-width: 1320px; }

.section-heading { margin-top: 2.5rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.hint-inline { color: var(--muted); font-size: 0.8rem; margin: 0.25rem 0 0; }
.optional { color: var(--muted); font-weight: normal; font-size: 0.85em; }

/* ---------- Hero (landing) ---------- */
.hero { text-align: center; padding: 2rem 0 1.5rem; }
.hero-title { margin: 0 0 1.1rem; line-height: 0; }
.hero-logo { width: 200px; height: auto; }   /* hand-drawn logo, wordmark included */
.hero-sub { font-size: 1.2rem; color: var(--ink-soft); max-width: 640px; margin: 0 auto 0.75rem; line-height: 1.5; }
.hero-body { color: var(--muted); max-width: 720px; margin: 0 auto 1.25rem; line-height: 1.6; font-size: 0.98rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 0.75rem 1.4rem !important; font-size: 1rem !important; }

.intro-block { max-width: 720px; margin-bottom: 0.5rem; }
.intro-block p { line-height: 1.55; }

/* ---------- Cards / choice grid ---------- */
.split-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0; }
.split-choice.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .split-choice, .split-choice.three { grid-template-columns: 1fr; } }
.choice-card {
  display: block; padding: 1.4rem 1.35rem; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); background: var(--paper); box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.choice-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-line); }
.choice-card h2 { margin: 0.25rem 0 0.4rem; font-size: 1.1rem; }
.choice-card p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.card-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 9px; background: var(--accent-soft); color: var(--accent-deep); font-size: 1.05rem; font-weight: 700;
}

/* ---------- Forms & buttons ---------- */
.form-card {
  background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
  max-width: 520px; display: flex; flex-direction: column; gap: 1rem; box-shadow: var(--shadow-sm);
}
.form-card label, .policy-builder label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; font-weight: 600; }
.form-card input, .form-card textarea, .form-card select,
.policy-builder input[type="text"], .policy-builder input[type="number"],
.policy-builder input[type="datetime-local"], .policy-builder select, .policy-builder textarea {
  font: inherit; padding: 0.6rem 0.75rem; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field);
}
.form-card input:focus, .form-card textarea:focus, .form-card select:focus,
.policy-builder input:focus, .policy-builder select:focus, .policy-builder textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-deep)); color: var(--on-accent); border: none; padding: 0.62rem 1.15rem;
  border-radius: 9px; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; width: fit-content;
  font-size: 0.9rem; box-shadow: 0 1px 2px var(--accent-shadow);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary {
  background: var(--field); border: 1px solid var(--border-strong); color: var(--ink); border-radius: 9px; padding: 0.55rem 0.95rem;
  font-size: 0.85rem; cursor: pointer; text-decoration: none; display: inline-block; font-weight: 500;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-tint); }
.danger-btn { background: var(--field); border: 1px solid var(--danger-line); color: var(--danger); border-radius: 9px; padding: 0.5rem 0.9rem; font-size: 0.85rem; cursor: pointer; }
.danger-btn:hover { background: var(--danger-soft); }
.action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; align-items: center; }

/* ---------- Policy builder ---------- */
.policy-builder { max-width: 680px; }
.policy-modes { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.policy-modes legend { font-weight: 700; padding: 0 0.3rem; }
.policy-mode-option { display: grid; grid-template-columns: auto 150px 1fr; align-items: start; gap: 0.6rem; font-weight: normal; padding: 0.5rem; border-radius: 8px; }
.policy-mode-option:has(input:checked) { background: var(--accent-soft); }
.mode-label { font-weight: 700; }
.mode-description { color: var(--muted); font-size: 0.85rem; }
.advanced { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.advanced summary { font-weight: 700; cursor: pointer; }
.advanced > label, .schedule-fields label { margin-top: 1rem; }
.schedule-fields { display: flex; gap: 1rem; }
.schedule-fields label { flex: 1; }
.date-fields { display: flex; gap: 1rem; flex-wrap: wrap; }
.date-fields label { flex: 1 1 14rem; min-width: 0; }
.date-fields input, .phase-row input, .phase-row select { min-width: 0; max-width: 100%; }
.checkbox-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 0.5rem; font-weight: normal !important; }

.phase-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.75rem; }
.phase-row { border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; position: relative; background: var(--accent-tint); }
.phase-row label { font-size: 0.8rem; font-weight: 600; }
.phase-row .full-width { grid-column: 1 / -1; }
.remove-phase-btn { position: absolute; top: 0.5rem; right: 0.5rem; border: none; background: none; color: var(--danger); cursor: pointer; font-size: 0.78rem; }
.add-phase-btn { align-self: flex-start; border: 1px dashed var(--accent); color: var(--accent); background: var(--field); border-radius: 8px; padding: 0.4rem 0.8rem; font-size: 0.85rem; cursor: pointer; margin-top: 0.75rem; }

/* Phases on a timeline (new / edit assignment; static/js/assignment_form.js).
   Each AI policy has a color, shared by its stretch of the bar and its card. */
.pt-mode-off { --mode: var(--ink-soft); --mode-soft: var(--surface-2); }
.pt-mode-proofread { --mode: var(--sky); --mode-soft: var(--sky-soft); }
.pt-mode-coach { --mode: var(--accent); --mode-soft: var(--accent-soft); }
.pt-mode-collaborate { --mode: var(--violet); --mode-soft: var(--violet-soft); }
.pt-mode-background { --mode: var(--warn); --mode-soft: var(--warn-soft); }
.pt-mode-formatting { --mode: var(--muted); --mode-soft: var(--surface); }
.pt-mode-open { --mode: var(--good); --mode-soft: var(--good-soft); }
.phases-section { margin: 0.25rem 0 0.5rem; }
.phase-timeline { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); padding: 0.9rem 1.1rem 0.7rem; box-shadow: var(--shadow-sm); }
.pt-notice { margin: 0; font-size: 0.88rem; color: var(--ink-soft); display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.pt-ends { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.pt-track { position: relative; height: 48px; margin: 1.7rem 0 0.25rem; border-radius: 10px; background: var(--surface-2);
  cursor: copy; user-select: none; -webkit-user-select: none; }
.pt-seg { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 0.6rem; overflow: hidden;
  background: var(--mode-soft); color: var(--mode); border-top: 5px solid var(--mode); font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; transition: box-shadow 0.12s; }
.pt-seg:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.pt-seg.is-last { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.pt-seg + .pt-seg { border-left: 1px solid var(--paper); }
.pt-seg-name { overflow: hidden; text-overflow: ellipsis; position: relative; z-index: 3; }
.pt-seg.is-hot { box-shadow: inset 0 0 0 2px var(--mode); }
.pt-handle { position: absolute; top: -10px; bottom: -10px; width: 22px; margin-left: -11px; padding: 0; border: none; background: none;
  cursor: ew-resize; touch-action: none; z-index: 3; }
.pt-handle::before { content: ""; position: absolute; left: 50%; top: 6px; bottom: 6px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 2px; }
.pt-handle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 20px; margin: -10px 0 0 -6px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; box-shadow: var(--shadow-sm); }
.pt-handle:hover::after, .pt-handle.is-dragging::after { border-color: var(--accent); }
.pt-handle:focus { outline: none; }
.pt-handle:focus-visible::after { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus-ring); }
.pt-handle-label { position: absolute; bottom: calc(100% - 4px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 0.72rem; font-weight: 600; color: var(--ink); background: var(--paper); padding: 0 0.3rem; border-radius: 4px; pointer-events: none; }
.pt-handle-label.is-low { bottom: auto; top: calc(100% - 4px); }
.pt-handle.is-dragging .pt-handle-label, .pt-handle:focus-visible .pt-handle-label { color: var(--accent-deep); background: var(--accent-soft); }
.pt-today { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 2px dashed var(--danger); pointer-events: none; z-index: 2; }
.pt-today span { position: absolute; top: 100%; left: 3px; font-size: 0.66rem; font-weight: 600; color: var(--danger); }
.pt-ghost { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--accent); opacity: 0.55; pointer-events: none; z-index: 1; }
.pt-ghost span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 2px; white-space: nowrap;
  font-size: 0.7rem; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); padding: 0 0.3rem; border-radius: 4px; }
.pt-ticks { position: relative; height: 1.25rem; margin-top: 0.1rem; font-size: 0.68rem; color: var(--muted); overflow: hidden; }
.pt-tick { position: absolute; top: 0.15rem; transform: translateX(-50%); white-space: nowrap; }
.pt-tick::before { content: ""; position: absolute; left: 50%; top: -0.3rem; height: 0.25rem; border-left: 1px solid var(--border-strong); }
.phase-timeline .hint-inline { margin-top: 0.35rem; }
.phase-timeline .form-error { margin: 0.5rem 0 0; }
.phase-card { border-left: 5px solid var(--mode, var(--accent)); background: var(--paper); transition: box-shadow 0.12s; }
.phase-card.is-hot { box-shadow: 0 0 0 2px var(--mode, var(--accent)); }
.phase-card-head { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; padding-right: 4.5rem; }
.phase-card-head .pt-swatch { width: 0.7rem; height: 0.7rem; border-radius: 3px; background: var(--mode); align-self: center; }
.phase-range { color: var(--muted); font-size: 0.82rem; }
.phase-mode-desc { grid-column: 1 / -1; margin: -0.25rem 0 0; font-size: 0.8rem; color: var(--muted); }
.phase-end-field .hint-inline { display: block; font-weight: normal; }
.phase-end-field input[readonly] { background: var(--surface); color: var(--ink-soft); }
.phase-paste { grid-column: 1 / -1; font-size: 0.82rem; }
.phase-paste summary { cursor: pointer; color: var(--ink-soft); }
.phase-paste-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-top: 0.5rem; }
.policy-by-phase { display: none; }
.policy-modes.is-by-phase .policy-by-phase { display: block; margin: 0; }
.policy-modes.is-by-phase .policy-mode-option { display: none; }
@media (max-width: 640px) {
  .phase-row, .phase-paste-grid { grid-template-columns: 1fr; }
  .pt-seg { padding: 0 0.35rem; font-size: 0.7rem; }
  .pt-ends { font-size: 0.72rem; }
  .phase-timeline { padding: 0.8rem 0.75rem 0.6rem; }
}

/* ---------- Tables, pills, badges ---------- */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 0.5rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th, .data-table td { text-align: left; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; vertical-align: middle; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--accent-tint); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-block; background: var(--accent-soft); color: var(--accent-deep); padding: 0.15rem 0.6rem;
  border-radius: 999px; font-size: 0.76rem; font-weight: 700; margin-left: 0.4rem; white-space: nowrap;
}
.pill.mode-off { background: var(--surface-2); color: var(--ink-soft); }
.pill.mode-proofread { background: var(--sky-soft); color: var(--sky); }
.pill.mode-coach { background: var(--accent-soft); color: var(--accent-deep); }
.pill.mode-collaborate { background: var(--violet-soft); color: var(--violet); }
.pill.mode-open { background: var(--good-soft); color: var(--good); }

.scope-badge { display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 5px; letter-spacing: 0.02em; }
.scope-badge.in_scope { background: var(--good-soft); color: var(--good); }
.scope-badge.borderline { background: var(--warn-soft); color: var(--warn); }
.scope-badge.out_of_scope { background: var(--danger-soft); color: var(--danger); }

.signal { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 6px; }
.signal.ok { background: var(--good-soft); color: var(--good); }
.signal.note { background: var(--warn-soft); color: var(--warn); }
.signal.flag { background: var(--danger-soft); color: var(--danger); }
.signal.na { background: var(--surface-2); color: var(--muted); }

.join-link { margin: 1.5rem 0; display: flex; align-items: center; gap: 0.6rem; }
.join-link input { flex: 1; padding: 0.55rem 0.7rem; border: 1px solid var(--field-line); border-radius: 8px; font: inherit; background: var(--field); }
.breadcrumb { margin-bottom: -0.5rem; font-size: 0.88rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.policy-summary { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; color: var(--muted); font-size: 0.9rem; margin: 0.75rem 0 1.25rem; }
.prompt-text { background: var(--paper); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; box-shadow: var(--shadow-sm); }

.transparency-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin: 1.5rem 0; box-shadow: var(--shadow-sm); }
.transparency-card h2 { margin-top: 0; font-size: 1.05rem; }
.visibility-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1rem 0; }
.visibility-grid h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-family: var(--font-body); }
.visibility-grid ul { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; line-height: 1.6; }
.locked-notice { color: var(--danger); background: var(--danger-soft); padding: 0.6rem 0.8rem; border-radius: 8px; }

/* ---------- Editor layout ---------- */
.editor-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-size: 0.9rem; }
#budget-meter { color: var(--muted); font-variant-numeric: tabular-nums; }
.editor-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 330px; gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .editor-layout { grid-template-columns: 1fr; } .doc-sidebar, .ai-sidebar { position: static !important; } }
.editor-pane { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; overflow: clip; box-shadow: var(--shadow-md); }

/* LedgerEditor — our own editor, no third-party component */
.lg-editor { display: flex; flex-direction: column; }
/* The toolbar strip (with the Spelling panel) stays in view as the page
   scrolls, just under the site's top bar, whose height app.js keeps in
   --topbar-h (it wraps onto two lines on narrower windows). */
.lg-head { position: sticky; top: var(--topbar-h, 0px); z-index: 20; }
@media (max-width: 760px) { .lg-head { position: static; } }
.lg-toolbar { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.lg-toolbar button, .lg-toolbar select { border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 0.32rem 0.55rem; font-size: 0.8rem; cursor: pointer; color: var(--ink-soft); font-family: var(--font-body); }
.lg-toolbar button:hover, .lg-toolbar select:hover { background: var(--accent-soft); color: var(--accent-deep); }
.lg-toolbar select { border-color: var(--border); background: var(--field); }
.lg-toolbar-sep { width: 1px; height: 1.3rem; background: var(--border-strong); margin: 0 0.2rem; }
.lg-editable { min-height: 520px; padding: 2.2rem 2.6rem; font-size: 1.02rem; line-height: 1.7; outline: none; font-family: Georgia, "Times New Roman", serif; color: var(--editor-ink); }
.lg-editable:focus { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.lg-editable h1 { font-size: 1.55rem; font-family: var(--font-display); }
.lg-editable h1.lg-title { font-size: 2.1rem; font-weight: 700; text-align: center; margin-bottom: 1.2rem; }
.lg-editable h2 { font-size: 1.3rem; font-family: var(--font-display); }
.lg-editable h3 { font-size: 1.1rem; font-family: var(--font-display); }
.lg-editable blockquote { border-left: 3px solid var(--accent); margin: 0.75rem 0; padding: 0.25rem 0 0.25rem 1rem; color: var(--muted); }
.lg-citation { color: var(--accent-deep); background: var(--accent-soft); padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.92em; font-family: var(--font-body); }
.lg-citation-unknown { color: var(--danger); background: var(--danger-soft); }
.lg-editor-footer { display: flex; justify-content: space-between; font-size: 0.76rem; color: var(--muted); padding: 0.4rem 0.9rem; margin: 0; border-top: 1px solid var(--border); background: var(--surface); }
.save-status { text-align: right; font-size: 0.78rem; color: var(--muted); padding: 0.4rem 0.8rem; margin: 0; }

/* citation autocomplete popup */
.cite-popup {
  position: absolute; z-index: 200; min-width: 300px; max-width: 420px; background: var(--field); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-md); padding: 0.3rem; font-family: var(--font-body); font-size: 0.82rem;
}
.cite-popup-head { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.25rem 0.55rem; }
.cite-item { padding: 0.4rem 0.55rem; border-radius: 7px; cursor: pointer; display: flex; flex-direction: column; gap: 0.1rem; }
.cite-item.active, .cite-item:hover { background: var(--accent-soft); }
.cite-key { font-family: ui-monospace, Menlo, monospace; color: var(--accent-deep); font-weight: 600; }
.cite-meta { color: var(--muted); font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cite-empty { padding: 0.5rem 0.55rem; color: var(--muted); }

/* ---------- Left column: document info + sources ---------- */
.doc-sidebar { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.6rem); }
.doc-info-box, .sources-panel { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; font-size: 0.85rem; box-shadow: var(--shadow-sm); }
.doc-info-box h2, .sources-panel h2 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.doc-stat-row { display: flex; justify-content: space-between; color: var(--muted); padding: 0.18rem 0; }
.doc-stat-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.doc-stats-sub { border-top: 1px dashed var(--border); margin-top: 0.5rem; padding-top: 0.5rem; }
.doc-stats-sub .doc-stat-row { font-size: 0.8rem; }
.print-btn { width: 100%; margin-top: 0.6rem; padding: 0.45rem; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--field); cursor: pointer; font-size: 0.82rem; font-family: var(--font-body); }
.print-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.source-group h3 { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); margin: 0.8rem 0 0.3rem; font-family: var(--font-body); letter-spacing: 0.05em; }
.source-item { border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.55rem; margin-bottom: 0.4rem; background: var(--field); }
.source-item .source-cite { font-size: 0.78rem; line-height: 1.4; }
.source-item .source-key { color: var(--accent-deep); font-size: 0.72rem; font-family: ui-monospace, Menlo, monospace; margin-top: 0.15rem; }
.source-add-toggle { font-size: 0.8rem; color: var(--accent); background: none; border: none; cursor: pointer; padding: 0; font-weight: 600; }
.source-form { display: none; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.source-form.open { display: flex; }
.source-form input, .source-form select { font: inherit; font-size: 0.82rem; padding: 0.4rem 0.5rem; border: 1px solid var(--field-line); border-radius: 6px; }
.source-form-kind { display: flex; gap: 0.6rem; font-size: 0.8rem; font-weight: normal; }
.cite-howto { background: var(--accent-tint); border: 1px dashed var(--accent-line); border-radius: 8px; padding: 0.5rem 0.6rem; font-size: 0.76rem; color: var(--ink-soft); margin-top: 0.6rem; line-height: 1.45; }
.cite-howto code { background: var(--field); }

/* ---------- AI sidebar ---------- */
.ai-sidebar { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.6rem); box-shadow: var(--shadow-sm); }
.ai-sidebar h2 { margin-top: 0; font-size: 1rem; }
/* The AI panel's small print (the mode's description, "AI today", hints):
   darker and a touch larger than other hints (feedback #10, 2026-11-13:
   "too light for older eyes"). --ink-soft is about 9:1 on the panel; --muted was 4.8:1. */
.ai-sidebar .hint-inline, .ai-sidebar .mode-description { color: var(--ink-soft); font-size: 0.86rem; line-height: 1.45; }
.capability-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: 0.85rem; color: var(--ink-soft); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.ai-action-btn { border: 1px solid var(--accent-line); color: var(--accent-deep); background: var(--accent-tint); border-radius: 999px; padding: 0.35rem 0.75rem; font-size: 0.8rem; cursor: pointer; font-family: var(--font-body); font-weight: 500; }
.ai-action-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.ai-conversation { display: flex; flex-direction: column; gap: 0.5rem; max-height: 320px; overflow-y: auto; margin: 0.75rem 0; }
.ai-bubble { padding: 0.55rem 0.75rem; border-radius: 10px; font-size: 0.85rem; line-height: 1.45; white-space: pre-wrap; }
.ai-bubble-you { background: var(--accent-soft); align-self: flex-end; max-width: 92%; border-bottom-right-radius: 3px; }
.ai-bubble-ai { background: var(--surface-2); max-width: 92%; border-bottom-left-radius: 3px; }
.ai-bubble-error { background: var(--danger-soft); color: var(--danger); }
.ai-bubble-flag { display: block; margin-top: 0.35rem; font-size: 0.72rem; color: var(--warn); font-weight: 600; }
#ai-chat-form { display: flex; flex-direction: column; gap: 0.5rem; }
#ai-chat-input { font: inherit; padding: 0.55rem; border: 1px solid var(--field-line); border-radius: 8px; resize: vertical; }
#ai-used-wrap { color: var(--muted); font-size: 0.85rem; }

/* ---------- Process timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 1.5rem 0; border-left: 2px solid var(--border-strong); }
.timeline-item { position: relative; padding: 0.5rem 0 0.5rem 1.4rem; font-size: 0.9rem; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 0.95rem; width: 12px; height: 12px; border-radius: 50%; background: var(--border-strong); border: 2px solid var(--paper); }
.timeline-ai::before { background: var(--accent); }
.timeline-document::before { background: var(--warn); }
.timeline-keys::before { background: var(--slate); }
.timeline-assignment::before { background: var(--good); }
.timeline-time { color: var(--muted); font-size: 0.76rem; display: block; font-variant-numeric: tabular-nums; }
.timeline-ai .timeline-body { color: var(--ink); }
.timeline-body { line-height: 1.5; }
.timeline-quote { display: block; color: var(--ink-soft); background: var(--surface); border-left: 3px solid var(--border-strong); padding: 0.35rem 0.6rem; border-radius: 4px; margin-top: 0.25rem; font-size: 0.84rem; white-space: pre-wrap; }
.timeline-day { list-style: none; margin: 1.25rem 0 0.25rem -2px; padding-left: 1.1rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }

/* ---------- Metrics & reports ---------- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.metric-card { background: var(--paper); border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 0.9rem; box-shadow: var(--shadow-sm); }
.metric-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); font-family: var(--font-display); }
.metric-label { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.1rem; }
.metric-sub { font-size: 0.76rem; color: var(--muted); margin-top: 0.2rem; }

.signals-box { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1rem 0; box-shadow: var(--shadow-sm); }
.signals-box h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.signals-box ul { margin: 0.4rem 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.signals-box li { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.88rem; line-height: 1.45; }
.signals-box .signal { flex-shrink: 0; margin-top: 0.1rem; }
.caveat { font-size: 0.78rem; color: var(--muted); font-style: italic; margin-top: 0.6rem; }

.composition-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--border); margin: 0.5rem 0 0.3rem; }
.composition-bar span { display: block; height: 100%; }
.comp-typed { background: var(--good); }
.comp-ai { background: var(--violet); }
.comp-ext { background: var(--warn); }
.comp-moved { background: var(--slate); }
.composition-legend { display: flex; gap: 1rem; font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; }
.composition-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.3rem; vertical-align: -1px; }

.report-section { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 1.25rem 0; box-shadow: var(--shadow-sm); }
.report-section h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.report-section .hint { margin-top: 0; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 820px) { .report-grid { grid-template-columns: 1fr; } }
.bar-list { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.75rem; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 58px; align-items: center; gap: 0.6rem; font-size: 0.84rem; }
.bar-label { color: var(--ink-soft); }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-bright), var(--accent-deep)); border-radius: 999px; }
.bar-fill.flagged { background: linear-gradient(90deg, #f87171, var(--danger)); }
.bar-fill.stage { background: linear-gradient(90deg, #a78bfa, var(--violet)); }
.bar-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.report-kicker { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.flag-list { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.86rem; line-height: 1.5; }

/* ---------- Document provenance view ---------- */
.view-links { display: flex; gap: 0.75rem; align-items: center; margin: 0.4rem 0 0.9rem; flex-wrap: wrap; }
.prov-legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1.25rem; align-items: center; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 1rem 0 0.6rem; font-size: 0.86rem; box-shadow: var(--shadow-sm); }
.prov-legend label { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.prov-swatch { display: inline-block; width: 15px; height: 15px; border-radius: 3px; }
.sw-paste_ext { background: var(--p-ext); border-bottom: 3px solid #ea7c1a; }
.sw-paste_ai { background: var(--p-ai); border-bottom: 3px solid #7c3aed; }
.sw-transcribed { background: var(--p-tr); border-bottom: 3px solid #d9a406; }
.sw-typed { background: var(--p-typed); border-bottom: 3px solid #0f7b4e; }
.sw-unknown { background: var(--field); border: 1px dotted var(--slate); }
.sw-moved { background: var(--p-moved); border-bottom: 3px solid #64748b; }
.prov-pane { margin-top: 0.75rem; }
.prov-doc { min-height: 280px; }
.prov { border-radius: 2px; }
.prov-paste_ext { background: var(--p-ext); box-shadow: inset 0 -2px 0 #ea7c1a; }
.prov-paste_ai { background: var(--p-ai); box-shadow: inset 0 -2px 0 #7c3aed; }
.prov-transcribed { background: var(--p-tr); box-shadow: inset 0 -2px 0 #d9a406; }
.prov-typed { background: transparent; }
.prov-moved { background: var(--p-moved); box-shadow: inset 0 -2px 0 #64748b; }
.prov-doc.show-typed .prov-typed { background: var(--p-typed); }
.prov-unknown { text-decoration: underline dotted var(--slate); }
.prov-doc.hide-paste_ext .prov-paste_ext, .prov-doc.hide-paste_ai .prov-paste_ai, .prov-doc.hide-transcribed .prov-transcribed, .prov-doc.hide-moved .prov-moved { background: transparent; box-shadow: none; }
.prov-doc.by-author .prov[data-author] { text-decoration: underline solid var(--author-color); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.prov-doc.hide-unknown .prov-unknown { text-decoration: none; }
.paste-details { margin-top: 0.3rem; }
.paste-details summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; }
.paste-text { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 0.88rem; line-height: 1.5; background: var(--paste-bg); border: 1px solid var(--paste-line); border-radius: 8px; padding: 0.65rem 0.85rem; margin: 0.35rem 0 0; max-height: 260px; overflow: auto; }
.paste-text.ai { background: var(--paste-ai-bg); border-color: var(--paste-ai-line); }
.paste-list .paste-item { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.paste-item-head { display: flex; gap: 0.6rem; align-items: center; font-size: 0.85rem; color: var(--muted); }

/* ---------- Course materials ---------- */
.materials-box { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin: 1rem 0; box-shadow: var(--shadow-sm); }
.materials-box h2 { margin-top: 0; font-size: 1rem; }
.material-item { display: flex; justify-content: space-between; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; gap: 1rem; }
.material-upload-form { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.75rem; flex-wrap: wrap; }
.material-upload-form input[type="text"] { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--field-line); border-radius: 8px; }
/* Spelling (shared editor): words the dictionary doesn't know, and the panel listing them. */
::highlight(lg-spell) { text-decoration: underline wavy var(--danger); text-decoration-skip-ink: none; text-underline-offset: 3px; }
.lg-spell-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-deep); }
.lg-spell { border: 1px solid var(--border); border-top: 0; background: var(--surface); padding: 0.55rem 0.9rem; font-size: 0.85rem; max-height: 14rem; overflow: auto; }
.lg-spell-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.lg-spell-status { font-weight: 600; color: var(--ink-soft); }
.lg-spell-note { color: var(--muted); font-size: 0.78rem; flex: 1 1 14rem; }
.lg-spell-close { border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 0.2rem; margin-left: auto; }
.lg-spell-list { list-style: none; margin: 0.45rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.lg-spell-list li { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.lg-spell-word { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--danger); text-decoration: underline wavy var(--danger); text-underline-offset: 3px; cursor: pointer; }
.lg-spell-n { color: var(--muted); font-size: 0.78rem; }
.lg-spell-sugg { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; color: var(--muted); }
.lg-spell-fix { border: 1px solid var(--border-strong); background: var(--paper); color: var(--ink); border-radius: 6px; padding: 0.1rem 0.5rem; font: inherit; font-size: 0.82rem; cursor: pointer; }
.lg-spell-fix:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-tint); }
.lg-spell-fix:disabled { opacity: 0.5; cursor: default; }
.lg-spell-ignore { border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.78rem; cursor: pointer; text-decoration: underline; margin-left: auto; }
.lg-spell-none { font-style: italic; }
/* Words in the highlighted text (editor footer, every product) and the Classroom outline. */
.lg-sel-count { font-size: 0.78rem; font-weight: 600; color: var(--accent-deep); background: var(--accent-soft); padding: 0.05rem 0.45rem; border-radius: 5px; margin-left: auto; margin-right: 0.6rem; white-space: nowrap; }
.doc-sel-row strong { color: var(--accent-deep); }
.doc-outline { border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); margin: 0 0 0.75rem; padding: 0.55rem 0.9rem; box-shadow: var(--shadow-sm); }
.doc-outline summary { cursor: pointer; display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.doc-outline summary .hint-inline { margin: 0; }
.doc-outline-root { margin: 0.5rem 0 0.25rem; max-height: 22rem; overflow: auto; }
.doc-outline-root .ol-text { font-size: 0.95rem; }
.doc-outline-status { display: block; min-height: 1em; }
.outline-readonly { margin: 0.25rem 0 0; padding-left: 1.2rem; font-family: Georgia, serif; }
.outline-readonly ul { padding-left: 1.2rem; }
.outline-readonly li { margin: 0.15rem 0; }
/* Classes and rosters (2026-11-13): a student's classes; an instructor's roster and CSV import. */
.class-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1rem; margin: 0.75rem 0 1.5rem; }
.class-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.5rem; }
.class-card h3 { margin: 0; font-size: 1.05rem; }
.class-card h3 a { color: var(--ink); text-decoration: none; }
.class-card h3 a:hover { color: var(--accent); }
.class-assignments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.class-assignments li { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.class-assignments li:last-child { border-bottom: 0; }
.ca-title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ca-state { display: inline-flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.class-link { font-size: 0.85rem; color: var(--accent); text-decoration: none; margin-top: auto; }
.class-materials { margin: 0.4rem 0 1rem; padding-left: 1.1rem; }
.class-materials li { margin: 0.35rem 0; }
.roster-table td { vertical-align: middle; }
.roster-actions { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.roster-actions form { display: inline; margin: 0; }
.roster-pw summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); }
.roster-pw form { display: flex; gap: 0.4rem; margin-top: 0.35rem; }
.roster-pw input { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.5rem; border: 1px solid var(--field-line); border-radius: 6px; min-width: 0; }
.danger-link { color: var(--danger); }
.students-import-form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.6rem; max-width: 44rem; }
.students-import-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.also-courses, .post-to { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; }
.also-courses legend, .post-to legend { font-weight: 700; padding: 0 0.3rem; }
.copy-to { margin-top: 1.25rem; }

/* Sign-up links and resets (2026-11-17) */
.roster-meta { display: block; font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.2rem; }
.signup-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin: 1.1rem 0; display: flex; flex-direction: column; gap: 0.6rem; max-width: 52rem; }
.signup-box h3 { margin: 0; font-size: 1.05rem; }
.signup-box p { margin: 0; }
.signup-box .join-link { margin: 0; }
.signup-actions { display: flex; gap: 0.9rem; align-items: flex-start; flex-wrap: wrap; }
.signup-actions > form { margin: 0; }
.signup-renew summary { cursor: pointer; font-size: 0.85rem; color: var(--accent); padding: 0.3rem 0; }
.signup-renew[open] { display: flex; flex-direction: column; gap: 0.5rem; }
.signup-form { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; margin: 0; }
.signup-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.signup-form input { width: 7rem; font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: inherit; }
.signup-page { align-items: start; }
.signup-page .login-intro { grid-row: 1 / span 2; align-self: start; position: sticky; top: calc(var(--topbar-h, 56px) + 2.5rem); margin-top: 2rem; }
.signup-page .signup-signin { grid-column: 2; }
.signup-nudge { margin: 0; font-size: 0.92rem; padding: 0.55rem 0.75rem; background: var(--accent-soft); border-radius: 8px; }
@media (max-width: 760px) {
  .signup-page .login-intro { grid-row: auto; position: static; margin-top: 0; }
  .signup-page .signup-signin { grid-column: auto; }
}
.copy-to h2 { font-size: 1.05rem; margin: 0 0 0.3rem; }
.gen-pw { user-select: all; }
@media (max-width: 640px) { .course-assignments th:nth-child(3), .course-assignments td:nth-child(3), .course-assignments th:nth-child(4), .course-assignments td:nth-child(4) { display: none; } }
@media (max-width: 640px) { .roster-table th:nth-child(4), .roster-table td:nth-child(4), .roster-table th:nth-child(5), .roster-table td:nth-child(5) { display: none; } }
.material-item a { color: var(--accent); text-decoration: none; }
.material-item a:hover { text-decoration: underline; }
.material-item > span { min-width: 0; overflow-wrap: anywhere; }
.material-citation { font-size: 0.92rem; max-width: 46rem; padding-left: 1.5rem; text-indent: -1.5rem; }
.material-text { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem;
  margin: 1rem 0; box-shadow: var(--shadow-sm); max-width: 46rem; line-height: 1.6; overflow-wrap: anywhere; }
.material-text h2 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }
.material-text h3 { font-size: 1.05rem; margin: 1.3rem 0 0.3rem; }
.material-text h4 { font-size: 0.93rem; margin: 0.9rem 0 0.15rem; }
.material-text > :first-child { margin-top: 0; }
.material-text p, .material-text ul { margin: 0.4rem 0 0.7rem; }
@media (max-width: 600px) { .material-text { padding: 1rem; } }

/* ---------- Playground ---------- */
.playground-banner { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); border-radius: 10px; padding: 0.9rem 1.1rem; font-size: 0.88rem; margin-bottom: 1.25rem; line-height: 1.5; }
.policy-switcher { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.6rem; }
.policy-switch-btn { border: 1px solid var(--border-strong); background: var(--field); border-radius: 999px; padding: 0.38rem 0.85rem; font-size: 0.8rem; cursor: pointer; font-family: var(--font-body); font-weight: 500; color: var(--ink-soft); }
.policy-switch-btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.policy-switch-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: 0 1px 2px var(--accent-shadow); }
.reset-demo-btn { font-size: 0.78rem; color: var(--warn); background: none; border: none; text-decoration: underline; cursor: pointer; margin-left: 0.5rem; }

/* ---------- Print ---------- */
@media print {
  .topbar, .doc-sidebar, .ai-sidebar, .lg-toolbar, .editor-topbar, .lg-editor-footer, .playground-banner, .policy-switcher, #mode-description, .presence-row, .collab-toast { display: none !important; }
  .lg-editable .lg-locked { background: none !important; box-shadow: none !important; }
  .lg-editable .lg-locked::after { display: none !important; }
  .editor-layout { display: block !important; }
  .editor-pane { border: none !important; box-shadow: none !important; }
  .lg-editable { padding: 0 !important; min-height: 0 !important; }
  .content { max-width: none !important; padding: 0 !important; }
  body { background: #fff; }
}

/* ---------- Group documents ---------- */
.presence-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin: -0.35rem 0 0.75rem; font-size: 0.8rem; }
.presence-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; flex: 1; }
.add-block-btn { font-size: 0.78rem; padding: 0.25rem 0.7rem; }
.presence-label { color: var(--muted); font-weight: 600; }
.presence-chip { --member-color: #64748b; display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.15rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--paper); color: var(--muted); }
.presence-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.presence-chip.online { color: var(--ink); border-color: var(--member-color); }
.presence-chip.online::before { background: var(--member-color); }
.lg-editable .lg-locked { --lock-color: #64748b; position: relative; background: color-mix(in srgb, var(--lock-color) 7%, transparent); box-shadow: -3px 0 0 var(--lock-color); border-radius: 2px; cursor: not-allowed; }
.lg-editable .lg-locked::after { content: attr(data-locked-by) " is editing"; position: absolute; top: -0.85rem; right: 0; font: 600 0.66rem/1.4 var(--font-body); color: #fff; background: var(--lock-color); padding: 0 0.4rem; border-radius: 4px; pointer-events: none; }
.collab-toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); opacity: 0; transition: opacity 0.2s, transform 0.2s; background: var(--ink); color: var(--bg); padding: 0.55rem 1rem; border-radius: 8px; font-size: 0.85rem; box-shadow: var(--shadow-md); pointer-events: none; z-index: 50; }
.collab-toast.show { opacity: 1; transform: translate(-50%, 0); }
.member-dot { --member-color: #64748b; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--member-color); margin-right: 0.45rem; vertical-align: 1px; }
.data-table tr.group-row td { border-top: 2px solid var(--border-strong); }
.data-table tr.member-row td { font-size: 0.84rem; color: var(--ink-soft); background: var(--accent-tint); padding-top: 0.35rem; padding-bottom: 0.35rem; }
.data-table tr.member-row td:first-child { padding-left: 1.4rem; }
.timeline-actor { --member-color: #64748b; display: inline-block; font-size: 0.72rem; font-weight: 600; color: var(--member-color); border: 1px solid var(--member-color); border-radius: 999px; padding: 0 0.45rem; margin: 0.1rem 0 0.15rem; }
.author-legend { gap: 0.5rem 0.9rem; }
.author-chip { --member-color: #64748b; display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.8rem; font-weight: 600; border-bottom: 2px solid var(--member-color); padding: 0 0.1rem; }
.group-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.2rem; margin: 0.6rem 0 0.4rem; }
.group-settings .inline-field { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; }
.group-settings .inline-field select { width: auto; }
.group-choice { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0.75rem 0 1rem; }
.group-choice legend { font-size: 0.88rem; font-weight: 600; padding: 0 0.3rem; }
.group-option { display: flex !important; align-items: flex-start; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.group-option:last-of-type { border-bottom: 0; }
.group-option input[type=radio] { width: auto; margin-top: 0.25rem; }
.group-option > span { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.group-option.full { opacity: 0.55; cursor: not-allowed; }
.group-option input[type=text] { margin-top: 0.3rem; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 0.5rem 0.75rem; margin: 0 0 0.75rem; font-size: 0.88rem; }
.paste-rules { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.9rem 0.75rem; margin: 0.75rem 0; }
.paste-rules legend { font-size: 0.88rem; font-weight: 600; padding: 0 0.3rem; }
.paste-source-row { display: flex !important; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.86rem; margin: 0.35rem 0; }
.paste-source-row select { width: auto; max-width: 62%; }
.doc-info-box .paste-source-row { flex-direction: column; align-items: stretch; gap: 0.2rem; font-size: 0.8rem; }
.doc-info-box .paste-source-row select { max-width: none; width: 100%; }
.paste-rule-list { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.92em; }

/* ---------- Accounts & sign-in (2026-11-05) ---------- */
.topbar { flex-wrap: wrap; row-gap: 0.4rem; }
.account-menu { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; margin-left: auto; }
.nav + .account-menu { margin-left: 0.25rem; }
.account-name { color: var(--ink-soft); font-weight: 600; padding: 0 0.35rem; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu form { margin: 0; }
.account-link { background: none; border: 0; font: inherit; color: var(--muted); padding: 0.4rem 0.55rem; border-radius: 8px; cursor: pointer; text-decoration: none; }
.account-link:hover { background: var(--accent-soft); color: var(--accent-deep); }
@media (max-width: 760px) {
  .nav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
  .account-menu { margin-left: auto; }
  .account-name { display: none; }
}

.login-page { display: grid; grid-template-columns: 1fr minmax(300px, 400px); gap: 3rem; align-items: center; max-width: 880px; margin: 2.5rem auto 0; }
.login-intro { text-align: center; }
.login-intro .hero-logo { width: 220px; }
.login-tagline { font-size: 1.12rem; color: var(--ink-soft); line-height: 1.5; max-width: 26rem; margin: 0 auto; }
.login-card { max-width: none; }
.login-card h2 { margin: 0; font-size: 1.35rem; }
@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1rem; }
  .login-intro .hero-logo { width: 150px; }
}

.form-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-line); border-radius: 8px; padding: 0.6rem 0.8rem; margin: 0; font-size: 0.9rem; }
.notice { border-radius: 8px; padding: 0.6rem 0.85rem; font-size: 0.9rem; }
/* The erase pages' can't-be-undone warning (shared/erase_student.html). */
.erase-warning { border: 1px solid var(--danger-line); border-left: 4px solid var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 0.75rem 1rem; margin: 0 0 1.25rem; }
.erase-warning h2 { color: var(--danger); font-size: 1.05rem; margin: 0 0 0.35rem; }
.erase-warning p { margin: 0.35rem 0 0; }
.erase-phrase { color: var(--danger); background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: 4px; padding: 0 0.3em; letter-spacing: 0.03em; white-space: nowrap; }
.notice-good { background: var(--good-soft); color: var(--good); border: 1px solid var(--good-line); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.account-create { margin-bottom: 1.5rem; }
.account-create h2 { margin: 0; font-size: 1.2rem; }

.issued-card { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 0 0 1.5rem; max-width: 640px; }
.issued-card h2 { margin: 0 0 0.25rem; font-size: 1.15rem; }
.issued-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; margin: 0.75rem 0 0; align-items: center; }
.issued-grid dt { font-weight: 600; font-size: 0.85rem; color: var(--ink-soft); }
.issued-grid dd { margin: 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.issued-pw { font: 600 1rem ui-monospace, SFMono-Regular, Menlo, monospace; padding: 0.4rem 0.6rem; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); width: 15rem; max-width: 100%; }

.inline-form { display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; }
.inline-form select { font: inherit; font-size: 0.85rem; padding: 0.2rem 0.3rem; border: 1px solid var(--field-line); border-radius: 6px; }
.link-btn { background: none; border: 0; padding: 0.2rem 0.3rem; font: inherit; font-size: 0.85rem; color: var(--accent); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }
.row-actions { white-space: nowrap; }
.row-muted td { color: var(--muted); }
.row-warn td { background: var(--warn-soft); }
.status { font-size: 0.78rem; font-weight: 600; padding: 0.12rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.status-on { background: var(--good-soft); color: var(--good); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-off { background: var(--surface-2); color: var(--muted); }
@media (max-width: 900px) { .accounts-table { display: block; overflow-x: auto; } }
.signed-out-banner { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 200; max-width: min(640px, calc(100% - 2rem)); background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn-line); border-radius: 10px; padding: 0.8rem 1rem; box-shadow: var(--shadow-md); font-size: 0.9rem; line-height: 1.45; }
.signed-out-banner a { color: var(--warn); font-weight: 600; }

/* ---------- Two products: chooser + header (2026-11-05) ---------- */
.brand-product { color: var(--accent); }
.topbar-classroom .brand-product { color: var(--accent); }
.nav-switch { color: var(--muted) !important; border: 1px solid var(--border); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin: 1.5rem 0; }
@media (max-width: 760px) { .product-grid { grid-template-columns: 1fr; } }
.product-card { position: relative; display: flex; flex-direction: column; gap: 0.6rem; padding: 1.6rem 1.5rem 1.4rem; background: var(--paper);
  border: 1px solid var(--border); border-radius: 16px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-line); }
.product-card h2 { margin: 0; font-size: 1.7rem; }
.product-card h2 span { color: var(--accent); }
.product-card p { margin: 0; color: var(--ink-soft); line-height: 1.55; font-size: 0.95rem; }
.product-demo { position: absolute; top: 1.1rem; right: 1.1rem; background: var(--highlight-soft); color: var(--highlight-ink); font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 4px; }
.product-go { margin-top: auto; color: var(--accent); font-weight: 600; font-size: 0.92rem; }

/* ---------- Shared editor: works cited, math, traces, outline boxes ---------- */
.works-cited { margin-top: 1rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.4rem; }
.works-cited h3, .works-cited h2.wc-title { margin: 0 0 0.6rem; font-size: 1rem; }
.wc-entry { margin: 0 0 0.45rem; padding-left: 2em; text-indent: -2em; font-family: Georgia, serif; font-size: 0.93rem; line-height: 1.5; }
.wc-missing { color: var(--danger); font-family: var(--font-body); text-indent: 0; padding-left: 0; }
.wc-empty { color: var(--muted); font-size: 0.85rem; margin: 0; }
.lg-math[data-display="1"] { display: block; text-align: center; }
.lg-trace { display: inline; }
.lg-hide-traces .lg-trace { display: none; }
.lg-otrace { position: relative; margin: 0.9rem 0 0.4rem; padding: 0.45rem 0.75rem; border: 1.5px solid var(--accent-line); border-radius: 8px;
  background: var(--accent-tint); color: var(--accent-ink); font-family: var(--font-body); font-size: 0.92rem; font-weight: 600; line-height: 1.45; }
.lg-otrace[data-level="2"] { margin-left: 1.5rem; }
.lg-otrace[data-level="3"] { margin-left: 3rem; }
.lg-otrace[data-level="4"], .lg-otrace[data-level="5"], .lg-otrace[data-level="6"] { margin-left: 4.5rem; }
.lg-otrace-missing { border-style: dashed; background: var(--surface); color: var(--muted); }
.lg-otrace-missing::after { content: " (no longer in the outline)"; font-weight: 400; font-size: 0.8em; }
.lg-hide-outline .lg-otrace { display: none; }
.cite-key-trace { font-family: var(--font-body); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--olive); }
.lg-editable code { background: var(--surface-2); padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.9em; }

/* ---------- Ledger Write workspace ---------- */
.w-content { padding-top: 1rem; }
.w-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 1.1rem; align-items: start; }
@media (max-width: 1150px) { .w-layout { grid-template-columns: 220px minmax(0, 1fr); } }
@media (max-width: 760px) { .w-layout { grid-template-columns: 1fr; } }
.w-left { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.6rem);
  box-shadow: var(--shadow-sm); max-height: calc(100vh - var(--topbar-h, 3.9rem) - 1.6rem); overflow-y: auto; }
.w-project-title { width: 100%; font: 700 1.05rem var(--font-display); border: 1px solid transparent; border-radius: 6px; padding: 0.2rem 0.35rem; background: transparent; }
.w-project-title:hover, .w-project-title:focus { border-color: var(--border-strong); background: var(--field); outline: none; }
.w-project-links { font-size: 0.78rem; color: var(--muted); padding: 0.1rem 0.35rem 0.6rem; }
.w-section-head { display: flex; justify-content: space-between; align-items: center; margin: 0.8rem 0 0.35rem; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.w-section-head .link-btn { font-size: 0.75rem; text-transform: none; letter-spacing: 0; }
.w-docs { list-style: none; margin: 0; padding: 0; }
.w-doc { display: flex; align-items: center; border-radius: 7px; }
.w-doc.active { background: var(--accent-soft); }
.w-doc-open { flex: 1; text-align: left; background: none; border: 0; font: inherit; font-size: 0.88rem; padding: 0.38rem 0.45rem; cursor: pointer;
  color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-doc.active .w-doc-open { font-weight: 600; color: var(--accent-ink); }
.w-doc-icon { display: inline-block; width: 1.2em; color: var(--muted); }
.w-doc-tools { display: none; }
.w-doc:hover .w-doc-tools, .w-doc.active .w-doc-tools { display: inline-flex; }
.w-doc-tools button { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 0.75rem; padding: 0.15rem 0.25rem; }
.w-doc-tools button:hover:not(:disabled) { color: var(--ink); }
.w-kb-search { width: 100%; font: inherit; font-size: 0.85rem; padding: 0.4rem 0.55rem; border: 1px solid var(--border-strong); border-radius: 7px; }
.w-kb { list-style: none; margin: 0.4rem 0; padding: 0; max-height: 42vh; overflow-y: auto; }
.w-kb-item { display: flex; gap: 0.45rem; align-items: flex-start; padding: 0.45rem 0.2rem; border-bottom: 1px solid var(--border); }
.w-kb-thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 4px; flex: none; }
.w-kb-body { flex: 1; min-width: 0; }
.w-kb-kind { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.w-kb-title { font-size: 0.84rem; font-weight: 600; line-height: 1.3; }
.w-kb-meta { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-kb-acts { display: flex; flex-direction: column; gap: 0.2rem; }
.w-kb-acts button { font-size: 0.68rem; border: 1px solid var(--border-strong); background: var(--field); border-radius: 5px; padding: 0.1rem 0.35rem; cursor: pointer; }
.w-kb-acts button:hover { border-color: var(--accent); color: var(--accent); }
.w-kb-empty { font-size: 0.8rem; color: var(--muted); padding: 0.4rem 0; }
.w-full { width: 100%; margin-top: 0.3rem; }
.w-kb-form { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.w-kb-form input, .w-kb-form select, .w-kb-form textarea { font: inherit; font-size: 0.82rem; padding: 0.35rem 0.5rem; border: 1px solid var(--field-line); border-radius: 6px; width: 100%; }
.w-row { display: flex; gap: 0.35rem; }
.w-row input:first-child { max-width: 5.5rem; }
.w-main { min-width: 0; }
.w-doc-head { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.w-doc-title { font: 700 1.35rem var(--font-display); border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 0.15rem 0.35rem; min-width: 12rem; flex: 1; }
.w-doc-title:hover, .w-doc-title:focus { border-color: var(--border-strong); background: var(--field); outline: none; }
.w-layers { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; font-size: 0.82rem; color: var(--ink-soft); }
.w-layers label { display: inline-flex; gap: 0.3rem; align-items: center; }
.w-layers select { font: inherit; font-size: 0.8rem; padding: 0.3rem 0.4rem; border: 1px solid var(--field-line); border-radius: 7px; }
.w-layers .btn-secondary { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.w-doc-foot { color: var(--muted); font-size: 0.8rem; margin: 0.5rem 0.2rem; }
#w-outline-wrap { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.4rem 1.6rem; box-shadow: var(--shadow-sm); }
.w-save-state { margin-left: 0.4rem; color: var(--muted); }
.w-ai { position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.6rem); max-height: calc(100vh - var(--topbar-h, 3.9rem) - 1.6rem); overflow-y: auto; }
.w-ai-head { display: flex; align-items: center; gap: 0.5rem; }
.w-ai-head h2 { flex: 1; }
.w-ai-close, .w-ai-toggle { display: none; }
/* Narrower windows (feedback #12, 2026-11-13): the AI panel used to drop
   below the whole document, squeezed full width. Now it's a drawer on the
   right, opened from "AI assistant" beside the file's title. */
@media (max-width: 1150px) {
  .w-ai-toggle { display: inline-flex; }
  .w-ai-close { display: inline-block; }
  .w-ai { display: none; }
  body.w-ai-open .w-ai { display: block; position: fixed !important; top: calc(var(--topbar-h, 3.9rem) + 0.5rem); right: 0.75rem; bottom: 0.75rem; z-index: 130;
    width: min(380px, calc(100vw - 1.5rem)); max-height: none; box-shadow: var(--shadow-md); }
}
@media (max-width: 760px) {
  body.w-ai-open .w-ai { top: auto; left: 0.5rem; right: 0.5rem; width: auto; height: 72vh; }
}
.w-mode-label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; }
.w-mode-label select { font: inherit; font-size: 0.88rem; padding: 0.4rem 0.5rem; border: 1px solid var(--field-line); border-radius: 7px; }
.w-ai .ai-bubble { white-space: normal; }
.w-ai .ai-bubble p { margin: 0 0 0.45em; }
.w-ai .ai-bubble p:last-child { margin-bottom: 0; }
.ai-pending { color: var(--muted); font-style: italic; }
.ai-flag { margin-top: 0.4rem; font-size: 0.74rem; color: var(--warn); font-weight: 600; }
.ai-kb { margin-top: 0.4rem; font-size: 0.74rem; color: var(--olive); }
.ai-sources { margin-top: 0.45rem; border-top: 1px solid var(--border); padding-top: 0.35rem; font-size: 0.76rem; }
.ai-sources-head { font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.05em; }
.ai-source { margin-top: 0.2rem; overflow-wrap: anywhere; }
.ai-source-via { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--border); border-radius: 3px; padding: 0 0.25em; }
.w-ai .ai-bubble ul, .w-ai .ai-bubble ol { margin: 0 0 0.45em; padding-left: 1.2em; }
.w-ai .ai-bubble li { margin: 0.1em 0; }
.ai-sources-note { margin-top: 0.4rem; font-size: 0.72rem; color: var(--muted); }
#w-chat { display: flex; flex-direction: column; gap: 0.5rem; }
#w-chat-input { font: inherit; padding: 0.55rem; border: 1px solid var(--field-line); border-radius: 8px; resize: vertical; }
.w-format { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.6rem 0; padding: 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.w-format label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; font-weight: 600; }
.w-format textarea { font: inherit; font-size: 0.84rem; padding: 0.45rem; border: 1px solid var(--field-line); border-radius: 7px; }
.w-format-preview { font-size: 0.8rem; }
.w-format-current dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.6rem; font-size: 0.76rem; margin: 0.4rem 0 0; }
.w-format-current dt { color: var(--muted); }
.w-format-current dd { margin: 0; }
.ai-flag-list { font-size: 0.78rem; color: var(--warn); }
.ai-flag-list ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.w-pop { position: absolute; z-index: 120; width: 300px; background: var(--field); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-md);
  padding: 0.75rem 0.85rem; font-size: 0.84rem; }
.w-pop-title { font-weight: 700; }
.w-pop-cite { color: var(--ink-soft); font-size: 0.8rem; margin-top: 0.2rem; }
.w-pop-reason { margin-top: 0.45rem; color: var(--violet); font-size: 0.8rem; }
.w-pop-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-top: 0.6rem; }
.w-pop-actions .btn-primary, .w-pop-actions .btn-secondary { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.w-pop-check { display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.8rem; }
.w-toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 150; background: var(--accent-deep); color: var(--on-accent); padding: 0.65rem 1rem;
  border-radius: 10px; box-shadow: var(--shadow-md); font-size: 0.86rem; max-width: min(560px, calc(100% - 2rem)); }
.w-home-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin: 1rem 0; }
.w-new-project { display: flex; gap: 0.5rem; flex: 1; min-width: 280px; }
.w-new-project input { flex: 1; font: inherit; padding: 0.6rem 0.75rem; border: 1px solid var(--field-line); border-radius: 8px; }

/* ---------- Outliner ---------- */
.ol-root .ol-list { list-style: none; margin: 0; padding-left: 1.4rem; }
.ol-root > .ol-list { padding-left: 0; }
.ol-root li { position: relative; }
.ol-root li::before { content: ""; position: absolute; left: -0.95rem; top: 0.78em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-mid); }
.ol-root > .ol-list > li::before { left: -0.95rem; }
.ol-root > .ol-list > li { margin-left: 1rem; }
.ol-text { padding: 0.25rem 0.35rem; border-radius: 5px; outline: none; font-size: 1rem; line-height: 1.5; min-height: 1.5em; font-family: Georgia, serif; }
.ol-text:focus { background: var(--accent-tint); }
.ol-text:empty::before { content: attr(data-placeholder); color: var(--slate); }

/* ---------- Knowledge base page ---------- */
.kb-add-details { margin: 1rem 0 1.4rem; }
.kb-add-details > summary { display: inline-block; list-style: none; cursor: pointer; }
.kb-add-details > summary::-webkit-details-marker { display: none; }
.kb-add-form { margin-top: 0.8rem; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.kb-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.35rem; }
.kb-card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.kb-card h3 { margin: 0; font-size: 1rem; }
.kb-card-img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 8px; }
.kb-cite { margin: 0; font-size: 0.82rem; color: var(--ink-soft); font-family: Georgia, serif; }
.kb-note { margin: 0; font-size: 0.82rem; color: var(--ink-soft); white-space: pre-wrap; }
.kb-card-foot { margin-top: auto; display: flex; gap: 0.8rem; align-items: center; font-size: 0.82rem; }

/* ---------- Print view ---------- */
.compile-content { max-width: 9.5in; }
.compile-bar { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.88rem; }
.compile-actions { float: right; display: inline-flex; gap: 0.8rem; align-items: center; }
.compile-checks { clear: both; margin: 0.6rem 0 0; padding-left: 1.2rem; color: var(--warn); font-size: 0.82rem; }
.page-sheet { background: var(--paper); box-shadow: var(--shadow-md); border-radius: 4px; }
.compiled { color: var(--editor-ink); }
.compiled .lg-citation { background: none; color: inherit; padding: 0; font: inherit; }
.compiled .lg-otrace { font-weight: 600; }
.compiled .trace-ref { font-size: 0.7em; color: var(--accent-ink); }
.compiled .title-page { text-align: center; padding: 30% 0; page-break-after: always; }
.compiled-section + .compiled-section { page-break-before: always; }
.compiled-wc { page-break-before: always; }
.compiled .wc-entry { font-family: inherit; font-size: inherit; text-indent: -2em; padding-left: 2em; }
@media print {
  .no-print, .topbar { display: none !important; }
  .compile-content { max-width: none; padding: 0 !important; margin: 0 !important; }
  .page-sheet { box-shadow: none; padding: 0 !important; }
  body { background: #fff; }
}

/* ---------- Knowledge base: drop to add + review cards ---------- */
.kb-drop { display: flex; flex-direction: column; gap: 0.15rem; align-items: center; text-align: center; margin: 0.5rem 0 0.4rem;
  padding: 0.75rem 0.6rem; border: 1.5px dashed var(--accent-line); border-radius: 10px; background: var(--accent-tint); color: var(--accent-ink); cursor: pointer;
  font-size: 0.82rem; transition: background .15s ease, border-color .15s ease; }
.kb-drop span { color: var(--muted); font-size: 0.74rem; line-height: 1.35; }
.kb-drop:hover, .kb-drop:focus { background: var(--accent-soft); border-color: var(--accent); outline: none; }
.kb-drop-lg { padding: 1.6rem 1.2rem; font-size: 1rem; margin: 1rem 0 0.6rem; }
.kb-drop-lg span { font-size: 0.85rem; max-width: 46rem; }
.kb-quick { display: flex; gap: 0.35rem; margin: 0 0 0.5rem; }
.kb-quick input { flex: 1; min-width: 0; font: inherit; font-size: 0.82rem; padding: 0.4rem 0.55rem; border: 1px solid var(--field-line); border-radius: 7px; }
.kb-quick .btn-secondary { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.kb-import .kb-quick input { font-size: 0.9rem; padding: 0.55rem 0.7rem; }
.kb-review { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.6rem; }
.kbr-card { background: var(--field); border: 1px solid var(--accent-line); border-radius: 10px; padding: 0.65rem 0.7rem; box-shadow: var(--shadow-sm); font-size: 0.8rem; }
.kb-import .kbr-card { padding: 0.9rem 1rem; font-size: 0.88rem; }
.kbr-pending { color: var(--muted); border-style: dashed; }
.kbr-error { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger); }
.kbr-head { display: flex; gap: 0.5rem; align-items: flex-start; justify-content: space-between; }
.kbr-source { font-size: 0.74rem; color: var(--olive); line-height: 1.35; }
.kbr-src-ai, .kbr-src-pdf { color: var(--warn); }
.kbr-x { background: none; border: 0; font-size: 1.1rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 0.15rem; }
.kbr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.5rem; margin: 0.5rem 0; }
.kb-import .kbr-grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
.kb-import .kbr-wide { grid-column: span 2; }
.kbr-grid label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); }
.kbr-wide { grid-column: 1 / -1; }
.kbr-grid input, .kbr-grid select { font: inherit; font-size: 0.8rem; font-weight: 400; padding: 0.3rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; width: 100%; }
.kbr-cite { font-size: 0.74rem; color: var(--muted); }
.kbr-citation { margin-top: 0.15rem; color: var(--ink-soft); font-family: Georgia, serif; font-size: 0.8rem; }
.kbr-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.kbr-actions .btn-primary { padding: 0.3rem 0.8rem; font-size: 0.8rem; }
.kbr-spinner { display: inline-block; width: 0.8em; height: 0.8em; border: 2px solid var(--accent-line); border-top-color: var(--accent); border-radius: 50%; animation: kbr-spin .8s linear infinite; vertical-align: -0.1em; }
@keyframes kbr-spin { to { transform: rotate(360deg); } }
#kb-drop-overlay { display: none; position: fixed; inset: 0; z-index: 300; background: rgba(18, 72, 92, 0.18); backdrop-filter: blur(1px);
  align-items: center; justify-content: center; pointer-events: none; }
#kb-drop-overlay > div { display: flex; flex-direction: column; gap: 0.3rem; align-items: center; background: var(--field); border: 2px dashed var(--accent);
  border-radius: 16px; padding: 2rem 2.6rem; color: var(--accent-ink); box-shadow: var(--shadow-md); }
#kb-drop-overlay span { color: var(--muted); font-size: 0.9rem; }
body.kb-dragging #kb-drop-overlay { display: flex; }

/* ---------- The record (shared: instructor process view, student "My record") ---------- */
.record-card { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; margin: 1rem 0; box-shadow: var(--shadow-sm); }
.record-card h2 { margin: 0 0 0.4rem; font-size: 1rem; }
.record-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.record-head h2 { margin: 0; }
.legend { font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); margin: 0.5rem 0; }
.legend-mini { font-size: 0.74rem; line-height: 1.35; color: var(--muted); margin-top: 0.25rem; max-width: 22rem; }
.reason-list { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-direction: column; gap: 0.45rem; }
.reason-list li { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.88rem; line-height: 1.45; }
.reason-list .signal { flex-shrink: 0; }
.signal.rhythm { background: var(--surface-2); color: var(--ink-soft); border: 1px dashed var(--border-strong); }
.signal-small { font-size: 0.72rem; }
.values-table { border-collapse: collapse; font-size: 0.84rem; margin-top: 0.4rem; }
.values-table th, .values-table td { text-align: left; padding: 0.25rem 0.9rem 0.25rem 0; border-bottom: 1px solid var(--border); }
.values-table th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.evidence-list { margin: 0.3rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; line-height: 1.5; }
.evidence-list li { margin: 0.2rem 0; }
.evidence-list .ev-note { color: var(--warn); }
.evidence-list .ev-ok { color: var(--good); }
.student-note { margin: 0.5rem 0; padding: 0.5rem 0.75rem; border-left: 3px solid var(--accent); background: var(--accent-tint); border-radius: 4px; font-size: 0.9rem; }
.note-form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 40rem; }
.note-form select, .note-form textarea { font: inherit; padding: 0.5rem 0.6rem; border: 1px solid var(--field-line); border-radius: 8px; }
.notice-ok { background: var(--good-soft); color: var(--good); padding: 0.6rem 0.8rem; border-radius: 8px; }
.statement-lines { line-height: 1.55; }
.comp-retyped { background: #a855f7; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 3px, transparent 3px 6px); }
.comp-nokey { background: #0ea5e9; }
.comp-unknown { background: var(--field); background-image: repeating-linear-gradient(90deg, var(--slate) 0 2px, transparent 2px 5px); }
.sw-retyped_ai { background: var(--p-retyped); border-bottom: 3px dashed #a855f7; }
.sw-nokey { background: var(--p-nokey); border-bottom: 3px solid #0ea5e9; }
.prov-retyped_ai { background: var(--p-retyped); box-shadow: inset 0 -2px 0 #a855f7; }
.prov-nokey { background: var(--p-nokey); box-shadow: inset 0 -2px 0 #0ea5e9; }
.prov-doc.hide-retyped_ai .prov-retyped_ai, .prov-doc.hide-nokey .prov-nokey { background: transparent; box-shadow: none; }
.paste-declared { font-size: 0.84rem; margin: 0.3rem 0 0; }
.paste-flag { font-size: 0.84rem; margin: 0.3rem 0 0; color: var(--warn); }
.recently-deleted ul { padding-left: 1.1rem; }
.recently-deleted li { margin: 0.35rem 0; }
.ext-details summary { cursor: pointer; color: var(--accent); font-size: 0.8rem; margin-top: 0.3rem; }
.ext-form { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.3rem; }
.btn-small { padding: 0.3rem 0.65rem !important; font-size: 0.8rem !important; }

/* ---------- Saving, and one window at a time ---------- */
.topbar-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.save-state { font-size: 0.8rem; color: var(--muted); }
.save-state.save-offline, .save-state.save-refused, .save-state.save-taken { color: var(--warn); font-weight: 600; }
.save-state.save-locked, .save-state.save-error { color: var(--danger); font-weight: 600; }
.sync-banner { border-radius: var(--radius); padding: 0.85rem 1rem; margin: 0.75rem 0; border: 1px solid var(--warn-line); background: var(--warn-soft); display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.sync-banner p { margin: 0; font-size: 0.9rem; line-height: 1.45; }
.sync-banner.sync-locked { border-color: var(--danger-line); background: var(--danger-soft); }
.sync-unsaved { width: 100%; min-height: 6rem; font: 0.85rem/1.45 Georgia, serif; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0.5rem; }
.paste-declare { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; padding: 0.55rem 0.8rem; background: var(--accent-tint); border-bottom: 1px solid var(--border); font-size: 0.84rem; }
.paste-declare .pd-choices { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.paste-declare button { border: 1px solid var(--border-strong); background: var(--field); border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.8rem; cursor: pointer; }
.paste-declare button.chosen { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.paste-declare .pd-close { border: none; background: none; font-size: 1.1rem; margin-left: auto; }
.ai-model { margin-top: 0.6rem; }
#ai-select-hint.nudge { color: var(--danger); font-weight: 600; }

/* --- platform: demo accounts, feedback & labs box, theme --- */
.demo-welcome { background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: var(--radius); padding: 0.85rem 1.1rem; margin: 0 0 1.4rem; max-width: 760px; font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); }
.demo-welcome ul { margin: 0.4rem 0 0.4rem 1.1rem; padding: 0; }
.demo-welcome li { margin: 0.2rem 0; }
.role-pill { display: inline-block; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--olive); background: var(--olive-soft); border: 1px solid var(--sage); border-radius: 999px; padding: 0.05rem 0.45rem; margin-left: 0.2rem; vertical-align: 1px; }
.labs-fab { position: fixed; right: 1rem; bottom: 1rem; z-index: 250; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.85rem 0.45rem 0.7rem; border-radius: 999px; border: 1px solid var(--accent-line); background: var(--paper); color: var(--accent); font: 600 0.8rem/1.2 var(--font-body); box-shadow: var(--shadow-md); cursor: pointer; opacity: 0.92; transition: opacity 0.15s, transform 0.15s; }
.labs-fab:hover, .labs-fab:focus-visible, .labs-fab[aria-expanded="true"] { opacity: 1; transform: translateY(-1px); border-color: var(--accent); }
.labs-fab-icon { color: var(--highlight); font-size: 0.95rem; }
.labs-panel { position: fixed; right: 1rem; bottom: 3.6rem; z-index: 251; width: min(360px, calc(100vw - 2rem)); max-height: calc(100vh - 5rem); overflow: auto; background: var(--paper); color: var(--ink); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 0.85rem 1rem 1rem; }
.labs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.labs-head h2 { margin: 0; font: 700 1.02rem var(--font-display); }
.labs-close { border: none; background: none; color: var(--muted); font-size: 1.35rem; line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.labs-close:hover { color: var(--ink); }
.labs-tabs { display: flex; gap: 0.25rem; padding: 0.2rem; background: var(--surface-2); border-radius: 9px; margin-bottom: 0.75rem; }
.labs-tabs button { flex: 1; border: none; background: none; border-radius: 7px; padding: 0.35rem 0.4rem; font: 600 0.78rem var(--font-body); color: var(--ink-soft); cursor: pointer; }
.labs-tabs button[aria-selected="true"] { background: var(--paper); color: var(--accent); box-shadow: var(--shadow-sm); }
.labs-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 0.6rem; }
.labs-field select, .labs-field textarea { font: inherit; font-weight: 400; font-size: 0.88rem; color: var(--ink); background: var(--field); border: 1px solid var(--field-line); border-radius: 8px; padding: 0.45rem 0.55rem; }
.labs-field textarea { resize: vertical; min-height: 6rem; }
.labs-field select:focus, .labs-field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.labs-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.labs-status { font-size: 0.8rem; color: var(--muted); }
.labs-status-good { color: var(--good); }
.labs-status-bad { color: var(--danger); }
.labs-hint { font-size: 0.74rem; color: var(--muted); margin: 0.6rem 0 0; line-height: 1.45; }
.labs-set { border: none; padding: 0; margin: 0 0 0.85rem; }
.labs-set legend { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 0.35rem; padding: 0; }
.labs-seg { display: flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.labs-seg label { flex: 1; text-align: center; font-size: 0.8rem; padding: 0.4rem 0.3rem; cursor: pointer; color: var(--ink-soft); border-left: 1px solid var(--border-strong); position: relative; }
.labs-seg label:first-child { border-left: none; }
.labs-seg input { position: absolute; opacity: 0; pointer-events: none; }
.labs-seg label:has(input:checked) { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.labs-seg label:has(input:focus-visible) { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.labs-modal { position: fixed; inset: 0; z-index: 400; background: rgba(10, 20, 24, 0.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.labs-modal[hidden] { display: none; }
.labs-modal-card { background: var(--paper); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-md); border: 1px solid var(--border); max-width: 640px; width: 100%; padding: 1.1rem 1.25rem 1.2rem; max-height: calc(100vh - 2rem); overflow: auto; }
.labs-modal-card h3 { margin: 0 0 0.35rem; font: 700 1.1rem var(--font-display); }
.labs-modal-text { font-size: 0.86rem; color: var(--ink-soft); margin: 0 0 0.75rem; line-height: 1.5; }
.labs-shot { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); min-height: 9rem; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.labs-shot img { display: block; max-width: 100%; max-height: 50vh; }
.labs-shot-msg { font-size: 0.84rem; color: var(--muted); padding: 1rem; text-align: center; }
.labs-modal-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-top: 0.9rem; }
@media (max-width: 640px) {
  .labs-fab { right: 0.75rem; bottom: 0.75rem; padding: 0.5rem; }
  .labs-fab-label { display: none; }
  .labs-panel { right: 0.5rem; left: 0.5rem; width: auto; bottom: 3.4rem; }
}
@media print { .labs-fab, .labs-panel, .labs-modal { display: none !important; } }
.fb-filter { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0 0 1rem; }
.fb-filter a { padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 0.82rem; color: var(--ink-soft); text-decoration: none; }
.fb-filter a.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fb-filter a span { font-size: 0.72rem; opacity: 0.8; }
.fb-entry { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 0.8rem; box-shadow: var(--shadow-sm); }
.fb-entry.fb-new { border-left: 4px solid var(--highlight); }
.fb-entry header { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: baseline; }
.fb-message { white-space: pre-wrap; margin: 0.5rem 0; font-size: 0.92rem; line-height: 1.5; }
.fb-shot { display: block; max-width: 360px; max-height: 220px; border: 1px solid var(--border); border-radius: 6px; margin: 0.4rem 0; }
.fb-review { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.4rem; }
.fb-review input[type=text] { flex: 1; min-width: 220px; }
.fb-review select, .fb-review input[type=text] { font: inherit; font-size: 0.86rem; padding: 0.4rem 0.55rem; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); color: var(--ink); }
/* --- write: comments, AI report, side notes, KB sorting --- */
/* Ledger Write additions (2026-11-09). Tokens only: open comments in sage,
   the comment in focus in terracotta (--highlight), side notes on mist. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.lg-cmt { border-radius: 2px; }
.lg-toolbar .lg-cmt-btn { color: var(--olive); font-weight: 600; }
.w-cmt-bubble { position: absolute; z-index: 140; border: 1px solid var(--sage); background: var(--field); color: var(--olive); font: 600 0.78rem var(--font-body);
  padding: 0.25rem 0.6rem; border-radius: 999px; box-shadow: var(--shadow-md); cursor: pointer; }
.w-cmt-bubble:hover { background: var(--sage-soft); }
.w-cmt-compose { position: absolute; z-index: 145; width: min(340px, calc(100vw - 16px)); background: var(--field); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 0.7rem; display: flex; flex-direction: column; gap: 0.45rem; }
.w-cmt-compose textarea { font: inherit; font-size: 0.88rem; padding: 0.45rem 0.55rem; border: 1px solid var(--field-line); border-radius: 7px; resize: vertical; background: var(--field); color: var(--ink); }
.w-cmt-compose-quote { font-size: 0.78rem; color: var(--muted); border-left: 3px solid var(--sage); padding-left: 0.5rem; }
.w-cmt-compose-acts { display: flex; gap: 0.4rem; justify-content: flex-end; align-items: center; }
.w-cmt-compose-acts .hint-inline { margin: 0 auto 0 0; font-size: 0.7rem; }
.w-cmt-compose-acts .btn-primary, .w-cmt-compose-acts .btn-secondary { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.w-count { font-weight: 400; color: var(--muted); }

/* the side panel: comment log and AI-use report. On wide screens it takes
   the AI panel's column while open; below 1150px it's a drawer. */
.w-side { position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.6rem); height: calc(100vh - var(--topbar-h, 3.9rem) - 1.6rem); display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
body.w-side-open .w-layout { grid-template-columns: 250px minmax(0, 1fr) 390px; }
body.w-side-open .w-ai { display: none; }
@media (max-width: 1150px) {
  .w-side { position: fixed; top: calc(var(--topbar-h, 3.9rem) + 0.5rem); right: 0.75rem; bottom: 0.75rem; height: auto; z-index: 130; width: min(440px, calc(100vw - 1.5rem)); box-shadow: var(--shadow-md); }
  body.w-side-open .w-layout { grid-template-columns: 220px minmax(0, 1fr); }
  body.w-side-open.w-ai-open .w-ai { display: none; }
}
.w-side-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.9rem 0.5rem; border-bottom: 1px solid var(--border); }
.w-side-head h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.w-side-body { overflow-y: auto; padding: 0.7rem 0.9rem 1rem; flex: 1; }
.sn-x { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 0.2rem; }
.sn-x:hover { color: var(--ink); }
@media (max-width: 760px) { .w-side { top: auto; left: 0.5rem; right: 0.5rem; width: auto; height: 72vh; }
  body.w-side-open .w-layout { grid-template-columns: 1fr; } }

.wc-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.78rem; color: var(--ink-soft); }
.wc-controls label { display: inline-flex; gap: 0.3rem; align-items: center; }
.wc-controls select { font: inherit; font-size: 0.78rem; padding: 0.25rem 0.35rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.wc-summary { margin: 0.35rem 0 0.5rem; }
.wc-list { display: flex; flex-direction: column; gap: 0.6rem; }
.wc-thread { border: 1px solid var(--border); border-left: 3px solid var(--sage); border-radius: 9px; padding: 0.55rem 0.7rem; background: var(--field); cursor: pointer; }
.wc-thread:focus { outline: 2px solid var(--focus-ring); }
.wc-thread.wc-active { border-left-color: var(--highlight); box-shadow: 0 0 0 2px var(--highlight-soft); }
.wc-thread.wc-resolved { border-left-color: var(--border-strong); background: var(--surface); }
.wc-thread.wc-resolved .wc-body { color: var(--muted); }
.wc-thread.wc-detached { border-left-style: dashed; }
.wc-quote { font-size: 0.78rem; color: var(--ink-soft); font-family: Georgia, serif; margin-bottom: 0.35rem; }
.wc-quote-detached { color: var(--muted); font-family: var(--font-body); }
.wc-badge { display: inline-block; font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.05rem 0.4rem; border-radius: 4px;
  background: var(--warn-soft); color: var(--warn); margin-right: 0.25rem; }
.wc-resolved-note { font-size: 0.72rem; color: var(--good); margin-bottom: 0.25rem; }
.wc-msg { padding: 0.3rem 0; }
.wc-msg + .wc-msg { border-top: 1px solid var(--border); margin-left: 0.6rem; }
.wc-meta { font-size: 0.72rem; color: var(--muted); }
.wc-meta strong { color: var(--ink); }
.wc-from { color: var(--accent-ink); }
.wc-body { font-size: 0.88rem; white-space: pre-wrap; line-height: 1.45; margin-top: 0.1rem; }
.wc-msg-acts { display: flex; gap: 0.2rem; }
.wc-msg-acts .link-btn { font-size: 0.72rem; padding: 0.1rem 0.25rem; }
.wc-edit textarea, .wc-reply textarea { width: 100%; font: inherit; font-size: 0.84rem; padding: 0.35rem 0.5rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.wc-reply { display: flex; gap: 0.35rem; align-items: flex-start; margin-top: 0.35rem; }
.wc-reply textarea { flex: 1; min-height: 2rem; resize: vertical; }
.wc-thread-acts { display: flex; justify-content: flex-end; margin-top: 0.35rem; }

/* AI-use report */
.wr-lede { font-size: 0.86rem; color: var(--ink-soft); margin: 0 0 0.6rem; }
.wr-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.8rem; margin: 0 0 0.7rem; background: var(--field); }
.wr-head { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.wr-head h3 { margin: 0; font-size: 0.95rem; }
.wr-tag { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.1rem 0.45rem; border-radius: 4px; }
.wr-tag-record { background: var(--accent-soft); color: var(--accent-ink); }
.wr-tag-reading { background: var(--surface-2); color: var(--ink-soft); border: 1px dashed var(--border-strong); }
.wr-reading { background: var(--surface); }
.wr-note { font-size: 0.78rem; color: var(--muted); margin: 0.4rem 0 0; line-height: 1.45; }
.wr-card p { font-size: 0.86rem; margin: 0.4rem 0; }
.wr-modes { line-height: 1.9; }
.wr-chip { display: inline-block; font-size: 0.74rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); margin-right: 0.2rem; }
.wr-chip-flag { background: var(--warn-soft); color: var(--warn); }
.wr-list { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.84rem; line-height: 1.5; }
.wr-list li { margin: 0.25rem 0; }
.wr-details summary { cursor: pointer; color: var(--accent); font-size: 0.8rem; margin-top: 0.3rem; }
.wr-quote { margin: 0.35rem 0; padding: 0.35rem 0.6rem; border-left: 3px solid var(--violet); background: var(--paste-ai-bg); font-size: 0.82rem; }
.wr-conv { margin: 0.5rem 0; }
.wr-x { border-left: 2px solid var(--border-strong); padding: 0.2rem 0 0.2rem 0.55rem; margin: 0.35rem 0; font-size: 0.82rem; }
.wr-x-ask { color: var(--ink); margin-top: 0.15rem; }
.wr-x-reply { color: var(--muted); margin-top: 0.15rem; }
.wr-src { display: inline-block; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.05rem 0.4rem; border-radius: 4px; background: var(--surface-2); color: var(--ink-soft); }
.wr-src-ai_panel { background: var(--violet-soft); color: var(--violet); }
.wr-src-external { background: var(--warn-soft); color: var(--warn); }
.wr-src-sidenote { background: var(--accent-soft); color: var(--accent-ink); }
.comp-sidenote { background: var(--accent-mid); }
.wr-timeline { list-style: none; margin: 0.4rem 0 0; padding: 0; font-size: 0.8rem; }
.wr-timeline li { padding: 0.22rem 0 0.22rem 0.6rem; border-left: 2px solid var(--border); }
.wr-timeline .wr-t-ai { border-left-color: var(--violet); }
.wr-timeline .wr-t-paste { border-left-color: var(--warn); }
.wr-timeline .wr-t-note { border-left-color: var(--accent-mid); }
.wr-t-time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 0.3rem; white-space: nowrap; }
.wr-page { max-width: 46rem; }

/* side notes: the capture page, cards, sticky notes, the Incorporate window */
.sn-content { max-width: 40rem; }
.sn-lede { margin-top: -0.3rem; }
.sn-form { display: flex; flex-direction: column; gap: 0.6rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; box-shadow: var(--shadow-sm); }
.sn-form textarea { width: 100%; font: 1.05rem/1.5 var(--font-body); padding: 0.7rem 0.8rem; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--ink); resize: vertical; min-height: 8rem; }
.sn-form textarea:focus { outline: 2px solid var(--focus-ring); border-color: var(--accent); }
.sn-form-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; font-size: 0.86rem; }
.sn-file { display: inline-flex; flex-direction: column; gap: 0.2rem; }
.sn-file input { font-size: 0.82rem; max-width: 100%; }
.sn-proj { display: inline-flex; gap: 0.35rem; align-items: center; }
.sn-proj select { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid var(--field-line); border-radius: 8px; background: var(--field); color: var(--ink); max-width: 14rem; }
.sn-save { padding: 0.75rem 1rem; font-size: 1rem; }
.sn-status { margin: 0; font-size: 0.86rem; min-height: 1.2em; }
.sn-status.ok { color: var(--good); }
.sn-status.warn { color: var(--warn); }
.sn-list { display: flex; flex-direction: column; gap: 0.6rem; }
.sn-card { background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: 10px; padding: 0.7rem 0.8rem; }
.sn-card-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; margin-bottom: 0.4rem; }
.sn-card-text { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.45; }
.sn-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: 0.45rem; flex-wrap: wrap; }
@media (max-width: 760px) {
  .sn-content { padding: 1rem 1rem 3rem; }
  .sn-content h1 { font-size: 1.6rem; }
  .sn-form-row { flex-direction: column; align-items: stretch; }
  .sn-proj select { max-width: none; flex: 1; }
}
.w-stickies { display: flex; flex-direction: column; gap: 0.45rem; }
.w-sticky { position: relative; background: var(--accent-tint); border: 1px solid var(--accent-line); border-radius: 4px 10px 4px 4px; padding: 0.45rem 0.55rem 0.3rem;
  box-shadow: var(--shadow-sm); font-size: 0.82rem; }
.w-sticky::after { content: ""; position: absolute; top: -1px; right: -1px; width: 12px; height: 12px; background: linear-gradient(225deg, var(--paper) 50%, var(--accent-line) 50%); border-radius: 0 10px 0 0; }
.w-sticky-text { white-space: pre-wrap; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.w-sticky-acts { display: flex; gap: 0.2rem; justify-content: flex-end; }
.w-sticky-acts .link-btn { font-size: 0.74rem; }
.sn-modal { position: fixed; inset: 0; z-index: 200; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 0.75rem; overflow-y: auto; }
.sn-dialog { width: min(640px, 100%); background: var(--paper); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-md); }
.sn-dialog-head { display: flex; align-items: center; padding: 0.8rem 1rem 0.4rem; }
.sn-dialog-head h2 { margin: 0; flex: 1; font-size: 1.15rem; }
.sn-dialog-body { padding: 0 1rem 1rem; font-size: 0.88rem; }
.sn-scanning { color: var(--muted); }
.sn-note-text { margin: 0.2rem 0 0.7rem; padding: 0.55rem 0.75rem; background: var(--accent-tint); border-left: 3px solid var(--accent); border-radius: 4px; white-space: pre-wrap; }
.sn-match { padding: 0.5rem 0.65rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.sn-match-strong { background: var(--good-soft); border-color: var(--good-line); }
.sn-match-none { background: var(--warn-soft); border-color: var(--warn-line); }
.sn-conf { font-weight: 700; }
.sn-ai-pick { margin: 0.35rem 0 0; color: var(--violet); }
.sn-kb { margin: 0.5rem 0 0; }
.sn-where { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.7rem 0 0.4rem; }
.sn-where label, .sn-opt-pos label { display: flex; flex-wrap: wrap; gap: 0.2rem 0.35rem; align-items: center; font-size: 0.82rem; min-width: 0; }
.sn-where select, .sn-opt-pos select { font: inherit; font-size: 0.82rem; padding: 0.3rem 0.4rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); min-width: 0; max-width: 100%; }
.sn-opt-pos select { flex: 1 1 14rem; }
.sn-options { border: 0; margin: 0.4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.sn-options legend { font-weight: 700; margin-bottom: 0.3rem; padding: 0; }
.sn-opt { border: 1px solid var(--border); border-radius: 9px; padding: 0.45rem 0.6rem; background: var(--field); }
.sn-opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.sn-opt-off { opacity: 0.55; }
.sn-opt-head { display: flex; gap: 0.4rem; align-items: center; cursor: pointer; }
.sn-rec { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--on-accent); background: var(--accent); padding: 0.05rem 0.4rem; border-radius: 4px; }
.sn-opt-what { margin-left: 1.5rem; }
.sn-opt-pos { margin: 0.25rem 0 0 1.5rem; }
.sn-opt-why { margin-left: 1.5rem; color: var(--olive); }
.sn-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.8rem; }
.sn-spacer { flex: 1; }

/* knowledge base: kinds, categories, tags, sorting */
.kb-title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.kb-title-row h1 { margin-bottom: 0.4rem; }
.kb-filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; margin: 1.2rem 0 0.6rem; padding: 0.6rem 0.75rem; background: var(--paper);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.82rem; color: var(--ink-soft); }
.kb-filters label { display: inline-flex; gap: 0.3rem; align-items: center; }
.kb-filters input[type="search"] { flex: 1; min-width: 12rem; font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--field-line); border-radius: 7px; background: var(--field); color: var(--ink); }
.kb-filters select { font: inherit; font-size: 0.82rem; padding: 0.3rem 0.4rem; border: 1px solid var(--field-line); border-radius: 7px; background: var(--field); color: var(--ink); max-width: 14rem; }
.kb-chiprow { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.4rem 0; }
.kb-chiprow-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 0.2rem; }
.kb-chip { display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.8rem; padding: 0.2rem 0.65rem; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--field); color: var(--ink-soft); text-decoration: none; }
.kb-chip span { color: var(--muted); font-size: 0.72rem; }
.kb-chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.kb-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.kb-chip.on span { color: var(--on-accent); opacity: 0.8; }
.kb-chip-cat { border-style: dashed; }
.kb-cat-new { display: inline-flex; gap: 0.3rem; }
.kb-cat-new input { font: inherit; font-size: 0.8rem; padding: 0.2rem 0.5rem; border: 1px solid var(--field-line); border-radius: 999px; width: 10rem; background: var(--field); color: var(--ink); }
.kb-group-head { font-size: 1.1rem; margin: 1.4rem 0 0.6rem; }
.kb-meta-edit { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: center; font-size: 0.76rem; color: var(--muted); margin-top: 0.2rem; }
.kb-meta-edit label { display: inline-flex; gap: 0.25rem; align-items: center; }
.kb-meta-edit select, .kb-meta-edit input { font: inherit; font-size: 0.76rem; padding: 0.15rem 0.35rem; border: 1px solid var(--border); border-radius: 5px; background: var(--field); color: var(--ink); }
.kb-meta-edit input { width: 11rem; }
.kb-meta-edit select:hover, .kb-meta-edit input:hover { border-color: var(--border-strong); }
.kb-saved { color: var(--good); }
.kb-card-sidenote { background: var(--accent-tint); border-color: var(--accent-line); }
.w-kb-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; margin: 0.35rem 0 0.2rem; }
.w-kb-filters select { font: inherit; font-size: 0.74rem; padding: 0.2rem 0.25rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); min-width: 0; }
.w-kb-cat { display: inline-block; font-size: 0.6rem; font-weight: 600; color: var(--olive); background: var(--sage-soft); padding: 0 0.35rem; border-radius: 4px; }
.w-kb-sidenote { background: var(--accent-tint); border-radius: 6px; padding-left: 0.35rem; }
.w-kb-sidenote .w-kb-title { font-weight: 500; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* phones: the workspace is one column, so its left panel scrolls with the page (sticky, it covered the editor) */
@media (max-width: 760px) { .w-left { position: static; max-height: none; } }
/* Knowledge-base import review card: match confidence, AI-allowance note,
   and the BibTeX disclosure (static/js/kb_import.js). Uses style.css tokens. */

.kbr-conf { display: inline-block; font-size: 0.68rem; font-weight: 600; line-height: 1.2; padding: 0.08rem 0.4rem; border-radius: 999px; margin-right: 0.25rem; vertical-align: 0.05em; }
.kbr-conf-high { color: var(--good); background: var(--good-soft); }
.kbr-conf-medium { color: var(--sky); background: var(--sky-soft); }
.kbr-conf-low { color: var(--warn); background: var(--warn-soft); }
.kbr-src-openalex, .kbr-src-semantic_scholar { color: var(--sky); }
.kbr-ai-note { display: block; margin-top: 0.15rem; color: var(--muted); }

.kbr-bib { margin-top: 0.45rem; font-size: 0.74rem; }
.kbr-bib > summary { cursor: pointer; color: var(--ink-soft); font-weight: 600; width: max-content; }
.kbr-bibtex { margin: 0.3rem 0 0.2rem; padding: 0.45rem 0.55rem; max-height: 14rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 0.72rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.kbr-copy { font-size: 0.72rem; }
/* --- editor: math, tables, paged --- */
.lg-editor { position: relative; }
.lg-toolbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); }
.lg-toolbar .lg-mathview-btn { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; }
/* the math source being edited (CSS Custom Highlight: no markup) */
::highlight(lg-math-src) { background-color: var(--accent-soft); color: var(--accent-ink); }
.lg-math-verbatim .lg-math[data-display="1"] { text-align: left; }

/* tables: in the editor, the instructor's document view and Write's print view */
.lg-editable table, .compiled table { border-collapse: collapse; width: 100%; table-layout: fixed; margin: 0.9rem 0; font-size: 0.95em; line-height: 1.5; }
.lg-editable td, .lg-editable th, .compiled td, .compiled th { border: 1px solid var(--border-strong); padding: 0.35rem 0.55rem; vertical-align: top; text-align: left; overflow-wrap: anywhere; }
.lg-editable th, .compiled th { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.lg-editable td p, .lg-editable th p { margin: 0; }
.compiled tr { page-break-inside: avoid; break-inside: avoid; }

/* table picker (toolbar) and the table's own controls */
.lg-table-picker { position: absolute; z-index: 60; width: 290px; background: var(--field); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 0.45rem; font-family: var(--font-body); font-size: 0.82rem; color: var(--ink); }
.lg-tp-head { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0.2rem 0.35rem 0.4rem; }
.lg-tp-opt { display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; color: inherit;
  border-radius: 8px; padding: 0.5rem; cursor: pointer; font: inherit; }
.lg-tp-opt:hover, .lg-tp-opt:focus-visible { background: var(--accent-tint); border-color: var(--accent-line); outline: none; }
.lg-tp-grid { display: inline-flex; flex-direction: column; gap: 2px; flex: none; }
.lg-tp-row { display: flex; gap: 2px; }
.lg-tp-cell { width: 14px; height: 9px; border: 1px solid var(--border-strong); background: var(--paper); border-radius: 1px; }
.lg-tp-headcell { background: var(--accent-soft); border-color: var(--accent-line); }
.lg-tp-label { display: flex; flex-direction: column; gap: 0.1rem; }
.lg-tp-label span { color: var(--muted); font-size: 0.76rem; }
.lg-tp-foot { color: var(--muted); font-size: 0.72rem; line-height: 1.45; padding: 0.4rem 0.35rem 0.15rem; border-top: 1px solid var(--border); margin-top: 0.3rem; }
.lg-table-bar { position: absolute; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: 1px; padding: 3px; background: var(--field);
  border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-md); font-family: var(--font-body); max-width: calc(100% - 8px); }
.lg-table-bar button { border: 0; background: transparent; color: var(--ink-soft); font: 500 0.72rem/1 var(--font-body); padding: 0.32rem 0.45rem; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.lg-table-bar button:hover { background: var(--accent-soft); color: var(--accent-deep); }
.lg-table-bar button.lg-tb-danger:hover { background: var(--danger-soft); color: var(--danger); }
.lg-tb-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }

/* page view: letter-size pages (8.5 × 11 in, 1 in margins) with a gap at
   every page break — set by html[data-layout="paged"]; screen only, so
   printing is unchanged. The editor scales the page to fit (--lg-page-zoom)
   and rounds the last page up to a whole page. */
@media screen {
  html[data-layout="paged"] .editor-pane { background: transparent; border-color: transparent; box-shadow: none; overflow: visible; }
  html[data-layout="paged"] .lg-editor { overflow-x: clip; }   /* not auto: a scroll box would keep the toolbar from sticking */
  html[data-layout="paged"] .lg-toolbar, html[data-layout="paged"] .lg-editor-footer { border-radius: 8px; border: 1px solid var(--border); }
  html[data-layout="paged"] .lg-editable {
    --lg-page-h: 11in;
    --lg-page-gap: 28px;
    zoom: var(--lg-page-zoom, 1);
    box-sizing: border-box; flex: none; width: 8.5in; max-width: none; margin: 1.25rem auto; padding: 1in;
    min-height: var(--lg-page-h);
    background: repeating-linear-gradient(to bottom,
      var(--paper) 0, var(--paper) calc(var(--lg-page-h) - 1px),
      var(--border-strong) calc(var(--lg-page-h) - 1px), var(--border-strong) var(--lg-page-h),
      var(--bg) var(--lg-page-h), var(--bg) calc(var(--lg-page-h) + var(--lg-page-gap) - 1px),
      var(--border-strong) calc(var(--lg-page-h) + var(--lg-page-gap) - 1px), var(--border-strong) calc(var(--lg-page-h) + var(--lg-page-gap)));
    box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
  }
  html[data-layout="paged"] .lg-editable:focus { box-shadow: 0 0 0 1px var(--accent-line), var(--shadow-md); }
}
/* The Feedback & labs button sits in the bottom-right corner: let side
   panels scroll their last item clear of it. */
.w-side-body { padding-bottom: 3.6rem; }

/* ---------- Long unbroken text (2026-11-10 feedback #1) ----------
   Web addresses, DOIs and long titles have no spaces to break at; grid and
   flex children default to min-width: auto, so they pushed past the card. */
.kb-grid > *, .kb-card, .kb-card > *, .kbr-card, .w-kb-item, .w-kb-item > *, .kb-card-foot > * { min-width: 0; }
.kb-card h3, .kb-cite, .kb-note, .kb-card-foot a, .w-kb-title, .w-kb-item, .kbr-citation, .kbr-source,
.wc-entry, .compiled .wc-entry { overflow-wrap: anywhere; }
.kb-meta-edit input, .kb-meta-edit select, .kbr-grid input, .kbr-grid select { max-width: 100%; min-width: 0; }

/* ---------- Citation style picker (Write) ---------- */
.wc-style-row { display: flex; justify-content: flex-end; margin-top: 1rem; font-size: 0.82rem; color: var(--ink-soft); }
.wc-style-row label { display: flex; gap: 0.4rem; align-items: center; }
.wc-style-row select { font: inherit; padding: 0.2rem 0.4rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.wc-style-row + .works-cited { margin-top: 0.4rem; }

/* ---------- Write projects page: sortable columns (2026-11-10 feedback #3) ---------- */
.w-proj-sort { display: block; margin-top: 0.2rem; }
.data-table th a.th-sort { color: inherit; text-decoration: none; }
.data-table th a.th-sort:hover { color: var(--accent); text-decoration: underline; }
.data-table th a.th-sort.on { color: var(--ink); }
.w-home-kb { margin-top: 1.5rem; }

/* ---------- Shelves (2026-11-10): projects page and knowledge base ----------
   Rows of cards on a sage plank; drag between shelves or use a card's ⋯ menu. */
.shelves-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.8rem; margin-top: 1.4rem; }
.shelves-bar .section-heading { margin: 0; }
.shelves-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; font-size: 0.84rem; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg-btn { padding: 0.4rem 0.85rem; background: var(--paper); color: var(--ink); text-decoration: none; font-weight: 500; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg-btn:hover:not(.on) { background: var(--accent-tint); }
.shelves-sort label { display: inline-flex; gap: 0.4rem; align-items: center; color: var(--ink-soft); }
.shelves-sort select, .shelf-menu select, .shelf-menu input { font: inherit; font-size: 0.84rem; padding: 0.3rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.shelf-new { position: relative; }
.shelf-new > summary { list-style: none; cursor: pointer; }
.shelf-new > summary::-webkit-details-marker { display: none; }
.shelf-new-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; display: flex; gap: 0.4rem; padding: 0.6rem; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md, 0 6px 20px rgba(0,0,0,0.12)); width: max-content; max-width: 86vw; }
.shelf-new-form input { font: inherit; font-size: 0.86rem; padding: 0.35rem 0.5rem; border: 1px solid var(--field-line); border-radius: 6px; min-width: 14rem; background: var(--field); color: var(--ink); }
.shelf-msg { margin: 0.4rem 0 0; }
.shelves { margin-top: 1rem; }
.shelves-intro { margin: 0 0 1rem; }
.shelf { margin-bottom: 1.9rem; border-radius: 12px; transition: background 0.12s; }
.shelf-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; margin-bottom: 0.6rem; }
.shelf-name { margin: 0; font-family: var(--font-body); font-size: 0.95rem; font-weight: 700; color: var(--olive); }
.shelf-count { font-size: 0.76rem; color: var(--muted); }
.shelf-head .shelf-menu { margin-left: auto; }
.shelf-row { display: flex; gap: 1rem; overflow-x: auto; padding: 0.25rem 0.25rem 0.35rem; min-height: 8.6rem; scroll-snap-type: x proximity; }
.shelf-plank { height: 10px; margin-top: 0.55rem; border-radius: 3px; background: var(--sage); box-shadow: 0 3px 0 color-mix(in srgb, var(--sage) 72%, #000); }
.shelf-card { position: relative; flex: 0 0 13.2rem; min-width: 0; min-height: 8.2rem; box-sizing: border-box; display: flex; flex-direction: column; gap: 0.3rem; padding: 0.95rem 1rem 0.85rem; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); scroll-snap-align: start; cursor: grab; overflow-wrap: anywhere; }
.shelf-card:hover { border-color: var(--border-strong); }
.shelf-card:focus-within { border-color: var(--accent); }
.shelf-card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.25; color: var(--ink); text-decoration: none; padding-right: 1.4rem; }
.shelf-card-title::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }     /* the whole card opens it */
.shelf-card-title:hover { color: var(--accent); }
.shelf-card-meta { font-size: 0.76rem; color: var(--muted); }
.shelf-card-meta:first-of-type { margin-top: auto; }
.shelf-card .w-kb-kind { margin: 0; }
.shelf-card-cite { font-size: 0.74rem; color: var(--ink-soft); }
.shelf-card-actions { position: relative; z-index: 2; display: flex; gap: 0.6rem; align-items: center; font-size: 0.76rem; }
.shelf-card-dragging { opacity: 0.45; }
.shelf-card-saving { opacity: 0.6; pointer-events: none; }
.shelves-dragging .shelf-card { cursor: grabbing; }
.shelf-empty { flex: 0 0 13.2rem; min-height: 8.2rem; box-sizing: border-box; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0.8rem; border: 2px dashed var(--sage); border-radius: 10px; color: var(--olive); font-size: 0.8rem; background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.shelf-empty[hidden] { display: none; }
.shelf-drop-target { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); outline: 2px dashed var(--accent); outline-offset: 4px; }
.shelf-loose { padding: 0.9rem 1rem 1rem; border: 1px dashed var(--border-strong); background: color-mix(in srgb, var(--paper) 60%, transparent); }
.shelf-loose .shelf-name { color: var(--ink-soft); font-weight: 600; }
.shelf-loose .shelf-row { flex-wrap: wrap; overflow: visible; min-height: 0; }
.shelf-loose-hint { margin-left: 0.2rem; }
.shelf-loose.shelf-drop-target { outline-offset: 2px; }
/* ⋯ menus */
.shelf-menu { position: relative; }
.shelf-menu > summary { list-style: none; cursor: pointer; min-width: 2rem; min-height: 2rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); font-weight: 700; font-size: 1.05rem; line-height: 1; }
.shelf-menu > summary::-webkit-details-marker { display: none; }
.shelf-menu > summary:hover, .shelf-menu[open] > summary { background: var(--accent-tint); color: var(--ink); }
.shelf-card-menu { position: absolute; top: 0.45rem; right: 0.35rem; z-index: 3; }
.shelf-menu-body { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; display: flex; flex-direction: column; align-items: flex-start; gap: 0.55rem; padding: 0.75rem 0.85rem; min-width: 14rem; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md, 0 6px 20px rgba(0,0,0,0.12)); font-size: 0.84rem; cursor: default; }
.shelf-menu-body form { margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.shelf-menu-body label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); }
.shelf-rename input { width: 11rem; }
@media (max-width: 640px) {
  .shelf-card, .shelf-empty { flex-basis: 11.5rem; }
  .shelves-controls { width: 100%; }
}

/* ---------- To-dos in the editor (2026-11-10, feedback #6) ----------
   <ul class="lg-todo"><li data-tid data-state="todo|doing|done">. The box is
   drawn in the item's left margin; clicking it checks the item off. */
ul.lg-todo { list-style: none; padding-left: 1.75em; }
ul.lg-todo > li { position: relative; }
ul.lg-todo > li::before { content: ""; position: absolute; left: -1.62em; top: 0.22em; font: 700 0.9em/1 var(--font-body); width: 1.06em; height: 1.06em; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 1.6px solid var(--olive); border-radius: 3px; background: var(--paper); color: #fff; cursor: pointer; }
ul.lg-todo > li[data-state="doing"]::before { background: linear-gradient(135deg, var(--sage) 50%, var(--paper) 50%); }
ul.lg-todo > li[data-state="done"]::before { content: "✓"; background: var(--accent); border-color: var(--accent); }
ul.lg-todo > li[data-state="done"] { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }

/* ---------- Focus view in Write (2026-11-10, feedback #7) ---------- */
.w-doc-head { position: relative; }
.w-head-btns { position: absolute; top: 0.15rem; right: 0; display: flex; gap: 0.4rem; }
.w-doc-head .w-doc-title { padding-right: 7.5rem; }
@media (max-width: 1150px) { .w-doc-head .w-doc-title { padding-right: 15rem; } body.w-focus .w-doc-head .w-doc-title { padding-right: 7.5rem; } }
body.w-focus .w-ai-toggle { display: none !important; }
body.w-focus .w-left, body.w-focus .w-ai, body.w-focus .w-side, body.w-focus .w-layers { display: none !important; }
body.w-focus .w-layout { grid-template-columns: minmax(0, 1fr) !important; max-width: 50rem; margin: 0 auto; }
body.w-focus .w-focus-btn { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- Tasks (2026-11-10): goals on a shelf, a To do · Doing · Done board ----------
   /writer/tasks (templates/writer/tasks.html). Built from the shelves above: the same cards,
   ⋯ menus, sage plank and drop targets (static/js/shelves.js + tasks.js). Tokens only;
   overdue dates in terracotta (--highlight). Columns stack at phone width. */
.tasks-msg { margin-top: 0.2rem; }
.tasks-inline-label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.tasks-inline-label input, .tasks-inline-label select, .tasks-add input, .tasks-filters select {
  font: inherit; font-size: 0.86rem; font-weight: 400; padding: 0.38rem 0.5rem; border: 1px solid var(--field-line);
  border-radius: 7px; background: var(--field); color: var(--ink); min-width: 0;
}
.tasks-add input:focus, .tasks-add select:focus, .tasks-filters select:focus, .goal-new-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring);
}
.goal-new-form { flex-wrap: wrap; align-items: center; }
.goal-new-form input[name="title"] { min-width: 15rem; }
/* goals */
.goals-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.8rem; padding: 0.25rem 0.25rem 0.35rem; }
.goal-card { position: relative; flex: 0 1 15rem; min-width: 12rem; min-height: 7.4rem; display: flex; flex-direction: column; gap: 0.32rem; padding: 0.9rem 1rem 0.85rem; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
.goal-card:hover { border-color: var(--border-strong); }
.goal-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.goal-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.25; color: var(--ink); text-decoration: none; padding-right: 1.6rem; }
.goal-title:hover { color: var(--accent); }
.goal-meta { font-size: 0.76rem; color: var(--muted); }
.goal-progress { margin-top: auto; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.goal-bar { display: block; height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.goal-bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.25s ease; }
.goal-achieved { background: var(--sage-soft); border-color: color-mix(in srgb, var(--sage) 60%, transparent); }
.goal-achieved .goal-title, .goal-achieved-label { color: var(--olive); }
.goal-achieved-label { font-weight: 600; }
.goal-achieved .goal-bar-fill { background: var(--olive); }
.goals-row .goals-empty { flex: 1 1 22rem; max-width: 34rem; min-height: 6rem; }
/* the board */
.tasks-board .shelves-bar { margin-top: 2rem; }
.tasks-filters label { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink-soft); }
.tasks-clear { font-size: 0.8rem; }
.tasks-add { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 0.8rem; margin: 0.9rem 0 1rem; padding: 0.7rem 0.8rem; background: var(--paper); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.tasks-add-text { flex: 1 1 20rem; display: flex; min-width: 0; }
.tasks-add-text input { flex: 1; min-width: 0; padding: 0.5rem 0.65rem; font-size: 0.92rem; }
.tasks-empty { max-width: 760px; margin: 0 0 1rem; padding: 0.9rem 1.1rem; border: 1px dashed var(--sage); border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 35%, transparent); color: var(--ink-soft); font-size: 0.9rem; line-height: 1.55; }
.tasks-empty p { margin: 0; }
.tboard { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; margin-top: 0; }
.tcol { margin: 0; padding: 0.75rem 0.75rem 0.85rem; background: color-mix(in srgb, var(--paper) 55%, transparent); border: 1px solid var(--border); border-top: 4px solid var(--sage); border-radius: 12px; }
.tcol-doing { border-top-color: var(--accent-mid); }
.tcol-done { border-top-color: var(--olive); }
.tcol .shelf-head { margin-bottom: 0.55rem; }
.tcol-more { margin-left: auto; font-size: 0.74rem; color: var(--muted); }
a.tcol-more { color: var(--accent); }
.tcol .shelf-row { flex-direction: column; gap: 0.6rem; overflow: visible; min-height: 5.5rem; padding: 0; scroll-snap-type: none; }
.tcol .shelf-card { flex: 0 0 auto; min-height: 0; display: grid; grid-template-columns: 1.35rem minmax(0, 1fr); column-gap: 0.6rem; row-gap: 0.3rem; align-items: start; padding: 0.7rem 2.3rem 0.7rem 0.75rem; }
.tcol .shelf-empty { flex: 0 0 auto; min-height: 5rem; }
.tcol .shelf-card-menu { top: 0.35rem; right: 0.3rem; }
.tcard-check-form { grid-row: 1 / span 2; margin: 0; }
.tcard-check { display: inline-flex; align-items: center; justify-content: center; width: 1.3rem; height: 1.3rem; margin-top: 0.05rem; padding: 0; border: 2px solid var(--sage); border-radius: 5px; background: var(--field); color: transparent; font-size: 0.78rem; font-weight: 800; line-height: 1; cursor: pointer; }
.tcard-check:hover, .tcard-check:focus-visible { border-color: var(--accent); color: var(--accent-mid); }
.tcard-check:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.tcol-doing .tcard-check { border-color: var(--accent-mid); background: color-mix(in srgb, var(--accent-soft) 70%, var(--field)); }
.tcol-done .tcard-check { border-color: var(--olive); background: var(--olive); color: var(--on-accent); }
.tcard-text { margin: 0; font-size: 0.92rem; line-height: 1.38; color: var(--ink); }
.tcol-done .tcard-text { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }
.tcard-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.55rem; font-size: 0.74rem; color: var(--muted); }
.tcard-src { color: var(--muted); }
a.tcard-src { text-decoration: none; }
a.tcard-src:hover { color: var(--accent); text-decoration: underline; }
.tcard-goal { display: inline-block; max-width: 100%; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--sage-soft); border: 1px solid color-mix(in srgb, var(--sage) 60%, transparent); color: var(--olive); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-goal:hover { border-color: var(--olive); }
.tcard-due { color: var(--ink-soft); }
.tcard-overdue { color: var(--highlight); font-weight: 600; }
.tcard-open { font-size: 0.84rem; }
.tcard-file-note { max-width: 15rem; margin: 0; }
@media (max-width: 860px) { .tboard { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .tasks-add { padding: 0.6rem; }
  .tasks-add-text { flex-basis: 100%; }
  .goal-card { flex: 1 1 100%; }
  .goal-new-form input[name="title"] { min-width: 0; width: 100%; }
}

/* ---------- Top bar on a phone (2026-11-10): Write's nav has five links now;
   let them wrap instead of pushing "Switch" off the screen. ---------- */
@media (max-width: 640px) {
  .nav { flex-wrap: wrap; row-gap: 0.25rem; margin-left: 0; width: 100%; }
}

/* ---------- Zotero (2026-11-10): the knowledge base's bar, item badges, the settings page ---------- */
.zot-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin-top: 0.75rem; padding: 0.55rem 0.8rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 0.9rem; }
.zot-name { font-weight: 700; }
.zot-status { color: var(--muted); flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.zot-bar-actions { display: flex; align-items: center; gap: 0.75rem; }
.zot-offer { margin: 0.6rem 0 0; }
.zot-badge { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent-mid); border: 1px solid var(--accent-soft); background: var(--surface); border-radius: 4px; padding: 0 0.3rem; }
.kb-kind-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin: 0; }
.kb-kind-row .w-kb-kind { margin: 0; }
.zot-removed { color: var(--danger); }
.zot-offered { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.5rem; margin: 0.25rem 0 0; }
.zot-offered code, .zot-status code { overflow-wrap: anywhere; }
.zot-lede { max-width: 46rem; }
.zot-steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.92rem; }
.zot-key-form { display: flex; flex-direction: column; gap: 0.75rem; }
.zot-key-form input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
.zot-settings { max-width: 46rem; display: flex; flex-direction: column; gap: 0.75rem; }
.zot-settings h2, .zot-disconnect h2 { font-size: 1.1rem; margin: 0.75rem 0 0; }
.zot-lib { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.9rem 0.8rem; margin: 0; background: var(--paper); }
.zot-lib legend { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.6rem; padding: 0 0.3rem; }
.zot-lib-name { font-weight: 700; }
.zot-check { display: flex; align-items: baseline; gap: 0.45rem; font-size: 0.92rem; line-height: 1.35; }
.zot-check input { flex: none; margin: 0; position: relative; top: 0.12em; }
.zot-scope { display: flex; flex-direction: column; gap: 0.4rem; }
.zot-colls { list-style: none; margin: 0.2rem 0 0; padding: 0.4rem 0.6rem; max-height: 22rem; overflow: auto; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 0.25rem; }
.zot-depth-1 { padding-left: 1.2rem; } .zot-depth-2 { padding-left: 2.4rem; } .zot-depth-3 { padding-left: 3.6rem; }
.zot-depth-4, .zot-depth-5, .zot-depth-6 { padding-left: 4.8rem; }
.zot-off { opacity: 0.45; }
.zot-actions { margin-top: 0.25rem; }
.zot-how { max-width: 46rem; margin: 1rem 0; font-size: 0.92rem; }
.zot-how summary { cursor: pointer; font-weight: 600; }
.zot-how ul { margin: 0.5rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.35rem; }
.zot-inline { margin: 0.75rem 0; }
.zot-inline p { margin: 0; }
.zot-disconnect { max-width: 46rem; margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.zot-disconnect form { display: flex; flex-direction: column; gap: 0.45rem; align-items: flex-start; margin-top: 0.5rem; }
.zot-off-btn { color: var(--danger); }
@media (max-width: 560px) { .zot-depth-1, .zot-depth-2, .zot-depth-3, .zot-depth-4, .zot-depth-5, .zot-depth-6 { padding-left: 0.9rem; } }

/* Two windows on one Write file (feedback #8, 2026-11-13) */
.w-conflict { background: var(--highlight-soft); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 0.8rem; }
.w-conflict p { margin: 0 0 0.5rem; }
.w-conflict-acts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.4rem; }
.w-conflict .hint-inline { margin: 0; font-size: 0.8rem; }

/* Tasks board: drag a card up or down a column (feedback #9, 2026-11-13) */
.shelf-insert { height: 3px; border-radius: 3px; background: var(--accent); margin: -1px 0; pointer-events: none; }
.tcard-order { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ---------- Tasks: boards, tags, subtasks (2026-11-16) ----------
   Tag colours are tokens (--tag-<key>, keys from services/tasks.py TAG_COLORS); a .tag-<key>
   class sets --tc, which chips, card stripes and Mahjong tiles all read. */
:root {
  --tag-petrol: #165A72; --tag-sky: #3d7fb0; --tag-teal: #2e8a7a; --tag-sage: #7d8c5c; --tag-olive: #4f5a22;
  --tag-gold: #a87b1e; --tag-terracotta: #b5552f; --tag-rose: #b4546e; --tag-plum: #6b4a7a; --tag-slate: #5c666b;
  --felt: #2e4f3e; --felt-2: #23402f; --tile-face: #fbf6e8; --tile-face-done: #e4dfcf; --tile-ink: #1b2629; --tile-edge: #b9ab84;
}
:root[data-theme="dark"] {
  --tag-petrol: #5fa8c4; --tag-sky: #7db4e0; --tag-teal: #6cc7b6; --tag-sage: #a3ae8a; --tag-olive: #b8c27c;
  --tag-gold: #e0b552; --tag-terracotta: #e08a63; --tag-rose: #e28aa2; --tag-plum: #b892c8; --tag-slate: #a3adb2;
  --felt: #1c3227; --felt-2: #14261d; --tile-face: #e9e2cf; --tile-face-done: #a9a493; --tile-ink: #1b2629; --tile-edge: #8f8467;
}
.tag-petrol { --tc: var(--tag-petrol); } .tag-sky { --tc: var(--tag-sky); } .tag-teal { --tc: var(--tag-teal); }
.tag-sage { --tc: var(--tag-sage); } .tag-olive { --tc: var(--tag-olive); } .tag-gold { --tc: var(--tag-gold); }
.tag-terracotta { --tc: var(--tag-terracotta); } .tag-rose { --tc: var(--tag-rose); } .tag-plum { --tc: var(--tag-plum); }
.tag-slate { --tc: var(--tag-slate); }
.tag-chip { display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%; padding: 0.04rem 0.5rem; border-radius: 999px;
  background: color-mix(in srgb, var(--tc, var(--sage)) 15%, var(--paper)); border: 1px solid color-mix(in srgb, var(--tc, var(--sage)) 55%, transparent);
  color: var(--ink); font-size: 0.72rem; font-weight: 600; line-height: 1.5; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-chip::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--tc, var(--sage)); }
a.tag-chip:hover { border-color: var(--tc); }
.tag-swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 4px; background: var(--tc); flex: none; }

/* boards */
.board-tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.3rem; margin: 0.9rem 0 0; padding: 0 0.1rem; border-bottom: 1px solid var(--border-strong); }
.board-tab { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.85rem; margin-bottom: -1px; border: 1px solid transparent;
  border-radius: 9px 9px 0 0; color: var(--ink-soft); font-weight: 500; font-size: 0.9rem; text-decoration: none; }
.board-tab:hover { color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.board-tab.on { background: var(--paper); border-color: var(--border-strong); border-bottom-color: var(--paper); color: var(--ink); font-weight: 650; }
.board-tab-n { min-width: 1.25rem; padding: 0 0.35rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.7rem; font-weight: 600; text-align: center; }
.board-new { align-self: center; margin-left: 0.4rem; }
.board-new summary { list-style: none; cursor: pointer; font-size: 0.86rem; }
.board-new summary::-webkit-details-marker { display: none; }
.board-new[open] { flex-basis: 100%; order: 10; margin: 0.5rem 0; }
.board-new-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.45rem; }
.board-new-form input { font: inherit; font-size: 0.88rem; padding: 0.4rem 0.55rem; border: 1px solid var(--field-line); border-radius: 7px; background: var(--field); color: var(--ink); min-width: 15rem; }
.board-menu { align-self: center; margin-left: auto; }
.board-projects { max-width: 16rem; margin: 0; }
.board-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.view-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: var(--field); }
.view-switch a { padding: 0.3rem 0.75rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); text-decoration: none; }
.view-switch a + a { border-left: 1px solid var(--border-strong); }
.view-switch a[aria-current] { background: var(--accent); color: var(--on-accent); }
.view-switch a:not([aria-current]):hover { background: var(--accent-soft); color: var(--accent-deep); }

/* tags */
.tags-manager { margin: -0.3rem 0 1rem; }
.tags-manager > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; cursor: pointer; font-size: 0.8rem; color: var(--ink-soft); list-style: none; }
.tags-manager > summary::-webkit-details-marker { display: none; }
.tags-manager-label { font-weight: 700; margin-right: 0.2rem; }
.tags-manager-label::after { content: " ▸"; color: var(--muted); }
.tags-manager[open] .tags-manager-label::after { content: " ▾"; }
.tags-manager-body { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; padding: 0.75rem 0.85rem; max-width: 40rem;
  background: var(--paper); border: 1px solid var(--border); border-radius: 10px; }
.tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tag-row form { margin: 0; }
.tag-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0; }
.tag-edit input, .tag-edit select { font: inherit; font-size: 0.84rem; padding: 0.3rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.tag-edit input { width: 12rem; }
.tag-new { padding-top: 0.35rem; border-top: 1px solid var(--border); }
.tcard-tagset fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; max-width: 15rem; }
.tcard-tagset legend { font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 0.2rem; }
.shelf-menu-body .tag-check { flex-direction: row; align-items: center; gap: 0.25rem; font-weight: 500; cursor: pointer; }
.tcard-newtag input { width: 7.5rem; }

/* cards: a tag stripe, chips, the subtask checklist */
.tcard.tagged { border-left: 4px solid var(--tc); }
.tcard-tags, .tcard-subs, .tsub-add { grid-column: 2; }
.tcard-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.tcard-subcount { font-weight: 600; color: var(--ink-soft); }
.tcard-hand { color: var(--tag-gold); font-weight: 600; }
.tcard-waits { color: var(--ink-soft); }
.tcard-subs { list-style: none; margin: 0.15rem 0 0; padding: 0.35rem 0 0; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 0.15rem; }
.tsub { display: flex; align-items: flex-start; gap: 0.4rem; padding-left: calc(var(--depth, 0) * 1.05rem); font-size: 0.84rem; line-height: 1.35; }
.tsub-check-form { margin: 0; }
.tsub-check { display: inline-flex; align-items: center; justify-content: center; width: 1rem; height: 1rem; margin-top: 0.1rem; padding: 0;
  border: 1.6px solid var(--sage); border-radius: 4px; background: var(--field); color: transparent; font-size: 0.66rem; font-weight: 800; cursor: pointer; }
.tsub-check:hover, .tsub-check:focus-visible { border-color: var(--accent); color: var(--accent-mid); outline: none; }
.tsub.done .tsub-check { background: var(--olive); border-color: var(--olive); color: var(--on-accent); }
.tsub-text { flex: 1; min-width: 0; color: var(--ink); }
.tsub.done .tsub-text { color: var(--muted); text-decoration: line-through; }
.tsub-file { color: var(--muted); font-size: 0.72rem; }
.tsub-tools { display: inline-flex; gap: 0.05rem; opacity: 0; transition: opacity 0.1s; }
.tsub:hover .tsub-tools, .tsub:focus-within .tsub-tools { opacity: 1; }
.tsub-tools form { margin: 0; display: inline-flex; }
.tsub-tool { border: 0; background: none; color: var(--muted); font-size: 0.78rem; padding: 0 0.2rem; cursor: pointer; }
.tsub-tool:hover { color: var(--ink); }
.tsub-add summary { list-style: none; cursor: pointer; font-size: 0.76rem; color: var(--muted); width: max-content; }
.tsub-add summary::-webkit-details-marker { display: none; }
.tsub-add summary:hover { color: var(--accent); }
.tsub-add-form { display: flex; gap: 0.35rem; margin: 0.3rem 0 0; }
.tsub-add-form input { flex: 1; min-width: 0; font: inherit; font-size: 0.84rem; padding: 0.28rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.tsub-add .hint-inline { margin-top: 0.3rem; font-size: 0.72rem; }

/* ---------- the Mahjong table (static/js/mahjong.js) ----------
   Tiles sit on a felt table at half-tile steps; a layer up is drawn a little up and to the
   left, like Mahjong solitaire. A tile's top band and edge take its first tag's colour. */
.mj { margin-top: 0.4rem; }
.mj-bar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.6rem 1rem; margin: 0.6rem 0; }
.mj-help { flex: 1 1 30rem; margin: 0; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5; }
.mj-help kbd { font: 600 0.72rem var(--font-body); padding: 0 0.3rem; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--field); }
.mj-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.mj-layout.has-detail { grid-template-columns: minmax(0, 1fr) 19rem; }
@media (max-width: 1000px) { .mj-layout.has-detail { grid-template-columns: minmax(0, 1fr); } }
.mj-wrap { position: relative; overflow: auto; height: calc(100vh - var(--topbar-h, 3.9rem) - 1.6rem); min-height: 32rem; border-radius: 14px;
  background: radial-gradient(ellipse at 50% 35%, var(--felt) 0%, var(--felt-2) 100%); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25), inset 0 2px 18px rgba(0,0,0,0.35); }
.mj-table { position: relative; --tw: 144px; --th: 187px; --tf: 0.92rem; --tl: 7; }
.mj-tile { position: absolute; width: var(--tw); height: var(--th); box-sizing: border-box; padding: 0.5rem 0.45rem 0.4rem; border-radius: 9px;
  background: var(--tile-face); color: var(--tile-ink); border: 1px solid color-mix(in srgb, var(--tile-edge) 70%, #fff);
  box-shadow: 3px 4px 0 color-mix(in srgb, var(--tc, var(--tile-edge)) 75%, #000), 4px 6px 9px rgba(0, 0, 0, 0.38);
  display: flex; flex-direction: column; gap: 0.2rem; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  transition: left 0.18s ease, top 0.18s ease, opacity 0.15s, filter 0.15s; outline: none; }
.mj-tile::before { content: ""; position: absolute; left: 6px; right: 6px; top: 4px; height: 4px; border-radius: 3px; background: var(--tc, var(--tile-edge)); }
.mj-table:not(.ready) .mj-tile { transition: none; }
.mj-tile:hover { filter: brightness(1.03); }
.mj-tile:focus-visible { box-shadow: 0 0 0 3px var(--focus-ring), 3px 4px 0 color-mix(in srgb, var(--tc, var(--tile-edge)) 75%, #000), 4px 6px 9px rgba(0,0,0,0.38); }
.mj-tile.blocked { filter: brightness(0.9) saturate(0.85); }
.mj-tile.dim { opacity: 0.32; }
.mj-tile.sel { border: 2px solid var(--tag-gold); }
.mj-tile.first { border: 2px dashed var(--tag-terracotta); }
.mj-tile.after { border: 2px dashed var(--tag-sky); }
.mj-tile.in-hand { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tag-gold) 80%, transparent), 3px 4px 0 color-mix(in srgb, var(--tc, var(--tile-edge)) 75%, #000), 4px 6px 12px rgba(0,0,0,0.45); }
.mj-tile.dragging { cursor: grabbing; transition: none; filter: brightness(1.05); box-shadow: 6px 10px 0 color-mix(in srgb, var(--tc, var(--tile-edge)) 75%, #000), 10px 18px 24px rgba(0,0,0,0.45); }
.mj-tile.done { background: var(--tile-face-done); }
.mj-tile.done .mj-text { text-decoration: line-through; opacity: 0.7; }
.mj-tile.landed { animation: mj-land 0.28s ease; }
@keyframes mj-land { 0% { transform: translateY(-6px) scale(1.04); } 100% { transform: none; } }
.mj-text { margin-top: 0.35rem; font: 600 var(--tf)/1.28 var(--font-body); overflow: hidden; display: -webkit-box; -webkit-line-clamp: var(--tl); -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.mj-foot { margin-top: auto; padding-right: calc(var(--tw) * 0.3); display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.35rem;
  font: 600 calc(var(--tf) * 0.78)/1.2 var(--font-body); color: #5a6662; }
.mj-foot .mj-over { color: #a3441f; }
.mj-pile { position: absolute; left: 4px; top: 10px; min-width: 1rem; padding: 0 0.2rem; border-radius: 6px; background: rgba(27,38,41,0.75); color: #fff; font: 700 0.58rem/1.4 var(--font-body); text-align: center; }
.mj-btns { position: absolute; top: 9px; right: 3px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; }
.mj-tile:hover .mj-btns, .mj-tile:focus-within .mj-btns, .mj-tile.sel .mj-btns, .mj-tile.done .mj-btns { opacity: 1; }
.mj-btn { width: 1.15rem; height: 1.15rem; padding: 0; border-radius: 50%; border: 1px solid #b9ab84; background: #fffdf6; color: #2d3a3e; font: 800 0.66rem/1 var(--font-body); cursor: pointer; }
.mj-btn:hover { background: #165A72; color: #fff; border-color: #165A72; }
.mj-tile.done .mj-check { background: #3C431B; color: #fff; border-color: #3C431B; }
.mj-ghost { position: absolute; width: var(--tw); height: var(--th); box-sizing: border-box; border: 2px dashed rgba(255, 253, 248, 0.85); border-radius: 9px;
  background: rgba(255, 253, 248, 0.12); pointer-events: none; z-index: 99999999; }
.mj-ghost-label { position: absolute; left: 50%; top: 0; transform: translate(-50%, calc(-100% - 6px)); padding: 0.1rem 0.45rem; border-radius: 6px; background: rgba(0,0,0,0.7); color: #fff;
  font: 600 0.68rem/1.4 var(--font-body); white-space: nowrap; }
.mj-empty { position: absolute; inset: 2rem; display: flex; align-items: center; justify-content: center; color: rgba(255,253,248,0.8); font-size: 0.95rem; text-align: center; pointer-events: none; }
/* today's hand */
.mj-hand { padding: 0.75rem 0.9rem; background: var(--paper); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.mj-hand-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }
.mj-hand-head h3 { margin: 0; font-size: 1rem; }
.mj-hand-date { font-size: 0.78rem; color: var(--muted); }
.mj-hand-date.stale { color: var(--highlight); font-weight: 600; }
.mj-hand-head label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.mj-hand-head select { font: inherit; font-size: 0.82rem; padding: 0.2rem 0.3rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.mj-hand-acts { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-left: auto; }
.mj-hand-tiles { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.7rem; min-height: 1rem; }
.mj-hand-note { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--muted); }
.mj-mini { position: relative; width: 7.4rem; min-height: 5.6rem; box-sizing: border-box; padding: 0.55rem 0.5rem 0.45rem 0.55rem; border-radius: 9px; background: var(--tile-face); color: var(--tile-ink);
  border: 1px solid color-mix(in srgb, var(--tile-edge) 70%, #fff); box-shadow: 2px 3px 0 color-mix(in srgb, var(--tc, var(--tile-edge)) 75%, #000);
  display: flex; flex-direction: column; gap: 0.25rem; cursor: pointer; text-align: left; font: 600 0.72rem/1.25 var(--font-body); }
.mj-mini::before { content: ""; position: absolute; left: 6px; right: 6px; top: 4px; height: 3px; border-radius: 3px; background: var(--tc, var(--tile-edge)); }
.mj-mini.done { background: var(--tile-face-done); }
.mj-mini.done .mj-mini-text { text-decoration: line-through; opacity: 0.7; }
.mj-mini-text { overflow-wrap: anywhere; padding-right: 1.2rem; }
.mj-mini .mj-btn { position: absolute; top: 8px; right: 5px; }
.mj-mini.dealt { animation: mj-deal 0.42s cubic-bezier(.2,.8,.3,1.2) both; }
@keyframes mj-deal { 0% { transform: translateY(-18px) rotate(-6deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
/* a tile's details */
.mj-detail { position: sticky; top: calc(var(--topbar-h, 3.9rem) + 0.8rem); padding: 0.9rem 1rem; background: var(--paper); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm); font-size: 0.86rem; display: flex; flex-direction: column; gap: 0.55rem; }
.mj-detail h3 { margin: 0; font-size: 1.02rem; line-height: 1.3; padding-right: 1.4rem; overflow-wrap: anywhere; }
.mj-detail .sn-x { position: absolute; top: 0.55rem; right: 0.6rem; }
.mj-detail-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; align-items: center; font-size: 0.78rem; color: var(--ink-soft); }
.mj-states { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; width: max-content; }
.mj-states button { border: 0; background: var(--field); padding: 0.3rem 0.65rem; font: 600 0.78rem var(--font-body); color: var(--ink-soft); cursor: pointer; }
.mj-states button + button { border-left: 1px solid var(--border-strong); }
.mj-states button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.mj-deps h4 { margin: 0 0 0.2rem; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-family: var(--font-body); }
.mj-deps ol { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.1rem; }
.mj-deps button { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-align: left; cursor: pointer; }
.mj-deps button:hover { text-decoration: underline; }
.mj-dep-first { border-left: 3px dashed var(--tag-terracotta); padding-left: 0.5rem; }
.mj-dep-after { border-left: 3px dashed var(--tag-sky); padding-left: 0.5rem; }
.mj-free { color: var(--olive); font-weight: 600; }
.mj-sub-form { display: flex; gap: 0.35rem; }
.mj-sub-form input { flex: 1; min-width: 0; font: inherit; font-size: 0.84rem; padding: 0.3rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
@media (max-width: 640px) {
  .board-tab { padding: 0.4rem 0.6rem; font-size: 0.84rem; }
  .board-new-form input { min-width: 0; width: 100%; }
  .mj-hand-acts { margin-left: 0; }
  .tsub-tools { opacity: 1; }
}

/* ---------- Mahjong, round 2 (2026-11-16): bigger tiles, tag symbols, project areas ---------- */
.content.mj-page { max-width: none; }
.mj-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.mj-size { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.mj-size button { border: 0; background: var(--field); color: var(--ink-soft); font: 700 0.76rem var(--font-body); padding: 0.32rem 0.6rem; cursor: pointer; }
.mj-size button + button { border-left: 1px solid var(--border-strong); }
.mj-size button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
/* a tag's symbol: a little Mahjong tile, the glyph in the tag's colour */
.mj-sym { display: inline-flex; align-items: center; justify-content: center; position: relative; box-sizing: border-box; flex: none;
  width: 1.15rem; height: 1.5rem; border-radius: 3px; background: #fffdf6; border: 1px solid #c9bc97; box-shadow: 1px 1.5px 0 color-mix(in srgb, var(--tc, #b9ab84) 70%, #000);
  color: var(--tc, #165A72); font: 700 0.86rem/1 "PingFang SC", "Hiragino Sans GB", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", "Songti SC", serif; }
.mj-sym-dots { font-size: 0.78rem; }
.mj-sym-white::after { content: ""; position: absolute; inset: 22% 22%; border: 2px solid var(--tc, #165A72); border-radius: 2px; }
.mj-syms { position: absolute; right: 6px; bottom: 6px; display: flex; flex-direction: row-reverse; gap: 3px; pointer-events: none; }
.mj-syms .mj-sym { width: calc(var(--tw) * 0.17); height: calc(var(--tw) * 0.22); font-size: calc(var(--tw) * 0.13); }
.mj-syms .mj-sym-dots { font-size: calc(var(--tw) * 0.11); }
.tag-glyph { font: 700 0.82rem/1 "PingFang SC", "Hiragino Sans GB", "Hiragino Sans", "Noto Sans CJK SC", "Microsoft YaHei", serif; color: var(--tc); }
.tag-glyph:empty { width: 0.62rem; height: 0.62rem; border: 2px solid var(--tc); border-radius: 2px; box-sizing: border-box; }
.tag-chip:has(.tag-glyph)::before { display: none; }
.tag-row .mj-sym { margin-right: 0.1rem; }
.tag-edit select[name="symbol"] { max-width: 12rem; }
/* tags on a tile's details */
.mj-tagset { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.mj-tagset-h { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 0.2rem; }
.mj-tagset-list { display: contents; }
.mj-tagset .tag-check { display: inline-flex; align-items: center; gap: 0.2rem; cursor: pointer; }
.mj-tagset .tag-check input { margin: 0; }
.mj-newtag { display: flex; gap: 0.3rem; flex-basis: 100%; }
.mj-newtag input { flex: 1; min-width: 0; font: inherit; font-size: 0.82rem; padding: 0.26rem 0.4rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
/* project areas */
.mj-area-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.8rem; margin: 0 0 0.7rem; padding: 0.7rem 0.85rem;
  background: var(--paper); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-sm); }
.mj-area-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); }
.mj-area-form input, .mj-area-form select { font: inherit; font-size: 0.86rem; padding: 0.32rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.mj-area-form .hint-inline { flex-basis: 100%; margin: 0; }
.mj-region { position: absolute; z-index: 1; box-sizing: border-box; border-radius: 16px; pointer-events: none;
  border: 2px solid color-mix(in srgb, var(--tc) 75%, transparent); background: color-mix(in srgb, var(--tc) 16%, transparent); }
.mj-region.moving { z-index: 8000000; opacity: 0.9; }
.mj-region-head { position: absolute; left: 12px; top: 0; transform: translateY(-100%); display: inline-flex; align-items: center; gap: 0.4rem;
  max-width: calc(100% - 24px); padding: 0.22rem 0.35rem 0.22rem 0.65rem; border-radius: 9px 9px 0 0; background: var(--tc); color: #fff;
  font: 700 0.82rem/1.25 var(--font-body); cursor: grab; pointer-events: auto; user-select: none; touch-action: none; white-space: nowrap; }
.mj-region-name { overflow: hidden; text-overflow: ellipsis; }
.mj-region-n { flex: none; min-width: 1.1rem; padding: 0 0.3rem; border-radius: 999px; background: rgba(255,255,255,0.25); font-size: 0.7rem; text-align: center; }
.mj-region-btn { flex: none; border: 0; background: none; color: #fff; font: 800 0.9rem/1 var(--font-body); padding: 0 0.25rem; cursor: pointer; }
.mj-region-size { position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; pointer-events: auto; cursor: nwse-resize; touch-action: none;
  border-right: 4px solid var(--tc); border-bottom: 4px solid var(--tc); border-radius: 0 0 14px 0; }
.mj-region-menu { position: absolute; left: 12px; top: 6px; z-index: 5; pointer-events: auto; display: flex; flex-direction: column; gap: 0.45rem; min-width: 14rem;
  padding: 0.7rem 0.8rem; background: var(--paper); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); font-size: 0.84rem; }
.mj-region-menu label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); }
.mj-region-menu input, .mj-region-menu select { font: inherit; font-size: 0.86rem; padding: 0.3rem 0.45rem; border: 1px solid var(--field-line); border-radius: 6px; background: var(--field); color: var(--ink); }
.mj-region-menu .hint-inline { margin: 0; max-width: 15rem; }
.mj-region-menu-acts { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.mj-region:has(.mj-region-menu) { z-index: 9000001; }

/* Full AI exchanges (shared/ai_log.html, 2026-11-18) */
.ai-log { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.9rem; }
.ai-log-item { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; box-shadow: var(--shadow-sm); }
.ai-log-item.ai-log-blocked, .ai-log-item.ai-log-error { border-left: 3px solid var(--danger); }
.ai-log-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; margin-bottom: 0.4rem; }
.ai-log-turn { margin: 0.5rem 0; }
.ai-log-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0.6rem 0 0.2rem; }
.ai-log-text { white-space: pre-wrap; word-break: break-word; font-family: var(--font-body); font-size: 0.86rem; line-height: 1.5; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.55rem 0.75rem; margin: 0; max-height: 360px; overflow: auto; color: var(--ink); }
.ai-log-model { margin: 0.5rem 0; }
.ai-log-model > summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-soft); }

/* Two-step sign-in (auth/two_step.html, 2026-11-18) */
.two-step-steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.two-step-qr { margin: 0.75rem 0; }
.two-step-qr img { background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--border); max-width: 100%; height: auto; }
.two-step-key { font-size: 1rem; letter-spacing: 0.06em; word-break: break-all; }
.two-step-confirm { display: flex; flex-direction: column; gap: 0.5rem; max-width: 320px; margin-top: 0.5rem; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.4rem 1rem; margin: 1rem 0; }
.recovery-codes code { font-size: 0.98rem; }
.two-step-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.two-step-actions .form-card h2 { font-size: 1.05rem; margin: 0 0 0.25rem; }
.btn-link { background: none; border: 0; color: var(--accent, var(--ink-soft)); text-decoration: underline; cursor: pointer; padding: 0; font: inherit; font-size: 0.88rem; }

/* Site footer and guides (2026-11-18) */
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.4rem; padding: 1.5rem 1rem 2rem; font-size: 0.82rem; color: var(--muted); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { color: var(--ink); text-decoration: underline; }
.guide-list { list-style: none; padding: 0; display: grid; gap: 1rem; }
.guide { max-width: 760px; line-height: 1.6; }
.guide h2 { margin-top: 2rem; }
.guide .guide-step { counter-increment: step; }
.guide ol, .guide ul { padding-left: 1.3rem; }
.guide li { margin: 0.35rem 0; }
.guide .guide-tip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.92rem; }
.guide-toc { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1.1rem; font-size: 0.92rem; }
.guide-toc ol { margin: 0.3rem 0 0; }


/* Accessibility (2026-11-18, the simulated WCAG 2.1 AA audit) -------------- */
/* 2.4.1 Bypass blocks: the first Tab stop on every page. */
.skip-link { position: absolute; left: 0.75rem; top: -3rem; z-index: 1000; background: var(--accent); color: var(--on-accent);
  padding: 0.55rem 0.9rem; border-radius: 8px; font-weight: 600; text-decoration: none; box-shadow: var(--shadow-md); }
.skip-link:focus { top: 0.6rem; outline: 3px solid var(--accent-line); outline-offset: 2px; }
main:focus, main[tabindex]:focus-visible { outline: none; }
/* 2.4.7 Focus visible: a clear default ring wherever a component doesn't draw its own. */
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible, select:focus-visible,
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible, input[type="file"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
/* The editor's title is the page's h1 (1.3.1), styled as it was. */
.editor-title { display: inline; font: inherit; font-weight: 700; font-size: 1rem; margin: 0; letter-spacing: 0; }
/* 1.4.10 Reflow: wide tables scroll inside their own box (app.js wraps them). */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .data-table { min-width: 100%; }
.table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 2.3.3 / user preference: no animation or smooth scrolling for people who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
/* Fieldsets default to min-width: min-content, which pushed the paste rules
   past a 320 px screen (1.4.10). */
fieldset { min-width: 0; }
.paste-source-row { flex-wrap: wrap; }
