/* Themes: white (default), pastel, black. With no explicit choice the system light/dark setting is used. */
:root {
  --bg: #ffffff; --fg: #000000; --muted: #6e6e6e; --line: #e6e6e6;
  --accent: #000000; --accent-fg: #ffffff; --dim: #b3b3b3; --para: #f4f4f4; --panel: #ffffff;
  --dotline: rgba(0,0,0,.35); --hl-pct: 50%; --sel-pct: 50%;
  --fs: 19px;
}
:root[data-theme="pastel"] {
  --bg: #f9e8d0; --fg: #40382c; --muted: #8a7a66; --line: #e8d3b5;
  --accent: #40382c; --accent-fg: #f9e8d0; --dim: #bfae93; --para: #f3dfc2; --panel: #fcf0de;
  --dotline: rgba(64,56,44,.35); --hl-pct: 50%; --sel-pct: 50%;
}
:root[data-theme="dark"] {
  --bg: #000000; --fg: #ffffff; --muted: #9a9a9a; --line: #262626;
  --accent: #ffffff; --accent-fg: #000000; --dim: #5c5c5c; --para: #161616; --panel: #111111;
  --dotline: rgba(255,255,255,.35); --hl-pct: 20%; --sel-pct: 20%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #000000; --fg: #ffffff; --muted: #9a9a9a; --line: #262626;
    --accent: #ffffff; --accent-fg: #000000; --dim: #5c5c5c; --para: #161616; --panel: #111111;
    --dotline: rgba(255,255,255,.35); --hl-pct: 20%; --sel-pct: 20%;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#top {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: 52px;
  padding: env(safe-area-inset-top) 12px 0 12px; box-sizing: content-box;
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
#top button { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; }
#heading { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: center; }
#bookTitle { font-size: 12px; color: var(--muted); }
#chapTitle { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#page { position: relative; padding: calc(52px + env(safe-area-inset-top) + 24px) 28px calc(180px + env(safe-area-inset-bottom)); }
#text { max-width: 38rem; margin: 0 auto; font: var(--fs)/1.65 Georgia, "Times New Roman", serif; hyphens: auto; }
#text p { margin: 0 0 1em; padding: 2px 6px; margin-left: -6px; margin-right: -6px; border-radius: 8px; }
#text .part, #text .title, #text .subhead, #text .tagline { hyphens: manual; }
#text .part { font: 600 13px/1.3 -apple-system, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
#text .title { font: 700 1.7em/1.2 Georgia, serif; margin: .2em 0 .3em; }
#text .tagline { font-style: italic; color: var(--muted); }
#text .epigraph { font-style: italic; margin-left: 1.2em; margin-right: 0; color: var(--muted); font-size: .95em; }
#text .subhead { font: 700 1.2em/1.3 Georgia, serif; margin-top: 1.6em; }
#text .formula { font: 500 .9em/1.5 ui-monospace, Menlo, monospace; text-align: center; background: var(--para); padding: 10px 12px; }
#text .note { font-size: .88em; line-height: 1.5; color: var(--muted); }
#text .note.active { color: var(--fg); }
#notesBox { margin-top: 2.5em; border-top: 1px solid var(--line); padding-top: 1em; }
#notesBox > summary { cursor: pointer; font: 600 15px -apple-system, sans-serif; color: var(--accent); padding: 8px 0; }
.chapter-end { text-align: center; margin: 2em 0; }
.chapter-end button { padding: 12px 20px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent); font-weight: 600; }

.w { cursor: pointer; }
/* while listening: unread text is dimmed, read text is full colour */
#text.listening p { color: var(--dim); transition: color .2s; }
#text.listening .w { transition: color .2s; }
#text.listening p.read, #text.listening .w.read { color: var(--fg); }
#text.listening .note { color: var(--dim); }
#text.listening .note.read { color: var(--fg); }
sup.fn { font: 600 .6em -apple-system, sans-serif; color: var(--accent); cursor: pointer; margin-left: 1px; }

