/* Scottish wildflower palette: heather purple, thistle lilac, gorse yellow, bluebell. */
:root {
  --bg: #f6f3fb;
  --bg-elev: rgba(255, 255, 255, 0.72);
  --card: #ffffff;
  --ink: #1b1530;
  --ink-2: #5a5470;
  --ink-3: #8d87a3;
  --line: rgba(60, 30, 110, 0.10);
  --accent: #5b2d8e;
  --accent-ink: #ffffff;
  --gorse: #f5c518;
  --gorse-ink: #3a2c00;
  --shadow: 0 1px 2px rgba(40, 20, 80, 0.06), 0 10px 30px -12px rgba(60, 30, 120, 0.25);
  --radius: 22px;
  --radius-sm: 14px;
  --heather: #6b3fa0;  --heather-soft: #efe6fb;
  --thistle: #a45ec9;  --thistle-soft: #f6ecfd;
  --gorse-m: #d9a600;  --gorse-soft: #fff6d6;
  --bluebell: #4c5fd5; --bluebell-soft: #e9ebfd;
  --tab-h: 72px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14101f;
    --bg-elev: rgba(20, 16, 31, 0.72);
    --card: #1f1930;
    --ink: #f3eefc;
    --ink-2: #b9b0cf;
    --ink-3: #7f7797;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #c9a2ff;
    --accent-ink: #1b1530;
    --gorse: #ffd447;
    --gorse-ink: #2b2000;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 10px 30px -12px rgba(0,0,0,0.6);
    --heather: #b98cf0;  --heather-soft: #2a2140;
    --thistle: #d59af0;  --thistle-soft: #2e2340;
    --gorse-m: #ffd447;  --gorse-soft: #332b12;
    --bluebell: #9aa6ff; --bluebell-soft: #222744;
  }
}
:root[data-theme="dark"] {
  --bg: #14101f; --bg-elev: rgba(20,16,31,0.72); --card: #1f1930; --ink: #f3eefc; --ink-2: #b9b0cf; --ink-3: #7f7797;
  --line: rgba(255,255,255,0.08); --accent: #c9a2ff; --accent-ink: #1b1530; --gorse: #ffd447; --gorse-ink: #2b2000;
  --heather: #b98cf0; --heather-soft: #2a2140; --thistle: #d59af0; --thistle-soft: #2e2340; --gorse-m: #ffd447; --gorse-soft: #332b12; --bluebell: #9aa6ff; --bluebell-soft: #222744;
}

/* module colour hooks */
.mod-heather  { --m: var(--heather);  --m-soft: var(--heather-soft); }
.mod-thistle  { --m: var(--thistle);  --m-soft: var(--thistle-soft); }
.mod-gorse    { --m: var(--gorse-m);  --m-soft: var(--gorse-soft); }
.mod-bluebell { --m: var(--bluebell); --m-soft: var(--bluebell-soft); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  background-image:
    radial-gradient(60% 40% at 100% -10%, color-mix(in srgb, var(--heather) 22%, transparent), transparent 70%),
    radial-gradient(40% 30% at -10% 10%, color-mix(in srgb, var(--gorse) 20%, transparent), transparent 70%);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-elev);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; }
.weeknav { display: flex; align-items: center; gap: 8px; }
.weektitle { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.weektitle.center { text-align: center; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow strong { color: var(--accent); }
.weektitle h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.sub { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.navbtn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow); color: var(--accent); flex: none;
  transition: transform .15s ease;
}
.navbtn:active { transform: scale(0.92); }
.navbtn[aria-disabled="true"] { opacity: 0.3; pointer-events: none; }
.navbtn.ghost { visibility: hidden; }

/* ---------- page */
.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px 24px; }
.section-label { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.accent { border-left: 5px solid var(--m, var(--accent)); }
.card p { color: var(--ink-2); font-size: 15px; }
.notice { background: var(--gorse-soft); color: var(--ink); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--gorse) 40%, transparent); }
.pill-link {
  display: inline-block; margin-bottom: 14px; padding: 8px 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}

