/* Audio Reader: shared styles for the library and the reader. */

:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e3e1dc;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --hl-sent: rgba(255, 221, 87, 0.45);
  --hl-word: rgba(255, 159, 28, 0.8);
  --pdf-sent: rgba(255, 214, 10, 0.3);
  --pdf-word: rgba(255, 140, 0, 0.45);
  --dim: rgba(246, 245, 242, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 10px;
  --ui-font: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17181b;
  --panel: #1f2125;
  --ink: #e9e9ea;
  --muted: #9a9ba1;
  --line: #2e3036;
  --accent: #7aa5ff;
  --accent-ink: #10131a;
  --danger: #ff7b6b;
  --hl-sent: rgba(255, 214, 80, 0.2);
  --hl-word: rgba(255, 170, 60, 0.6);
  --dim: rgba(23, 24, 27, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
:root[data-theme="sepia"] {
  --bg: #f3ead7;
  --panel: #faf3e3;
  --ink: #3b2f20;
  --muted: #7a6a55;
  --line: #e0d3b8;
  --accent: #a35a1f;
  --accent-ink: #fff8ea;
  --hl-sent: rgba(240, 190, 80, 0.4);
  --hl-word: rgba(225, 130, 40, 0.7);
  --dim: rgba(243, 234, 215, 0.72);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--ui-font);
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 12px;
  line-height: 1.3;
}
a.btn { text-decoration: none; display: inline-block; color: inherit; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.icon-btn {
  border: 0;
  background: transparent;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.icon-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.icon-btn svg, .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- library */

.library { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }
.library header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.library h1 { font-size: 24px; margin: 0; flex: 1; letter-spacing: -0.01em; }
.status-pill { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa0a6; }
.status-pill.ready::before { background: #2ea043; }
.status-pill.loading::before { background: #e3a008; animation: pulse 1s infinite alternate; }
.status-pill.error::before { background: var(--danger); }
@keyframes pulse { to { opacity: 0.3; } }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.dropzone strong { color: var(--ink); display: block; font-size: 16px; margin-bottom: 4px; }
.dropzone .btn { margin-top: 12px; }
.upload-row { margin-top: 12px; font-size: 14px; color: var(--muted); }
.upload-row.error { color: var(--danger); }

.doc-list { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; }
.doc-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  align-items: center;
}
.doc-card h2 { font-size: 16px; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc-card h2 a { color: inherit; text-decoration: none; }
.doc-card h2 a:hover { color: var(--accent); }
.doc-meta { color: var(--muted); font-size: 13px; }
.doc-actions { display: flex; gap: 8px; grid-row: span 3; }
.doc-warn { grid-column: 1 / -1; font-size: 13px; color: var(--danger); }
.bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; max-width: 420px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }

/* signing in */
body.sign-in { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.sign-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 26px; text-align: center; }
.sign-card h1 { font-size: 22px; margin: 10px 0 6px; }
.sign-lead { color: var(--muted); margin: 0 0 18px; }
.sign-card form { display: grid; gap: 14px; text-align: left; }
.sign-card label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.sign-card input { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 10px 12px; font-size: 16px; font-weight: 400; }
.sign-card .btn { padding: 10px; font-size: 16px; }
.sign-error { margin: 0; color: var(--danger); font-size: 14px; }

/* account and sharing */
.account { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.account .btn { padding: 4px 10px; font-size: 13px; }
.people-lead { color: var(--muted); font-size: 14px; margin: 16px 2px 0; }
.people-warn { border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); padding: 8px 10px; border-radius: 6px; font-size: 14px; margin: 12px 0 0; }
.doc-card.person .doc-actions { grid-row: span 3; }
.person-chat { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 14px; }
.person-chat select, .invite-form select { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 5px 8px; }
.person-chat input { accent-color: var(--accent); }
.invite-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.invite-form input { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 8px 12px; }
.invite-result { margin-top: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; }
.invite-result p { margin: 8px 0 0; color: var(--muted); }
.invite-link { display: flex; gap: 8px; margin-top: 8px; }
.invite-link input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 8px 10px; font: 13px ui-monospace, Consolas, monospace; }

.lib-tabs { display: flex; gap: 4px; margin-top: 24px; border-bottom: 1px solid var(--line); }
.lib-tabs button { border: 0; background: transparent; padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lib-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.lib-tabs + section .doc-list { margin-top: 16px; }
.zotero-bar { display: flex; gap: 10px; margin-top: 16px; }
.zotero-bar input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 8px 12px; }
.zotero-bar select { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 8px 10px; max-width: 45%; }
.zotero-count { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }
.zotero-count + .doc-list { margin-top: 10px; }
#zoteroMore { display: block; margin: 16px auto 0; }
.doc-card.zotero { grid-template-columns: 1fr auto; }
.doc-card.zotero .doc-actions { grid-row: span 2; }
.doc-card.zotero.missing h2 { color: var(--muted); }
.doc-card .tag { font-size: 11.5px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); margin-left: 8px; font-weight: 400; white-space: nowrap; }

/* ----------------------------------------------------------------- reader */

body.reader-page {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 52px 1fr auto;
  grid-template-areas: "top top top" "side stage settings" "player player player";
  height: 100vh;
  overflow: hidden;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.topbar .title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.sidebar {
  grid-area: side;
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar.collapsed { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1 1 auto; border: 0; background: transparent; padding: 10px 4px; font-size: 13.5px; white-space: nowrap; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { flex: 1; overflow-y: auto; padding: 8px; min-height: 0; }

.outline-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.outline-item:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.outline-item.current { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
.outline-item.skipped { color: var(--muted); opacity: 0.6; }
.outline-item[data-level="2"] { padding-left: 22px; }
.outline-item[data-level="3"] { padding-left: 36px; font-size: 13px; }
.outline-item[data-level="4"] { padding-left: 50px; font-size: 13px; }
.side-empty { color: var(--muted); font-size: 14px; padding: 12px 8px; }

.bookmark { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; }
.bookmark .excerpt { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.bookmark .excerpt:hover { color: var(--ink); }
.bookmark textarea { width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 6px; resize: vertical; min-height: 34px; }
.bookmark .row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; color: var(--muted); }
.bookmark .row button { border: 0; background: transparent; color: var(--muted); padding: 2px 4px; }
.bookmark .row button:hover { color: var(--danger); }
.side-actions { display: flex; gap: 8px; padding: 4px 0 10px; }

.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; }
.view { position: absolute; inset: 0; overflow: auto; }

/* PDF view */
.pdf-view { padding: 20px; --zoom: 1; }
.page {
  position: relative;
  margin: 0 auto 18px;
  width: calc(var(--zoom) * min(820px, 100%));
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.page.flash { outline: 3px solid var(--accent); outline-offset: 3px; transition: outline-color 1.2s; }
.page img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.page .layer { position: absolute; inset: 0; pointer-events: none; }
.page .hl { position: absolute; border-radius: 2px; mix-blend-mode: multiply; }
.page .hl.sent { background: var(--pdf-sent); }
.page .hl.word { background: var(--pdf-word); outline: 1.5px solid rgba(230, 120, 0, 0.9); outline-offset: 1px; }
.page .hl.mark { background: rgba(47, 111, 237, 0.9); mix-blend-mode: normal; border-radius: 2px; }
.page svg.dimmer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; }
.pdf-view.focus .page svg.dimmer { display: block; }
.page svg.dimmer path { fill: rgba(255, 255, 255, 0.78); fill-rule: evenodd; }
.page-num { position: absolute; right: -4px; top: 0; transform: translateX(100%); font-size: 12px; color: var(--muted); padding-left: 8px; }

/* Reader view */
.text-view { padding: 36px 24px 50vh; }
.text-col {
  --reader-size: 20px;
  --reader-line: 1.7;
  --reader-width: 680px;
  --reader-font: Georgia, "Times New Roman", serif;
  --reader-spacing: 0em;
  max-width: var(--reader-width);
  margin: 0 auto;
  font-family: var(--reader-font);
  font-size: var(--reader-size);
  line-height: var(--reader-line);
  letter-spacing: var(--reader-spacing);
}
.text-col p { margin: 0 0 1em; }
.text-col h1, .text-col h2, .text-col h3, .text-col h4 { font-family: var(--ui-font); line-height: 1.25; margin: 1.6em 0 0.6em; letter-spacing: 0; }
.text-col h1 { font-size: 1.6em; margin-top: 0; }
.text-col h2 { font-size: 1.3em; }
.text-col h3 { font-size: 1.12em; }
.text-col h4 { font-size: 1em; }
.text-col .caption { font-size: 0.88em; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; }
.text-col .equation { font-family: "Cambria Math", Cambria, serif; text-align: center; color: var(--muted); }
.text-col .footnote, .text-col .reference, .text-col .table, .text-col .figure, .text-col .front { font-size: 0.85em; color: var(--muted); }
.text-col .w { cursor: pointer; border-radius: 3px; }
.text-col .w:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.text-col .s { border-radius: 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: opacity 0.2s; }
.text-col .s.cur { background: var(--hl-sent); }
.text-col .w.cur { background: var(--hl-word); box-shadow: 0 0 0 2px var(--hl-word); }
.text-col .w.marked { border-bottom: 2px solid var(--accent); }
.text-view.focus .s { opacity: 0.25; }
.text-view.focus .s.cur { opacity: 1; }

.follow-btn {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: var(--shadow);
  font-weight: 600;
  z-index: 5;
}
.notice {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: min(560px, 90%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 6;
  font-size: 14px;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 108px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 14px;
  z-index: 20;
  max-width: 340px;
}
.toast .bar { margin-top: 8px; }

/* settings panel */
.settings {
  grid-area: settings;
  width: 300px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 14px 16px 24px;
}
.settings h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.settings h3:first-child { margin-top: 0; }
.settings label.check { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 14px; cursor: pointer; }
.settings label.check input { margin-top: 3px; accent-color: var(--accent); }
.settings label.check small { display: block; color: var(--muted); }
.field { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.field input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.field output { color: var(--muted); font-variant-numeric: tabular-nums; }
.settings select, .player select { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 8px; max-width: 100%; }
.settings .hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.keys { font-size: 13px; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
kbd { font: 12px/1.4 ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--bg); color: var(--ink); white-space: nowrap; }

/* defined terms: underlined uses, hover card, glossary tab */
.page .layer.terms { pointer-events: none; }
.term-mark {
  position: absolute; pointer-events: auto; cursor: help;
  border-bottom: 1.5px dotted rgba(47, 111, 237, 0.95); border-radius: 2px;
}
.term-mark:hover { background: rgba(47, 111, 237, 0.14); }
.text-col .w.term { border-bottom: 1.5px dotted var(--accent); cursor: help; }
body.no-terms .term-mark { display: none; }
body.no-terms .text-col .w.term { border-bottom: 0; cursor: pointer; }
.flash-word { position: absolute; border-radius: 3px; outline: 3px solid var(--accent); background: rgba(47, 111, 237, 0.18); pointer-events: none; animation: fade-out 2.2s forwards; }
.text-col .w.flash { outline: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
@keyframes fade-out { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.term-tip {
  position: fixed; z-index: 40; width: min(360px, calc(100vw - 16px));
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 12px; font-size: 14px; line-height: 1.45;
}
.tip-head { display: flex; align-items: baseline; gap: 8px; }
.tip-head strong { font-size: 16px; }
.tip-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tip-def { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.tip-context { margin: 6px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tip-context mark { background: var(--hl-sent); color: inherit; padding: 0 2px; border-radius: 3px; }
.tip-go { margin-top: 8px; border: 0; background: transparent; color: var(--accent); padding: 0; font-size: 13px; font-weight: 600; }
.tip-go:hover { text-decoration: underline; }
.gloss-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 8px 4px; }
.gloss-item {
  display: grid; grid-template-columns: auto 1fr; gap: 0 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; font-size: 13.5px; line-height: 1.35;
}
.gloss-item:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.gloss-item span { overflow-wrap: anywhere; }
.gloss-item small { grid-column: 2; color: var(--muted); font-size: 12px; }

/* ask Claude */
.chat {
  grid-area: settings;
  width: 400px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-model { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.page-ref { white-space: nowrap; }
.chat-head .btn { padding: 3px 10px; font-size: 13px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 100%; }
.chat-msg.user { align-self: flex-end; max-width: 88%; }
.chat-msg.user .chat-body {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border-radius: 14px 14px 4px 14px;
  padding: 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-msg.assistant .chat-body { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.chat-body > :first-child { margin-top: 0; }
.chat-body > :last-child { margin-bottom: 0; }
.chat-body p { margin: 0 0 0.7em; }
.chat-body h3, .chat-body h4, .chat-body h5, .chat-body h6 { font-size: 1em; margin: 1em 0 0.4em; }
.chat-body h3 { font-size: 1.08em; }
.chat-body ul, .chat-body ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.chat-body li { margin: 0.2em 0; }
.chat-body li.nested { margin-left: 1.2em; }
.chat-body code { font: 0.9em ui-monospace, Consolas, monospace; background: color-mix(in srgb, var(--ink) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.chat-body pre { background: color-mix(in srgb, var(--ink) 7%, transparent); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 0 0 0.7em; font: 13px/1.45 ui-monospace, Consolas, monospace; }
.chat-body pre code { background: none; padding: 0; font: inherit; }
.chat-body blockquote { margin: 0 0 0.7em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.chat-body a { color: var(--accent); }
.page-ref {
  border: 0; padding: 0 5px; border-radius: 5px; font: inherit; font-size: 0.92em;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600;
}
.page-ref:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.chat-status { color: var(--muted); font-size: 13.5px; font-style: italic; }
.chat-msg.assistant .chat-status:only-child { animation: pulse 0.9s infinite alternate; }
.chat-error { border-left: 3px solid var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); padding: 8px 10px; border-radius: 6px; font-size: 14px; }
.chat-hint { background: color-mix(in srgb, var(--ink) 5%, transparent); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.chat-hint p { margin: 6px 0 0; color: var(--muted); }
.chat-hint ol { margin: 8px 0 12px; padding-left: 1.3em; }
.chat-hint li { margin: 6px 0; }
.chat-hint pre { margin: 6px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--bg); font: 12.5px ui-monospace, Consolas, monospace; overflow-x: auto; }
.chat-hint a { color: var(--accent); }
.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 0; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 11px; font-size: 13px; }
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.chip:disabled, .chat-send:disabled { opacity: 0.45; cursor: default; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px 6px; }
.chat-compose textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 8px 10px; line-height: 1.4; max-height: 160px; min-height: 38px;
}
.chat-send.stop { background: var(--panel); color: var(--danger); border-color: var(--danger); }
.chat-note { margin: 0; padding: 0 14px 10px; font-size: 11.5px; color: var(--muted); }
.chat-note kbd { font-size: 10.5px; }

/* player */
.player {
  grid-area: player;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 16px 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "seek seek seek" "left transport right";
  gap: 4px 16px;
  align-items: center;
}
.seek { grid-area: seek; display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek input { flex: 1; accent-color: var(--accent); height: 18px; }
.player .left { grid-area: left; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .left b { color: var(--ink); font-weight: 600; }
.transport { grid-area: transport; display: flex; align-items: center; gap: 4px; }
.play-btn {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; margin: 0 6px;
}
.play-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.play-btn.loading { animation: pulse 0.7s infinite alternate; }
.play-btn:disabled { opacity: 0.4; cursor: default; }
.player .right { grid-area: right; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.speed { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; }
.speed button { border: 0; background: transparent; width: 30px; height: 32px; font-size: 16px; }
.speed output { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }

.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; min-width: 250px; z-index: 30;
}
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; }
.menu-list button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.menu-list small { display: block; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { position: absolute; z-index: 15; top: 52px; bottom: 0; left: 0; box-shadow: var(--shadow); }
  .settings { position: absolute; z-index: 15; top: 52px; bottom: 0; right: 0; box-shadow: var(--shadow); }
  .chat { position: absolute; z-index: 15; top: 52px; bottom: 0; right: 0; width: min(400px, 100%); box-shadow: var(--shadow); }
  .player { grid-template-columns: auto 1fr; grid-template-areas: "seek seek" "transport right"; }
  .player .left { display: none; }
  .page-num { display: none; }
}