#player {
  position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto;
  padding: 12px 14px 10px; border-radius: 28px;
  background: color-mix(in srgb, var(--bg) 38%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid color-mix(in srgb, var(--fg) 12%, transparent);
  box-shadow: 0 12px 34px rgba(0,0,0,.16);
  transition: opacity .28s ease, transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
/* reading mode: only a round glass play button */
body:not(.expanded) #player { opacity: 0; transform: translateY(26px) scale(.9); visibility: hidden; pointer-events: none; transition: opacity .2s ease, transform .25s ease, visibility 0s .25s; }
#fab {
  position: fixed; z-index: 21; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); width: 60px; height: 60px; margin-left: -30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: var(--fg);
  background: color-mix(in srgb, var(--bg) 38%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid color-mix(in srgb, var(--fg) 14%, transparent); box-shadow: 0 8px 26px rgba(0,0,0,.18);
  transition: opacity .25s ease, transform .3s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
#fab svg { margin-left: 2px; }
body.expanded #fab { opacity: 0; transform: scale(.55); visibility: hidden; pointer-events: none; transition: opacity .18s ease, transform .22s ease, visibility 0s .22s; }
.seek { display: flex; align-items: center; gap: 10px; font: 12px ui-monospace, Menlo, monospace; color: var(--muted); margin: 0 auto; }
.seek input { flex: 1; accent-color: var(--accent); height: 28px; }
.ctrl { display: flex; justify-content: space-between; align-items: center; gap: 2px; margin: 2px auto 0; }
.ctrl button { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 44px; padding: 0 5px; border-radius: 12px; font-size: 15px; }
.ctrl button:hover { background: var(--para); }
.ctrl .primary { width: 60px; height: 50px; background: var(--accent); color: var(--accent-fg); border-radius: 25px; margin: 0 2px; }
.ctrl .primary:hover { background: var(--accent); opacity: .88; }

#follow {   /* "back to the voice": translucent white glass, sits just above the player */
  position: fixed; z-index: 15; left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--player-h, 104px) + 10px + 8px + env(safe-area-inset-bottom)); white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font: 600 13px -apple-system, sans-serif; color: #000;
  background: rgba(255,255,255,.62); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid rgba(0,0,0,.08); box-shadow: 0 6px 18px rgba(0,0,0,.14);
}

#drawer { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(88vw, 380px); background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.drawer-inner { flex: 1; overflow-y: auto; }
#drawer[hidden], #scrim[hidden], #sheet[hidden], #follow[hidden] { display: none; }
#scrim { position: fixed; inset: 0; z-index: 25; background: #0006; }
#toc { list-style: none; margin: 0; padding: 12px 0; }
#toc .part { padding: 16px 20px 6px; font: 600 12px -apple-system, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
#toc button { display: block; width: 100%; text-align: left; padding: 10px 20px; font-size: 15px; line-height: 1.3; }
#toc button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
#toc button.now { background: var(--para); font-weight: 600; }
#toc button:hover { background: var(--para); }

#sheet { position: fixed; z-index: 40; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 8px 28px #0005; display: flex; flex-wrap: wrap; gap: 6px; max-width: 92vw; justify-content: center; }
#sheet button { padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
#sheet button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

@media (min-width: 900px) {
  #page { padding-left: 24px; }
  #text p { padding: 3px 10px; margin-left: -10px; margin-right: -10px; }
}

#banner[hidden], #login[hidden], #pwDialog[hidden], #logout[hidden] { display: none; }
#banner { position: fixed; z-index: 35; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top)); width: min(92vw, 520px); display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 22px #0004; font-size: 14px; }
#banner span { flex: 1; }
#banner button { padding: 6px 10px; border-radius: 8px; color: var(--accent); font-weight: 600; }
#login, #pwDialog { position: fixed; z-index: 60; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
#loginForm, #pwForm { width: min(100%, 380px); display: flex; flex-direction: column; gap: 12px; }
#loginForm h2, #pwForm h2 { margin: 0; font: 700 28px Georgia, serif; }
#loginForm p, #pwForm p { margin: 0; color: var(--muted); }
#loginForm input, #pwForm input { font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); }
.primary-btn { background: var(--accent); color: var(--accent-fg) !important; padding: 12px; border-radius: 10px; font-weight: 600; }
.link-btn { color: var(--muted) !important; text-decoration: underline; padding: 8px; }

