/* ---------- Sendy Study Tool — Apple HIG-inspired theme ----------
   Semantic tokens, light + dark. Dark kicks in via prefers-color-scheme
   or the manual toggle (html[data-theme]). */

:root {
  /* Apple system palette — light */
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --teal: #30b0c7;

  --bg: #f2f2f7;                       /* grouped background */
  --bg-elevated: #ffffff;              /* cards */
  --bg-secondary: #f7f7fa;
  --sidebar-glass: rgba(246, 246, 248, 0.78);
  --ink: #1d1d1f;
  --logo-tile: #1d1d1f;
  --ink-secondary: rgba(60, 60, 67, 0.78);
  --muted: rgba(60, 60, 67, 0.6);
  --line: rgba(60, 60, 67, 0.14);
  --line-strong: rgba(60, 60, 67, 0.24);
  --fill: rgba(120, 120, 128, 0.12);   /* system fill */
  --fill-hover: rgba(120, 120, 128, 0.2);

  --accent: var(--blue);
  --accent-soft: color-mix(in srgb, var(--blue) 12%, transparent);
  --ok: #248a3d;         --ok-soft: color-mix(in srgb, #34c759 16%, transparent);
  --warn: #c93400;       --warn-soft: color-mix(in srgb, #ff9500 16%, transparent);
  --fail: #d70015;       --fail-soft: color-mix(in srgb, #ff3b30 12%, transparent);
  --audio: #8944ab;      --audio-soft: color-mix(in srgb, #af52de 14%, transparent);

  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .08), 0 24px 60px rgba(0, 0, 0, .12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --purple: #bf5af2;
    --teal: #40cbe0;

    --bg: #0d0d0f;
    --bg-elevated: #1c1c1e;
    --bg-secondary: #161618;
    --sidebar-glass: rgba(22, 22, 24, 0.72);
    --ink: #f5f5f7;
    --logo-tile: #2c2c2e;
    --ink-secondary: rgba(235, 235, 245, 0.72);
    --muted: rgba(235, 235, 245, 0.55);
    --line: rgba(84, 84, 88, 0.48);
    --line-strong: rgba(84, 84, 88, 0.72);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-hover: rgba(120, 120, 128, 0.36);

    --ok: #30d158;
    --warn: #ffd60a;
    --fail: #ff6961;
    --audio: #d8a9f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .5), 0 24px 60px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --teal: #40cbe0;

  --bg: #0d0d0f;
  --bg-elevated: #1c1c1e;
  --bg-secondary: #161618;
  --sidebar-glass: rgba(22, 22, 24, 0.72);
  --ink: #f5f5f7;
  --logo-tile: #2c2c2e;
  --ink-secondary: rgba(235, 235, 245, 0.72);
  --muted: rgba(235, 235, 245, 0.55);
  --line: rgba(84, 84, 88, 0.48);
  --line-strong: rgba(84, 84, 88, 0.72);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-hover: rgba(120, 120, 128, 0.36);

  --ok: #30d158;
  --warn: #ffd60a;
  --fail: #ff6961;
  --audio: #d8a9f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .5), 0 24px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 {
  font-size: 1.9rem; margin: 0 0 .25rem; font-weight: 700;
  letter-spacing: -0.022em;
}
h1[style*="--accent"] { border-left: 4px solid var(--accent); padding-left: .65rem; }
.muted { color: var(--muted); }
.error-text { color: var(--fail); font-size: .9rem; margin: .3rem 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--sidebar-glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--line);
  padding: 1.2rem 1rem;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