/* ---------- coming up */
.soon { margin-bottom: 18px; }
.soon-row { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.soon-row::-webkit-scrollbar { display: none; }
.soon-card {
  flex: 0 0 200px; scroll-snap-align: start;
  background: linear-gradient(135deg, var(--m), color-mix(in srgb, var(--m) 70%, black));
  color: #fff; border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow);
}
.mod-gorse.soon-card { color: var(--gorse-ink); background: linear-gradient(135deg, #ffd84a, #f0b400); }
.soon-when { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.soon-mod { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.8; }
.soon-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.soon-date { font-size: 12px; opacity: 0.85; margin-top: 4px; }

/* ---------- week grid */
.days { display: grid; gap: 14px; }
@media (min-width: 900px) { .days { grid-template-columns: repeat(5, 1fr); align-items: start; } .days .day:nth-child(n+6) { grid-column: span 1; } }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.day.today { outline: 2px solid var(--accent); outline-offset: 0; }
.day.empty { background: color-mix(in srgb, var(--card) 60%, transparent); box-shadow: none; border: 1px dashed var(--line); }
.day-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 6px 10px; }
.day-name { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.day-date { color: var(--ink-3); font-weight: 600; font-size: 14px; }
.today-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gorse); margin-left: auto; box-shadow: 0 0 0 4px color-mix(in srgb, var(--gorse) 30%, transparent); }
.day-empty { color: var(--ink-3); font-size: 14px; padding: 0 6px 6px; }

/* ---------- event */
.event { display: flex; gap: 10px; background: var(--m-soft); border-radius: var(--radius-sm); padding: 10px 12px 10px 10px; margin-bottom: 8px; }
.event:last-child { margin-bottom: 0; }
.event-rail { width: 4px; border-radius: 4px; background: var(--m); flex: none; }
.event-body { min-width: 0; flex: 1; }
.event-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 2px; }
.event-time { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 800; font-size: 13px; }
.event-kind { color: var(--m); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.event-mod { color: var(--ink-3); }
.event-title { font-size: 15px; font-weight: 600; line-height: 1.3; }
.event-detail { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.kind-deadline .event-rail { background: var(--gorse); }
.kind-deadline { background: var(--gorse-soft); }
.kind-deadline .event-kind { color: var(--gorse-m); }
.kind-deadline .event-title { font-weight: 800; }
.kind-lecture { background: transparent; border: 1px solid var(--line); }
.kind-lecture .event-rail { opacity: 0.55; }
.kind-case { background: transparent; border: 1px dashed var(--line); }
.kind-case .event-title { font-weight: 500; font-size: 14px; }
.badge-verify { background: var(--gorse); color: var(--gorse-ink); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 18px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--m); margin-right: 6px; vertical-align: -1px; }

/* ---------- dates page */
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.month { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin: 18px 4px 10px; }
.datelist { display: flex; flex-direction: column; gap: 8px; }
.daterow { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: var(--shadow); }
.daterow.past { opacity: 0.45; }
.daterow-date { width: 44px; flex: none; text-align: center; background: var(--m-soft); border-radius: 12px; padding: 6px 0; }
.daterow.kind-deadline .daterow-date { background: var(--gorse); color: var(--gorse-ink); }
.dd { display: block; font-size: 20px; font-weight: 800; line-height: 1; }
.dw { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--ink-2); }
.daterow.kind-deadline .dw { color: inherit; }
.daterow-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.daterow-title { font-weight: 600; font-size: 15px; }
.daterow.kind-deadline .daterow-title { font-weight: 800; }
.daterow-time { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.daterow-until { font-size: 12px; font-weight: 700; color: var(--ink-3); flex: none; text-align: right; }

/* ---------- modules */
.modgrid { display: grid; gap: 12px; margin-bottom: 18px; }
@media (min-width: 640px) { .modgrid { grid-template-columns: repeat(2, 1fr); } }
.modcard {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--m), color-mix(in srgb, var(--m) 70%, black)); color: #fff; box-shadow: var(--shadow);
  transition: transform .15s ease;
}
.modcard:active { transform: scale(0.98); }
.modcard.mod-gorse { color: var(--gorse-ink); background: linear-gradient(135deg, #ffd84a, #f0b400); }
.modcode { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; opacity: 0.8; }
.modname { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.modslot { font-size: 13px; opacity: 0.9; font-weight: 500; }
.linklist, .plain { margin: 0; padding: 0; list-style: none; }
.linklist li, .plain li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.linklist li:first-child, .plain li:first-child { border-top: 0; padding-top: 0; }
.linklist a { color: var(--accent); font-weight: 600; }
.plain a { color: var(--accent); }
.weeklist { margin: 0; padding: 0; list-style: none; }
.weeklist li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.weeklist li:first-child { border-top: 0; padding-top: 0; }
.weeklist li.now { background: var(--m-soft); margin: 0 -18px; padding: 12px 18px; border-radius: 0; }
.wk { flex: none; width: 52px; display: flex; flex-direction: column; }
.wk-n { font-weight: 800; font-size: 14px; color: var(--m); }
.wk-d { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.wk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wk-topic { font-size: 15px; font-weight: 600; }
.wk-ev { font-size: 13px; color: var(--ink-2); }
.wk-ev.kind-deadline { color: var(--ink); font-weight: 700; }
.wk-ev .event-kind { margin-right: 4px; }
.wk-ev.kind-deadline .event-kind { color: var(--gorse-m); }

/* ---------- tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  background: var(--bg-elev); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 14px; color: var(--ink-3); font-size: 11px; font-weight: 600; }
.tabbar a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tabbar svg { width: 24px; height: 24px; }

/* ---------- books */
.buy-first { --m: var(--gorse); }
.buy-first li { color: var(--ink); }
.buy-first > p:first-of-type { margin-bottom: 12px; }
.tip { margin-top: 12px; font-size: 13px; color: var(--ink-2); background: var(--gorse-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.book-modtag { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--m); background: var(--m-soft); padding: 2px 8px; border-radius: 999px; vertical-align: 1px; }
.bookgroup { margin: 22px 0 8px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin: 0 4px 10px; }
.group-title i { width: 10px; height: 10px; border-radius: 3px; background: var(--m); }
.group-code { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.05em; }
.book { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px 16px; box-shadow: var(--shadow); margin-bottom: 10px; border-left: 5px solid var(--m); transition: opacity .2s ease; }
.book.prio-further { border-left-color: var(--line); }
.book.owned { opacity: 0.55; }
.book.owned .book-title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--m); }
.book-main { flex: 1; min-width: 0; }
.prio { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--m); }
.prio-further .prio { color: var(--ink-3); }
.prio-essential .prio { color: var(--gorse-ink); background: var(--gorse); padding: 2px 8px; border-radius: 999px; }
.badge-online { font-size: 11px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.book-title { font-size: 16px; font-weight: 700; line-height: 1.3; margin-top: 4px; }
.book-by { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.book-pub { display: block; font-size: 13px; color: var(--ink-3); }
.book-note { font-size: 13px; color: var(--ink-2); margin-top: 6px; padding: 8px 10px; background: var(--m-soft); border-radius: 10px; }
.book-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.book-actions a { font-size: 13px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 6px 12px; border-radius: 999px; }
.got { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: transparent; color: transparent; cursor: pointer; display: grid; place-items: center; transition: all .15s ease; }
.got svg { width: 20px; height: 20px; stroke-width: 2.4; }
.got[aria-pressed="true"] { background: var(--m); border-color: var(--m); color: #fff; }
.mod-gorse .got[aria-pressed="true"] { color: var(--gorse-ink); }

/* ---------- forms */
.input { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.input.small { font-size: 14px; padding: 8px 12px; width: auto; max-width: 60%; }
.btn { font: inherit; font-weight: 700; font-size: 15px; padding: 12px 18px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.btn.wide { width: 100%; }
.btn.small { font-size: 13px; padding: 7px 12px; }
.btn.ghost { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.btn.danger { color: #c0392b; background: color-mix(in srgb, #c0392b 10%, transparent); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center-row { display: flex; justify-content: center; margin: 22px 0 10px; }
.iconbtn { border: 0; background: transparent; color: var(--ink-3); font-size: 16px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.iconbtn:hover { background: var(--line); color: var(--ink); }
.form-error { color: #c0392b; font-size: 14px; font-weight: 600; }
.userrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.userrow-actions { display: flex; gap: 6px; }

/* ---------- login */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.login h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 14px; }
.login-form { margin-top: 26px; text-align: left; display: flex; flex-direction: column; gap: 14px; background: var(--card); padding: 22px; border-radius: var(--radius); box-shadow: var(--shadow); }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }

/* ---------- library */
.doclist { list-style: none; margin: 0 0 14px; padding: 0; }
.doc { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); }
.doc:first-child { border-top: 0; }
.doc-main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 0; min-width: 0; }
.doc-ext { flex: none; width: 44px; height: 52px; border-radius: 10px; background: var(--heather-soft); color: var(--heather); font-size: 11px; font-weight: 800; text-transform: uppercase; display: grid; place-items: center; }
.doc-body { display: flex; flex-direction: column; min-width: 0; }
.doc-title { font-weight: 700; font-size: 15px; }
.doc-meta { font-size: 12px; color: var(--ink-3); }
.status-processing .doc-ext { opacity: 0.5; }
.upload { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.filepick { position: relative; display: block; padding: 14px; border: 2px dashed var(--line); border-radius: var(--radius-sm); text-align: center; font-weight: 600; color: var(--accent); cursor: pointer; }
.filepick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.filepick:has(input:valid) { border-style: solid; border-color: var(--accent); }
.filepick:has(input:valid) span::after { content: " ✓"; }

/* ---------- ask */
.ask-layout { display: grid; gap: 14px; }
@media (min-width: 900px) { .ask-layout { grid-template-columns: 260px 1fr; align-items: start; } }
.chats { display: none; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.chats.open { display: block; }
@media (min-width: 900px) { .chats { display: block; position: sticky; top: 90px; } #toggle-chats { visibility: hidden; } }
.chatlist { list-style: none; margin: 0; padding: 0; }
.chatlist li { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.chatlist li a { flex: 1; padding: 9px 10px; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatlist li.active { background: var(--heather-soft); }
.chatlist li.active a { color: var(--accent); font-weight: 700; }
.chat { display: flex; flex-direction: column; min-height: 60vh; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 130px; }
.welcome { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); font-size: 15px; color: var(--ink-2); display: flex; flex-direction: column; gap: 12px; }
.welcome .tip { margin: 0; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; }
.starter { text-align: left; white-space: normal; }
.msg { max-width: 92%; padding: 12px 16px; border-radius: 20px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 6px; white-space: normal; }
.msg.assistant p { margin: 0 0 10px; } .msg.assistant p:last-child { margin: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 16px; margin: 12px 0 6px; }
.msg.assistant ul, .msg.assistant ol { margin: 6px 0 10px; padding-left: 22px; }
.msg.assistant code { background: var(--heather-soft); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.msg.assistant pre { background: var(--heather-soft); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.msg.assistant blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--m, var(--accent)); color: var(--ink-2); }
.msg.pending { color: var(--ink-3); animation: pulse 1.2s ease-in-out infinite; }
.msg.error { color: #c0392b; }
@keyframes pulse { 50% { opacity: 0.4; } }
.sources { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; padding-left: 6px; }
.src-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); align-self: center; }
.src { font-size: 12px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 4px 10px; border-radius: 999px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 9; background: var(--bg-elev); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--line); padding: 8px 16px 10px; }
@media (min-width: 900px) { .composer { left: auto; right: auto; width: min(1100px - 32px - 274px, calc(100vw - 32px)); margin-left: calc((100vw - min(1100px, 100vw)) / 2 + 16px + 274px); } }
.composer-opts { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); color: var(--ink); resize: none; max-height: 160px; }
.sendbtn { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.starters .chip { flex: initial; white-space: normal; max-width: 100%; }
.top:has(.top-inner:empty) { display: none; }

.doc { display: block; }
.doc-row { display: flex; align-items: center; gap: 4px; }
.doc-by { font-size: 13px; color: var(--ink-2); }
.doc-summary { font-size: 13px; color: var(--ink-2); margin-top: 3px; font-style: italic; }
.doc-mod { font-weight: 700; color: var(--m); background: var(--m-soft); padding: 1px 8px; border-radius: 999px; margin-right: 4px; }
.doc-edit { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 12px 56px; }
.doc-edit .input.small { max-width: none; flex: 1 1 160px; }

.welcome .hint { font-size: 13px; color: var(--ink-3); margin: 0; }

.book-isbn { font-size: 13px; color: var(--ink-2); margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.isbn-num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); user-select: all; }
.copy { font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--line); background: transparent; color: var(--accent); border-radius: 999px; padding: 2px 8px; cursor: pointer; }

.book.in-library { border-left-color: var(--gorse); }
.book-lib { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.readlink { font-size: 13px; font-weight: 700; color: var(--gorse-ink); background: var(--gorse); padding: 6px 12px; border-radius: 999px; }
.lib-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.doc-rl { color: var(--accent); font-weight: 600; }