#pwDialog { z-index: 61; }

/* ---------- marks: position dots, selection, comments ---------- */
#marks { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#marks > * { pointer-events: auto; }
.dot { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; padding: 0; border-radius: 50%; background: var(--c);
  transition: left .25s, top .25s; cursor: pointer; }
.dot::after { content: ''; position: absolute; inset: -14px; }
.dot[hidden] { display: none; }
.dot.own { z-index: 2; }
.mk { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; padding: 0; border-radius: 50%; background: var(--c); cursor: pointer; transition: transform .15s; }
.mk::after { content: ''; position: absolute; inset: -9px; }
.mk.open { transform: scale(1.5); }
.handle { position: absolute; width: 32px; height: 32px; margin: -16px 0 0 -16px; touch-action: none; cursor: grab; z-index: 3;
  transition: left .3s cubic-bezier(.2,.8,.2,1), top .3s cubic-bezier(.2,.8,.2,1); }
.handle.dragging, .handle.nofly { transition: none; }
#marks > .dot.own.picked { opacity: 0; pointer-events: none; }   /* id selector: must beat '#marks > *' or the hidden dot keeps catching taps */
.handle::before { content: ''; position: absolute; left: 13px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
/* highlights live in their own layer UNDER the text: one rounded plate per line, no gaps between words */
#hl { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
#text { position: relative; z-index: 1; }
.hlr { position: absolute; border-radius: 7px; background: color-mix(in srgb, var(--c) var(--hl-pct), transparent); }
.hlr.selr { background: color-mix(in srgb, var(--c) var(--sel-pct), transparent); }
.pcard { position: absolute; z-index: 6; width: 190px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 20px #0004; font: 13px/1.4 -apple-system, sans-serif; }
.pcard b { color: var(--fg); border-bottom: 3px solid var(--c); }
.pcard button { margin-top: 8px; color: var(--accent); font-weight: 600; }

.composer, .thread { margin: -.3em 0 1.2em; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--fg); }
.cq { color: var(--muted); font-style: italic; margin-bottom: 8px; }
.composer textarea, .reply textarea { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: none; }
.crow { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { padding: 6px 12px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--fg); color: var(--bg); }
.crow .cancel { color: var(--muted); padding: 8px 10px; }
.crow .send, .reply button { background: var(--accent); color: var(--accent-fg); padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.crow .send:disabled, .reply button:disabled { opacity: .5; }
.tg { padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.tn { margin-bottom: 8px; }
.tn + .tn { margin-left: 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.th { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.th i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--dotline); }
.th b { color: var(--fg); font-weight: 600; }
.th button { font-size: 12px; color: var(--muted); text-decoration: underline; padding: 2px 4px; }
.tn blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); font-style: italic; }
.tb { white-space: pre-wrap; margin-top: 4px; }
.tb.muted { color: var(--muted); }
.reply { display: flex; gap: 8px; align-items: flex-end; margin-top: 6px; }
.reply textarea { flex: 1; min-height: 38px; max-height: 120px; }
.thread .close { color: var(--muted); font-size: 13px; text-decoration: underline; }
#toc .pdot { display: inline-block; width: 9px; height: 9px; margin-left: 8px; border-radius: 50%; vertical-align: 1px; box-shadow: 0 0 0 1px var(--dotline); }
@media (min-width: 900px) { #page { padding-left: 40px; padding-right: 40px; } }

/* drawer footer: my colour + name; tapping the circle pops up three more colours */
#me { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
#meBtn, #palette button { width: 36px; height: 36px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px var(--dotline); }
#meName { font-weight: 600; font-size: 15px; }
#palette { position: absolute; left: 18px; bottom: calc(100% - 6px); display: flex; flex-direction: column-reverse; gap: 10px; padding-bottom: 6px; pointer-events: none; }
#palette button { opacity: 0; transform: translateY(14px) scale(.55); transition: opacity .2s ease, transform .26s cubic-bezier(.2,.8,.2,1); }
#palette.open { pointer-events: auto; }
#palette.open button { opacity: 1; transform: none; }
#palette.open button:nth-child(2) { transition-delay: .04s; }
#palette.open button:nth-child(3) { transition-delay: .08s; }
#speed { min-width: 44px !important; height: 30px !important; font: 600 13px -apple-system, sans-serif; color: var(--muted); border: 1px solid var(--line); border-radius: 999px !important; }
#sleep.on { color: var(--accent); background: color-mix(in srgb, var(--fg) 10%, transparent); }
#sleep, #prev, #next, #back, #fwd { color: var(--fg); }
#notesBox > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style-position: inside; }
#notesBtn { font: 600 13px -apple-system, sans-serif; color: var(--fg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px; }
#notesBtn svg { width: 14px; height: 14px; }
#notesBtn.on { background: var(--fg); color: var(--bg); }

/* ---------- one glass language: header, menu, sheets, banner ---------- */
:root { --glass-bg: color-mix(in srgb, var(--bg) 46%, transparent); --glass-line: color-mix(in srgb, var(--fg) 12%, transparent); --glass-shadow: 0 12px 34px rgba(0,0,0,.16); }
#top {
  inset: auto; left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top)); max-width: 720px; margin: 0 auto;
  height: 52px; padding: 0 6px; box-sizing: border-box; border: 1px solid var(--glass-line); border-radius: 26px;
  background: var(--glass-bg); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); box-shadow: var(--glass-shadow);
}
#top button { border-radius: 50%; display: grid; place-items: center; }   /* centre the icon: an inline svg would sit on the text baseline */
#page { padding-top: calc(52px + 8px + env(safe-area-inset-top) + 28px); }
#drawer {
  inset: auto; left: 12px; top: calc(8px + env(safe-area-inset-top)); bottom: calc(10px + env(safe-area-inset-bottom)); width: min(86vw, 360px);
  padding-top: 0; border: 1px solid var(--glass-line); border-radius: 28px; overflow: hidden;
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); box-shadow: var(--glass-shadow);
}
#drawer:not([hidden]) { animation: glass-in .28s cubic-bezier(.2,.8,.2,1); }
@keyframes glass-in { from { opacity: 0; transform: translateX(-14px) scale(.97); } to { opacity: 1; transform: none; } }
.drawer-inner { padding-top: 8px; }
#me { border-top-color: var(--glass-line); }
#scrim { background: rgba(0,0,0,.14); }
#sheet { background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); border: 1px solid var(--glass-line); border-radius: 22px; box-shadow: var(--glass-shadow); }
#banner { background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); border: 1px solid var(--glass-line); border-radius: 22px; top: calc(70px + env(safe-area-inset-top)); box-shadow: var(--glass-shadow); }