/* Brand lockup = brand/sendy-wordmark.svg: tile icon, "Sendy" over spaced "STUDY TOOL" */
.brand {
  display: flex; align-items: center; gap: .6rem;
  color: var(--ink); margin-bottom: 1.2rem; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .logo-beer { width: 2.25rem; height: 2.25rem; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.04em; }
.brand-sub {
  margin-top: .22rem; font-size: .58rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.brand-hero { gap: .9rem; }
.brand-hero .logo-beer { width: 3.6rem; height: 3.6rem; }
.brand-hero .brand-name { font-size: 2.3rem; }
.brand-hero .brand-sub { font-size: .8rem; margin-top: .35rem; }
.side-course { margin-bottom: 1rem; }
.side-course-head {
  display: flex; align-items: center; gap: .25rem;
  border-left: 3px solid var(--accent); padding-left: .55rem;
  margin-bottom: .3rem; border-radius: 1px;
}
.side-course-title {
  flex: 1; min-width: 0; font-weight: 600; color: var(--ink); font-size: .93rem;
}
.side-course-toggle {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; padding: 0; border: 0; background: none;
  color: var(--muted); border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.side-course-toggle:hover { background: var(--fill); color: var(--ink); }
.side-course-toggle svg { transition: transform .18s ease; }
.side-course.collapsed .side-course-toggle svg { transform: rotate(-90deg); }
.side-course.collapsed .side-units { display: none; }
.side-course.collapsed { margin-bottom: .55rem; }
@media (prefers-reduced-motion: reduce) { .side-course-toggle svg { transition: none; } }
.side-units {
  display: flex; flex-direction: column; gap: 1px;
  margin-left: .6rem; padding-left: .4rem; border-left: 1px solid var(--line);
}
.side-units a {
  color: var(--ink-secondary); font-size: .88rem;
  padding: .28rem .6rem; border-radius: var(--radius-sm);
  transition: background .12s ease;
}
.side-units a:hover { background: var(--fill); text-decoration: none; }
.side-units a.active { background: var(--accent); color: #fff; font-weight: 600; }
[data-reorder-url] a[data-slug] { cursor: grab; }
[data-reorder-url] a[data-slug].dragging { opacity: .4; cursor: grabbing; }
.side-section-label {
  font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: .3rem .35rem .5rem;
}
.sidebar nav { flex: 1; overflow-y: auto; min-height: 0; }
.side-add {
  display: block; margin-top: .2rem; padding: .34rem .6rem;
  font-size: .88rem; font-weight: 500; color: var(--muted);
  border-radius: var(--radius-sm); transition: background .12s ease, color .12s ease;
}
.side-add:hover { background: var(--fill); color: var(--accent); text-decoration: none; }
.side-profile {
  display: flex; align-items: center; gap: .65rem;
  margin-top: .8rem; padding-top: .9rem; border-top: 1px solid var(--line);
}
.side-avatar {
  width: 40px; height: 40px; border-radius: 11px; overflow: hidden;
  flex-shrink: 0; box-shadow: var(--shadow);
}
.side-avatar svg { display: block; width: 100%; height: 100%; }
.side-profile-info { flex: 1; min-width: 0; line-height: 1.3; }
.side-profile-name {
  display: block; font-weight: 600; font-size: .93rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-switch { font-size: .8rem; color: var(--muted); }
.side-switch:hover { color: var(--accent); }
.content { flex: 1; padding: 2.2rem 2.6rem 4rem; min-width: 0; }
.content-solo { display: grid; place-items: center; min-height: 100vh; background: var(--bg); max-width: none; }

/* theme toggle */
.theme-toggle {
  background: var(--fill); border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: .95rem; line-height: 1; display: inline-grid; place-items: center;
  transition: background .12s ease;
}
.theme-toggle:hover { background: var(--fill-hover); }

/* ---------- buttons / pills / forms ---------- */
.btn {
  display: inline-block; border: none; cursor: pointer;
  font-size: .92rem; font-weight: 600; font-family: inherit; line-height: 1.3;
  padding: .5rem 1rem; border-radius: 9px;
  text-decoration: none !important;
  transition: transform .07s ease, background .1s ease, filter .1s ease, box-shadow .1s ease;
}
.btn:active { transform: translateY(1px) scale(.99); filter: brightness(.92); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--fill); color: var(--accent); }
.btn-ghost:hover { background: var(--fill-hover); }
.btn-danger { background: var(--fill); color: var(--fail); }
.btn-danger:hover { background: var(--fail-soft); }
.btn-sm { padding: .3rem .8rem; font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; align-items: center; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .95rem; width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center; transition: background .12s ease;
}
.icon-btn:hover { background: var(--fail-soft); color: var(--fail); }
.icon-btn-neutral:hover { background: var(--fill-hover); color: var(--ink); }

.pill {
  font-size: .74rem; font-weight: 600; padding: .16rem .55rem; border-radius: 6px;
  background: var(--fill); color: var(--muted); white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-wait { background: var(--warn-soft); color: var(--warn); }
.pill-fail { background: var(--fail-soft); color: var(--fail); }
.pill-audio { background: var(--audio-soft); color: var(--audio); }

input[type="text"], input[type="url"], input[type="password"], textarea, select {
  font: inherit; padding: .55rem .8rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--ink); width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-soft);
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }
label input, label textarea, label select { margin-top: .3rem; font-weight: 400; }

.form-card, .login-card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 1.7rem; max-width: 480px;
}
.login-card { width: 390px; text-align: center; box-shadow: var(--shadow-lg); }
.login-card h1 { margin-bottom: 0; border: none; padding: 0; }
.login-card form { text-align: left; margin-top: 1.1rem; }
.login-card .btn { width: 100%; margin-top: .4rem; }
.stack-form { display: flex; flex-direction: column; gap: .5rem; margin-top: .6rem; }

/* class accent colour: preset swatches instead of a colour dropper */
.swatches { border: 0; padding: 0; margin: 0 0 1rem; }
.swatches legend { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .45rem; padding: 0; }
.swatch-row { display: flex; flex-wrap: wrap; gap: .55rem; }
.swatch { position: relative; width: 2rem; height: 2rem; cursor: pointer; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch-dot {
  display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--swatch);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
  transition: transform .12s ease, box-shadow .12s ease;
}
.swatch:hover .swatch-dot { transform: scale(1.08); }
.swatch input:checked + .swatch-dot {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--swatch);
}
.swatch input:focus-visible + .swatch-dot { box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--ink); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-form { display: flex; gap: .5rem; flex: 1; }

/* ---------- page furniture ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.greeting { margin-bottom: 1.6rem; }
.greeting h1 { margin-bottom: .25rem; }
.greeting-line { color: var(--muted); font-size: 1.02rem; margin: 0; }
.greeting-exams_now .greeting-line,
.greeting-exams_soon .greeting-line,
.greeting-midterms_now .greeting-line,
.greeting-midterms_soon .greeting-line { color: var(--ink); font-weight: 500; }
.page-subhead { margin: 0; font-size: 1.15rem; }
.crumb { margin: 0 0 .1rem; font-size: .85rem; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
@media (max-width: 900px) { .card-grid { grid-template-columns: minmax(0, 1fr); } }
.course-card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem; color: var(--ink); position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.course-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--accent);
}
.course-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.course-card h2 { margin: .2rem 0 .2rem; font-size: 1.15rem; letter-spacing: -0.01em; }
.course-card p { margin: .15rem 0; font-size: .88rem; }
.course-card-head { display: block; color: var(--ink); }
.course-card-head:hover { text-decoration: none; }
.course-card-head:hover h2 { color: var(--accent); }
.course-card-units {
  margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .5rem;
  display: flex; flex-direction: column;
}
.course-card-unit {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  padding: .42rem .5rem; margin: 0 -.5rem; border-radius: var(--radius-sm);
  color: var(--ink); font-size: .92rem;
  transition: background .12s ease;
}
.course-card-unit:hover { background: var(--fill); text-decoration: none; }
.course-card-unit-name {
  font-weight: 500; flex: 1 1 40%; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.course-card .unit-badges { flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }
.course-card-none { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.empty-state {
  background: var(--bg-elevated); border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg); padding: 2.6rem 2rem; text-align: center;
  color: var(--muted); margin-top: 1rem;
}
.empty-state p { margin: .2rem auto; max-width: 440px; }
.empty-state .btn { margin-top: 1rem; }
.empty-title { font-weight: 600; color: var(--ink); font-size: 1.05rem; }
.unit-list { display: flex; flex-direction: column; gap: .55rem; }
.unit-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem 1.15rem; color: var(--ink);
  transition: border-color .12s ease, transform .12s ease;
}
.unit-row:hover { text-decoration: none; border-color: var(--accent); transform: translateX(2px); }
.unit-badges { display: flex; gap: .4rem; }

/* ---------- tabs (segmented-control style) ---------- */
.tab-groups {
  display: flex; gap: 1.6rem; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 1.3rem;
}
.tab-groups .tabs { margin-bottom: 0; }
.tab-group-label {
  display: block; margin: 0 0 .35rem .5rem;
  font-size: .66rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.tab-group + .tab-group { border-left: 1px solid var(--line); padding-left: 1.6rem; }
.tabs {
  display: inline-flex; gap: 2px; background: var(--fill);
  padding: 3px; border-radius: 9px; margin-bottom: 1.3rem;
}
.tab {
  padding: .38rem 1rem; color: var(--ink-secondary); font-weight: 600;
  font-size: .92rem; border-radius: 7px; transition: background .15s ease, color .15s ease;
}
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active {
  color: var(--ink); background: var(--bg-elevated);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.tab-count { font-size: .74rem; background: var(--fill); border-radius: 5px; padding: 0 .4rem; margin-left: .15rem; }
.tab-panel { animation: fadein .18s ease-in; }
@keyframes fadein { from { opacity: .5; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.panel-actions { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; }

/* generate card */
.generate-card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem; margin-bottom: 1rem;
  position: relative; overflow: hidden;
}
.generate-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent);
}
.generate-form { display: flex; flex-direction: column; gap: .7rem; }
.generate-copy { display: flex; flex-direction: column; gap: .1rem; }
.generate-copy strong { font-size: 1rem; letter-spacing: -0.01em; }
.generate-copy span { color: var(--muted); font-size: .87rem; }
.generate-controls { display: flex; gap: .6rem; align-items: center; }
.generate-controls input { flex: 1; }
.generate-controls .btn { flex-shrink: 0; }

/* toolbar above the rendered notes */
.notes-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin: .2rem 0 .7rem;
}
.notes-meta { color: var(--muted); font-size: .82rem; }
.version-select { width: auto; font-size: .85rem; padding: .3rem .6rem; }

/* ---------- upload / sources ---------- */
.upload-zone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg);
  background: var(--bg-elevated); padding: 1.7rem; text-align: center;
  margin-bottom: .9rem; transition: border-color .15s, background .15s;
}
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone p { margin: .2rem 0; }
.upload-icon {
  width: 40px; height: 40px; margin: 0 auto .5rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 1.15rem; font-weight: 700;
}
.add-row { display: flex; gap: .8rem; margin-bottom: 1.3rem; align-items: flex-start; flex-wrap: wrap; }
.paste-details summary { list-style: none; }
.paste-details summary::-webkit-details-marker { display: none; }
.paste-details form { min-width: 340px; }
.source-list { display: flex; flex-direction: column; gap: .45rem; }
.source-row {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .6rem 1rem;
}
.src-toggle input { width: 17px; height: 17px; accent-color: var(--accent); }
.src-kind {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; padding: .14rem .5rem; border-radius: 6px;
}
.kind-pptx { background: var(--warn-soft); color: var(--warn); }
.kind-pdf { background: var(--fail-soft); color: var(--fail); }
.kind-docx { background: var(--accent-soft); color: var(--accent); }
.kind-youtube, .kind-video { background: var(--fail-soft); color: var(--fail); }
.kind-text, .kind-link { background: var(--fill); color: var(--muted); }
.kind-pocket { background: var(--ok-soft); color: var(--ok); }