/* menu footer: who is where (partner row + my row with settings under the gear) */
#people { border-top: 1px solid var(--glass-line); padding: 4px 14px calc(8px + env(safe-area-inset-bottom)); }
.person { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 2px; }
.ring { position: relative; width: 42px; height: 42px; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.5; }
.ring .track { stroke: color-mix(in srgb, var(--fg) 12%, transparent); }
.ring .arc { stroke: var(--c); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; transition: stroke-dashoffset .4s ease; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 12px -apple-system, sans-serif; color: var(--muted); }
.who { flex: 1; min-width: 0; }
.who b { display: block; font: 600 16px/1.25 -apple-system, sans-serif; }
.who small { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; font: 600 13px -apple-system, sans-serif; padding: 8px 12px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 8%, transparent); }
#gearBtn { flex: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); border-radius: 50%; }
#gearBtn[aria-expanded="true"] { color: var(--fg); background: color-mix(in srgb, var(--fg) 8%, transparent); }
/* gear: the rows slide up and a settings strip opens underneath */
#settings { display: flex; flex-direction: column; gap: 10px; max-height: 0; opacity: 0; overflow: hidden; padding: 0 2px;
  transition: max-height .32s cubic-bezier(.2,.8,.2,1), opacity .2s ease, padding .32s cubic-bezier(.2,.8,.2,1); }
#settings { border-top: 1px solid transparent; }
#settings.open { max-height: 140px; opacity: 1; padding: 10px 2px 6px; border-top-color: var(--glass-line); }
.colors { display: flex; gap: 12px; padding: 4px 2px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; background: var(--c); }
.colors button.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.acts { display: flex; align-items: center; gap: 8px; }
.act.icon { margin-left: auto; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; color: var(--muted); }   /* log out: bottom-right corner */
.act { font: 600 14px -apple-system, sans-serif; padding: 9px 14px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 8%, transparent); }
#settings .act[hidden] { display: none; }

/* header: menu on the left, titles right after it (left-aligned), partner ring and Aa on the right */
#top { gap: 4px; }
#heading { text-align: left; align-items: flex-start; padding-left: 2px; }
#bookTitle, #chapTitle { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring.sm { width: 30px; height: 30px; }
.ring.sm circle { stroke-width: 3; }
.ring.sm span { font-size: 10px; color: var(--fg); }

/* other readers: progress rings in the header (tap = go to that place) */
#partners { display: flex; gap: 0; }
.pbtn { width: 40px; height: 40px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
/* comment recipients: coloured initials, on by default; tap to leave someone out */
.rcpts { display: flex; gap: 6px; }
.rcpts[hidden] { display: none; }
.rc { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 12px -apple-system, sans-serif; color: #000;
  background: var(--c); transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.rc:not(.on) { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--c); }
.rc.me { cursor: default; }

/* login logo, centred; the three dots over the "i" are moved by logo.js (they jump past each other) */
.brand { margin: 0 0 clamp(40px, 9vh, 96px); line-height: 0; text-align: center; }   /* logo sits well above the fields */
.brand .logo { display: inline-block; width: 190px; height: auto; color: var(--fg); overflow: visible; }
.leap { transform-box: fill-box; transform-origin: 50% 100%; }


/* comment form: floating glass sheet at the bottom; the player steps aside while it is open */
.composer.floating {
  position: fixed; z-index: 24; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto;
  padding: 14px; border-radius: 24px; border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1); transition: transform .2s ease;
}
.composer.floating textarea { background: color-mix(in srgb, var(--bg) 70%, transparent); }
@keyframes sheet-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
body.composing #player, body.composing #fab, body.composing #follow { opacity: 0; transform: translateY(26px) scale(.94); visibility: hidden; pointer-events: none;
  transition: opacity .2s ease, transform .25s ease, visibility 0s .25s; }