/* Pocket note-taker panel: the student's own class notes */
.pocket-panel {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-left: 3px solid var(--ok); border-radius: var(--radius-lg);
  padding: 1rem 1.1rem 1.1rem; margin-bottom: 1.3rem;
}
.pocket-form { display: flex; flex-direction: column; gap: .6rem; }
.pocket-head { display: flex; gap: .8rem; align-items: flex-start; }
.pocket-head p { margin: .15rem 0 0; font-size: .88rem; }
.pocket-title { margin: 0; font-size: 1rem; }
.pocket-icon {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center; font-size: 1.05rem; font-weight: 700;
}
.pocket-form textarea { font-size: .9rem; }
.pocket-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.pocket-file-label { cursor: pointer; font-size: .85rem; }
.pocket-file-label.has-file { border-color: var(--ok); color: var(--ok); }
.src-title { flex: 1; min-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-title a { color: var(--ink); }
.src-fail-detail { flex-basis: 100%; padding-left: 2rem; }
.src-player summary { list-style: none; cursor: pointer; }
.src-player summary::-webkit-details-marker { display: none; }
.src-player[open] { flex-basis: 100%; padding-left: 2rem; }
.src-player video { display: block; width: 100%; max-width: 720px; margin-top: .5rem;
  border-radius: 10px; background: #000; }
.src-fail-detail textarea { font-size: .85rem; }
.token-bar { margin-top: .8rem; font-size: .85rem; }

/* ---------- jobs ---------- */
.job-banner {
  display: flex; align-items: center; gap: .6rem;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .65rem 1rem; margin-bottom: 1rem; font-size: .92rem;
}
.job-failed { background: var(--fail-soft); border-color: var(--fail); }
.job-done { background: var(--ok-soft); border-color: var(--ok); }
.job-stopped { color: var(--muted); }
.job-stop { margin-left: auto; }
.job-stop .btn { padding: .18rem .7rem; font-size: .8rem; }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- notes body ---------- */
.notes-body {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 2.4rem 2.8rem; margin-bottom: .6rem;
  font-size: 16px; line-height: 1.8;
}
/* Readable measure: cap text line length so long lines don't overwhelm */
.notes-body > p, .notes-body > ul, .notes-body > ol, .notes-body > dl,
.notes-body > blockquote { max-width: 46rem; }
.notes-body h2 {
  font-size: 1.4rem; margin: 2.4rem 0 .9rem; letter-spacing: -0.018em;
  padding-bottom: .35rem; border-bottom: 1px solid var(--line);
}
.notes-body h2:first-child { margin-top: 0; }
.notes-body h3 { font-size: 1.12rem; margin: 1.7rem 0 .55rem; letter-spacing: -0.01em; }
.notes-body h4 { font-size: 1rem; margin: 1.3rem 0 .4rem; }
.notes-body p { margin: .85rem 0; }
.notes-body ul, .notes-body ol { margin: .7rem 0; padding-left: 1.5rem; }
.notes-body li { margin: .45rem 0; }
.notes-body li::marker { color: var(--accent); }
.notes-body hr { border: none; border-top: 1px solid var(--line); margin: 1.6rem 0; }
.notes-body img { max-width: 100%; height: auto; }
.notes-body figure {
  margin: 1.3rem auto; padding: 1rem 1rem .8rem; max-width: 640px;
  background: var(--bg-secondary); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: center;
}
.notes-body figure img {
  border-radius: var(--radius-sm); background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .1);
}
.notes-body figcaption {
  font-size: .84rem; color: var(--muted); margin-top: .6rem;
  text-align: left; line-height: 1.5;
}
/* Generated HTML comes from a model: it must never be able to break the layout.
   Long words and URLs wrap at the box edge (break-word does not shrink table
   columns the way `anywhere` does), and cells keep their inner spacing tight. */
.notes-body { overflow-wrap: break-word; }
.notes-body a { overflow-wrap: anywhere; }
.notes-body td > :first-child, .notes-body th > :first-child { margin-top: 0; }
.notes-body td > :last-child, .notes-body th > :last-child { margin-bottom: 0; }
.notes-body td ul, .notes-body td ol { padding-left: 1.1rem; margin: .25rem 0; }
.notes-body td li { margin: .15rem 0; }

/* Tables: words never break mid-word (the chat bubble's overflow-wrap:anywhere
   would otherwise let the auto layout squeeze a column to one letter per line).
   Wide tables scroll sideways inside .table-wrap (added by app.js) instead. */
.notes-body .table-wrap {
  overflow-x: auto; margin: 1.1rem 0; border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}
.notes-body .table-wrap > table { margin: 0; }
.notes-body table {
  border-collapse: separate; border-spacing: 0; width: 100%; margin: 1.1rem 0;
  font-size: .92rem; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.notes-body th, .notes-body td {
  border: none; border-bottom: 1px solid var(--line);
  padding: .6rem .85rem; text-align: left; vertical-align: top;
  overflow-wrap: normal; word-break: normal; hyphens: manual; min-width: 5.5rem;
}
.notes-body td:first-child { font-weight: 600; }
.notes-body th {
  background: var(--accent-soft); color: var(--accent);
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.notes-body tbody tr:last-child td { border-bottom: none; }
.notes-body tbody tr:nth-child(even) td { background: var(--bg-secondary); }
.notes-body tbody tr { transition: background .12s ease; }
.notes-body tbody tr:hover td { background: var(--fill); }

/* timeline: chronological content gets a spine, dots, and a scroll-in reveal */
.notes-body .timeline { position: relative; margin: 1.3rem 0; padding-left: 1.7rem; max-width: 46rem; }
.notes-body .timeline::before {
  content: ""; position: absolute; left: .42rem; top: .4rem; bottom: .4rem;
  width: 2.5px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--teal));
}
.notes-body .tl-item {
  position: relative; margin: 0 0 1.15rem;
  opacity: 0; transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}
.notes-body .tl-item.in-view { opacity: 1; transform: none; }
.notes-body .tl-item::before {
  content: ""; position: absolute; left: -1.55rem; top: .3rem;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft);
}
.notes-body .tl-date {
  display: block; font-weight: 700; font-size: .78rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--accent);
  margin-bottom: .1rem;
}
.notes-body .tl-body p { margin: .2rem 0; }
@media (prefers-reduced-motion: reduce) {
  .notes-body .tl-item { opacity: 1; transform: none; transition: none; }
}
.notes-body code {
  background: var(--fill); padding: .12rem .4rem; border-radius: 6px; font-size: .88em;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}