body.composing #follow { transform: translate(-50%, 26px); }
.crow .del { color: #e5484d; padding: 8px 10px; font-weight: 600; }
.crow .del[hidden] { display: none; }

/* selection actions: three glass circles; "comment" turns them into the field + who-sees-it circles + close */
.composer.floating { background: none; border: 0; box-shadow: none; padding: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
  max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.composer .cbox { position: relative; width: 100%; display: none; }
.composer.mode-comment .cbox { display: block; animation: sheet-up .25s cubic-bezier(.2, .8, .2, 1); }
.composer .cbox textarea { display: block; width: 100%; min-height: 89px; margin: 0; resize: none; border-radius: 18px;   /* 18 = 14 (button radius) + 4 (gap) */
  padding: 12px 14px; font: 16px/1.4 -apple-system, BlinkMacSystemFont, sans-serif; color: var(--fg);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); }
.composer .cbox textarea:focus { outline: none; }
.composer .selrows { display: grid; }
.composer .selrow { grid-area: 1 / 1; display: flex; justify-content: center; align-items: center; gap: 10px; transition: opacity .2s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }
.composer .rc-row { opacity: 0; transform: scale(.8); pointer-events: none; }
.composer.mode-comment .acts-row { opacity: 0; transform: scale(.8); pointer-events: none; }
.composer.mode-comment .rc-row { opacity: 1; transform: none; pointer-events: auto; }
.composer .rcpts { display: flex; gap: 10px; }
.sbtn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--fg);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%); }
.sbtn.on { background: var(--me); color: #000; border-color: transparent; }
.sbtn.done { color: #2e9d57; }
.sbtn.fail { color: #e5484d; }
.composer .rc { width: 32px; height: 32px; box-shadow: var(--glass-shadow); }
.composer .rc:not(.on) { background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  color: var(--muted); box-shadow: inset 0 0 0 1px var(--glass-line), var(--glass-shadow); }
/* selection buttons: same size as the glass Play button */
.sbtn, .composer .rc { width: 60px; height: 60px; }
.composer .selrow, .composer .rcpts { gap: 12px; }
.sbtn svg { width: 26px; height: 26px; }
.composer .rc { font: 700 18px -apple-system, BlinkMacSystemFont, sans-serif; }

/* send = bright "+" in the row (replaces "close"); a grab bar above the field folds it away */
.composer .sbtn.send { background: var(--me); color: #000; border-color: transparent; opacity: .45; transition: opacity .15s ease, transform .15s ease; }
.composer .sbtn.send.ready { opacity: 1; }
.composer .sbtn.send:active { transform: scale(.94); }
.composer .sbtn.send svg { width: 26px; height: 26px; }
.grab { display: none; width: 44px; height: 18px; padding: 0; position: relative; touch-action: none; }
.grab::before { content: ''; position: absolute; left: 6px; right: 6px; top: 6px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--fg) 30%, transparent); }
.composer.mode-comment .grab { display: block; }

/* reading app, not a web page: no zoom, no system text selection in the book */
html { touch-action: manipulation; }
#text { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { font-size: 16px; }   /* iOS zooms into fields with smaller text */
.mk.big { width: 18px; height: 18px; margin: -9px 0 0 -9px; display: grid; place-items: center; color: #000;   /* a comment, not just a highlight */
  box-shadow: 0 0 0 2px var(--bg); }
.mk.big svg { width: 12px; height: 12px; }

/* comment sheet: same glass as the comment form; thread on top, answer field + "Ответить" below */
.thread.sheet { position: fixed; z-index: 24; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto;
  padding: 2px 14px 12px; border-radius: 24px; display: flex; flex-direction: column; gap: 8px; max-height: min(70vh, 560px);
  border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1); transition: transform .2s ease; }
.thread.sheet .grab { display: block; align-self: center; }
.thread.sheet .tlist { overflow-y: auto; min-height: 0; }
.thread.sheet .tg { border-bottom: 0; margin: 0; padding: 4px 0; }
.thread.sheet .tg.target { box-shadow: inset 3px 0 0 var(--me); padding-left: 10px; }
.thread.sheet .reply { display: flex; gap: 8px; align-items: flex-end; margin: 0; }
.thread.sheet .reply textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 14px; border-radius: 22px; font: 16px/1.35 -apple-system, sans-serif;
  border: 1px solid var(--glass-line); background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--fg); resize: none; }
.thread.sheet .reply button { height: 44px; padding: 0 18px; border-radius: 22px; background: var(--me); color: #000; font: 600 15px -apple-system, sans-serif; }
.thread.sheet .reply button:disabled { opacity: .45; }

/* selection buttons inverted for contrast over the text: dark on light themes, light on the black theme */
.composer .sbtn:not(.on):not(.send) { background: color-mix(in srgb, var(--fg) 88%, transparent); color: var(--bg); border-color: transparent; }
.composer .rc:not(.on) { background: color-mix(in srgb, var(--fg) 88%, transparent); color: color-mix(in srgb, var(--bg) 70%, transparent);
  box-shadow: var(--glass-shadow); }