.notes-body pre { background: #1c1c1e; color: #f5f5f7; padding: 1rem 1.2rem; border-radius: var(--radius); overflow-x: auto; }
.notes-body pre code { background: none; color: inherit; }
.notes-body blockquote { border-left: 3px solid var(--line-strong); margin: .9rem 0; padding: .2rem 1rem; color: var(--muted); }

.notes-body .tldr {
  background: var(--accent-soft); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.3rem; margin-bottom: 1.5rem;
}
.notes-body .tldr::before { content: "TL;DR"; display: block; font-weight: 700; font-size: .76rem; letter-spacing: .08em; color: var(--accent); margin-bottom: .3rem; }
.notes-body .callout {
  background: var(--ok-soft); border-left: 4px solid var(--ok);
  border-radius: var(--radius); padding: .8rem 1.2rem; margin: 1rem 0;
}
.notes-body .callout::before { content: "Key insight"; display: block; font-weight: 700; font-size: .76rem; color: var(--ok); margin-bottom: .2rem; }
.notes-body .key-term {
  background: var(--audio-soft); border-radius: var(--radius); padding: .7rem 1.1rem; margin: .8rem 0;
}
.notes-body .key-term dt { font-weight: 700; color: var(--audio); }
.notes-body .key-term dd { margin: .15rem 0 0; }
.notes-body .example {
  background: var(--bg-secondary); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .8rem 1.2rem; margin: 1rem 0;
}
.notes-body .example::before { content: "Example"; display: block; font-weight: 700; font-size: .76rem; color: var(--muted); margin-bottom: .2rem; }
.notes-body .warning {
  background: var(--warn-soft); border-left: 4px solid var(--warn);
  border-radius: var(--radius); padding: .8rem 1.2rem; margin: 1rem 0;
}
.notes-body .warning::before { content: "Watch out"; display: block; font-weight: 700; font-size: .76rem; color: var(--warn); margin-bottom: .2rem; }
.notes-body .recall {
  background: var(--bg-secondary); border: 1.5px dashed var(--accent);
  border-radius: var(--radius); padding: .8rem 1.2rem; margin: 1rem 0;
}
.notes-body .recall::before { content: "Try it from memory first"; display: block; font-weight: 700; font-size: .76rem; letter-spacing: .04em; color: var(--accent); margin-bottom: .2rem; }
.notes-body .misconception {
  background: var(--fail-soft); border-left: 4px solid var(--fail);
  border-radius: var(--radius); padding: .8rem 1.2rem; margin: 1rem 0;
}
.notes-body .misconception::before { content: "Feels true — isn't"; display: block; font-weight: 700; font-size: .76rem; color: var(--fail); margin-bottom: .2rem; }
.notes-body .mcq {
  background: var(--bg-secondary); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.2rem; margin: 1.1rem 0;
}
.notes-body .mcq::before { content: "Quick check"; display: block; font-weight: 700; font-size: .76rem; letter-spacing: .04em; color: var(--accent); margin-bottom: .35rem; }
.notes-body .mcq-q { font-weight: 600; margin: 0 0 .55rem; }
.notes-body .mcq-option {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .45rem .8rem; margin: .35rem 0; cursor: pointer; font-size: .94rem;
  transition: background .12s ease, border-color .12s ease;
}
.notes-body .mcq:not(.mcq-answered) .mcq-option:hover { background: var(--fill); border-color: var(--accent); }
.notes-body .mcq-answered .mcq-option { cursor: default; opacity: .75; }
.notes-body .mcq-answered .mcq-correct {
  background: var(--ok-soft); border-color: var(--ok); opacity: 1; font-weight: 600;
}
.notes-body .mcq-answered .mcq-correct::after { content: "  ✓"; color: var(--ok); font-weight: 700; }
.notes-body .mcq-answered .mcq-picked:not(.mcq-correct) {
  background: var(--fail-soft); border-color: var(--fail); opacity: 1;
}
.notes-body .mcq-answered .mcq-picked:not(.mcq-correct)::after { content: "  ✕"; color: var(--fail); font-weight: 700; }
.notes-body .mcq-why {
  display: none; margin-top: .55rem; padding-top: .55rem;
  border-top: 1px solid var(--line); font-size: .9rem; color: var(--ink-secondary);
}
.notes-body .mcq-answered .mcq-why { display: block; }

/* margin notes (saved annotations) */
.annotation-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; }
.annotation-kind {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent);
}
.annotation-user .annotation-kind { color: var(--warn); }
.annotation.unanchored .annotation-kind::after {
  content: " · from an older version of these notes";
  color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none;
}
.annotation-user .clarify-answer { background: var(--warn-soft); border-radius: var(--radius-sm); padding: .5rem .8rem; }
.annotation-x { width: 22px; height: 22px; font-size: .8rem; }
.annotation-empty { padding: .5rem .2rem; font-size: .9rem; }

/* reading progress bar (notes pages) */
.read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  z-index: 300; transition: width .1s linear; border-radius: 0 2px 2px 0;
}

/* "Picked up where you left off" toast after a resumed scroll */
.resume-pill {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 12px);
  background: var(--bg-elevated); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow); padding: .45rem .95rem;
  font-size: .85rem; opacity: 0; z-index: 320; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.resume-pill.show { opacity: 1; transform: translate(-50%, 0); }
.draft-status { font-size: .82rem; min-width: 7rem; }

/* ---------- highlight-to-ask (clarify) ---------- */
::highlight(sendy-clarify) { background-color: rgba(255, 204, 0, .38); }

.clarify-hint { font-size: .82rem; margin: .2rem 0 0; }

.clarify-fab {
  position: fixed; z-index: 60;
  border: none; cursor: pointer; font: inherit;
  font-size: .85rem; font-weight: 600; line-height: 1.2;
  padding: .42rem .9rem; border-radius: 980px;
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-lg);
  animation: fadein .12s ease-out;
}
.clarify-fab:hover { filter: brightness(1.1); }
.clarify-fab:active { transform: scale(.97); }

/* Word-style margin: annotation cards float beside the passage they anchor to. */
.notes-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.4rem; align-items: start;
}
.notes-main { min-width: 0; }
.clarify-panel { position: relative; }
#clarify-close, .clarify-head { display: none; }
.clarify-exchange {
  padding: .6rem .75rem;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: .88rem;
  transition: box-shadow .18s ease, border-color .18s ease, top .3s ease;
}
.annotation.floating { position: absolute; left: 0; right: 0; }
.annotation.hot, .clarify-exchange:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); }

/* connector lines from highlight to card (Word-style) */
.notes-layout { position: relative; }
svg.ann-lines {
  position: absolute; top: 0; left: 0; pointer-events: none; z-index: 4;
  overflow: visible;
}
.ann-lines path {
  fill: none; stroke: color-mix(in srgb, var(--warn) 45%, transparent);
  stroke-width: 1.5; transition: stroke .15s ease, stroke-width .15s ease;
}
.ann-lines path.hot { stroke: var(--warn); stroke-width: 2; }

/* long cards collapse to a preview; click expands */
.annotation:not(.expanded) .clarify-answer.clampable {
  max-height: 150px; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 97%);
  mask-image: linear-gradient(180deg, #000 62%, transparent 97%);
}
.annotation .clarify-answer.clampable { cursor: pointer; }

/* the highlighted passage in the text */
mark.ann-anchor {
  background: color-mix(in srgb, var(--warn) 20%, transparent);
  color: inherit; border-bottom: 2px solid var(--warn);
  border-radius: 2px; cursor: pointer; transition: background .15s ease;
}
mark.ann-anchor.hot, mark.ann-anchor:hover {
  background: color-mix(in srgb, var(--warn) 38%, transparent);
}

/* composer: appears in the margin at the height of the selection */
.margin-composer {
  position: absolute; left: 0; right: 0; z-index: 6;
  background: var(--bg-elevated); border: 1px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .7rem .75rem;
}
/* high-specificity hide: the later .clarify-form{display:flex} must not win */
.clarify-panel:not(.composing) .margin-composer { display: none; }
.margin-composer .clarify-quote[hidden] { display: none; }

@media (max-width: 1150px) {
  /* Narrow screens: fall back to a slide-over drawer with a static list. */
  .notes-layout { grid-template-columns: 1fr; }
  .clarify-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 55;
    width: min(400px, 100vw);
    display: flex; flex-direction: column;
    border-left: 1px solid var(--line);
    background: var(--bg-elevated); box-shadow: var(--shadow-lg);
    transform: translateX(110%); visibility: hidden;
    transition: transform .22s ease, visibility .22s;
  }
  .clarify-panel.open { transform: none; visibility: visible; }
  #clarify-close { display: inline-grid; }
  .clarify-head {
    display: flex; justify-content: space-between; align-items: center; gap: .6rem;
    padding: .85rem 1.1rem; border-bottom: 1px solid var(--line);
  }
  .clarify-log { flex: 1; overflow-y: auto; padding: .9rem .9rem 0; }
  .clarify-exchange { margin-bottom: .9rem; }
  /* drawer keeps a permanent composer at the bottom */
  .clarify-panel:not(.composing) .margin-composer { display: flex; }
  .margin-composer {
    position: static; border-color: var(--line);
    border-radius: 0; border-left: none; border-right: none; border-bottom: none;
    box-shadow: none;
  }
}
.clarify-quote {
  margin: 0 0 .45rem; padding: .45rem .8rem;
  border-left: 3px solid var(--warn); border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--ink-secondary);
  font-size: .84rem; line-height: 1.45;
}
.clarify-question { margin: 0 0 .45rem; font-size: .9rem; font-weight: 600; }
.clarify-answer.notes-body {
  padding: 0; margin-bottom: 0;
  font-size: .92rem; line-height: 1.55;
  background: none; border: none; border-radius: 0; box-shadow: none;
}
.clarify-answer.notes-body > :first-child { margin-top: 0; }
.clarify-answer.notes-body > :last-child { margin-bottom: 0; }
.clarify-answer.notes-body h2 { font-size: 1.02rem; margin: .7rem 0 .3rem; border: none; padding: 0; }
.clarify-answer.notes-body h3 { font-size: .95rem; margin: .6rem 0 .25rem; }
/* Margin answers stay flat: neutralize any boxed elements older answers used. */
.clarify-answer .tldr, .clarify-answer .callout, .clarify-answer .key-term,
.clarify-answer .example, .clarify-answer .warning, .clarify-answer .misconception,
.clarify-answer .recall, .clarify-answer .mcq {
  background: none; border: none; box-shadow: none; padding: 0; margin: .45rem 0;
}
.clarify-answer .tldr::before, .clarify-answer .callout::before,
.clarify-answer .example::before, .clarify-answer .warning::before,
.clarify-answer .misconception::before, .clarify-answer .recall::before,
.clarify-answer .mcq::before { display: none; }
.clarify-answer .key-term dt { color: inherit; }
.clarify-error {
  background: var(--fail-soft); border: 1px solid var(--fail);
  border-radius: var(--radius); padding: .6rem .9rem; font-size: .9rem;
}
.clarify-form {
  display: flex; flex-direction: column; gap: .5rem;
  border-top: 1px solid var(--line); padding: .85rem 1.1rem;
}
.clarify-form .clarify-quote { max-height: 108px; overflow-y: auto; }
.clarify-form .btn { align-self: flex-end; }
.clarify-panel .chat-typing { padding: 0 1.1rem .4rem; }

/* Answered highlights pinned into the notes so they survive scrolling */
::highlight(sendy-pinned) { background-color: rgba(255, 204, 0, .2); }


/* ---------- podcast ---------- */
.podcast-card {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.5rem 1.7rem;
}
.podcast-card h3 { margin: 0 0 .8rem; letter-spacing: -0.01em; }
.podcast-card audio { width: 100%; }
.transcript {
  white-space: pre-wrap; font-size: .88rem; background: var(--bg-secondary);
  border: 1px solid var(--line); padding: 1rem; border-radius: var(--radius);
  max-height: 400px; overflow-y: auto;
}

/* ---------- print: just the notes ---------- */
@media print {
  .sidebar, .tabs, .page-head .btn-row, .panel-actions, .job-banner,
  .clarify-fab, .clarify-panel, .clarify-hint { display: none !important; }
  .content { padding: 0; max-width: none; }
  .notes-body { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 1.2rem; }
  .notes-body { padding: 1.3rem; }
  .generate-controls { flex-direction: column; align-items: stretch; }
}

/* ---------- Ask Sendy chat ---------- */
.side-ask {
  display: block; font-weight: 600; font-size: .93rem; color: var(--ink);
  padding: .38rem .6rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
  background: var(--fill); text-align: center;
  position: relative; overflow: hidden;
  transition: background .12s ease, transform .15s ease, box-shadow .15s ease;
}
.side-ask::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%,
    color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: ask-shimmer 6s ease-in-out infinite;
}
.side-ask.active::after {
  background: linear-gradient(105deg, transparent 40%,
    rgba(255, 255, 255, .28) 50%, transparent 60%);
}
@keyframes ask-shimmer {
  0%, 78% { transform: translateX(-100%); }
  92%, 100% { transform: translateX(100%); }
}
.side-ask:hover {
  background: var(--fill-hover); text-decoration: none;
  transform: translateY(-1px); box-shadow: var(--shadow);
}
.side-ask:active { transform: scale(.97); }
.side-ask.active { background: var(--accent); color: #fff; }
/* the same periodic shimmer on every box where you can ask Sendy something */
.query-shimmer { position: relative; overflow: hidden; }
.query-shimmer::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: linear-gradient(105deg, transparent 40%,
    color-mix(in srgb, var(--accent) 16%, transparent) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: ask-shimmer 6s ease-in-out infinite;
}
.query-shimmer:focus-within::after { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .side-ask::after, .query-shimmer::after { animation: none; }
}

.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 12rem); min-height: 360px;
}
.chat-scroll { flex: 1; overflow-y: auto; padding: .2rem .2rem 1rem; }
.chat-msg { display: flex; margin: .55rem 0; }
.chat-user { justify-content: flex-end; }
.chat-assistant { justify-content: flex-start; }
.chat-bubble {
  max-width: 78%; min-width: 0; padding: .65rem 1rem; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); font-size: .95rem; overflow-wrap: break-word;
}
.chat-user .chat-bubble {
  background: var(--accent); color: #fff; border-bottom-right-radius: 6px;
}
.chat-assistant .chat-bubble {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.chat-bubble.notes-body { padding: .65rem 1.1rem; }
/* A bubble holding a table needs the full column so columns aren't crushed. */
.chat-assistant .chat-bubble:has(table) { max-width: 100%; }
.chat-bubble.notes-body > :first-child { margin-top: 0; }
.chat-bubble.notes-body > :last-child { margin-bottom: 0; }
.chat-error { background: var(--fail-soft); border: 1px solid var(--fail); color: var(--ink); }

.chat-form {
  display: flex; gap: .6rem; align-items: flex-end;
  border-top: 1px solid var(--line); padding-top: .9rem;
}
.chat-form .chat-input-wrap { flex: 1; min-width: 0; border-radius: var(--radius); }
.chat-form textarea { display: block; width: 100%; max-height: 140px; }
.chat-form .btn { flex-shrink: 0; }

.chat-typing { display: none; gap: 5px; padding: .4rem .6rem; }
.chat-typing.htmx-request { display: inline-flex; }
.chat-typing span {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  animation: chat-bounce 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Past chats: history list, search, read-only thread view */
.history-search { position: relative; margin-bottom: 1.3rem; max-width: 46rem; }
.history-search input[type="search"] {
  width: 100%; box-sizing: border-box; padding: .7rem 2.4rem .7rem 1rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg-elevated); color: var(--ink); font: inherit; font-size: 1rem;
}
.history-search input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.history-spinner {
  position: absolute; right: .9rem; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%;
  opacity: 0; animation: spin .8s linear infinite;
}
.history-search.htmx-request .history-spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }
.thread-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; max-width: 46rem; }
.thread-card {
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; transition: border-color .12s ease, transform .07s ease;
}
.thread-card:hover { border-color: var(--line-strong); }
.thread-current { border-left: 3px solid var(--accent); }
.thread-main { display: block; padding: .85rem 1.1rem; text-decoration: none; color: inherit; }
.thread-main:hover .thread-title { color: var(--accent); }
.thread-title { display: block; font-weight: 600; font-size: 1rem; line-height: 1.35; }
.thread-meta { display: block; color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.thread-hits { list-style: none; margin: 0; padding: .2rem .6rem .7rem; border-top: 1px solid var(--line); }
.thread-hit a {
  display: flex; gap: .6rem; padding: .4rem .5rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); font-size: .88rem; line-height: 1.45;
}
.thread-hit a:hover { background: var(--fill); }
.thread-hit.muted { padding: .2rem .5rem; font-size: .8rem; }
.hit-who { flex-shrink: 0; width: 3.2rem; font-weight: 600; font-size: .75rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); padding-top: .15rem; }
.thread-hit-user .hit-who { color: var(--accent); }
.hit-text mark, .chat-readonly mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 .1em; }
.crumb { margin: 0 0 .2rem; font-size: .85rem; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--accent); }
.thread-heading { font-size: 1.5rem; margin: 0 0 .2rem; }
.chat-readonly { max-width: 62rem; }
.chat-readonly .chat-msg:target .chat-bubble { outline: 2px solid var(--accent); outline-offset: 3px; }
.chat-readonly .chat-msg { scroll-margin-top: 1.5rem; }

/* ---------- class context: how the weeks connect ---------- */
.links-card {
  background: var(--bg-elevated); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1rem 1.2rem 1.1rem; margin-bottom: 1.3rem;
}
.links-title { margin: 0 0 .15rem; font-size: 1rem; }
.links-card > .muted { margin: 0 0 .7rem; font-size: .85rem; }
.links-list { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .7rem; }
.links-unit { font-weight: 600; color: var(--ink); }
.links-summary { margin: .15rem 0 .25rem; font-size: .9rem; }
.links-builds, .links-strip { margin: 0; font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.links-strip { margin: -.3rem 0 .9rem; }
.chip {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; text-decoration: none;
}
.chip:hover { background: var(--accent); color: #fff; }

/* ---------- class summary ---------- */
.course-summary { margin-top: 2.2rem; }
.course-summary .generate-card::before { background: var(--audio); }
.chat-bubble.notes-body {
  font-size: .95rem; line-height: 1.55; margin-bottom: 0;
  box-shadow: var(--shadow); border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
}
.chat-bubble.notes-body h2 { font-size: 1.1rem; margin: .8rem 0 .3rem; }
.chat-bubble.notes-body h3 { font-size: 1rem; margin: .7rem 0 .25rem; }

/* ---------- home layout: main column + year-round right rail ---------- */
.home-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(420px, 34vw, 520px);
  gap: 2rem; align-items: start;
}
.home-rail {
  display: flex; flex-direction: column; gap: 1.2rem;
  position: sticky; top: 1.6rem;
}
@media (max-width: 1150px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-rail { position: static; }
}

/* ---------- dashboard: calendar + agenda ---------- */
.dashboard {
  display: grid; grid-template-columns: 320px 1fr; gap: 1.2rem;
  margin-bottom: 2.4rem; align-items: stretch;
}
.dash-title { margin: 0 0 .9rem; font-size: 1.12rem; letter-spacing: -0.01em; }
.dash-calendar, .dash-agenda {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 1.4rem 1.5rem;
}
.dash-agenda { display: flex; flex-direction: column; }
.agenda-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 1.2rem; gap: .1rem;
}
.agenda-empty p { margin: .15rem 0; max-width: 380px; }
.agenda-empty-title { font-weight: 600; color: var(--ink); font-size: 1rem; }
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-grid th {
  font-size: .68rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; padding: .2rem 0 .45rem; text-align: center;
}
.cal-grid td {
  text-align: center; padding: .3rem 0 .38rem; border-radius: 8px;
  vertical-align: top; height: 50px;
}
.cal-day { font-size: .95rem; display: block; line-height: 1.55; }
.cal-today { background: var(--accent-soft); }
.cal-today .cal-day { color: var(--accent); font-weight: 700; }
.cal-dots { display: flex; gap: 2px; justify-content: center; margin-top: 2px; min-height: 6px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.cal-more { font-size: .6rem; color: var(--muted); line-height: 6px; }

.agenda-group { margin-bottom: .9rem; }
.agenda-label {
  margin: 0 0 .35rem; font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.agenda-row {
  display: flex; align-items: baseline; gap: .65rem; padding: .42rem .5rem;
  border-radius: var(--radius-sm); font-size: .95rem;
}
.agenda-row:hover { background: var(--fill); }
.agenda-date { flex-shrink: 0; width: 74px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.agenda-body { flex: 1; min-width: 0; }
.agenda-course {
  font-size: .8rem; color: var(--ink-secondary);
  border-left: 3px solid var(--accent); padding-left: .4rem;
}
.agenda-body .agenda-course { display: block; width: fit-content; margin-top: .15rem; }
.ev-kind {
  flex-shrink: 0; font-size: .68rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 6px; text-transform: uppercase; letter-spacing: .03em;
}
.ev-homework { background: var(--accent-soft); color: var(--accent); }
.ev-quiz { background: var(--audio-soft); color: var(--audio); }
.ev-test, .ev-exam { background: var(--fail-soft); color: var(--fail); }
.ev-project { background: var(--warn-soft); color: var(--warn); }
.ev-lecture, .ev-other { background: var(--fill); color: var(--muted); }

.syllabus-card { margin: 1.4rem 0; }
.event-details summary { cursor: pointer; color: var(--accent); font-size: .9rem; padding: .4rem 0; }
.event-list { margin-top: .4rem; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
}

/* ---------- home: ask bar + left-off resume pill ---------- */
.left-off {
  display: inline-flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  margin-top: .9rem; padding: .6rem 1.05rem;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow);
  font-size: 1.02rem; color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.left-off:hover {
  text-decoration: none; transform: translateY(-1px);
  box-shadow: var(--shadow-lg); border-color: var(--accent);
}
.left-off-kicker {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.left-off-label { font-weight: 600; letter-spacing: -0.01em; }
.left-off-when { font-size: .85rem; color: var(--muted); }
.left-off-arrow { color: var(--accent); font-weight: 600; transition: transform .12s ease; }

/* brand icon (partials/_logo.html); inline size for prose, overridden in .brand */
.logo-beer { width: 1.25em; height: 1.25em; vertical-align: -0.22em; border-radius: 22.6%; }
.agenda-cheers .logo-beer { width: 1.4em; height: 1.4em; }
.left-off:hover .left-off-arrow { transform: translateX(2px); }
.home-ask {
  display: flex; align-items: center; gap: .6rem;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
  padding: .45rem .6rem .45rem 1rem; margin: 1.1rem 0 1.6rem; max-width: 640px;
}
.home-ask::after { border-radius: 12px; }
.home-ask input {
  border: none; background: transparent; box-shadow: none; padding: .3rem 0;
}
.home-ask input:focus { border: none; box-shadow: none; outline: none; }
.home-ask .btn { flex-shrink: 0; }

/* ---------- full-window drag-and-drop overlay ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 200; display: none;
  place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
}
.drop-overlay.active { display: grid; }
.drop-overlay-box {
  border: 2.5px dashed var(--accent); border-radius: var(--radius-lg);
  background: var(--bg-elevated); box-shadow: var(--shadow-lg);
  padding: 2.4rem 3.2rem; text-align: center; color: var(--ink);
}
.drop-overlay-box strong { font-size: 1.2rem; display: block; margin-bottom: .3rem; }
.drop-overlay-box span { color: var(--muted); font-size: .92rem; }

/* ---------- Flashcards ---------- */
.fc-deck { max-width: 620px; margin-top: 1.4rem; }
.fc-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.fc-card {
  perspective: 1200px; height: 300px; cursor: pointer; outline: none;
}
.fc-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .45s cubic-bezier(.4, .1, .2, 1);
}
.fc-card.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 2rem 2.4rem; font-size: 1.15rem; line-height: 1.5;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.fc-front { font-weight: 600; }
.fc-back { transform: rotateY(180deg); background: var(--accent-soft); border-color: var(--accent); }
.fc-hint {
  position: absolute; bottom: .9rem; left: 0; right: 0;
  font-size: .75rem; font-weight: 500; color: var(--muted);
}
.fc-controls { display: flex; justify-content: center; gap: .7rem; margin-top: 1.1rem; }
.fc-keys { text-align: center; font-size: .8rem; margin-top: .5rem; }
@media (prefers-reduced-motion: reduce) { .fc-inner { transition: none; } }

/* ---------- Test Mode ---------- */
.test-week-picker { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .6rem; }
.test-week {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0;
  font-size: .88rem; font-weight: 500; cursor: pointer;
  background: var(--fill); border-radius: 8px; padding: .28rem .75rem;
}
.test-week:has(input:checked) { background: var(--accent-soft); color: var(--accent); }
.test-week input { accent-color: var(--accent); margin: 0; }

.test-list { display: flex; flex-direction: column; gap: .7rem; margin-top: 1rem; }
.test-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.15rem;
}
.test-row-info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.test-row-info .muted { font-size: .85rem; }
.test-why { font-style: italic; }

.test-instructions {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: .7rem 1rem; max-width: 780px;
}
.test-form { max-width: 780px; }
.test-question {
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem; margin-bottom: 1rem;
}
.test-q-head { margin: 0 0 .6rem; font-weight: 500; }
.test-q-num { color: var(--accent); font-weight: 700; margin-right: .25rem; }
.test-q-pts { font-size: .82rem; }
.test-options { display: flex; flex-direction: column; gap: .35rem; }
.test-option {
  display: flex; align-items: baseline; gap: .55rem; margin: 0;
  font-weight: 400; font-size: .95rem; cursor: pointer;
  border-radius: var(--radius-sm); padding: .4rem .6rem;
}
.test-option:hover { background: var(--fill); }
.test-option:has(input:checked) { background: var(--accent-soft); }
.test-option input { accent-color: var(--accent); }
.test-submit-row { display: flex; align-items: center; gap: 1rem; margin: 1.2rem 0 2rem; }

.test-score-card {
  display: flex; align-items: center; gap: 1.3rem; max-width: 780px;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem; margin-bottom: 1.4rem;
}
.test-score-big { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); }
.test-overall { margin-top: .3rem; font-size: .95rem; }
.test-result { max-width: 780px; border-left: 4px solid var(--warn); }
.test-result.test-full { border-left-color: var(--ok); }
.test-result.test-zero { border-left-color: var(--fail); }
.test-q-score { float: right; font-weight: 700; color: var(--ink-secondary); }
.test-your-answer { margin: .5rem 0; font-size: .93rem; }
blockquote.test-your-answer {
  border-left: 3px solid var(--line-strong); padding: .4rem .8rem; margin-left: 0;
  background: var(--bg-secondary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.test-feedback { font-size: .93rem; }
.test-feedback p:first-child { margin-top: .3rem; }

/* ---------- video overview ---------- */
.podcast-video { width: 100%; border-radius: var(--radius); background: #000; margin: .3rem 0; }
.video-head { margin-top: 1.2rem; }
.video-hint { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: 1rem; }

/* ---------- Bierparty: logo-click easter egg ---------- */
.bierparty {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: bierparty-in .35s cubic-bezier(.34, 1.4, .64, 1);
}
.bierparty iframe { display: block; }
.bierparty-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(90deg, color-mix(in srgb, var(--orange) 22%, transparent), transparent);
}
.bierparty-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}
.bierparty-close:hover { color: var(--ink); background: var(--fill); }
@keyframes bierparty-in {
  from { transform: translateY(24px) scale(.9); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.bierparty-wiggle {
  animation: bierparty-prost .6s ease-in-out infinite;
  transform-origin: 50% 90%;
}
@keyframes bierparty-prost {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-11deg) translateY(-1px); }
  75%      { transform: rotate(11deg) translateY(-1px); }
}

/* ---------- Landing page (anonymous /) ---------- */
.content-solo:has(.landing) { display: block; place-items: unset; }
.landing { max-width: 1040px; margin: 0 auto; padding: 0 1.4rem 4rem; }
.landing-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 0;
}
.landing-nav-links { display: flex; align-items: center; gap: 1.4rem; font-size: .95rem; }
.landing-nav-links a { color: var(--ink-secondary); }
.landing-nav-links a:hover { color: var(--ink); text-decoration: none; }
.landing-hero { text-align: center; padding: 4.5rem 0 3.5rem; }
.landing-eyebrow {
  margin: 0 0 1rem; font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
}
.landing-hero h1 {
  border: none; padding: 0; margin: 0 0 1.2rem; display: block;
  font-size: clamp(2.2rem, 5.5vw, 3.6rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.05;
}
.landing-lede {
  max-width: 44rem; margin: 0 auto; font-size: 1.15rem; line-height: 1.55; color: var(--ink-secondary);
}
.landing-cta { display: flex; flex-direction: column; align-items: center; gap: .9rem; margin-top: 2.2rem; }
.landing-cta-secondary { color: var(--muted); font-size: .95rem; }
.landing-fineprint { margin: .9rem 0 0; font-size: .8rem; color: var(--muted); }
.btn-lg { padding: .85rem 1.7rem; font-size: 1.05rem; border-radius: 999px; }
.btn.is-disabled { opacity: .55; cursor: default; pointer-events: none; }
.landing-section { padding: 3.5rem 0; }
.landing-section h2 {
  border: none; padding: 0; margin: 0 0 .5rem; text-align: center;
  font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -0.03em;
}
.landing-section-lede { text-align: center; color: var(--ink-secondary); margin: 0 auto 2.2rem; max-width: 36rem; }
.landing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.landing-card {
  background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 1.4rem; box-shadow: var(--shadow);
}
.landing-card-icon {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 14%, transparent); font-size: 1.2rem; margin-bottom: .8rem;
}
.landing-card h3 { margin: 0 0 .35rem; font-size: 1.05rem; font-weight: 700; }
.landing-card p { margin: 0; color: var(--ink-secondary); font-size: .95rem; line-height: 1.5; }
.landing-section-alt {
  background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 3rem 2rem; box-shadow: var(--shadow);
}
.landing-steps { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.6rem; }
.landing-steps h3 { margin: .6rem 0 .3rem; font-size: 1.05rem; font-weight: 700; }
.landing-steps p { margin: 0; color: var(--ink-secondary); font-size: .95rem; line-height: 1.5; }
.landing-step-num {
  display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem;
}
.landing-pricing {
  max-width: 26rem; margin: 0 auto; text-align: center; background: var(--bg-elevated);
  border-radius: var(--radius-lg); padding: 2.4rem 2rem; box-shadow: var(--shadow-lg);
}
.landing-price { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; margin: .4rem 0 1rem; }
.landing-pricing-list { list-style: none; padding: 0; margin: 0 0 1.6rem; color: var(--ink-secondary); line-height: 1.9; }
.landing-pricing-list li::before { content: "✓  "; color: var(--ok); font-weight: 700; }
.landing-footer {
  display: flex; flex-wrap: wrap; gap: 1.4rem; justify-content: center; padding-top: 2rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem;
}
.landing-thanks { text-align: center; padding-top: 6rem; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.landing-thanks .brand-hero { justify-content: center; }
.landing-thanks h1 { border: none; padding: 0; margin: 0; font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; }
@media (max-width: 760px) {
  .landing-grid, .landing-steps { grid-template-columns: 1fr; }
  .landing-nav-links a:not(.btn) { display: none; }
  .landing-hero { padding: 2.8rem 0 2.4rem; }
  .landing-section-alt { padding: 2rem 1.2rem; }
}
