:root {
  --bg: #07060d;
  --text: #efeaf8;
  --muted: #a49cb8;
  --faint: #6b6380;
  --line: rgba(196, 181, 253, 0.12);
  --glass: rgba(24, 18, 40, 0.55);
  --glass-2: rgba(40, 30, 66, 0.6);
  --violet: #8b5cf6;
  --lilac: #c4b5fd;
  --orchid: #e879f9;
  --gold: #e9c47e;
  --mood: #a78bfa;
  --lvl: 0;
  --r: 18px;
  --display: 'Cormorant Garamond', 'Times New Roman', serif;
  --caps: 'Cinzel', 'Times New Roman', serif;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --dock-h: 128px;
  color-scheme: dark;
}
body[data-mood='amused'] { --mood: #f0abfc; }
body[data-mood='brooding'] { --mood: #7c6cf0; }
body[data-mood='menacing'] { --mood: #f0508a; }
body[data-mood='solemn'] { --mood: #a5b4cf; }
body[data-mood='delighted'] { --mood: #f5c97a; }
body[data-mood='wistful'] { --mood: #8ecbf5; }
body[data-mood='intense'] { --mood: #ff6fb5; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip; /* not "hidden": that would break the sticky reaction bar */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--lilac); }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#smoke, #embers { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#smoke { z-index: 0; filter: saturate(1.1); }
#embers { z-index: 1; }

.app {
  position: relative; z-index: 2;
  max-width: 580px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px calc(env(safe-area-inset-bottom) + 40px);
}
body[data-view='stage'] .app { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 24px); }

/* ---------- top bar ---------- */
.top { display: flex; justify-content: space-between; align-items: center; height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--caps); font-size: 12.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--lilac); }
.brand-mark { width: 9px; height: 9px; rotate: 45deg; border: 1.5px solid var(--gold); box-shadow: 0 0 12px rgba(233, 196, 126, .6); }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: background .2s, transform .15s, border-color .2s, color .2s;
}
.icon-btn:hover { background: var(--glass-2); border-color: rgba(196, 181, 253, .25); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn.accent { background: linear-gradient(135deg, var(--violet), #b153e8); border-color: transparent; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--orchid); box-shadow: 0 0 10px var(--orchid); }

/* ---------- presence / avatar ---------- */
.presence { display: flex; flex-direction: column; align-items: center; margin: 14px 0 6px; transition: margin .5s; }
.who { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 14px; }
.name { font-family: var(--caps); font-size: 15px; letter-spacing: .18em; color: var(--gold); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background .4s; }
body.playing .pulse { background: var(--mood); box-shadow: 0 0 10px var(--mood); animation: blink 1.6s ease-in-out infinite; }
body.thinking .pulse { background: var(--gold); animation: blink .8s ease-in-out infinite; }

body[data-view='stage'] .presence { margin-top: 2px; }
body[data-view='stage'] .who { margin-top: 10px; }

/* ---------- composer ---------- */
.composer { display: flex; flex-direction: column; gap: 22px; margin-top: 18px; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.greeting { text-align: center; }
.eyebrow { margin: 0; font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
h1 { margin: 8px 0 0; font-family: var(--display); font-weight: 500; font-size: clamp(30px, 8vw, 40px); line-height: 1.08; text-wrap: balance; }
h1 em { color: var(--lilac); }
.label { display: block; font-size: 12.5px; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.value { font-size: 13px; color: var(--lilac); font-variant-numeric: tabular-nums; }
.group, .panel { display: flex; flex-direction: column; }
.panel { gap: 12px; animation: rise .35s cubic-bezier(.2, .8, .2, 1); }
.panel .label { margin-bottom: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--glass); border-radius: 999px;
  padding: 8px 14px; font-size: 13.5px; color: var(--muted); white-space: nowrap;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: color .2s, background .2s, border-color .2s, transform .15s;
}
.chip svg { width: 15px; height: 15px; }
.chip:hover { color: var(--text); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed='true'], .chip[aria-checked='true'] {
  color: #f5f0ff; border-color: color-mix(in srgb, var(--violet) 70%, transparent);
  background: linear-gradient(135deg, rgba(139, 92, 246, .35), rgba(232, 121, 249, .18));
}
.chip:disabled { opacity: .35; pointer-events: none; }

.programs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.programs button {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 2px; align-items: center;
  text-align: left; padding: 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color .25s, background .25s, transform .15s;
}
.programs button svg { grid-row: span 2; width: 22px; height: 22px; color: var(--lilac); }
.programs b { font-weight: 600; font-size: 14.5px; }
.programs small { font-size: 12px; color: var(--muted); line-height: 1.3; }
.programs button:active { transform: scale(.98); }
.programs button[aria-checked='true'] {
  border-color: color-mix(in srgb, var(--violet) 75%, transparent);
  background: linear-gradient(150deg, rgba(139, 92, 246, .3), rgba(30, 20, 50, .55));
  box-shadow: 0 10px 30px rgba(139, 92, 246, .18);
}

.input {
  width: 100%; min-height: 48px; padding: 12px 15px; border-radius: 14px;
  background: rgba(14, 10, 26, .6); border: 1px solid var(--line); color: var(--text); font-size: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s;
}
textarea.input { resize: vertical; line-height: 1.45; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input:focus { outline: none; border-color: rgba(167, 139, 250, .6); }
.input::placeholder { color: var(--faint); }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; }
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--violet) var(--fill, 20%), rgba(196, 181, 253, .15) var(--fill, 20%)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(196, 181, 253, .15); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--violet); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%; background: #f5f0ff; box-shadow: 0 0 0 5px rgba(139, 92, 246, .35), 0 4px 10px rgba(0, 0, 0, .4); }
input[type='range']::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #f5f0ff; box-shadow: 0 0 0 5px rgba(139, 92, 246, .35); }

.drop {
  display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--r); cursor: pointer;
  border: 1.5px dashed rgba(196, 181, 253, .28); background: rgba(14, 10, 26, .45); transition: border-color .2s, background .2s;
}
.drop:hover, .drop.over { border-color: var(--lilac); background: rgba(139, 92, 246, .12); }
.drop svg { width: 26px; height: 26px; color: var(--lilac); }
.drop span { display: flex; flex-direction: column; gap: 3px; }
.drop small { color: var(--muted); font-size: 12.5px; }
.paste summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 4px 2px; }
.paste[open] summary { margin-bottom: 10px; }
.paste .ghost { margin-top: 10px; }
.book-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--glass); }
.book-title { font-family: var(--display); font-size: 22px; line-height: 1.15; color: var(--gold); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(14, 10, 26, .6); border: 1px solid var(--line); }
.segmented button { min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13.5px; transition: all .2s; padding: 0 6px; }
.segmented button[aria-pressed='true'] { background: linear-gradient(135deg, rgba(139, 92, 246, .45), rgba(177, 83, 232, .3)); color: #fff; box-shadow: 0 4px 14px rgba(139, 92, 246, .25); }

.cta {
  position: relative; width: 100%; height: 56px; border: 0; border-radius: 999px; overflow: hidden;
  background: linear-gradient(120deg, #3b1578, #5b21b6 48%, #7e1d8f);
  color: #fff; font-weight: 600; font-size: 16px; letter-spacing: .02em;
  box-shadow: 0 10px 30px rgba(59, 21, 120, .5), 0 0 0 1px rgba(255, 255, 255, .1) inset;
  transition: transform .15s, opacity .2s, box-shadow .3s;
}
.cta::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .25) 50%, transparent 70%); transform: translateX(-100%); animation: sheen 4.5s ease-in-out infinite; }
.cta:active { transform: scale(.985); }
.cta:disabled { opacity: .55; pointer-events: none; }
.cta span { position: relative; z-index: 1; }
.ghost {
  min-height: 42px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass);
  color: var(--lilac); font-size: 14px; font-weight: 500; transition: background .2s;
}
.ghost:hover { background: var(--glass-2); }
.ghost.small { min-height: 34px; font-size: 13px; padding: 0 14px; border-radius: 999px; }
.ghost.danger { color: #fb7185; }
.fine { margin: 0; font-size: 12.5px; color: var(--faint); line-height: 1.5; }
.fine.center { text-align: center; }
code { font-size: 12px; padding: 1px 5px; border-radius: 5px; background: rgba(196, 181, 253, .1); }

/* ---------- stage / prompter ---------- */
.stage { margin-top: 18px; animation: rise .5s cubic-bezier(.2, .8, .2, 1); }
.stage-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.stage-head h2 { margin: 6px 0 0; font-family: var(--display); font-style: italic; font-weight: 500; font-size: 26px; line-height: 1.1; color: var(--lilac); text-wrap: balance; }
.prompter { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; }
.seg {
  position: relative; padding: 12px 14px 14px 18px; border-radius: 16px; cursor: pointer;
  opacity: .42; transition: opacity .5s, background .5s;
}
.seg::before { content: ''; position: absolute; left: 4px; top: 16px; bottom: 16px; width: 2px; border-radius: 2px; background: var(--line); transition: background .5s; }
.seg:hover { opacity: .7; }
.seg.past { opacity: .3; }
.seg.now { opacity: 1; background: linear-gradient(135deg, rgba(40, 28, 70, .55), rgba(20, 14, 36, .35)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.seg.now::before { background: linear-gradient(var(--mood), var(--violet)); box-shadow: 0 0 10px var(--mood); }
.seg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.kind { font-family: var(--caps); letter-spacing: .16em; text-transform: uppercase; font-size: 10.5px; color: var(--gold); flex: none; }
.kind.tangent, .kind.answer { color: var(--orchid); }
.kind.reading { color: var(--lilac); }
.seg-meta .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-meta a { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 11.5px; }
.seg-meta a:hover { color: var(--lilac); }
.seg-meta a svg { width: 13px; height: 13px; }
.seg-text { margin: 0; font-family: var(--display); font-size: 19px; line-height: 1.5; color: #e9e3f5; }
.seg.reading-seg .seg-text { font-style: italic; }
.seg.now .seg-text { font-size: 23px; line-height: 1.45; }
.seg.now .w { color: rgba(233, 227, 245, .45); transition: color .25s; }
.seg.now .w.on { color: #fff; text-shadow: 0 0 18px color-mix(in srgb, var(--mood) 40%, transparent); }
.seg.pending .seg-text { color: var(--faint); font-style: italic; }
.seg.pending .seg-text::after { content: ''; display: inline-block; width: 1.4em; animation: dots 1.2s steps(4) infinite; }
.question { display: block; font-family: var(--ui); font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 14px);
  padding-top: 26px;
  background: linear-gradient(to top, rgba(12, 8, 24, .62) 0%, rgba(12, 8, 24, .42) 60%, rgba(12, 8, 24, 0) 100%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#viz { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 124px; pointer-events: none; opacity: .38; z-index: 0; }
.reactions, .controls, .askbar { position: relative; width: 100%; max-width: 560px; }
.reactions .chip { background: rgba(26, 19, 44, .9); }
.reactions { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; justify-content: center; }
.reactions::-webkit-scrollbar { display: none; }
@media (max-width: 420px) { .reactions { justify-content: flex-start; } }
.controls { z-index: 1; display: grid; grid-template-columns: 54px repeat(2, 44px) 68px 44px 52px; justify-content: center; align-items: center; gap: 12px; }
.askbar { z-index: 1; }
.icon-btn.speed { width: 52px; border-radius: 999px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--lilac); }
.play {
  position: relative; width: 68px; height: 68px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #7c3aed, #c026d3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14) inset, 0 10px 30px rgba(139, 92, 246, .45), 0 0 calc(10px + var(--lvl) * 8px) rgba(217, 70, 239, .4);
  transition: transform .15s;
}
.play:active { transform: scale(.94); }
.play svg { grid-area: 1 / 1; width: 26px; height: 26px; transition: opacity .2s, transform .2s; }
.play .i-play { translate: 2px 0; }
.play .i-pause, .play .spin { opacity: 0; }
body.playing .play .i-play { opacity: 0; transform: scale(.6); }
body.playing .play .i-pause { opacity: 1; }
body.loading .play svg { opacity: 0 !important; }
.spin { grid-area: 1 / 1; width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .25); border-top-color: #fff; animation: spin .8s linear infinite; }
body.loading .play .spin { opacity: 1; }
.askbar { display: flex; gap: 8px; animation: rise .25s ease; }
.askbar input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(167, 139, 250, .35); background: rgba(20, 14, 36, .85); font-size: 16px; }
.askbar input:focus { outline: none; border-color: var(--lilac); }
#micBtn.listening { color: #fff; background: #db2777; border-color: transparent; animation: blink 1s infinite; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(4, 3, 9, .55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); animation: fade .25s; }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 21; width: min(600px, 100%);
  max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
  translate: -50% 105%; transition: translate .4s cubic-bezier(.2, .8, .2, 1);
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 24px);
  border-radius: 26px 26px 0 0; border: 1px solid var(--line); border-bottom: 0;
  background: linear-gradient(180deg, rgba(28, 20, 48, .97), rgba(12, 9, 22, .98));
  box-shadow: 0 -30px 80px rgba(0, 0, 0, .55);
  display: flex; flex-direction: column; gap: 12px;
}
.sheet.open { translate: -50% 0; }
.handle { width: 40px; height: 4px; border-radius: 4px; background: rgba(196, 181, 253, .25); margin: 0 auto 6px; flex: none; }
.sheet-head h3 { margin: 4px 0 4px; font-family: var(--display); font-size: 26px; font-weight: 500; color: var(--lilac); }
.set { border: 1px solid var(--line); border-radius: var(--r); background: rgba(255, 255, 255, .02); padding: 0 14px; }
.set > summary { display: flex; align-items: center; gap: 10px; min-height: 54px; cursor: pointer; list-style: none; font-weight: 500; }
.set > summary::-webkit-details-marker { display: none; }
.set > summary svg { color: var(--lilac); }
.set > summary small { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.set > summary::after { content: ''; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); rotate: 45deg; margin-left: 8px; transition: rotate .25s; }
.set > summary small + ::after { margin-left: 8px; }
.set[open] > summary::after { rotate: 225deg; }
.set[open] { padding-bottom: 16px; }
.set[open] > :not(summary) { margin-top: 12px; }
.set [data-show] > * + * { margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--muted); }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { appearance: none; flex: none; width: 42px; height: 24px; margin: 2px 0 0; border-radius: 999px; background: rgba(196, 181, 253, .15); position: relative; transition: background .2s; cursor: pointer; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: translate .2s; }
.toggle input:checked { background: var(--violet); }
.toggle input:checked::after { translate: 18px 0; }
.toggle span { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.toggle small { color: var(--faint); font-size: 12px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.peek summary { cursor: pointer; font-size: 13px; color: var(--lilac); }
.peek pre { white-space: pre-wrap; font-size: 11.5px; line-height: 1.5; color: var(--muted); background: rgba(0, 0, 0, .3); border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 300px; overflow: auto; }
.voice-search, .find-more { display: flex; gap: 8px; }
.voice-search .input, .find-more .input { flex: 1; }
.voices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.voice, .voice-current .voice { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 10px; align-items: center; padding: 8px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.voice img, .voice .ph { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #241a3a; }
.voice b { display: block; font-size: 14px; font-weight: 500; }
.voice small { font-size: 11.5px; color: var(--faint); }
.voice .icon-btn { width: 38px; height: 38px; }
.voice.selected { border-color: rgba(167, 139, 250, .6); background: rgba(139, 92, 246, .14); }
.voice-current:empty::before { content: 'No voice chosen yet. Search below.'; font-size: 13px; color: var(--faint); }

.docket { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.docket li { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); transition: opacity .2s; }
.docket li.off { opacity: .45; }
.docket input { appearance: none; width: 22px; height: 22px; margin: 1px 0 0; border-radius: 7px; border: 1.5px solid rgba(196, 181, 253, .4); cursor: pointer; display: grid; place-items: center; }
.docket input:checked { background: var(--violet); border-color: var(--violet); }
.docket input:checked::after { content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -1px; }
.docket b { display: block; font-size: 14.5px; font-weight: 500; line-height: 1.35; }
.docket p { margin: 4px 0 6px; font-size: 13px; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.docket .src { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--faint); }
.docket .src a { color: var(--lilac); text-decoration: none; }
.badge { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: rgba(196, 181, 253, .1); color: var(--lilac); }
.badge.now { background: rgba(232, 121, 249, .2); color: var(--orchid); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); z-index: 30;
  translate: -50% -20px; opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: rgba(28, 20, 48, .94); border: 1px solid var(--line); backdrop-filter: blur(12px);
  font-size: 14px; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .4); transition: all .3s;
}
.toast.show { translate: -50% 0; opacity: 1; }
.toast.err { border-color: rgba(251, 113, 133, .4); }

:focus-visible { outline: 2px solid var(--lilac); outline-offset: 3px; }

@keyframes spin { to { rotate: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes sheen { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
@keyframes poke { 30% { transform: scale(.88) rotate(-6deg); } 60% { transform: scale(1.06) rotate(4deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =================================================================== v3 additions */


/* ---------- screen transitions ---------- */
.avatar { view-transition-name: avatar; }
.who { view-transition-name: who; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .45s; }
::view-transition-old(root) { animation-name: vtOut; }
::view-transition-new(root) { animation-name: vtIn; }
::view-transition-group(avatar), ::view-transition-group(who) { animation-duration: .55s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
@keyframes vtOut { to { opacity: 0; transform: translateY(-8px) scale(.99); filter: blur(4px); } }
@keyframes vtIn { from { opacity: 0; transform: translateY(12px) scale(.99); filter: blur(4px); } }

/* ---------- transcript: new parts arrive, the current one glows ---------- */
.seg.fresh { animation: segIn .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes segIn { from { opacity: 0; transform: translateY(14px); filter: blur(3px); } }
.seg.now { box-shadow: 0 0 0 1px color-mix(in srgb, var(--mood) 22%, transparent), 0 18px 50px rgba(0, 0, 0, .35); }
.seg.now::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--mood) 14%, transparent), transparent 60%);
  opacity: calc(.6 + var(--lvl) * .6); transition: background 1s;
}

/* ---------- stage head & small buttons ---------- */
.stage-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 17px; height: 17px; }
.icon-btn.busy svg { animation: blink 1s infinite; }

/* sleep timer */

/* ---------- link reader ---------- */
.link-form { display: flex; gap: 8px; }
.link-form .input { flex: 1; min-width: 0; }

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history li { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 12px 12px 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); animation: segIn .4s cubic-bezier(.2, .8, .2, 1) both; }
.history b { font-family: var(--display); font-size: 19px; font-weight: 500; color: var(--text); line-height: 1.2; }
.history small { display: block; margin-top: 3px; font-size: 12px; color: var(--faint); }
.history .row-actions { display: flex; gap: 6px; }
.history .icon-btn { width: 38px; height: 38px; }
.history .empty { display: block; text-align: center; color: var(--faint); font-size: 13px; padding: 30px 0; border: 0; background: none; animation: none; }

/* ---------- usage ---------- */
.usage { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.usage div { padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.usage b { display: block; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--lilac); }
.usage span { font-size: 11.5px; color: var(--muted); }

/* ---------- welcome ---------- */
.welcome { gap: 16px; }
.welcome-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; }
.welcome-hero h3 { margin: 10px 0 0; font-family: var(--display); font-weight: 500; font-size: 30px; color: var(--lilac); }
.welcome-hero p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; max-width: 36ch; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px 14px 14px 52px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.steps li::before { content: counter(step); position: absolute; left: 14px; top: 13px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: linear-gradient(135deg, var(--violet), #b153e8); }
.welcome .ghost { align-self: center; border: 0; background: none; color: var(--muted); }

/* ---------- cta press ripple ---------- */
.cta .ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .35); transform: scale(0); animation: ripple .7s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* program cards: soft lift */
.programs button { transition: border-color .25s, background .25s, transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s; }
@media (hover: hover) { .programs button:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, .3); } }

/* =================================================================== portrait (static, meme style) */
.avatar {
  position: relative; width: 156px; height: 156px; padding: 0; border: 0; background: none;
  display: grid; place-items: center; cursor: pointer; transition: width .5s, height .5s;
}
/* during a session his head sits in the dock, next to the chat button */
.dock-head { position: relative; width: 54px; height: 54px; display: grid; place-items: center; }
body[data-view='stage'] .avatar { width: 54px; height: 54px; }
body[data-view='stage'] .presence { display: none; }
.aura {
  position: absolute; inset: -30%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--mood) 50%, transparent) 0%, transparent 62%);
  opacity: calc(.4 + var(--lvl) * .12); filter: blur(8px); transition: background 1s;
}
.face { position: relative; width: 100%; height: 100%; display: block; --hop: 0; }
.face .frame {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0; /* frames swap instantly, like a PNGtuber */
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .55));
  transform: translateY(calc(var(--hop) * -7px)) scale(calc(1 + var(--hop) * .035));
}
.face .frame.on { opacity: 1; }
.face.tint .frame { filter: sepia(.5) saturate(2.4) hue-rotate(-30deg) contrast(1.12) drop-shadow(0 0 16px rgba(255, 40, 30, .8)); }
.face.scheme .frame { filter: drop-shadow(0 0 22px rgba(255, 30, 20, .85)) drop-shadow(0 0 4px rgba(255, 200, 150, .6)); }
.face.boom { animation: boom .55s cubic-bezier(.2, 1.6, .4, 1); }
.face.poke { animation: pokeShake .4s linear; }
@keyframes boom {
  0% { transform: scale(1); }
  12% { transform: scale(1.32) rotate(-3deg); }
  24% { transform: scale(1.18) translate(4px, -3px) rotate(2deg); }
  36% { transform: scale(1.22) translate(-4px, 2px) rotate(-2deg); }
  52% { transform: scale(1.1) translate(3px, 1px); }
  100% { transform: scale(1); }
}
@keyframes pokeShake {
  20% { transform: translate(-5px, 1px) rotate(-4deg); }
  40% { transform: translate(5px, -1px) rotate(3deg); }
  60% { transform: translate(-3px, 0) rotate(-2deg); }
  80% { transform: translate(2px, 0); }
}

/* the whole room reddens while he schemes */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 50% 20%, transparent 35%, rgba(150, 0, 0, .45) 100%);
  mix-blend-mode: screen; transition: opacity .5s;
}
body.scheming::after { opacity: 1; }
body.scheming .aura { background: radial-gradient(circle, rgba(255, 30, 20, .55) 0%, transparent 62%); }

/* welcome screen portrait */
.welcome-mask { width: 112px; height: 112px; }

/* settings: portrait slots */
.portraits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.portrait-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 10px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); text-align: center; }
.portrait-slot .thumb { width: 84px; height: 84px; margin-bottom: 4px; border-radius: 12px; background: repeating-conic-gradient(rgba(255, 255, 255, .04) 0 25%, transparent 0 50%) 0 0 / 14px 14px; }
.portrait-slot .thumb img { width: 100%; height: 100%; object-fit: contain; }
.portrait-slot b { font-size: 13.5px; font-weight: 600; }
.portrait-slot small { font-size: 11.5px; color: var(--faint); min-height: 1.3em; }
.portrait-slot.scheme b { color: #ff7a6b; }
.slot-actions { display: flex; gap: 6px; margin-top: 4px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .ghost { flex: 1; }
.eye-marker { display: flex; flex-direction: column; gap: 8px; }
.eye-stage { position: relative; align-self: center; cursor: crosshair; border-radius: 12px; overflow: hidden; background: repeating-conic-gradient(rgba(255, 255, 255, .05) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.eye-stage img { display: block; max-width: 100%; max-height: 300px; }
.eye-dot { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: radial-gradient(circle, #fff 0 20%, #ff3b2f 45%, transparent 72%); box-shadow: 0 0 14px #ff2a1a; pointer-events: none; }
.portrait-slot .thumb img.borrowed { opacity: .45; filter: grayscale(.4); }
.portrait-slot.angry .thumb img.borrowed { filter: sepia(.6) saturate(3) hue-rotate(-30deg) drop-shadow(0 0 6px rgba(255, 40, 30, .6)); opacity: .6; }

/* voiced-ahead marker: a small dot that lights once the part's audio is ready */
.seg .kind::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 8px; vertical-align: 2px;
  background: rgba(196, 181, 253, .18); transition: background .4s, box-shadow .4s;
}
.seg.voiced .kind::after { background: #a78bfa; box-shadow: 0 0 6px rgba(167, 139, 250, .8); }
.seg.past .kind::after { opacity: .4; }

/* the logo is the home button */
button.brand { background: none; border: 0; padding: 6px 4px; margin-left: -4px; cursor: pointer; border-radius: 10px; transition: color .2s, text-shadow .2s; }
button.brand:hover { color: #ede9fe; text-shadow: 0 0 14px rgba(167, 139, 250, .6); }
button.brand:active { transform: scale(.97); }

/* =================================================================== layout v4 */
/* reactions pinned at the top of a session */
.stage .reactions {
  position: sticky; top: calc(env(safe-area-inset-top) + 6px); z-index: 4;
  justify-content: flex-start; max-width: none; margin: 10px -16px 0; padding: 8px 16px;
  background: linear-gradient(to bottom, rgba(10, 7, 20, .78), rgba(10, 7, 20, .55) 70%, rgba(10, 7, 20, 0));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#sleepBtn[aria-pressed='true'] span { font-variant-numeric: tabular-nums; }
.stage-status { display: flex; align-items: center; gap: 7px; margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

/* topics with sub-topics */
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.link-btn:hover { color: var(--lilac); }
.subtopics { display: flex; flex-direction: column; gap: 8px; }
.subtopics:empty { display: none; }
.subrow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .025); animation: rise .3s cubic-bezier(.2, .8, .2, 1);
}
.subhead { font-size: 11.5px; letter-spacing: .05em; color: var(--lilac); margin: 0 4px 0 2px; white-space: nowrap; }
.chip.sub { padding: 5px 11px; font-size: 12.5px; }
.stage .reactions { width: auto; gap: 6px; background: linear-gradient(to bottom, rgba(10, 7, 20, .7), rgba(10, 7, 20, 0)); }
.stage .reactions .chip { padding: 6px 11px; font-size: 12.5px; flex: none; }

/* a chunk that continues the paragraph above: no repeated label, tucked closer */
.seg.cont { margin-top: -8px; padding-top: 6px; }
.seg.cont .seg-meta { display: none; }

/* =================================================================== v5: summon, length, shelf, discourse */
/* Summon: dark crimson so it stands out from all the violet */
.cta {
  background: linear-gradient(120deg, #3d0a1f 0%, #6e1230 45%, #8c1a3f 75%, #6b1752 100%);
  color: #ffe9ee;
  box-shadow: 0 10px 34px rgba(150, 20, 50, .42), 0 0 0 1px rgba(255, 130, 150, .18) inset;
}
.cta:hover { box-shadow: 0 12px 40px rgba(170, 25, 60, .5), 0 0 0 1px rgba(255, 140, 160, .26) inset; }

/* Length: a slim pill in the same crimson, directly under Summon */
#lengthGroup { margin-top: -6px; }
#lengthGroup .label-row { padding: 0 4px; }
#length { height: 30px; }
#length::-webkit-slider-runnable-track {
  height: 30px; border-radius: 999px;
  background: linear-gradient(90deg, #3d0a1f, #7a1434 calc(var(--fill, 20%) - 1%), rgba(255, 255, 255, .05) var(--fill, 20%));
  box-shadow: 0 0 0 1px rgba(255, 130, 150, .16) inset, 0 6px 18px rgba(120, 15, 40, .25);
}
#length::-webkit-slider-thumb {
  width: 24px; height: 24px; margin-top: 3px; border-radius: 50%;
  background: #ffe4ea; box-shadow: 0 0 0 4px rgba(140, 26, 63, .55), 0 2px 8px rgba(0, 0, 0, .5);
}
#length::-moz-range-track { height: 30px; border-radius: 999px; background: rgba(255, 255, 255, .05); box-shadow: 0 0 0 1px rgba(255, 130, 150, .16) inset; }
#length::-moz-range-progress { height: 30px; border-radius: 999px; background: linear-gradient(90deg, #3d0a1f, #7a1434); }
#length::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #ffe4ea; box-shadow: 0 0 0 4px rgba(140, 26, 63, .55); }

/* The Sharmat's shelf: two rows of covers you swipe through */
.shelf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 6px; }
.shelf-head .label { margin: 0; color: var(--gold); font-family: var(--caps); letter-spacing: .14em; text-transform: uppercase; font-size: 11px; }
.shelf {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: 104px; gap: 14px 12px;
  overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 2px 10px; margin: 0 -2px;
  scrollbar-width: thin; scrollbar-color: rgba(167, 139, 250, .3) transparent;
}
.book { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; text-align: left; scroll-snap-align: start; cursor: pointer; }
.book .cover {
  position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden;
  background: linear-gradient(160deg, #2a1d45, #120c20); box-shadow: 0 8px 18px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06) inset;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1), box-shadow .25s;
}
.book .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book b { font-size: 12.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book small { font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .book:hover .cover { transform: translateY(-3px); box-shadow: 0 14px 26px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .1) inset; } }
.book.chosen .cover { box-shadow: 0 0 0 2px #b4234f, 0 10px 24px rgba(140, 26, 63, .5); }
.book .spin { position: absolute; inset: 0; margin: auto; opacity: 0; }
.book.loading .cover img { filter: brightness(.35) blur(1px); }
.book.loading .spin { opacity: 1; }

/* Discourse questions */
.questions { display: flex; flex-wrap: wrap; gap: 8px; }
.question-chip {
  border: 1px solid var(--line); background: var(--glass); border-radius: 14px; padding: 9px 13px;
  font-size: 13.5px; line-height: 1.3; color: var(--muted); text-align: left; transition: all .2s;
}
.question-chip:hover { color: var(--text); }
.question-chip[aria-pressed='true'] { color: #fff; border-color: rgba(180, 35, 79, .7); background: linear-gradient(135deg, rgba(110, 18, 48, .55), rgba(60, 20, 70, .45)); }
.question-chip.trending { border-style: dashed; }
.questions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.question-chip { font-size: 12.5px; padding: 9px 11px; }
.question-chip.trending { grid-column: 1 / -1; text-align: center; }
.shelf-head .fine { font-size: 11.5px; text-align: right; }

/* =================================================================== v6: glass summon, compact length, vertical shelf */
.cta {
  background: linear-gradient(120deg, rgba(110, 18, 48, .42), rgba(150, 28, 66, .4) 50%, rgba(110, 24, 88, .42));
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 140, 165, .28);
  box-shadow: 0 8px 28px rgba(120, 15, 45, .28), 0 1px 0 rgba(255, 255, 255, .12) inset;
}
.cta:hover { background: linear-gradient(120deg, rgba(125, 20, 55, .52), rgba(165, 32, 74, .5) 50%, rgba(122, 28, 98, .52)); }

/* Length: one compact row — label, glass slider, value */
.length-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: -8px; padding: 0 4px; }
.length-row .label { margin: 0; }
.length-row .value { min-width: 46px; text-align: right; }
#length { height: 22px; }
#length::-webkit-slider-runnable-track {
  height: 22px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(110, 18, 48, .45), rgba(150, 28, 66, .45) calc(var(--fill, 20%) - 1%), rgba(255, 255, 255, .05) var(--fill, 20%));
  box-shadow: 0 0 0 1px rgba(255, 140, 165, .22) inset;
}
#length::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: 2px; background: #ffe4ea; box-shadow: 0 0 0 3px rgba(150, 28, 66, .5), 0 2px 6px rgba(0, 0, 0, .45); }
#length::-moz-range-track { height: 22px; background: rgba(255, 255, 255, .05); box-shadow: 0 0 0 1px rgba(255, 140, 165, .22) inset; }
#length::-moz-range-progress { height: 22px; background: linear-gradient(90deg, rgba(110, 18, 48, .45), rgba(150, 28, 66, .45)); }
#length::-moz-range-thumb { width: 18px; height: 18px; box-shadow: 0 0 0 3px rgba(150, 28, 66, .5); }

/* activities: one swipeable row instead of three wrapped ones */
#activity { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 24px), transparent); }
#activity::-webkit-scrollbar { display: none; }
#activity .chip { flex: none; }

/* literature: mode switch with the impressions chip beside it */
.lit-top { display: flex; align-items: center; gap: 8px; }
.lit-top .segmented { flex: 1; }
.lit-top .impressions { flex: none; font-size: 12.5px; padding: 9px 12px; }

/* the shelf scrolls vertically now (no clipped corners), covers dimmed to sit in the scene */
.shelf {
  grid-auto-flow: row; grid-template-rows: none; grid-auto-columns: auto;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  overflow-x: visible; overflow-y: auto; max-height: 480px; scroll-snap-type: y proximity;
  padding: 8px 6px 18px; margin: 0 -6px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent);
}
.book .cover img { filter: brightness(.74) saturate(.82); opacity: .86; transition: filter .25s, opacity .25s; }
.book:hover .cover img, .book.chosen .cover img { filter: brightness(.95) saturate(1); opacity: 1; }
.lit-top .segmented button { white-space: nowrap; }
.lit-top .impressions svg { width: 14px; height: 14px; }

/* =================================================================== v7 */
/* activities: a tidy grid of real buttons (all visible, easy to click) */
#activity {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px;
  overflow: visible; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none;
}
#activity .chip { justify-content: center; padding: 10px 8px; font-size: 13.5px; cursor: pointer; }

/* length: thinner */
#length { height: 16px; }
#length::-webkit-slider-runnable-track { height: 12px; }
#length::-webkit-slider-thumb { width: 16px; height: 16px; margin-top: -2px; box-shadow: 0 0 0 3px rgba(150, 28, 66, .5), 0 2px 6px rgba(0, 0, 0, .45); }
#length::-moz-range-track { height: 12px; }
#length::-moz-range-progress { height: 12px; }
#length::-moz-range-thumb { width: 16px; height: 16px; }
.length-row { margin-top: -10px; }

/* literature: interjection buttons under the mode switch */
.impressions-group { display: flex; flex-direction: column; gap: 8px; }
.impressions-group .label { margin: 0; }

/* =================================================================== topics: rows of topic + sub-topics */
.topic-rows { display: flex; flex-direction: column; gap: 8px; }
.trow {
  display: grid; grid-template-columns: 128px 1fr; gap: 10px; align-items: center;
  padding: 8px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02);
  transition: border-color .25s, background .25s;
}
.trow.on { border-color: rgba(167, 139, 250, .32); background: linear-gradient(135deg, rgba(139, 92, 246, .13), rgba(30, 20, 50, .25)); }
.tbtn {
  display: flex; flex-direction: column; justify-content: center; gap: 3px; align-self: stretch; min-height: 58px;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass);
  text-align: left; cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
}
.tbtn:active { transform: scale(.98); }
.tbtn b { font-size: 14px; font-weight: 600; color: var(--text); }
.tbtn small { font-size: 11px; line-height: 1.25; color: var(--faint); }
.tbtn[aria-pressed='true'] { border-color: rgba(167, 139, 250, .65); background: linear-gradient(135deg, rgba(139, 92, 246, .38), rgba(177, 83, 232, .2)); }
.tbtn[aria-pressed='true'] small { color: var(--lilac); }
.tsubs { display: flex; flex-wrap: wrap; gap: 6px; align-content: center; }
.tsub {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(14, 10, 26, .5);
  font-size: 12.5px; color: var(--muted); cursor: pointer; transition: all .2s;
}
.tsub:hover { color: var(--text); border-color: rgba(196, 181, 253, .3); }
.trow:not(.on) .tsub { opacity: .62; }
.tsub[aria-pressed='true'] { opacity: 1; color: #fff; border-color: rgba(167, 139, 250, .6); background: rgba(139, 92, 246, .3); }
@media (max-width: 360px) { .trow { grid-template-columns: 1fr; } }

/* =================================================================== personality dials + model picker */
.dial { display: flex; flex-direction: column; gap: 4px; padding: 10px 2px 4px; }
.dial .label-row .label { margin: 0; color: var(--text); font-size: 13.5px; }
.dial .ticks { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; font-size: 10.5px; color: var(--faint); }
.dial .ticks span { text-align: center; transition: color .2s; }
.dial .ticks span:first-child { text-align: left; }
.dial .ticks span:last-child { text-align: right; }
.dial .ticks span.on { color: var(--lilac); }
.dial .fine { margin-top: 2px; }
.model-pick { display: flex; flex-direction: column; gap: 8px; }
.model-pick .label-row .label { margin: 0; }

/* =================================================================== settings: nested sections */
.set.sub { margin-top: 14px; padding: 0 12px; border-radius: 14px; background: rgba(0, 0, 0, .18); border-color: rgba(196, 181, 253, .1); }
.set.sub > summary { min-height: 46px; font-size: 14px; }
.set.sub > summary svg { width: 17px; height: 17px; }
.set.sub[open] { padding-bottom: 14px; }
.privacy { margin: 2px 0 0; font-size: 12px; color: #fff; opacity: .9; letter-spacing: .01em; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.keys dt { font-variant-numeric: tabular-nums; }
.keys dt { padding: 1px 8px; border-radius: 6px; background: rgba(196, 181, 253, .12); color: var(--lilac); font-size: 12px; text-align: center; min-width: 34px; }
.keys dd { margin: 0; color: var(--muted); align-self: center; }

/* =================================================================== settings: accordion, open section stands out */
.set { position: relative; transition: border-color .25s, background .25s, box-shadow .25s; }
.set:not([open]) > summary { color: var(--muted); }
.set:not([open]) > summary:hover { color: var(--text); }
.set[open] {
  border-color: rgba(167, 139, 250, .5);
  background: linear-gradient(160deg, rgba(139, 92, 246, .12), rgba(255, 255, 255, .02) 40%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3), 0 0 0 1px rgba(167, 139, 250, .12), 0 0 24px rgba(139, 92, 246, .12);
}
.set[open] > summary { color: #fff; }
.set[open] > summary svg { color: #c4b5fd; filter: drop-shadow(0 0 6px rgba(167, 139, 250, .6)); }
.set[open]::before {
  content: ''; position: absolute; left: -1px; top: 14px; width: 3px; height: 26px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--lilac), var(--violet)); box-shadow: 0 0 10px rgba(167, 139, 250, .7);
}
.set.sub[open] { border-color: rgba(167, 139, 250, .38); background: rgba(139, 92, 246, .08); box-shadow: none; }
.set.sub[open]::before { top: 11px; height: 22px; }
.credits { margin: 0; font-family: var(--display); font-style: italic; font-size: 18px; line-height: 1.5; color: var(--lilac); text-align: center; padding: 6px 4px 2px; }

/* =================================================================== dial info tips + credits */
.dial .label { display: inline-flex; align-items: center; gap: 7px; }
.info {
  position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0;
  border-radius: 50%; border: 1px solid rgba(196, 181, 253, .35); background: transparent;
  font: italic 600 10px/1 Georgia, serif; color: var(--muted); cursor: help; opacity: .7; transition: opacity .2s, color .2s;
}
.info:hover, .info:focus-visible, .info.show { opacity: 1; color: var(--lilac); }
.info .tip {
  position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 5; translate: -30% 4px;
  width: max-content; max-width: 230px; padding: 8px 11px; border-radius: 10px;
  background: rgba(24, 17, 40, .97); border: 1px solid rgba(167, 139, 250, .3); box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  font: 400 12px/1.45 var(--ui); font-style: normal; color: var(--text); text-align: left; white-space: normal;
  opacity: 0; pointer-events: none; transition: opacity .18s, translate .18s;
}
.info:hover .tip, .info:focus-visible .tip, .info.show .tip { opacity: 1; translate: -30% 0; }
.credits { display: flex; flex-direction: column; gap: 9px; padding: 4px 2px 6px; text-align: center; font-family: var(--display); font-style: italic; font-size: 16.5px; line-height: 1.45; color: var(--muted); }
.credits p { margin: 0; }
.credits b { font-weight: 600; color: var(--lilac); }
.credits .sign { margin-top: 6px; font-size: 19px; color: var(--gold); }

/* model picker: ‹ dropdown › */
.model-row { display: grid; grid-template-columns: 38px 1fr 38px; gap: 8px; align-items: center; }
.model-row .icon-btn.small { width: 38px; height: 38px; }
.model-row select { min-width: 0; }

/* =================================================================== brain: model row, actions, animated test */
.model-row { grid-template-columns: 1fr 38px 38px; }
.brain-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.brain-actions .ghost.small { min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13px; }
.brain-actions .ghost:disabled { opacity: .5; }
.ghost.test { display: inline-flex; align-items: center; gap: 0; transition: background .35s, border-color .35s, color .35s, gap .25s; }
.ghost.test::before { content: ''; width: 0; height: 14px; flex: none; transition: width .25s; }
.ghost.test.testing, .ghost.test.pass, .ghost.test.fail { gap: 8px; }
.ghost.test.testing { opacity: 1 !important; }
.ghost.test.testing::before { width: 14px; border-radius: 50%; border: 2px solid rgba(196, 181, 253, .3); border-top-color: var(--lilac); animation: spin .8s linear infinite; }
.ghost.test.pass { background: rgba(34, 197, 94, .18); border-color: rgba(74, 222, 128, .6); color: #86efac; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1); }
.ghost.test.pass::before, .ghost.test.fail::before { width: 15px; height: 15px; }
.ghost.test.pass::before {
  background: #4ade80;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ghost.test.fail { background: rgba(244, 63, 94, .15); border-color: rgba(251, 113, 133, .55); color: #fda4af; animation: shake .4s; }
.ghost.test.fail::before {
  background: #fb7185;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6 6 18' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6 6 18' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
@keyframes pop { 40% { transform: scale(1.08); } }
@keyframes shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
/* keep all three on one row, even when the test label grows to "Brain works" */
.brain-actions { flex-wrap: nowrap; gap: 6px; }
.brain-actions .ghost.small { min-height: 34px; padding: 0 11px; font-size: 12.5px; white-space: nowrap; }

/* =================================================================== session dock v2 */
/* the shade behind the controls: barely there, so the smoke shows through */
.dock {
  padding-top: 14px;
  background: linear-gradient(to top, rgba(10, 7, 20, .2) 0%, rgba(10, 7, 20, .08) 55%, rgba(10, 7, 20, 0) 100%);
}
/* bottom bar: head · play · volume · speed · gear */
.controls { grid-template-columns: 54px 60px 1fr 50px 44px; gap: 12px; justify-content: stretch; max-width: 560px; }
.play { width: 60px; height: 60px; }
.volume { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 4px; color: var(--muted); }
.volume svg { width: 18px; height: 18px; flex: none; }
.volume input { flex: 1; min-width: 0; height: 20px; }
.volume input::-webkit-slider-runnable-track { height: 4px; }
.volume input::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; box-shadow: 0 0 0 3px rgba(139, 92, 246, .35); }
.volume input::-moz-range-thumb { width: 14px; height: 14px; }
.speed-wrap { position: relative; }
.icon-btn.speed { width: 50px; }
.speed-menu {
  position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 6; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  border-radius: 14px; background: rgba(24, 17, 40, .96); border: 1px solid rgba(167, 139, 250, .3); box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
  animation: rise .18s ease;
}
.speed-menu button { min-width: 64px; padding: 8px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; text-align: right; }
.speed-menu button:hover { background: var(--surface-2); color: var(--text); }
.speed-menu button[aria-pressed='true'] { background: rgba(139, 92, 246, .3); color: #fff; }
#sessionBtn { position: relative; }
#sessionBtn .dot { top: 6px; right: 7px; background: var(--lilac); box-shadow: 0 0 8px var(--lilac); }

/* top bar: ‹ › 💬 | More · Ramble · No tangents */
.stage .reactions .icon-chip { width: 34px; height: 32px; padding: 0; justify-content: center; flex: none; }
.stage .reactions .icon-chip svg { width: 15px; height: 15px; }
.stage .reactions .icon-chip:disabled { opacity: .35; }
.rx-sep { flex: none; width: 1px; height: 20px; margin: 0 2px; align-self: center; background: var(--line); }

/* session options sheet */
.session-block { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .02); }
.session-block > .label { margin: 0; color: var(--gold); font-family: var(--caps); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.session-block .dial { padding-top: 6px; }
.cta.rewrite { height: 48px; font-size: 15px; }
/* visualizer: hairlines from the very bottom edge, see-through */
#viz { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 96px; margin: 0; opacity: .5; z-index: 0; pointer-events: none; filter: none; }
/* top bar fits a phone: compact chips, text-only labels on narrow screens */
.stage .reactions { gap: 5px; }
.stage .reactions .icon-chip { width: 32px; }
@media (max-width: 440px) {
  .stage .reactions .chip:not(.icon-chip) { padding: 6px 10px; font-size: 12px; }
  .stage .reactions .chip:not(.icon-chip) svg { display: none; }
}

/* =================================================================== transcript rows + "tell me more" branches */
.seg-row {
  display: flex; gap: 10px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px 0;
}
.seg-row::-webkit-scrollbar { display: none; }
.cell { position: relative; display: flex; align-items: center; gap: 6px; flex: 0 0 100%; min-width: 0; scroll-snap-align: center; }
.cell > .seg { flex: 1; min-width: 0; }
/* with branches, cards are a little narrower so the next one peeks in from the right */
.seg-row.branched .cell { flex-basis: 88%; }
.cell.branch > .seg { background: linear-gradient(135deg, rgba(232, 121, 249, .07), rgba(20, 14, 36, .25)); border: 1px solid rgba(232, 121, 249, .16); }
.cell.branch > .seg::before { background: linear-gradient(var(--orchid), var(--violet)); }
.cell.branch > .seg.now { border-color: rgba(232, 121, 249, .4); }
.cell[data-depth='2'] > .seg { background: linear-gradient(135deg, rgba(232, 121, 249, .11), rgba(20, 14, 36, .3)); }
.kind.return, .seg.return .kind { color: var(--orchid); }
.seg.return .seg-text { font-size: 16px; font-style: italic; color: var(--muted); }
.seg.now.return .seg-text { font-size: 18px; }

/* ＋ beside a news card */
.more-btn {
  flex: none; position: relative; width: 30px; height: 30px; padding: 0; display: grid; place-items: center; align-self: center;
  border-radius: 50%; border: 1px solid rgba(232, 121, 249, .35); background: rgba(24, 17, 40, .75); color: var(--orchid);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); cursor: pointer; transition: transform .15s, background .2s, border-color .2s;
}
.more-btn svg { grid-area: 1 / 1; width: 15px; height: 15px; stroke-width: 2.2; transition: opacity .2s; }
.more-btn:hover { background: rgba(232, 121, 249, .16); border-color: rgba(232, 121, 249, .6); }
.more-btn:active { transform: scale(.9); }
.more-btn .spin { grid-area: 1 / 1; width: 16px; height: 16px; border-width: 2px; opacity: 0; border-color: rgba(232, 121, 249, .25); border-top-color: var(--orchid); }
.more-btn.loading svg { opacity: 0; }
.more-btn.loading .spin { opacity: 1; }
/* cards in a branched row line up at the top, not centred against the tallest one */
.seg-row { align-items: flex-start; }
.cell { align-items: flex-start; }
.cell .more-btn { margin-top: 14px; }

/* top bar: pure blur, no dark fade; a clock on the far left */
.stage .reactions { background: transparent; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.rx-clock {
  flex: none; align-self: center; margin-right: 4px; white-space: nowrap;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.rx-clock b { color: var(--lilac); font-weight: 600; }
@media (max-width: 440px) { .rx-clock { font-size: 11px; margin-right: 2px; } }

/* =================================================================== dock v3: short volume, speed slider, gear menu */
.controls { grid-template-columns: 54px 60px minmax(64px, 92px) minmax(0, 1fr) 44px; gap: 10px; }
.speed-slider { display: flex; align-items: center; gap: 8px; min-width: 0; }
.speed-slider input { flex: 1; min-width: 0; height: 22px; }
.speed-slider input::-webkit-slider-runnable-track { height: 4px; }
.speed-slider input::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; box-shadow: 0 0 0 3px rgba(139, 92, 246, .35); }
.speed-slider input::-moz-range-thumb { width: 14px; height: 14px; }
.speed-slider output { flex: none; min-width: 3.4em; text-align: right; font-size: 12.5px; font-weight: 600; color: var(--lilac); font-variant-numeric: tabular-nums; }
.speed-slider.wide output { font-size: 14px; }
.speed-slider.wide input { height: 28px; }

.gear-wrap { position: relative; }
#sessionBtn[aria-expanded='true'] { background: rgba(139, 92, 246, .28); border-color: rgba(167, 139, 250, .5); color: #fff; }
.gear-menu {
  position: absolute; right: 0; bottom: calc(100% + 12px); z-index: 8; width: min(290px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  border-radius: 18px; border: 1px solid rgba(167, 139, 250, .28);
  background: rgba(22, 16, 38, .9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  transform-origin: bottom right; animation: gear-pop .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes gear-pop { from { opacity: 0; transform: translateY(6px) scale(.96); } }
.gm-block { display: flex; flex-direction: column; gap: 6px; padding: 6px 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.gm-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.gm-label svg, .gm-item svg { width: 17px; height: 17px; flex: none; color: var(--lilac); }
.gm-label em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gm-sleep { padding: 3px; border-radius: 11px; }
.gm-sleep button { min-height: 30px; font-size: 12.5px; border-radius: 8px; }
.gm-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 8px; border: 0; border-radius: 12px;
  background: transparent; color: var(--text); text-align: left; font-size: 14px; cursor: pointer; transition: background .15s;
}
.gm-item:hover { background: rgba(167, 139, 250, .1); }
.gm-item:disabled { opacity: .4; pointer-events: none; }
.gm-item > span { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.gm-item small { font-size: 11.5px; color: var(--muted); }
.gm-item .gm-chev { width: 15px; height: 15px; color: var(--muted); }
.gm-switch { flex: none; position: relative; width: 34px; height: 20px; border-radius: 999px; background: rgba(196, 181, 253, .15); transition: background .2s; }
.gm-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #d8ccf5; transition: translate .2s; }
.gm-item[aria-pressed='true'] .gm-switch { background: var(--violet); }
.gm-item[aria-pressed='true'] .gm-switch::after { translate: 14px 0; background: #fff; }

/* top bar: clock on the left, ‹ › 💬 on the right */
.stage .reactions { align-items: center; }
.stage .reactions #prevBtn { margin-left: auto; }

/* sheet buttons never get squashed (zoomed in, the sheet's column used to shrink them) */
.sheet > .cta { flex: none; height: auto; min-height: 52px; padding: 12px 20px; }
@media (max-width: 440px) {
  .controls { grid-template-columns: 48px 60px 64px minmax(0, 1fr) 42px; gap: 8px; }
  .controls .volume { padding: 0; }
  .controls .volume svg { display: none; }
  .speed-slider { gap: 6px; }
  .speed-slider output { min-width: 2.9em; font-size: 12px; }
}
@media (max-width: 440px) { .dock-head { width: 48px; height: 48px; } }
@media (max-width: 440px) {
  .controls { grid-template-columns: 48px 60px 72px minmax(0, 1fr) 42px; }
  .controls .volume { gap: 4px; }
  .controls .volume svg { display: block; width: 14px; height: 14px; }
}

/* =================================================================== save / bookmark */
#saveBtn[aria-pressed='true'] { color: #fff; background: rgba(139, 92, 246, .32); border-color: rgba(196, 181, 253, .45); }
#saveBtn[aria-pressed='true'] svg, .history .mark[aria-pressed='true'] svg { fill: currentColor; }
#saveBtn svg { transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
#saveBtn[aria-pressed='true'] svg { transform: scale(1.08); }
.history .group { display: block; padding: 10px 2px 2px; border: 0; background: none; animation: none; color: var(--gold); font-family: var(--caps); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.history .group:first-child { padding-top: 0; }
.history li.saved { border-color: rgba(196, 181, 253, .28); background: rgba(139, 92, 246, .07); }
.history .mark[aria-pressed='true'] { color: var(--lilac); border-color: rgba(196, 181, 253, .4); }
@media (max-width: 440px) { .history .row-actions { gap: 4px; } .history .icon-btn { width: 34px; height: 34px; } }

/* =================================================================== volume: icon tucked under the slider */
.controls { grid-template-columns: 54px 60px minmax(72px, 108px) minmax(0, 1fr) 44px; }
.controls .volume { position: relative; display: block; padding: 0; }
.controls .volume input { position: relative; z-index: 1; display: block; width: 100%; }
.controls .volume svg { display: block; position: absolute; left: 0; bottom: -11px; width: 13px; height: 13px; opacity: .55; z-index: 0; pointer-events: none; }
@media (max-width: 440px) {
  .controls { grid-template-columns: 48px 60px 80px minmax(0, 1fr) 42px; }
  .controls .volume svg { width: 12px; height: 12px; }
}

/* =================================================================== play: glass, like the rest */
.play {
  background: radial-gradient(120% 120% at 30% 20%, rgba(196, 160, 255, .32), rgba(139, 92, 246, .16) 55%, rgba(110, 40, 180, .14));
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(221, 205, 255, .28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -10px 20px rgba(80, 30, 140, .18), 0 8px 26px rgba(20, 8, 40, .45), 0 0 calc(6px + var(--lvl) * 16px) rgba(192, 132, 252, calc(.15 + var(--lvl) * .35));
}
.play:hover { background: radial-gradient(120% 120% at 30% 20%, rgba(206, 175, 255, .4), rgba(139, 92, 246, .22) 55%, rgba(110, 40, 180, .18)); }
.play svg { filter: drop-shadow(0 1px 6px rgba(120, 60, 200, .45)); }
.stage .reactions #prevBtn { margin-left: 0; }
.stage .reactions #saveBtn { margin-left: auto; }
.play {
  background: radial-gradient(120% 120% at 30% 18%, rgba(214, 185, 255, .42), rgba(150, 100, 250, .22) 52%, rgba(120, 50, 200, .2));
  border-color: rgba(230, 215, 255, .34);
}
.play {
  background: radial-gradient(130% 130% at 30% 15%, rgba(222, 196, 255, .5), rgba(160, 110, 255, .3) 50%, rgba(125, 60, 215, .26));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), inset 0 -12px 22px rgba(70, 20, 130, .2), 0 8px 26px rgba(20, 8, 40, .4), 0 0 calc(10px + var(--lvl) * 18px) rgba(192, 132, 252, calc(.22 + var(--lvl) * .35));
}
.controls .volume svg { opacity: .75; color: var(--lilac); }

/* =================================================================== speed: tap to cycle, hold for a slider above */
.controls { grid-template-columns: 54px 60px 108px 56px 44px; justify-content: center; gap: 14px; }
@media (max-width: 440px) { .controls { grid-template-columns: 48px 60px 84px 54px 42px; gap: 10px; } }
.icon-btn.speed { width: 56px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--lilac); font-variant-numeric: tabular-nums; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.icon-btn.speed[aria-expanded='true'] { background: rgba(139, 92, 246, .28); border-color: rgba(167, 139, 250, .5); color: #fff; }
.speed-pop {
  position: absolute; left: 50%; bottom: calc(100% + 12px); z-index: 8; translate: -50% 0;
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto 1fr; justify-items: center; gap: 8px 6px;
  padding: 12px 12px 14px; border-radius: 18px; border: 1px solid rgba(167, 139, 250, .28);
  background: rgba(22, 16, 38, .88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  transform-origin: bottom center; animation: gear-pop .18s cubic-bezier(.2, .8, .2, 1);
}
.speed-pop output { grid-column: 1 / -1; font-size: 15px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; }
/* vertical: slide up for faster */
.speed-pop input { writing-mode: vertical-lr; direction: rtl; width: 28px; height: 150px; margin: 0; }
.speed-pop input::-webkit-slider-runnable-track { width: 4px; height: 100%; background: linear-gradient(0deg, var(--violet) var(--fill, 20%), rgba(196, 181, 253, .15) var(--fill, 20%)); }
.speed-pop input::-webkit-slider-thumb { margin-top: 0; margin-left: -9px; }
.speed-pop input::-moz-range-track { width: 4px; height: 100%; }
.speed-pop input::-moz-range-progress { width: 4px; }
.speed-ends { display: flex; flex-direction: column; justify-content: space-between; height: 150px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* sleep timer on: a little moon on the gear instead of a dot */
.moon-badge {
  position: absolute; top: -3px; right: -3px; width: 18px; height: 18px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(30, 20, 52, .95); border: 1px solid rgba(196, 181, 253, .45);
  box-shadow: 0 0 10px rgba(196, 181, 253, .45); animation: gear-pop .25s ease;
}
.moon-badge[hidden] { display: none; }
.moon-badge svg { width: 11px; height: 11px; color: var(--lilac); fill: currentColor; stroke-width: 1.5; }

/* =================================================================== glass pass: play, top buttons, ＋ */
.play {
  background: rgba(255, 255, 255, .035);
  backdrop-filter: blur(30px) saturate(1.4); -webkit-backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid rgba(235, 225, 255, .2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 8px 26px rgba(10, 4, 24, .25), 0 0 calc(4px + var(--lvl) * 18px) rgba(192, 132, 252, calc(.08 + var(--lvl) * .3));
}
.play:hover { background: rgba(255, 255, 255, .07); }

.stage .reactions .chip { background: rgba(255, 255, 255, .035); border-color: rgba(235, 225, 255, .14); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); }
.stage .reactions .chip:hover { background: rgba(255, 255, 255, .08); }
.stage .reactions #saveBtn[aria-pressed='true'] { background: rgba(139, 92, 246, .24); border-color: rgba(196, 181, 253, .4); }

/* ＋: bigger, glass, and as faded as the card it belongs to */
.more-btn {
  width: 46px; height: 46px; border: 1px solid rgba(232, 121, 249, .24); background: rgba(255, 255, 255, .03);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
  opacity: .42; transition: opacity .5s, transform .15s, background .2s, border-color .2s;
}
.more-btn svg { width: 22px; height: 22px; stroke-width: 1.8; }
.more-btn .spin { width: 22px; height: 22px; }
.cell:has(> .seg.now) .more-btn { opacity: 1; background: linear-gradient(135deg, rgba(40, 28, 70, .4), rgba(20, 14, 36, .2)); border-color: rgba(232, 121, 249, .4); }
.cell:has(> .seg.past) .more-btn { opacity: .3; }
.cell .more-btn:hover, .more-btn.loading { opacity: 1; background: rgba(232, 121, 249, .1); border-color: rgba(232, 121, 249, .55); }
.cell .more-btn { margin-top: 10px; }

/* =================================================================== glass pass 2 */
/* dock buttons: clear glass */
.controls .icon-btn { background: rgba(255, 255, 255, .035); border-color: rgba(235, 225, 255, .16); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); }
.controls .icon-btn:hover { background: rgba(255, 255, 255, .08); }
.controls .icon-btn[aria-expanded='true'] { background: rgba(139, 92, 246, .22); border-color: rgba(196, 181, 253, .4); }
/* play: barely there, light blur */
.play { background: rgba(255, 255, 255, .015); backdrop-filter: blur(6px) saturate(1.2); -webkit-backdrop-filter: blur(6px) saturate(1.2); border-color: rgba(235, 225, 255, .18); }
.play:hover { background: rgba(255, 255, 255, .05); }

/* speed: a horizontal glass bar above the button */
.speed-pop {
  left: auto; right: -40px; translate: none; transform-origin: bottom right;
  display: grid; grid-template-columns: auto 180px auto; grid-template-rows: auto auto; align-items: center; gap: 4px 10px;
  padding: 10px 14px 12px; border-radius: 16px;
  background: rgba(40, 28, 70, .22); border-color: rgba(235, 225, 255, .16);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.speed-pop output { grid-column: 1 / -1; justify-self: center; font-size: 14px; }
.speed-pop input { writing-mode: horizontal-tb; direction: ltr; width: 180px; height: 26px; }
.speed-pop input::-webkit-slider-runnable-track { width: auto; height: 4px; background: linear-gradient(90deg, var(--violet) var(--fill, 20%), rgba(196, 181, 253, .15) var(--fill, 20%)); }
.speed-pop input::-webkit-slider-thumb { width: 16px; height: 16px; margin-top: -6px; margin-left: 0; box-shadow: 0 0 0 4px rgba(139, 92, 246, .3); }
.speed-pop input::-moz-range-track { width: auto; height: 4px; }
.speed-pop input::-moz-range-progress { width: auto; height: 4px; }
.speed-pop input::-moz-range-thumb { width: 16px; height: 16px; }
.speed-end { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 440px) { .speed-pop { grid-template-columns: auto 150px auto; right: -50px; } .speed-pop input { width: 150px; } }

/* ＋: monochrome and barely there */
.more-btn { color: rgba(240, 236, 250, .55); border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .012); opacity: .28; }
.more-btn .spin { border-color: rgba(255, 255, 255, .15); border-top-color: rgba(255, 255, 255, .7); }
.cell:has(> .seg.past) .more-btn { opacity: .18; }
.cell:has(> .seg.now) .more-btn { opacity: .5; background: rgba(255, 255, 255, .02); border-color: rgba(255, 255, 255, .14); }
.cell .more-btn:hover, .more-btn.loading { opacity: .9; color: #fff; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .28); }
.cell:has(> .seg.now) .more-btn { opacity: .36; }

/* =================================================================== branched rows: run to the screen edge, fade out, scrollbar */
.seg-row.branched {
  margin-right: calc(-1 * var(--bleed, 0px)); padding-right: 40px; padding-bottom: 10px;
  scroll-snap-type: x proximity; scrollbar-width: auto;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 72px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 72px), transparent);
}
.seg-row.branched::-webkit-scrollbar { display: block; height: 6px; }
.seg-row.branched::-webkit-scrollbar-track { background: rgba(255, 255, 255, .05); border-radius: 6px; }
.seg-row.branched::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); border-radius: 6px; }
/* Firefox has no ::-webkit-scrollbar; give it the standard thin one */
@supports not selector(::-webkit-scrollbar) { .seg-row.branched { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .28) transparent; } }
.seg-row.branched::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .35); }
.seg-row.branched .cell { flex: 0 0 calc(var(--colw, 100%) * .9); scroll-snap-align: start; }

/* ＋: bigger */
.more-btn { width: 56px; height: 56px; }
.more-btn svg { width: 28px; height: 28px; stroke-width: 1.6; }
.more-btn .spin { width: 26px; height: 26px; }
.cell .more-btn { margin-top: 6px; }

/* top bar: time spent on this session, between chat and prev */
.rx-elapsed { flex: none; align-self: center; min-width: 3.2em; padding: 0 4px; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--lilac); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.stage .reactions #prevBtn { margin-left: 0; }

/* =================================================================== centred dialogs: archive and settings */
.sheet.dialog {
  top: 50%; bottom: auto; width: min(600px, calc(100% - 32px)); max-height: min(86dvh, 860px);
  translate: -50% -46%; scale: .97; opacity: 0; visibility: hidden; pointer-events: none;
  transition: translate .32s cubic-bezier(.2, .8, .2, 1), scale .32s cubic-bezier(.2, .8, .2, 1), opacity .22s, visibility 0s .32s;
  padding: 18px 18px 22px; border-radius: 24px; border: 1px solid rgba(196, 181, 253, .18);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
}
.sheet.dialog.open { translate: -50% -50%; scale: 1; opacity: 1; visibility: visible; pointer-events: auto; transition: translate .32s cubic-bezier(.2, .8, .2, 1), scale .32s cubic-bezier(.2, .8, .2, 1), opacity .22s; }
.sheet.dialog .sheet-head { position: relative; padding-right: 48px; }
.dialog-close { position: absolute; top: 0; right: 0; width: 38px; height: 38px; background: rgba(255, 255, 255, .035); border-color: rgba(235, 225, 255, .14); }
.dialog-close svg { width: 16px; height: 16px; }
.dialog-close:hover { background: rgba(255, 255, 255, .09); }

/* archive row: play · save · download   ·   delete */
.history .del { margin-left: 10px; }
.history .del:hover { color: #fca5a5; border-color: rgba(252, 165, 165, .35); }

/* =================================================================== sticky bars: controls, plus the chapter bar when reading */
.stage-bars { position: sticky; top: calc(env(safe-area-inset-top) + 6px); z-index: 4; margin: 10px -16px 0; }
.stage .stage-bars .reactions { position: relative; top: auto; margin: 0; }
.chapter-bar {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 8px;
  background: transparent; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .3s ease;
}
.chapter-bar[hidden] { display: none; }
.chapter-bar .chip { flex: none; width: 32px; height: 32px; padding: 0; justify-content: center; background: rgba(255, 255, 255, .035); border-color: rgba(235, 225, 255, .14); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); }
.chapter-bar .chip:hover { background: rgba(255, 255, 255, .08); }
.chapter-bar .chip svg { width: 15px; height: 15px; }
.chapter-bar .chip:disabled { opacity: .3; }
.chapter-now { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.chapter-title {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--caps); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  text-shadow: 0 0 14px rgba(233, 196, 126, .25);
}
.chapter-now small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* =================================================================== his own thoughts sit on the right */
.seg.thought { text-align: right; padding: 12px 18px 14px 14px; }
.seg.thought::before { left: auto; right: 4px; }
.seg.thought .seg-meta { flex-direction: row-reverse; }
.seg.thought .seg-meta a { margin-left: 0; margin-right: auto; }
.seg.thought .question { display: block; }
.seg.thought .kind::after { content: none; }
.seg.thought .kind::before {
  content: ''; display: inline-block; width: 5px; height: 5px; margin-right: 8px; vertical-align: 2px;
  background: rgba(196, 181, 253, .18); transition: background .4s, box-shadow .4s;
}
.seg.thought.voiced .kind::before { background: #a78bfa; box-shadow: 0 0 6px rgba(167, 139, 250, .8); }
.seg.thought.past .kind::before { opacity: .4; }
/* digressions: header and line on the right, but the text reads left-aligned like everything else */
.seg.thought { text-align: left; }
.seg.thought .seg-meta { justify-content: flex-start; }
/* anchored from the left so it snaps to whole pixels like the left-hand line (no soft, thinner edge at 125%/150% scaling) */
.seg.thought::before { right: auto; left: calc(100% - 6px); }

/* =================================================================== states of mind (thoughts.js) */
/* the screen's edges glow in the aside's colour while it plays (scheming has its own red, in body.scheming) */
.thought-glow {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 1.2s ease, background 1.2s ease;
  background: radial-gradient(120% 90% at 50% 20%, transparent 38%, var(--thought-glow, transparent) 100%);
  mix-blend-mode: screen;
}
body.playing[data-thought] .thought-glow { opacity: 1; }
body.playing[data-thought] .aura { background: radial-gradient(circle, color-mix(in srgb, var(--thought) 55%, transparent) 0%, transparent 62%); }
/* the card says which kind of aside it is, in its colour */
.seg.aside .kind { color: var(--thought); }
.seg.aside.now::before { background: linear-gradient(var(--thought), color-mix(in srgb, var(--thought) 45%, var(--violet))); box-shadow: 0 0 10px var(--thought); }
.seg.aside.now { box-shadow: 0 0 0 1px color-mix(in srgb, var(--thought) 26%, transparent), 0 18px 50px rgba(0, 0, 0, .35); }
.seg.aside.now::after { background: radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--thought) 14%, transparent), transparent 60%); }
.seg.aside.now .w.on { text-shadow: 0 0 18px color-mix(in srgb, var(--thought) 40%, transparent); }
.thought-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.thought-legend li { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--thought) 22%, transparent); background: color-mix(in srgb, var(--thought) 5%, transparent); }
.thought-legend .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--thought); box-shadow: 0 0 10px var(--thought); }
.thought-legend span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.thought-legend b { font-family: var(--caps); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--thought); font-weight: 500; }
.thought-legend small { font-size: 12px; color: var(--muted); }
.thought-legend .icon-btn { width: 34px; height: 34px; flex: none; }
.thought-legend .icon-btn svg { width: 14px; height: 14px; }

/* book recaps: "the story so far", on the book's side, so you can follow along */
.kind.recap { color: #c4b5fd; }
.seg.recap-seg .seg-text { font-size: 17.5px; }
.seg.recap-seg.now .seg-text { font-size: 21px; }
/* softer, slower edge glow to match the gentler smoke */
.thought-glow { transition: opacity 4s ease, background 4s ease; }
body.playing[data-thought] .thought-glow { opacity: .6; }
.aura { transition: background 3s ease; }

/* =================================================================== states of mind: sliders and previews */
.aside-dials { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.aside-dials > .label { color: var(--gold); font-family: var(--caps); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.aside-dials > .fine { margin: 0 0 4px; }
.aside-dial .label-row .label { color: var(--thought); display: inline-flex; align-items: center; gap: 6px; }
.aside-dial input[type='range']::-webkit-slider-runnable-track { background: linear-gradient(90deg, var(--thought) var(--fill, 20%), rgba(196, 181, 253, .15) var(--fill, 20%)); }
.aside-dial input[type='range']::-moz-range-progress { background: var(--thought); }
.preview-btn {
  width: 24px; height: 24px; padding: 0; display: inline-grid; place-items: center; flex: none; cursor: pointer;
  border-radius: 50%; border: 1px solid color-mix(in srgb, var(--thought) 45%, transparent);
  background: color-mix(in srgb, var(--thought) 10%, transparent); color: var(--thought); transition: background .2s, transform .15s;
}
.preview-btn:hover { background: color-mix(in srgb, var(--thought) 22%, transparent); }
.preview-btn:active { transform: scale(.9); }
.preview-btn svg { width: 10px; height: 10px; fill: currentColor; translate: 1px 0; }

/* while previewing, the room shows through: menus fade back for a few seconds */
body.previewing[data-thought] .thought-glow { opacity: .6; }
body.previewing[data-thought] .aura { background: radial-gradient(circle, color-mix(in srgb, var(--thought) 55%, transparent) 0%, transparent 62%); }
body.previewing .scrim { opacity: 0; transition: opacity .6s; }
body.previewing .sheet.open { opacity: .08; transition: opacity .6s; }

/* =================================================================== chat moves to the dock; back arrow replaces End */
.controls { grid-template-columns: 44px 54px 60px 100px 56px 44px; gap: 12px; }
@media (max-width: 440px) { .controls { grid-template-columns: 40px 46px 58px 72px 52px 40px; gap: 7px; } .controls .icon-btn { width: 40px; height: 40px; } .icon-btn.speed { width: 52px; } }
.stage .reactions #saveBtn { margin-left: 0; }
.stage .reactions #endSession { margin-left: auto; }

/* Personality: Vibes / States of mind / Face & atmosphere / Voice */
#setStates > summary { font-family: var(--caps); color: var(--gold); letter-spacing: .14em; text-transform: uppercase; font-size: 13px; font-weight: 500; }
#setStates > summary svg { color: var(--gold); }
#setStates .aside-dials { margin-top: 0; padding-top: 0; border-top: 0; }
#setStates .dial[data-dial='moodVolume'] { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }

/* chapter bar v2:  ‹  [3 of 12]   CHAPTER TITLE   [Page 4/9]  ›  */
.chapter-bar { margin-top: 2px; padding-top: 4px; gap: 8px; }
.chapter-pill {
  flex: none; height: 32px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
  background: rgba(255, 255, 255, .035); border: 1px solid rgba(235, 225, 255, .14);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.chapter-pill[hidden] { display: none; }
.chapter-bar .chapter-title { font-size: 17px; letter-spacing: .12em; line-height: 1.2; }
@media (max-width: 440px) {
  .chapter-bar { gap: 6px; }
  .chapter-pill { padding: 0 9px; font-size: 12px; }
  .chapter-bar .chapter-title { font-size: 15px; letter-spacing: .1em; }
}
/* pills: "1 of 3" and "Passage 4/9" on one line; on phones a tiny caps label stacked over the number */
.chapter-pill { gap: 5px; }
.chapter-pill b { font-weight: 500; color: var(--text); }
.chapter-pill .narrow, #chapterCount small { display: none; }
@media (max-width: 440px) {
  .chapter-pill { flex-direction: column; justify-content: center; gap: 0; padding: 0 10px; line-height: 1.05; }
  .chapter-pill small { display: block !important; font-family: var(--caps); font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
  .chapter-pill b { font-size: 12px; }
  .chapter-pill .wide { display: none; }
  .chapter-pill .narrow { display: inline; }
}
/* pills with the old marks: ❡ chapter, § passage. One line on every screen. */
.chapter-pill i { font-style: normal; font-family: var(--display), Georgia, 'Times New Roman', serif; font-size: 16px; line-height: 1; color: var(--gold); opacity: .85; translate: 0 -1px; }
@media (max-width: 440px) {
  .chapter-pill { flex-direction: row; gap: 5px; padding: 0 10px; line-height: 1; }
  .chapter-pill i { font-size: 15px; }
}

/* =================================================================== Brain and Voice: live status */
.stack-status { margin-left: auto; display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.set > summary small:has(.api-badge) { margin-left: auto; }
.api-badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; color: var(--muted); white-space: nowrap;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(235, 225, 255, .12);
}
.api-badge i { font-style: normal; font-weight: 700; font-size: 11px; width: 14px; height: 14px; display: grid; place-items: center; border-radius: 50%; }
.api-badge.ok i { color: #0b2b1d; background: #6ee7b7; box-shadow: 0 0 8px rgba(110, 231, 183, .6); }
.api-badge.warn i { color: #3a2604; background: #fbbf24; }
.api-badge.bad i { color: #fff; background: #f43f5e; box-shadow: 0 0 8px rgba(244, 63, 94, .5); }
.api-badge.off i { color: var(--muted); border: 1px solid var(--muted); }
.api-badge.checking i { color: var(--lilac); animation: blink 1.2s ease-in-out infinite; }
@media (max-width: 440px) { .stack-status .api-badge { font-size: 10.5px; padding: 2px 6px 2px 7px; } }
/* while a menu is open, only the menu scrolls; and its sections are never squeezed to fit */
html.sheet-open, html.sheet-open body { overflow: hidden; }
.sheet > * { flex-shrink: 0; }

/* sleep timer: a dark veil settles over everything as he drifts off (--drowse 0..1, set by the timer) */
.drowse-veil {
  position: fixed; inset: 0; z-index: 9; pointer-events: none; background: #020105;
  opacity: calc(var(--drowse, 0) * .62); transition: opacity 2s ease;
}
/* inside the LLM API sub-section the row is narrower: let the buttons wrap instead of spilling out */
.brain-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }

/* volume: a button like speed (tap to step, hold for the slider) */
.controls { grid-template-columns: 44px 54px 60px 68px 56px 44px; }
@media (max-width: 440px) { .controls { grid-template-columns: 40px 46px 58px 62px 52px 40px; } }
.icon-btn.vol-btn { width: 68px; display: inline-flex; gap: 4px; justify-content: center; }
.icon-btn.vol-btn svg { width: 13px; height: 13px; flex: none; opacity: .8; }
.icon-btn.vol-btn.muted { color: var(--muted); }
.icon-btn.vol-btn.muted svg { opacity: .35; }
@media (max-width: 440px) { .icon-btn.vol-btn { width: 62px; gap: 3px; font-size: 12px; } .icon-btn.vol-btn svg { width: 11px; height: 11px; } }

/* previous / next moved into the dock, after the gear: eight controls */
.controls { grid-template-columns: 44px 54px 60px 68px 56px 44px 44px 44px; gap: 10px; }
.controls #prevBtn svg, .controls #nextBtn svg { width: 18px; height: 18px; }
.controls #prevBtn:disabled, .controls #nextBtn:disabled { opacity: .35; }
@media (max-width: 440px) {
  .controls { grid-template-columns: 36px 38px 52px 46px 46px 36px 36px 36px; gap: 4px; }
  .controls .icon-btn { width: 36px; height: 36px; }
  .controls .play { width: 52px; height: 52px; }
  .dock-head { width: 38px; height: 38px; }
  .icon-btn.vol-btn { width: 46px; font-size: 11.5px; }
  .icon-btn.vol-btn svg { display: none; }
  .icon-btn.speed { width: 46px; font-size: 11.5px; }
  .controls .icon-btn svg { width: 16px; height: 16px; }
}
/* his head fills its dock slot, whatever size the slot is on this screen */
body[data-view='stage'] .dock-head .avatar { width: 100%; height: 100%; }

/* during a session the Settings button sits in the top bar, styled like its neighbours */
.stage .reactions #settingsBtn { width: 32px; height: 32px; flex: none; padding: 0; background: rgba(255, 255, 255, .035); border: 1px solid rgba(235, 225, 255, .14); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); }
.stage .reactions #settingsBtn:hover { background: rgba(255, 255, 255, .08); }
.stage .reactions #settingsBtn svg { width: 15px; height: 15px; }
.stage .reactions #settingsBtn .dot { top: 3px; right: 3px; width: 7px; height: 7px; }

/* phones: his head tucks a little under the chat and play buttons, so the corner buttons fit */
@media (max-width: 440px) {
  .controls { grid-template-columns: 36px 24px 52px 44px 44px 36px 36px 36px; gap: 3px; }
  .controls .dock-head { width: 38px; height: 38px; justify-self: center; position: relative; z-index: 0; }
  .controls > :not(.dock-head) { position: relative; z-index: 1; }
  .icon-btn.vol-btn, .icon-btn.speed { width: 44px; }
}
@media (max-width: 370px) {
  .controls { grid-template-columns: 34px 22px 50px 42px 42px 34px 34px 34px; }
  .controls .icon-btn { width: 34px; height: 34px; }
  .controls .play { width: 50px; height: 50px; }
  .icon-btn.vol-btn, .icon-btn.speed { width: 42px; font-size: 11px; }
}

/* phones, final word: no button changes size. Dagoth's slot gives way first (down to nothing: his head
   stays full size, tucked behind chat and play), and the bar may use the screen's side margins. */
@media (max-width: 440px) {
  .dock { padding-left: 6px; padding-right: 6px; }
  .controls { width: 100%; max-width: none; justify-content: center; grid-template-columns: 36px minmax(0, 24px) 52px 44px 44px 36px 36px 36px; gap: 3px; }
}
@media (max-width: 370px) {
  .controls { grid-template-columns: 34px minmax(0, 22px) 50px 42px 42px 34px 34px 34px; gap: 2px; }
}

/* Personality's subsections all wear the gold caps (Vibes, States of mind, Avatar & Atmosphere) */
#setPersonality > details.set.sub > summary { font-family: var(--caps); color: var(--gold); letter-spacing: .14em; text-transform: uppercase; font-size: 13px; font-weight: 500; }
#setPersonality > details.set.sub > summary svg { color: var(--gold); }
#setPersonality > details.set.sub:not([open]) > summary { color: color-mix(in srgb, var(--gold) 75%, var(--muted)); }

/* four providers in one row */
.provider-choice button { padding: 0 4px; font-size: 13px; }
@media (max-width: 440px) { .provider-choice button { font-size: 12px; } }

/* Help → This build */
.build { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12.5px; }
.build dt { color: var(--muted); }
.build dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#reloadLatest { align-self: flex-start; }
.build-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(196, 181, 253, .16); background: rgba(139, 92, 246, .06); }
.build-card .label { margin: 0; }
.build-card #reloadLatest { margin-top: 2px; }

/* Personality's three subsections, each with its own character:
   Vibes: elegant italic serif in lilac to pink · States of mind: gold caps · Avatar & Atmosphere: embers */
#setPersonality > #setVibes > summary { font-family: var(--display); font-style: italic; font-size: 21px; letter-spacing: .01em; text-transform: none; font-weight: 500; }
#setPersonality > #setVibes > summary .sub-title { background: linear-gradient(100deg, #c4b5fd, #f0abfc 60%, #f9a8d4); -webkit-background-clip: text; background-clip: text; color: transparent; }
#setPersonality > #setVibes > summary svg { color: #e9a8f5; }
#setPersonality > #setFace > summary { font-family: var(--caps); letter-spacing: .14em; text-transform: uppercase; font-size: 13px; font-weight: 500; }
#setPersonality > #setFace > summary .sub-title { background: linear-gradient(100deg, #fb923c, #f87171 55%, #e11d48); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 8px rgba(248, 113, 113, .25)); }
#setPersonality > #setFace > summary svg { color: #fb7a5c; width: 19px; height: 19px; }
/* closed: a little quieter, like the others */
#setPersonality > #setVibes:not([open]) > summary .sub-title, #setPersonality > #setFace:not([open]) > summary .sub-title { opacity: .8; }

/* =================================================================== home: the program, set apart in maroon */
/* everything below "While you're": a deep maroon section, then the chosen program's options in an inset card */
.studio {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  margin: 6px -16px 0; padding: 20px 16px 22px; border-radius: 28px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(160, 30, 70, .22), transparent 70%),
    linear-gradient(180deg, rgba(92, 14, 40, .42) 0%, rgba(62, 10, 30, .34) 45%, rgba(28, 6, 18, .22) 100%);
  border: 1px solid rgba(255, 120, 150, .14); border-bottom-color: rgba(255, 120, 150, .05);
  box-shadow: inset 0 1px 0 rgba(255, 170, 190, .08), 0 -12px 40px rgba(80, 10, 30, .18);
}
.studio-label { margin: 0 2px -4px; color: #f4b3c2; }
.studio .programs button { background: rgba(20, 6, 14, .35); border-color: rgba(255, 140, 165, .14); }
.studio .programs button[aria-checked='true'], .studio .programs button[aria-pressed='true'] { border-color: rgba(255, 150, 175, .5); background: linear-gradient(140deg, rgba(150, 26, 64, .45), rgba(70, 12, 40, .4)); box-shadow: 0 10px 30px rgba(120, 14, 50, .3); }
.studio-panel {
  display: flex; flex-direction: column; gap: 12px; padding: 16px 14px 18px; border-radius: 20px;
  background: rgba(12, 4, 10, .42); border: 1px solid rgba(255, 140, 165, .12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03), inset 0 10px 30px rgba(0, 0, 0, .18);
}
.studio-panel > .panel[hidden] { display: none; }
@media (min-width: 640px) { .studio { margin-inline: -20px; padding-inline: 20px; } }
/* seamless: no card edges, full width, the maroon fades in and out of the purple */
.studio {
  margin-inline: calc(50% - 50vw); padding-inline: max(16px, calc(50vw - 50%)); padding-top: 34px; padding-bottom: 40px;
  border: 0; border-radius: 0; box-shadow: none;
  background: linear-gradient(180deg, rgba(70, 10, 32, 0) 0%, rgba(70, 10, 32, .26) 16%, rgba(58, 8, 28, .24) 72%, rgba(58, 8, 28, 0) 100%);
}
@media (min-width: 640px) { .studio { margin-inline: calc(50% - 50vw); padding-inline: max(20px, calc(50vw - 50%)); } }
.studio .programs button { background: rgba(20, 6, 14, .22); border-color: rgba(255, 140, 165, .1); }
.studio .programs button[aria-checked='true'] { background: linear-gradient(140deg, rgba(150, 26, 64, .32), rgba(70, 12, 40, .26)); border-color: rgba(255, 150, 175, .38); box-shadow: 0 8px 24px rgba(120, 14, 50, .2); }
.studio-panel { background: rgba(12, 4, 10, .26); border-color: rgba(255, 140, 165, .08); box-shadow: inset 0 8px 24px rgba(0, 0, 0, .12); }
.studio { background: linear-gradient(180deg, rgba(78, 10, 34, 0) 0%, rgba(78, 10, 34, .36) 18%, rgba(64, 8, 30, .32) 70%, rgba(64, 8, 30, 0) 100%); }
/* the section starts at a fine rose line, with a clean maroon glow for ~100px below it */
.studio { padding-top: 26px; background: linear-gradient(180deg, rgba(118, 18, 50, .5) 0px, rgba(90, 12, 38, .36) 100px, rgba(64, 8, 30, .3) 70%, rgba(64, 8, 30, 0) 100%); }
.studio::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 140, 170, .45) 18%, rgba(255, 185, 200, .75) 50%, rgba(255, 140, 170, .45) 82%, transparent);
  box-shadow: 0 0 12px rgba(255, 110, 150, .35);
}
.studio-label { align-self: center; margin: 0 0 -2px; font-family: var(--caps); color: var(--gold); font-size: 12px; letter-spacing: .26em; text-transform: uppercase; text-shadow: 0 0 14px rgba(233, 196, 126, .25); }
/* the line spans just the content width, centred, fading out at its ends */
.studio::before { left: 50%; right: auto; width: min(620px, calc(100vw - 24px)); translate: -50% 0; }
.studio {
  background:
    radial-gradient(360px 110px at 50% 0, rgba(130, 20, 55, .42), transparent 100%),
    linear-gradient(180deg, rgba(78, 10, 34, 0) 0px, rgba(78, 10, 34, .3) 130px, rgba(64, 8, 30, .3) 70%, rgba(64, 8, 30, 0) 100%);
}
/* deeper, darker wine: it should darken the smoke toward maroon, not tint it pink */
.studio {
  background:
    radial-gradient(360px 110px at 50% 0, rgba(96, 10, 36, .5), transparent 100%),
    linear-gradient(180deg, rgba(34, 4, 16, 0) 0px, rgba(34, 4, 16, .42) 130px, rgba(28, 3, 14, .4) 70%, rgba(28, 3, 14, 0) 100%);
}
/* no wash over the smoke: just the line, and a short maroon glow under it that fades out on every side */
.studio { background: radial-gradient(380px 100px at 50% 0, rgba(110, 14, 42, .45), transparent 100%); }

/* "You're currently": the same treatment as Program, in green. A fine line, a short glow under it, gold label. */
.zone-activity {
  position: relative; gap: 12px; margin-inline: calc(50% - 50vw); padding: 26px max(16px, calc(50vw - 50%)) 6px;
  background: radial-gradient(380px 100px at 50% 0, rgba(16, 110, 82, .38), transparent 100%);
}
.zone-activity::before {
  content: ''; position: absolute; top: 0; left: 50%; width: min(620px, calc(100vw - 24px)); height: 1px; translate: -50% 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(110, 231, 183, .4) 18%, rgba(167, 243, 208, .7) 50%, rgba(110, 231, 183, .4) 82%, transparent);
  box-shadow: 0 0 12px rgba(52, 211, 153, .3);
}
.zone-label { align-self: center; margin: 0 0 -2px; font-family: var(--caps); color: var(--gold); font-size: 12px; letter-spacing: .26em; text-transform: uppercase; text-shadow: 0 0 14px rgba(233, 196, 126, .25); }
/* the chosen activity picks up the green */
.zone-activity .chip[aria-checked='true'], .zone-activity .chip[aria-pressed='true'] { background: linear-gradient(135deg, rgba(16, 120, 88, .5), rgba(12, 80, 70, .4)); border-color: rgba(110, 231, 183, .5); color: #ecfdf5; box-shadow: 0 6px 20px rgba(16, 120, 88, .25); }
/* the glow under each line now reaches ~220px down (still fading out on every side) */
.studio { background: radial-gradient(400px 220px at 50% 0, rgba(110, 14, 42, .42), transparent 100%); }
.zone-activity { background: radial-gradient(400px 220px at 50% 0, rgba(16, 110, 82, .34), transparent 100%); }

/* activities: 3 × 3 on phones (eight + "Other"), 4 × 3 on wider screens (eleven + "Other") */
#activity { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
  #activity { grid-template-columns: repeat(3, 1fr); }
  #activity .chip.wide:not([aria-checked='true']) { display: none; }
}
/* the "+" activity: what you're actually doing */
#activity .custom-act { gap: 5px; border-style: dashed; border-color: rgba(167, 243, 208, .3); }
#activity .custom-act[aria-checked='true'] { border-style: solid; }
#activity .custom-act svg { width: 13px; height: 13px; flex: none; stroke-width: 2.2; color: #6ee7b7; }
#activity .custom-act span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#activity .custom-input { padding: 10px 12px; font-size: 13.5px; text-align: center; color: var(--text); background: rgba(16, 80, 64, .3); border: 1px solid rgba(110, 231, 183, .5); outline: none; min-width: 0; width: 100%; }

/* =================================================================== themed type on the home page */
/* You're currently: old-book serif */
#activity .chip { font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: .01em; padding: 8px 8px; }
#activity .custom-input { font-family: var(--display); font-size: 17px; font-weight: 600; }
@media (max-width: 440px) { #activity .chip, #activity .custom-input { font-size: 16px; } }

/* Program: engraved names, serif everything else (text boxes keep the plain UI font, to stay easy to type in) */
.studio .programs b { font-family: var(--caps); font-size: 14px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.studio .programs small { font-family: var(--display); font-style: italic; font-size: 15px; line-height: 1.2; }
.studio-panel .label, .studio-panel .label-row .label { font-family: var(--caps); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; color: color-mix(in srgb, var(--gold) 80%, var(--muted)); }
.studio-panel .link-btn { font-family: var(--display); font-size: 15px; font-style: italic; }
.studio .tbtn b { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: .01em; }
.studio .tbtn small { font-family: var(--display); font-style: italic; font-size: 14.5px; }
.studio .tsub { font-family: var(--display); font-size: 16px; font-weight: 600; }
.studio .segmented button { font-family: var(--display); font-size: 16.5px; font-weight: 600; }
.studio .book b { font-family: var(--display); font-size: 15px; }
.studio .book small { font-family: var(--display); font-style: italic; font-size: 12.5px; }
.studio .questions button, .studio #questions > * { font-family: var(--display); font-size: 16.5px; }
.studio-panel .fine { font-family: var(--display); font-style: italic; font-size: 15px; }
.studio-panel .drop b { font-family: var(--display); font-size: 18px; font-weight: 600; }
.studio-panel .drop small { font-family: var(--display); font-style: italic; font-size: 14px; }
.studio-panel details > summary { font-family: var(--display); font-style: italic; font-size: 15px; }

/* =================================================================== each program has its colour */
/* Summon, the Length slider and the Program section all follow the chosen program, and glide between them. */
@property --prog { syntax: '<color>'; inherits: true; initial-value: #96203f; }
@property --prog-hi { syntax: '<color>'; inherits: true; initial-value: #ff8ca5; }
@property --prog-deep { syntax: '<color>'; inherits: true; initial-value: #6e1230; }
body { transition: --prog .6s ease, --prog-hi .6s ease, --prog-deep .6s ease; }
body[data-program='news'] { --prog: #96203f; --prog-hi: #ff8ca5; --prog-deep: #6e1230; } /* crimson */
body[data-program='literature'] { --prog: #a8741e; --prog-hi: #f5c97a; --prog-deep: #6b4510; } /* amber, like old pages */
body[data-program='discourse'] { --prog: #2563a8; --prog-hi: #93c5fd; --prog-deep: #173a6b; } /* sapphire, cool and thoughtful */
body[data-program='talk'] { --prog: #7c3aed; --prog-hi: #c4b5fd; --prog-deep: #4c1d95; } /* violet, conversation */

/* Summon: grander, engraved, in the program's colour */
#begin {
  font-family: var(--caps); font-weight: 600; font-size: 15.5px; letter-spacing: .16em; text-transform: uppercase;
  text-shadow: 0 0 18px color-mix(in srgb, var(--prog-hi) 45%, transparent), 0 1px 0 rgba(0, 0, 0, .35);
  background: linear-gradient(120deg, color-mix(in srgb, var(--prog-deep) 48%, transparent), color-mix(in srgb, var(--prog) 46%, transparent) 50%, color-mix(in srgb, var(--prog-deep) 48%, transparent));
  border: 1px solid color-mix(in srgb, var(--prog-hi) 32%, transparent);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--prog-deep) 34%, transparent), 0 1px 0 rgba(255, 255, 255, .12) inset;
}
#begin:hover { background: linear-gradient(120deg, color-mix(in srgb, var(--prog-deep) 58%, transparent), color-mix(in srgb, var(--prog) 56%, transparent) 50%, color-mix(in srgb, var(--prog-deep) 58%, transparent)); }
@media (max-width: 440px) { #begin { font-size: 14px; letter-spacing: .13em; } }

/* Length slider */
#length::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 50%, transparent), color-mix(in srgb, var(--prog) 50%, transparent) calc(var(--fill, 20%) - 1%), rgba(255, 255, 255, .05) var(--fill, 20%));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--prog-hi) 24%, transparent) inset;
}
#length::-webkit-slider-thumb { background: color-mix(in srgb, var(--prog-hi) 25%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--prog) 55%, transparent), 0 2px 6px rgba(0, 0, 0, .45); }
#length::-moz-range-track { box-shadow: 0 0 0 1px color-mix(in srgb, var(--prog-hi) 24%, transparent) inset; }
#length::-moz-range-progress { background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 50%, transparent), color-mix(in srgb, var(--prog) 50%, transparent)); }
#length::-moz-range-thumb { background: color-mix(in srgb, var(--prog-hi) 25%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--prog) 55%, transparent); }

/* the Program section: its line, the glow under it, and the chosen card */
.studio { background: radial-gradient(400px 220px at 50% 0, color-mix(in srgb, var(--prog-deep) 42%, transparent), transparent 100%); }
.studio::before {
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--prog-hi) 45%, transparent) 18%, color-mix(in srgb, var(--prog-hi) 75%, #fff 10%) 50%, color-mix(in srgb, var(--prog-hi) 45%, transparent) 82%, transparent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--prog) 40%, transparent);
}
.studio .programs button[aria-checked='true'] {
  background: linear-gradient(140deg, color-mix(in srgb, var(--prog) 34%, transparent), color-mix(in srgb, var(--prog-deep) 28%, transparent));
  border-color: color-mix(in srgb, var(--prog-hi) 42%, transparent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--prog-deep) 24%, transparent);
}
.studio .programs button[aria-checked='true'] svg { color: var(--prog-hi); }
.studio .programs button { border-color: color-mix(in srgb, var(--prog-hi) 10%, transparent); }

/* News topics wear the program's colour (crimson) instead of purple */
.studio .trow.on { border-color: color-mix(in srgb, var(--prog-hi) 28%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--prog) 14%, transparent), rgba(30, 10, 22, .22)); }
.studio .tbtn[aria-pressed='true'] { border-color: color-mix(in srgb, var(--prog-hi) 55%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--prog) 42%, transparent), color-mix(in srgb, var(--prog-deep) 30%, transparent)); }
.studio .tbtn[aria-pressed='true'] small { color: color-mix(in srgb, var(--prog-hi) 80%, #fff); }
.studio .tsub:hover { border-color: color-mix(in srgb, var(--prog-hi) 30%, transparent); }
.studio .tsub[aria-pressed='true'] { border-color: color-mix(in srgb, var(--prog-hi) 55%, transparent); background: color-mix(in srgb, var(--prog) 34%, transparent); }

/* "Unselect": a quiet little pill button */
.ghost-pill {
  padding: 3px 11px; border-radius: 999px; cursor: pointer; font-family: var(--display); font-style: italic; font-size: 14.5px;
  color: var(--muted); background: rgba(255, 255, 255, .025); border: 1px solid rgba(255, 255, 255, .09);
  transition: color .2s, background .2s, border-color .2s;
}
.ghost-pill:hover { color: var(--text); background: color-mix(in srgb, var(--prog) 14%, transparent); border-color: color-mix(in srgb, var(--prog-hi) 30%, transparent); }
.ghost-pill:active { transform: scale(.96); }
.ghost-pill[hidden] { display: none; }
/* You're currently: Marcellus, inscriptional like Cinzel but sturdier and easier to read at button size */
#activity .chip, #activity .custom-input { font-family: 'Marcellus', var(--display); font-weight: 400; font-size: 15.5px; letter-spacing: .02em; }
@media (max-width: 440px) { #activity .chip, #activity .custom-input { font-size: 14.5px; } }
/* under his face: only when there's something to say ("Thinking…"), never an idle line */
#status:has(#statusText:empty) { display: none; }

/* =================================================================== modern sliders on the home page (Audience) */
/* a slim glowing track in the program's colour, a small luminous handle, quiet step labels */
.studio .dial { gap: 6px; padding: 12px 2px 6px; }
.studio .dial .label-row .value { font-family: var(--display); font-style: italic; font-size: 16px; color: color-mix(in srgb, var(--prog-hi) 85%, #fff); }
.studio .dial input[type='range'] { height: 22px; cursor: pointer; }
.studio .dial input[type='range']::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 80%, transparent), var(--prog) var(--fill, 20%), rgba(255, 255, 255, .07) var(--fill, 20%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05), 0 0 14px color-mix(in srgb, var(--prog) 25%, transparent);
}
.studio .dial input[type='range']::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fff 0 28%, color-mix(in srgb, var(--prog-hi) 70%, #fff) 70%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--prog) 32%, transparent), 0 0 14px color-mix(in srgb, var(--prog-hi) 55%, transparent), 0 2px 6px rgba(0, 0, 0, .5);
  transition: transform .15s ease, box-shadow .2s ease;
}
.studio .dial input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.12); }
.studio .dial input[type='range']:active::-webkit-slider-thumb { transform: scale(1.22); box-shadow: 0 0 0 6px color-mix(in srgb, var(--prog) 30%, transparent), 0 0 20px color-mix(in srgb, var(--prog-hi) 65%, transparent), 0 2px 6px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); }
.studio .dial input[type='range']::-moz-range-progress { height: 6px; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 80%, transparent), var(--prog)); }
.studio .dial input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border: 0; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fff 0 28%, color-mix(in srgb, var(--prog-hi) 70%, #fff) 70%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--prog) 32%, transparent), 0 0 14px color-mix(in srgb, var(--prog-hi) 55%, transparent);
}
.studio .dial .ticks { font-size: 10.5px; letter-spacing: .04em; color: rgba(255, 255, 255, .28); }
.studio .dial .ticks span.on { color: color-mix(in srgb, var(--prog-hi) 85%, #fff); text-shadow: 0 0 10px color-mix(in srgb, var(--prog-hi) 40%, transparent); }
/* game-style: a thick grooved track with notches at each step, and a tall bar of a handle */
.studio .dial input[type='range'] { height: 26px; }
.studio .dial input[type='range']::-webkit-slider-runnable-track {
  height: 14px; border-radius: 7px;
  background:
    linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255, 255, 255, .14) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255, 255, 255, .14) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 85%, transparent), var(--prog) var(--fill, 20%), rgba(0, 0, 0, .28) var(--fill, 20%));
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07), 0 0 14px color-mix(in srgb, var(--prog) 22%, transparent);
}
.studio .dial input[type='range']::-webkit-slider-thumb {
  width: 10px; height: 24px; margin-top: -5px; border-radius: 4px;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--prog-hi) 35%, #e9e4f5));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 0 12px color-mix(in srgb, var(--prog-hi) 60%, transparent), 0 3px 6px rgba(0, 0, 0, .5);
}
.studio .dial input[type='range']:hover::-webkit-slider-thumb { transform: scaleY(1.06); }
.studio .dial input[type='range']:active::-webkit-slider-thumb { transform: scaleY(1.1); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 0 18px color-mix(in srgb, var(--prog-hi) 75%, transparent), 0 3px 6px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']::-moz-range-track { height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .28); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07); }
.studio .dial input[type='range']::-moz-range-progress { height: 14px; border-radius: 7px; background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 85%, transparent), var(--prog)); }
.studio .dial input[type='range']::-moz-range-thumb { width: 10px; height: 24px; border: 0; border-radius: 4px; background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--prog-hi) 35%, #e9e4f5)); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 0 12px color-mix(in srgb, var(--prog-hi) 60%, transparent); }
/* the handle: a round knob just a touch bigger than the 14px groove, tinted rather than white */
.studio .dial input[type='range']::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -1px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, color-mix(in srgb, var(--prog-hi) 70%, #fff) 0 22%, color-mix(in srgb, var(--prog-hi) 75%, var(--prog)) 60%, color-mix(in srgb, var(--prog) 85%, #000) 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 10px color-mix(in srgb, var(--prog-hi) 45%, transparent), 0 2px 5px rgba(0, 0, 0, .5);
}
.studio .dial input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.1); }
.studio .dial input[type='range']:active::-webkit-slider-thumb { transform: scale(1.18); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 16px color-mix(in srgb, var(--prog-hi) 65%, transparent), 0 2px 5px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, color-mix(in srgb, var(--prog-hi) 70%, #fff) 0 22%, color-mix(in srgb, var(--prog-hi) 75%, var(--prog)) 60%, color-mix(in srgb, var(--prog) 85%, #000) 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 0 10px color-mix(in srgb, var(--prog-hi) 45%, transparent);
}

/* Audience: your first question, typed or spoken, right on the home page */
.aud-ask { display: flex; gap: 8px; align-items: center; }
.aud-ask .input { flex: 1; min-width: 0; border-radius: 999px; padding-inline: 18px; }
.aud-ask .icon-btn { flex: none; width: 44px; height: 44px; }
.aud-ask .icon-btn.accent { background: color-mix(in srgb, var(--prog) 40%, transparent); border-color: color-mix(in srgb, var(--prog-hi) 45%, transparent); color: #fff; }
#audMic.listening { background: color-mix(in srgb, var(--prog) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--prog) 30%, transparent); animation: blink 1.2s ease-in-out infinite; }

/* every text box in the Program section: the book serif; placeholders in the italic of "Speak or type…" */
.studio-panel .input, .studio-panel textarea.input {
  font-family: var(--display); font-size: 17.5px; font-weight: 500; letter-spacing: .01em;
  background: rgba(10, 4, 10, .32); border-color: color-mix(in srgb, var(--prog-hi) 16%, transparent);
}
.studio-panel .input::placeholder { font-style: italic; color: color-mix(in srgb, var(--muted) 85%, transparent); }
.studio-panel .input:focus { outline: none; border-color: color-mix(in srgb, var(--prog-hi) 50%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--prog) 18%, transparent); }

/* =================================================================== the options card wears the program's colour too */
.studio-panel {
  background: linear-gradient(160deg, color-mix(in srgb, var(--prog-deep) 26%, rgba(10, 4, 10, .4)), color-mix(in srgb, var(--prog-deep) 12%, rgba(10, 4, 10, .34)));
  border-color: color-mix(in srgb, var(--prog-hi) 18%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--prog-hi) 10%, transparent), inset 0 10px 30px rgba(0, 0, 0, .14);
}
/* and so does everything chosen inside it */
.studio .segmented { border-color: color-mix(in srgb, var(--prog-hi) 14%, transparent); }
.studio .segmented button[aria-pressed='true'] {
  background: linear-gradient(135deg, color-mix(in srgb, var(--prog) 48%, transparent), color-mix(in srgb, var(--prog-deep) 40%, transparent));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--prog) 25%, transparent);
}
.studio .question-chip { border-color: color-mix(in srgb, var(--prog-hi) 14%, transparent); }
.studio .question-chip:hover { border-color: color-mix(in srgb, var(--prog-hi) 35%, transparent); }
.studio .question-chip[aria-pressed='true'] { border-color: color-mix(in srgb, var(--prog-hi) 60%, transparent); background: linear-gradient(135deg, color-mix(in srgb, var(--prog) 45%, transparent), color-mix(in srgb, var(--prog-deep) 38%, transparent)); }
.studio .book.chosen .cover { box-shadow: 0 0 0 2px var(--prog-hi), 0 10px 24px color-mix(in srgb, var(--prog) 45%, transparent); }
.studio .trow { border-color: color-mix(in srgb, var(--prog-hi) 10%, transparent); }
.studio .tbtn:not([aria-pressed='true']) { border-color: color-mix(in srgb, var(--prog-hi) 10%, transparent); }
.studio .drop { border-color: color-mix(in srgb, var(--prog-hi) 30%, transparent); }
.studio .drop svg { color: var(--prog-hi); }

/* text boxes with a mic: the mic sits beside the box */
.mic-field { display: flex; gap: 8px; align-items: center; }
.mic-field .input { flex: 1; min-width: 0; }
.mic-field .icon-btn { flex: none; width: 42px; height: 42px; }
.mic-field .icon-btn svg { width: 17px; height: 17px; }
.mic-field .icon-btn.listening, .aud-ask .icon-btn.listening { color: #fff; background: color-mix(in srgb, var(--prog) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--prog) 30%, transparent); animation: blink 1.2s ease-in-out infinite; }
.studio .mic-field .icon-btn, .aud-ask .icon-btn { background: rgba(10, 4, 10, .32); border-color: color-mix(in srgb, var(--prog-hi) 18%, transparent); color: color-mix(in srgb, var(--prog-hi) 80%, #fff); }

/* home: the time, above the date, in the engraved capitals */
.home-time {
  margin: 0 0 2px; display: flex; align-items: baseline; gap: 8px;
  font-family: var(--caps); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums;
}
.home-time .hm {
  font-size: clamp(40px, 11vw, 52px); letter-spacing: .04em;
  background: linear-gradient(180deg, #f6ecd6 0%, var(--gold) 55%, #b98d45 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(233, 196, 126, .22));
}
.home-time .ampm { font-size: 14px; letter-spacing: .22em; color: color-mix(in srgb, var(--gold) 75%, var(--muted)); }
.home-time { justify-content: center; }

/* =================================================================== gold handles on every slider */
:root { --knob: radial-gradient(circle at 36% 32%, #fff6dc 0 14%, #f1d08c 42%, #c99a4c 78%, #8a6428 100%); }
input[type='range']::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(60, 40, 10, .5), 0 0 10px rgba(233, 196, 126, .35), 0 2px 6px rgba(0, 0, 0, .45); }
input[type='range']::-moz-range-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(60, 40, 10, .5), 0 0 10px rgba(233, 196, 126, .35); }
#length::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(60, 40, 10, .5), 0 0 0 3px color-mix(in srgb, var(--prog) 40%, transparent), 0 0 10px rgba(233, 196, 126, .35), 0 2px 6px rgba(0, 0, 0, .45); }
#length::-moz-range-thumb { background: var(--knob); }
.studio .dial input[type='range']::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(60, 40, 10, .55), 0 0 10px rgba(233, 196, 126, .4), 0 2px 5px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']:active::-webkit-slider-thumb { box-shadow: 0 0 0 1px rgba(60, 40, 10, .55), 0 0 16px rgba(233, 196, 126, .6), 0 2px 5px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']::-moz-range-thumb { background: var(--knob); }
.controls input[type='range']::-webkit-slider-thumb, .speed-pop input::-webkit-slider-thumb { background: var(--knob); }
/* the time now matches the date line: same font and spaced capitals, just larger */
.home-time { gap: 7px; font-family: var(--ui); font-weight: 500; margin-bottom: 4px; }
.home-time .hm { font-size: 22px; letter-spacing: .14em; background: none; color: color-mix(in srgb, var(--text) 82%, var(--muted)); filter: none; -webkit-background-clip: border-box; background-clip: border-box; }
.home-time .ampm { font-size: 11.5px; letter-spacing: .2em; color: var(--muted); }

/* =================================================================== darker handles, and a warm glow where the fill meets the handle */
:root { --knob: radial-gradient(circle at 50% 42%, #3a352e 0 34%, #2a2621 50%, #5c4a2a 72%, #c99a4c 88%, #e9c47e 100%); }
/* the generic sliders (Settings, pop-ups): violet fill that warms to gold just before the handle */
input[type='range']::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, var(--violet) 0, var(--violet) max(0%, calc(var(--fill, 20%) - 14%)), color-mix(in srgb, var(--violet) 55%, #e9c47e) var(--fill, 20%), rgba(196, 181, 253, .15) var(--fill, 20%));
}
/* the home page's program-coloured sliders */
.studio .dial input[type='range']::-webkit-slider-runnable-track {
  background:
    linear-gradient(90deg, transparent calc(33.33% - .5px), rgba(255, 255, 255, .14) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255, 255, 255, .14) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 85%, transparent), var(--prog) max(0%, calc(var(--fill, 20%) - 14%)), color-mix(in srgb, var(--prog) 60%, #e9c47e) var(--fill, 20%), rgba(0, 0, 0, .28) var(--fill, 20%));
}
#length::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, color-mix(in srgb, var(--prog-deep) 50%, transparent), color-mix(in srgb, var(--prog) 50%, transparent) max(0%, calc(var(--fill, 20%) - 14%)), color-mix(in srgb, var(--prog) 45%, rgba(233, 196, 126, .55)) calc(var(--fill, 20%) - 1%), rgba(255, 255, 255, .05) var(--fill, 20%));
}
/* centred on the digits themselves: AM/PM hangs off to the right without pushing them over */
.home-time { position: relative; display: flex; justify-content: center; align-items: center; width: max-content; margin-inline: auto; font-weight: 400; }
.home-time .hm { display: inline-flex; align-items: center; gap: 9px; font-weight: 400; }
.home-time .sep { width: 5px; height: 5px; rotate: 45deg; background: var(--gold); opacity: .75; box-shadow: 0 0 6px rgba(233, 196, 126, .5); flex: none; }
.home-time .ampm { position: absolute; left: 100%; bottom: 3px; margin-left: 8px; }
/* lighter: brushed silver with a fine gold rim */
:root { --knob: radial-gradient(circle at 36% 30%, #f4f3f0 0 12%, #cfccc6 36%, #9b968e 64%, #7a746b 80%, #c99a4c 90%, #e9c47e 100%); }
/* antique bronze, like his mask: a warm highlight, bronze body, a touch of green patina at the edge */
:root { --knob: radial-gradient(circle at 36% 30%, #f1d9a0 0 10%, #c99a55 32%, #946a34 58%, #6a5a32 78%, #4f6040 92%, #3c4a30 100%); }

/* handles: a little of the slider's own colour, a little silver, a little gold. No bright highlight. */
input[type='range'] {
  --knob-tint: var(--violet);
  --knob: radial-gradient(circle at 42% 38%,
    color-mix(in srgb, var(--knob-tint) 35%, #b9b8c2) 0 30%,
    color-mix(in srgb, var(--knob-tint) 45%, #8f8d98) 58%,
    color-mix(in srgb, var(--knob-tint) 40%, #b08a4e) 84%,
    color-mix(in srgb, var(--knob-tint) 25%, #c9a35c) 100%);
}
.studio input[type='range'], #length { --knob-tint: var(--prog); }
input[type='range']::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--knob-tint) 40%, transparent), 0 2px 5px rgba(0, 0, 0, .45); }
input[type='range']::-moz-range-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--knob-tint) 40%, transparent); }
#length::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 0 3px color-mix(in srgb, var(--prog) 35%, transparent), 0 2px 5px rgba(0, 0, 0, .45); }
#length::-moz-range-thumb { background: var(--knob); }
.studio .dial input[type='range']::-webkit-slider-thumb { background: var(--knob); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--knob-tint) 40%, transparent), 0 2px 5px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']:active::-webkit-slider-thumb { box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 14px color-mix(in srgb, var(--knob-tint) 60%, transparent), 0 2px 5px rgba(0, 0, 0, .5); }
.studio .dial input[type='range']::-moz-range-thumb { background: var(--knob); }
.controls input[type='range']::-webkit-slider-thumb, .speed-pop input::-webkit-slider-thumb { background: var(--knob); }

/* =================================================================== one slider style everywhere */
/* thick grooved track with notches at each step, a fill that warms toward the handle, a blended handle.
   Colour: violet by default; the program's colour on the home page; a mood's own colour on its slider. */
.dial, .speed-pop { --tint: var(--violet); --tint-deep: color-mix(in srgb, var(--violet) 55%, #1a0b2e); }
.studio .dial { --tint: var(--prog); --tint-deep: var(--prog-deep); }
.aside-dial { --tint: var(--thought); --tint-deep: color-mix(in srgb, var(--thought) 45%, #10091c); }
.dial.dial input[type='range'], .speed-pop.speed-pop input[type='range'] { --knob-tint: var(--tint); height: 26px; cursor: pointer; }
.dial.dial input[type='range']::-webkit-slider-runnable-track, .speed-pop.speed-pop input[type='range']::-webkit-slider-runnable-track {
  width: auto; height: 14px; border-radius: 7px;
  background:
    var(--notch, linear-gradient(transparent, transparent)),
    linear-gradient(90deg, color-mix(in srgb, var(--tint-deep) 85%, transparent), var(--tint) max(0%, calc(var(--fill, 20%) - 14%)), color-mix(in srgb, var(--tint) 60%, #e9c47e) var(--fill, 20%), rgba(0, 0, 0, .28) var(--fill, 20%));
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07), 0 0 12px color-mix(in srgb, var(--tint) 18%, transparent);
}
.dial.dial input[type='range']::-webkit-slider-thumb, .speed-pop.speed-pop input[type='range']::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -1px; margin-left: 0; border-radius: 50%; background: var(--knob);
  box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--tint) 40%, transparent), 0 2px 5px rgba(0, 0, 0, .45);
  transition: transform .15s ease, box-shadow .2s ease;
}
.dial.dial input[type='range']:hover::-webkit-slider-thumb, .speed-pop.speed-pop input[type='range']:hover::-webkit-slider-thumb { transform: scale(1.1); }
.dial.dial input[type='range']:active::-webkit-slider-thumb, .speed-pop.speed-pop input[type='range']:active::-webkit-slider-thumb { transform: scale(1.18); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 14px color-mix(in srgb, var(--tint) 60%, transparent), 0 2px 5px rgba(0, 0, 0, .5); }
.dial.dial input[type='range']::-moz-range-track, .speed-pop.speed-pop input[type='range']::-moz-range-track { height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .28); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .07); }
.dial.dial input[type='range']::-moz-range-progress, .speed-pop.speed-pop input[type='range']::-moz-range-progress { height: 14px; border-radius: 7px; background: linear-gradient(90deg, color-mix(in srgb, var(--tint-deep) 85%, transparent), var(--tint)); }
.dial.dial input[type='range']::-moz-range-thumb, .speed-pop.speed-pop input[type='range']::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--knob); box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--tint) 40%, transparent); }
/* the step labels and value, as on the home page */
.dial .ticks { letter-spacing: .04em; }
.dial .ticks span.on { color: color-mix(in srgb, var(--tint, var(--lilac)) 70%, #fff); }
.aside-dial .ticks span.on { color: color-mix(in srgb, var(--thought) 80%, #fff); }
#volPop { left: 50%; right: auto; translate: -50% 0; transform-origin: bottom center; }
/* Audience takes sapphire; Discourse becomes forest jade (a yellower green than "You're currently") */
body[data-program='talk'] { --prog: #2563a8; --prog-hi: #93c5fd; --prog-deep: #173a6b; }
body[data-program='discourse'] { --prog: #3b8a3e; --prog-hi: #a7e3a0; --prog-deep: #1d4d22; }

/* phones: the chat button sits on top of his face (they share one slot), freeing a column in the dock */
@media (max-width: 440px) {
  .controls { grid-template-columns: 54px 52px 44px 44px 36px 36px 36px; gap: 5px; }
  .controls .dock-head { grid-column: 1; grid-row: 1; justify-self: end; align-self: start; width: 46px; height: 46px; margin: -10px -2px 0 0; z-index: 0; }
  .controls #askBtn { grid-column: 1; grid-row: 1; justify-self: start; align-self: end; width: 34px; height: 34px; margin: 0 0 -6px -2px; z-index: 2; }
}
@media (max-width: 370px) {
  .controls { grid-template-columns: 50px 50px 42px 42px 34px 34px 34px; gap: 4px; }
}

/* time spent: a small pill hanging off the play button's lower right; it takes no room of its own */
.play .rx-elapsed {
  position: absolute; right: -10px; bottom: -6px; z-index: 3; min-width: 0; padding: 2px 7px; pointer-events: none;
  font-family: var(--ui); font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: var(--lilac); font-variant-numeric: tabular-nums;
  border-radius: 999px; background: rgba(18, 12, 32, .82); border: 1px solid rgba(196, 181, 253, .22);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
#viz { height: 120px; } /* 1.25x taller: the bars scale with it */
/* further right, and just the numbers: no pill behind them */
.play .rx-elapsed { right: -26px; bottom: -4px; padding: 0; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .8), 0 0 8px rgba(0, 0, 0, .6); }
.play .rx-elapsed { right: -21px; }

/* =================================================================== the page's scrollbar: slim and quiet */
html { scrollbar-width: thin; scrollbar-color: rgba(196, 181, 253, .28) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(196, 181, 253, .22); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(196, 181, 253, .45); border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
/* scrollers inside menus keep the same look */
.sheet { scrollbar-width: thin; scrollbar-color: rgba(196, 181, 253, .25) transparent; }

/* jump to where he is now (or to the bottom) */
.jump-btn {
  position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 112px); z-index: 6;
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px 7px 9px; border-radius: 999px; cursor: pointer;
  font-family: var(--ui); font-size: 12px; font-weight: 500; color: var(--lilac);
  background: rgba(24, 16, 42, .55); border: 1px solid rgba(196, 181, 253, .22);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  animation: rise .25s ease; transition: background .2s, border-color .2s;
}
.jump-btn:hover { background: rgba(60, 40, 100, .6); border-color: rgba(196, 181, 253, .45); color: #fff; }
.jump-btn[hidden] { display: none; }
.jump-btn svg { width: 15px; height: 15px; transition: rotate .2s; }
.jump-btn[data-dir='down'] svg { rotate: 90deg; }
.jump-btn[data-dir='up'] svg { rotate: -90deg; }
/* top bar centre: the book or episode, in the chapter bar's gold capitals */
.stage .reactions .rx-title {
  flex: 1; min-width: 0; text-align: center; padding: 0 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--caps); font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  text-shadow: 0 0 14px rgba(233, 196, 126, .22);
}
.stage .reactions #endSession { margin-left: 0; }
@media (max-width: 440px) { .stage .reactions .rx-title { font-size: 11px; letter-spacing: .1em; padding: 0 4px; } }

/* jump button: icon only, round, monochrome glass */
.jump-btn {
  width: 46px; height: 46px; padding: 0; justify-content: center; gap: 0; color: rgba(255, 255, 255, .85);
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 8px 22px rgba(0, 0, 0, .35);
}
.jump-btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); color: #fff; }
.jump-btn svg { width: 20px; height: 20px; stroke-width: 2; }

/* the sideways scrollbar under tangent cards: thicker, frosted glass */
.seg-row.branched::-webkit-scrollbar { height: 12px; }
.seg-row.branched::-webkit-scrollbar-track { background: rgba(255, 255, 255, .04); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); margin: 0 12px; }
.seg-row.branched::-webkit-scrollbar-thumb {
  border-radius: 12px; border: 2px solid transparent; background-clip: padding-box;
  background-color: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.seg-row.branched::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .32); }
@supports not selector(::-webkit-scrollbar) { .seg-row.branched { scrollbar-width: auto; scrollbar-color: rgba(255, 255, 255, .28) rgba(255, 255, 255, .04); } }
.seg-row.branched { padding-bottom: 14px; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; } /* no little arrow buttons at the ends */
.seg-row.branched { scrollbar-color: auto; scrollbar-width: auto; } /* opt out of the page-wide setting, so the glass styling above applies */
.jump-btn[data-dir] svg { rotate: none; } /* each direction has its own icon now */
/* top / back-to-him / bottom, stacked on the right above the dock */
.jump-stack { position: fixed; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 112px); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.jump-stack .jump-btn { position: static; pointer-events: auto; }
.jump-btn.small { width: 36px; height: 36px; }
.jump-btn.small svg { width: 17px; height: 17px; }
/* ⤒ at the top of the screen (its height is set from the sticky bars), ⤓ and ◉ at the bottom */
.jump-stack #jumpTop { position: fixed; right: 14px; }

/* =================================================================== the jump buttons, animated */
.jump-btn {
  transition: right .45s cubic-bezier(.22, .8, .2, 1), transform .45s cubic-bezier(.22, .8, .2, 1), opacity .3s ease,
    background .35s ease, border-color .35s ease, box-shadow .45s ease, color .3s ease;
}
/* page top / bottom: tucked against the screen's edge */
.jump-stack .jump-btn, .jump-stack #jumpTop { right: 6px; }
.jump-stack { right: 0; align-items: flex-end; }
.jump-stack #jumpEnd { position: relative; }
/* back to him: glides inward, with a violet ring, so it reads differently at a glance */
.jump-btn[data-mode='now'] {
  transform: translateX(-12px);
  border-color: rgba(196, 181, 253, .5); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 0 4px rgba(139, 92, 246, .18), 0 0 18px rgba(167, 139, 250, .35), 0 8px 22px rgba(0, 0, 0, .35);
}
/* shown / hidden by fading and shrinking, never popping */
.jump-btn.gone { opacity: 0; transform: scale(.7); pointer-events: none; }
.jump-btn[data-mode='now'].gone { transform: translateX(-12px) scale(.7); }
/* the icon swap: out, change, back in */
.jump-btn.swap svg { animation: jump-swap .3s cubic-bezier(.4, 0, .2, 1); }
@keyframes jump-swap {
  0% { opacity: 1; transform: scale(1); }
  45% { opacity: 0; transform: scale(.45); }
  55% { opacity: 0; transform: scale(.45); }
  100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .jump-btn { transition: opacity .2s; } .jump-btn.swap svg { animation: none; } }
/* back to him = lock on: gold */
.jump-btn[data-mode='now'] {
  color: var(--gold); border-color: rgba(233, 196, 126, .55);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, .14), 0 0 0 4px rgba(233, 196, 126, .14), 0 0 18px rgba(233, 196, 126, .3), 0 8px 22px rgba(0, 0, 0, .35);
}
.jump-btn[data-mode='now']:hover { color: #fbe3b0; border-color: rgba(233, 196, 126, .8); background: rgba(233, 196, 126, .1); }
.jump-btn[data-mode='now'] svg { filter: drop-shadow(0 0 6px rgba(233, 196, 126, .45)); }
.jump-stack #jumpEnd { bottom: auto; top: auto; } /* drop the old 112px offset: it sits at the stack's foot, just above the dock */

/* =================================================================== Settings: the Sharmat's chambers */
/* a darker, richer room: obsidian with a warm glow from above and a fine gold-tinted edge */
#settingsSheet {
  background:
    radial-gradient(120% 40% at 50% 0%, rgba(233, 196, 126, .07), transparent 70%),
    linear-gradient(180deg, rgba(22, 15, 30, .97), rgba(10, 7, 14, .985));
  border-color: rgba(233, 196, 126, .2);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(233, 196, 126, .12);
}
#settingsSheet .sheet-head { text-align: center; padding-inline: 48px; }
#settingsSheet .sheet-head h3 {
  font-family: var(--caps); font-weight: 600; font-size: 21px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  text-shadow: 0 0 22px rgba(233, 196, 126, .25); margin-top: 6px;
}
#settingsSheet .sheet-head .fine { font-family: var(--display); font-style: italic; font-size: 15px; }
@media (max-width: 440px) { #settingsSheet .sheet-head h3 { font-size: 17px; letter-spacing: .1em; } #settingsSheet .sheet-head { padding-inline: 40px; } }

/* each section, its own colour */
#setPersonality { --sec: #f472b6; }
#setBrain { --sec: #60a5fa; }
#setUI { --sec: #34d399; }
#setData { --sec: #f59e0b; }
#setHelp { --sec: #a78bfa; }
#setCredits { --sec: #e9c47e; }
#settingsSheet > .set { border-color: color-mix(in srgb, var(--sec) 16%, transparent); background: color-mix(in srgb, var(--sec) 3%, rgba(255, 255, 255, .015)); }
#settingsSheet > .set > summary svg { color: var(--sec); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--sec) 45%, transparent)); }
#settingsSheet > .set:not([open]) > summary:hover { color: color-mix(in srgb, var(--sec) 50%, #fff); }
#settingsSheet > .set[open] {
  border-color: color-mix(in srgb, var(--sec) 42%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--sec) 9%, transparent), color-mix(in srgb, var(--sec) 3%, transparent) 220px);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--sec) 10%, transparent);
}
#settingsSheet > .set[open]::before { background: var(--sec); box-shadow: 0 0 12px var(--sec); }
#settingsSheet > .set[open] > summary svg { color: var(--sec); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--sec) 70%, transparent)); }

/* the chevron always follows the section's name; extras (status badges, summaries) go to the far right */
.set > summary::after { order: 1; }
.set > summary > small, .set > summary > .stack-status { order: 2; margin-left: auto; }

/* looping icons, each in character */
#setPersonality > summary svg { animation: icon-beat 2.4s ease-in-out infinite; }
#setBrain > summary svg { animation: icon-twinkle 3.2s ease-in-out infinite; }
#setUI > summary svg { animation: icon-blink 4.5s ease-in-out infinite; transform-origin: 50% 50%; }
#setData > summary svg { animation: icon-sway 3.6s ease-in-out infinite; transform-origin: 50% 15%; }
#setHelp > summary svg { animation: icon-bob 2.8s ease-in-out infinite; }
#setCredits > summary svg { animation: icon-turn 12s linear infinite; }
@keyframes icon-beat { 0%, 60%, 100% { transform: scale(1); } 10% { transform: scale(1.18); } 20% { transform: scale(1); } 30% { transform: scale(1.12); } }
@keyframes icon-twinkle { 0%, 100% { transform: rotate(0) scale(1); opacity: 1; } 50% { transform: rotate(18deg) scale(1.12); opacity: .75; } }
@keyframes icon-blink { 0%, 44%, 52%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes icon-sway { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes icon-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes icon-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #settingsSheet > .set > summary svg { animation: none; } }
/* section names stay on one line (badges wrap instead); nested sections take their parent's colour */
#settingsSheet .set > summary { white-space: nowrap; }
#settingsSheet .set > summary > .stack-status, #settingsSheet .set > summary > small { white-space: normal; min-width: 0; }
#settingsSheet .set .set[open] { border-color: color-mix(in srgb, var(--sec) 32%, transparent); background: color-mix(in srgb, var(--sec) 5%, transparent); box-shadow: none; }
#settingsSheet .set .set[open]::before { background: var(--sec); box-shadow: 0 0 8px var(--sec); }
#settingsSheet .set .set > summary svg { color: color-mix(in srgb, var(--sec) 70%, #fff); }

/* Voice API: proxy and model side by side; earlier voices as small chips */
.field-pair { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.field-pair .input { min-width: 0; width: 100%; text-overflow: ellipsis; }
#voiceSearch { margin-top: 8px; }
.voice-recent { display: flex; align-items: center; gap: 8px; min-width: 0; }
.voice-recent > .fine { flex: none; margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.voice-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; padding: 2px 0; }
.voice-chips::-webkit-scrollbar { display: none; }
.voice-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 150px; padding: 3px 10px 3px 3px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  opacity: .75; transition: opacity .2s, border-color .2s, color .2s;
}
.voice-chip:hover, .voice-chip:focus-visible { opacity: 1; color: var(--text); border-color: color-mix(in srgb, var(--sec, #a78bfa) 50%, transparent); }
.voice-chip img, .voice-chip .ph { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: #241a3a; flex: none; }
.voice-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#settingsSheet .voice.selected { border-color: color-mix(in srgb, var(--sec) 55%, transparent); background: color-mix(in srgb, var(--sec) 12%, transparent); }

/* Vibes: a sunset down the list, rose through coral to amber, instead of the usual violet */
#setVibes .dial { --tint: #e0607e; --tint-deep: color-mix(in srgb, var(--tint) 45%, #1a0910); }
#setVibes .dial:nth-of-type(2) { --tint: #e66a6f; }
#setVibes .dial:nth-of-type(3) { --tint: #eb7562; }
#setVibes .dial:nth-of-type(4) { --tint: #ee8158; }
#setVibes .dial:nth-of-type(5) { --tint: #ee8e4f; }
#setVibes .dial:nth-of-type(6) { --tint: #ec9b48; }
#setVibes .dial:nth-of-type(7) { --tint: #e8a844; }
#setVibes .dial:nth-of-type(n+8) { --tint: #e3b443; }
#setVibes .dial .label-row .value { color: color-mix(in srgb, var(--tint) 75%, #fff); }
#setPersonality > #setVibes > summary .sub-title { background: linear-gradient(100deg, #f49ab0, #f59a7a 55%, #f2c46d); -webkit-background-clip: text; background-clip: text; color: transparent; }
#setPersonality > #setVibes > summary svg { color: #f08a8a; }
#setPersonality > #setVibes[open]::before { background: linear-gradient(#e0607e, #e8a844); box-shadow: 0 0 10px rgba(232, 120, 100, .6); }

/* =================================================================== Toggles, game style like the sliders */
/* a grooved track that fills with the section's colour (warming toward gold), and a metal knob tinted to match */
.toggle { --tog: var(--sec, var(--violet)); align-items: center; }
.toggle input {
  width: 46px; height: 26px; margin: 0; border-radius: 13px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .38), rgba(0, 0, 0, .22));
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .07);
  transition: background .3s, box-shadow .3s;
}
.toggle input::after {
  top: 4px; left: 4px; width: 18px; height: 18px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .55), transparent 45%),
    conic-gradient(from 210deg,
      color-mix(in srgb, var(--tog) 20%, #a9a8b2) 0 30%,
      color-mix(in srgb, var(--tog) 25%, #7d7b86) 58%,
      color-mix(in srgb, var(--tog) 20%, #9c7b45) 84%,
      color-mix(in srgb, var(--tog) 20%, #a9a8b2) 100%);
  box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 2px 4px rgba(0, 0, 0, .5);
  transition: translate .28s cubic-bezier(.3, 1.4, .5, 1), background .3s, box-shadow .3s;
}
.toggle input:checked {
  background: linear-gradient(90deg, color-mix(in srgb, var(--tog) 45%, #12091a), var(--tog) 70%, color-mix(in srgb, var(--tog) 65%, #e9c47e));
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .1), 0 0 12px color-mix(in srgb, var(--tog) 35%, transparent);
}
.toggle input:checked::after {
  translate: 20px 0;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .7), transparent 45%),
    conic-gradient(from 210deg,
      color-mix(in srgb, var(--tog) 30%, #d6d4de) 0 30%,
      color-mix(in srgb, var(--tog) 35%, #a3a1ac) 58%,
      color-mix(in srgb, var(--tog) 25%, #c9a35c) 84%,
      color-mix(in srgb, var(--tog) 30%, #d6d4de) 100%);
  box-shadow: 0 0 0 1px rgba(20, 12, 30, .55), 0 0 8px color-mix(in srgb, var(--tog) 55%, transparent), 0 2px 4px rgba(0, 0, 0, .45);
}
.toggle input:active::after { width: 22px; }
.toggle input:checked:active::after { translate: 16px 0; }
.toggle input:focus-visible { outline: 2px solid color-mix(in srgb, var(--tog) 70%, #fff); outline-offset: 2px; }
.toggle b { font-weight: 500; transition: color .3s; }
.toggle:has(input:checked) b { color: color-mix(in srgb, var(--tog) 30%, #fff); }
/* in the subsections, a shade of their own: News sources sky, Avatar & Atmosphere ember */
#setNews { --sec: #38bdf8; }
#setFace { --sec: #fb923c; }
@media (prefers-reduced-motion: reduce) { .toggle input::after { transition: none; } }
/* settings choice buttons wear their section's colour too */
#settingsSheet .segmented button[aria-pressed='true'] {
  background: linear-gradient(135deg, color-mix(in srgb, var(--sec) 48%, transparent), color-mix(in srgb, var(--sec) 26%, transparent));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--sec) 22%, transparent), inset 0 1px 0 rgba(255, 255, 255, .1);
}
.voice .icon-btn.playing { color: #fff; border-color: color-mix(in srgb, var(--sec, var(--violet)) 60%, transparent); background: color-mix(in srgb, var(--sec, var(--violet)) 22%, transparent); box-shadow: 0 0 10px color-mix(in srgb, var(--sec, var(--violet)) 35%, transparent); }

/* News sources: the three source switches on the left, the RSS list standing tall beside them */
.news-sources { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: 14px; align-items: stretch; }
.news-toggles { display: flex; flex-direction: column; gap: 12px; justify-content: space-between; }
.rss-field { min-height: 0; }
.rss-field > span small { display: block; font-size: 11px; color: var(--faint); }
.rss-field textarea { flex: 1; min-height: 150px; resize: none; font-size: 12px; line-height: 1.6; padding: 10px 12px; overflow: auto; white-space: pre; }
@media (max-width: 340px) { .news-sources { grid-template-columns: 1fr; } }
.news-sources { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.news-toggles .toggle { gap: 10px; }
.news-toggles .toggle span { min-width: 0; overflow-wrap: anywhere; }
.news-toggles .toggle b { font-size: 13.5px; line-height: 1.25; }
.news-toggles .toggle small { font-size: 11.5px; line-height: 1.35; }
.news-toggles .toggle input { width: 40px; height: 23px; }
.news-toggles .toggle input::after { width: 15px; height: 15px; }
.news-toggles .toggle input:checked::after { translate: 17px 0; }
.news-toggles .toggle input:checked:active::after { translate: 13px 0; }
.news-toggles .toggle input:active::after { width: 19px; }
/* on a phone the descriptions crowd the column; the names say enough */
@media (max-width: 520px) { .news-toggles .toggle small { display: none; } .news-toggles { justify-content: space-around; } .rss-field textarea { min-height: 130px; } }
/* the switches set the height; the RSS box stretches to fill it rather than pushing them apart */
.news-sources { grid-template-rows: minmax(0, auto); }
.rss-field { position: relative; }
.rss-field textarea { min-height: 96px; height: 100%; }
.news-toggles { justify-content: center; gap: 14px; }
@media (max-width: 520px) { .news-toggles { gap: 16px; justify-content: center; } .rss-field textarea { min-height: 96px; } }

/* UI/UX: the smoke slider with its freeze switch beside it */
.smoke-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.smoke-row .toggle { max-width: 150px; }
.smoke-row .toggle b { font-size: 13.5px; line-height: 1.25; }
.smoke-row .toggle small { font-size: 11.5px; }
#setUI .dial { --tint: var(--sec); --tint-deep: color-mix(in srgb, var(--sec) 45%, #08140f); }
@media (max-width: 400px) { .smoke-row { gap: 10px; } .smoke-row .toggle { max-width: 118px; } }
.smoke-row .toggle { flex-direction: column; align-items: center; gap: 6px; text-align: center; max-width: 120px; }
.smoke-row .toggle span { align-items: center; }
#setUI .dial .label-row .value { color: color-mix(in srgb, var(--sec) 70%, #fff); }
@media (max-width: 400px) { .smoke-row .toggle { max-width: 96px; } }

/* options that explain themselves: the hint floats above the whole row (hover on desktop, a moment after a tap on phones) */
.segmented.hinted { position: relative; overflow: visible; }
.segmented.hinted button { position: static; }
.segmented.hinted button::after {
  content: attr(data-hint); position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 3;
  padding: 9px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; text-align: left; color: var(--text); font-weight: 400;
  background: rgba(14, 10, 22, .96); border: 1px solid color-mix(in srgb, var(--sec, var(--violet)) 35%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); backdrop-filter: blur(10px);
  opacity: 0; translate: 0 4px; pointer-events: none; transition: opacity .18s, translate .18s;
}
@media (hover: hover) { .segmented.hinted button:hover::after { opacity: 1; translate: 0 0; transition-delay: .35s; } }
.segmented.hinted button.hint-show::after { opacity: 1; translate: 0 0; }
#setUI .segmented button { font-size: 13px; padding: 0 4px; line-height: 1.15; }

/* negative: the canvas sits just behind the dock (outside its layer) and inverts what's there */
#viz.negative { position: fixed; z-index: 4; opacity: .9; mix-blend-mode: difference; }
.dock[hidden] + #viz { display: none; }

/* UI/UX: section headings (Display, Audio visualizer) above their own labelled rows */
.set-heading {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 2px; font-family: var(--caps); font-size: 12px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: color-mix(in srgb, var(--sec, var(--gold)) 70%, #fff);
}
.set-heading::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, color-mix(in srgb, var(--sec, var(--gold)) 40%, transparent), transparent); }
#setUI > summary + .set-heading { margin-top: 6px; }
#setUI .label { font-size: 12px; color: var(--muted); }
/* style on the left, density on the right */
.viz-shape { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 16px; align-items: end; }
.viz-shape > div:first-child { display: flex; flex-direction: column; gap: 7px; }
.viz-shape .dial { padding-top: 0; }
.viz-shape { margin-top: 12px; }
@media (max-width: 480px) { .viz-shape { grid-template-columns: minmax(0, 1fr); gap: 12px; } .viz-shape .segmented { max-width: 220px; } }

/* =================================================================== The archive (history), dressed like the Sharmat's chambers */
#historySheet {
  background:
    radial-gradient(120% 40% at 50% 0%, rgba(233, 196, 126, .07), transparent 70%),
    linear-gradient(180deg, rgba(22, 15, 30, .97), rgba(10, 7, 14, .985));
  border-color: rgba(233, 196, 126, .2);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(233, 196, 126, .12);
}
#historySheet .sheet-head { text-align: center; padding-inline: 48px; }
#historySheet .sheet-emblem {
  display: block; width: 30px; height: 30px; margin: 2px auto 4px; color: var(--gold); fill: none; stroke: currentColor; stroke-width: 1.5;
  filter: drop-shadow(0 0 10px rgba(233, 196, 126, .45)); animation: emblem-float 4.5s ease-in-out infinite;
}
@keyframes emblem-float { 0%, 100% { translate: 0 0; rotate: -3deg; } 50% { translate: 0 -3px; rotate: 3deg; } }
#historySheet .sheet-head h3 {
  font-family: var(--caps); font-weight: 600; font-size: 21px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold);
  text-shadow: 0 0 22px rgba(233, 196, 126, .25); margin-top: 0;
}
#historySheet .sheet-head .fine { font-family: var(--display); font-style: italic; font-size: 15px; }
@media (max-width: 440px) { #historySheet .sheet-head h3 { font-size: 18px; } #historySheet .sheet-head { padding-inline: 40px; } }

/* group headings: gold caps, a count, and a fading rule */
.history .archive-group { display: flex; flex-direction: row; justify-content: flex-start; text-align: left; border: 0; background: none; animation: none; border-radius: 0; text-transform: uppercase; align-items: center; gap: 10px; padding: 14px 2px 2px; color: var(--gold); font-family: var(--caps); font-size: 12px; font-weight: 600; letter-spacing: .18em; }
.history .archive-group::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(233, 196, 126, .35), transparent); order: 3; }
.history .archive-group i { order: 2; font-style: normal; font-family: var(--sans, inherit); font-size: 11px; letter-spacing: 0; padding: 1px 7px; border-radius: 999px; background: rgba(233, 196, 126, .12); color: color-mix(in srgb, var(--gold) 80%, #fff); }
.history .archive-group:first-child { padding-top: 2px; }

/* each session wears its program's colour: an icon, a soft wash, and an accent on the left */
.history li.entry {
  position: relative; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 12px 12px 12px 14px; overflow: hidden;
  border-color: color-mix(in srgb, var(--pc) 16%, transparent);
  background: linear-gradient(100deg, color-mix(in srgb, var(--pc) 7%, transparent), rgba(255, 255, 255, .015) 55%);
  transition: border-color .2s, background .2s, transform .2s;
}
.history li.entry::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pc); opacity: .55; transition: opacity .2s, box-shadow .2s; }
.history li.entry:hover { border-color: color-mix(in srgb, var(--pc) 38%, transparent); background: linear-gradient(100deg, color-mix(in srgb, var(--pc) 12%, transparent), rgba(255, 255, 255, .02) 60%); }
.history li.entry:hover::before { opacity: 1; box-shadow: 0 0 10px var(--pc); }
.history .glyph { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--pc); background: color-mix(in srgb, var(--pc) 12%, rgba(0, 0, 0, .25)); border: 1px solid color-mix(in srgb, var(--pc) 22%, transparent); }
.history .glyph svg { width: 20px; height: 20px; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--pc) 45%, transparent)); }
.history .entry-info { min-width: 0; }
.history .entry-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .entry-info small { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; }
.history .prog { color: var(--pc); font-weight: 600; letter-spacing: .02em; }
/* saved: a gold edge and a filled gold bookmark */
.history li.entry.saved { border-color: rgba(233, 196, 126, .3); box-shadow: inset 0 0 0 1px rgba(233, 196, 126, .06), 0 6px 22px rgba(0, 0, 0, .25); }
.history .mark[aria-pressed='true'] { color: var(--gold); border-color: rgba(233, 196, 126, .45); background: rgba(233, 196, 126, .1); }
/* replay: the one action that matters most, a glowing disc in the program's colour */
.history .icon-btn.replay { color: #fff; border-color: transparent; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--pc) 75%, #fff), color-mix(in srgb, var(--pc) 70%, #000) 90%); box-shadow: 0 0 14px color-mix(in srgb, var(--pc) 40%, transparent); }
.history .icon-btn.replay svg { fill: currentColor; translate: 1px 0; }
.history .icon-btn.replay:hover { transform: scale(1.06); box-shadow: 0 0 20px color-mix(in srgb, var(--pc) 60%, transparent); }
.history .row-actions .icon-btn:not(.replay) { background: rgba(255, 255, 255, .03); }
@media (max-width: 440px) {
  .history li.entry { grid-template-columns: auto minmax(0, 1fr); padding: 12px; }
  .history .glyph { width: 36px; height: 36px; }
  .history .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) { #historySheet .sheet-emblem { animation: none; } }
@media (max-width: 440px) { .history li.entry .row-actions { grid-column: 2; justify-content: flex-start; margin-top: -2px; } }

/* archive: frosted glass rather than a solid panel */
#historySheet {
  background:
    radial-gradient(120% 40% at 50% 0%, rgba(233, 196, 126, .08), transparent 70%),
    linear-gradient(180deg, rgba(26, 18, 36, .4), rgba(12, 8, 18, .48));
  backdrop-filter: blur(26px) saturate(1.3); -webkit-backdrop-filter: blur(26px) saturate(1.3);
  border-color: rgba(233, 196, 126, .22);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px rgba(255, 255, 255, .02);
}
#historySheet .history li.entry { background: linear-gradient(100deg, color-mix(in srgb, var(--pc) 8%, rgba(255, 255, 255, .03)), rgba(255, 255, 255, .025) 55%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
/* replay: quiet, just tinted with the program's colour */
.history .icon-btn.replay {
  color: color-mix(in srgb, var(--pc) 85%, #fff); border-color: color-mix(in srgb, var(--pc) 30%, transparent);
  background: color-mix(in srgb, var(--pc) 12%, rgba(255, 255, 255, .02)); box-shadow: none;
}
.history .icon-btn.replay:hover { transform: none; background: color-mix(in srgb, var(--pc) 20%, rgba(255, 255, 255, .03)); border-color: color-mix(in srgb, var(--pc) 50%, transparent); box-shadow: 0 0 10px color-mix(in srgb, var(--pc) 20%, transparent); }

/* visualizer style: a two-column grid of the shape's controls (style choice, then sliders) */
.viz-style { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 18px; align-items: end; margin-bottom: 10px; }
.viz-style[hidden] { display: none; }
.viz-style .viz-kind { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 7px; }
.viz-style .viz-kind .segmented { max-width: 260px; }
.viz-style .dial { padding-top: 6px; }
@media (max-width: 480px) { .viz-style { grid-template-columns: minmax(0, 1fr); } }
/* the reset sits at the end of the heading's rule */
.set-heading .ghost-pill { order: 1; font-family: var(--sans, inherit); font-size: 11px; font-weight: 500; letter-spacing: .02em; text-transform: none; padding: 3px 10px; color: var(--muted); }
.set-heading .ghost-pill:hover { color: color-mix(in srgb, var(--sec, var(--gold)) 70%, #fff); border-color: color-mix(in srgb, var(--sec, var(--gold)) 45%, transparent); }
#settingsSheet .set-heading .ghost-pill { font-family: Inter, system-ui, sans-serif; font-style: normal; text-transform: none; letter-spacing: .02em; font-size: 11.5px; }
#settingsSheet .set-heading .ghost-pill { background: rgba(255, 255, 255, .03); border-color: color-mix(in srgb, var(--sec) 28%, transparent); color: color-mix(in srgb, var(--sec) 55%, var(--muted)); }
#settingsSheet .set-heading .ghost-pill:hover { background: color-mix(in srgb, var(--sec) 12%, transparent); border-color: color-mix(in srgb, var(--sec) 50%, transparent); color: color-mix(in srgb, var(--sec) 70%, #fff); }

/* =================================================================== Side chat ("A word aside") */
/* frosted glass in the session's colour; a docked panel on the left on wide screens, an overlay on phones */
.side-chat {
  position: fixed; z-index: 21; display: flex; flex-direction: column; min-height: 0;
  background:
    radial-gradient(140% 30% at 0% 0%, color-mix(in srgb, var(--prog, #8b5cf6) 16%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(24, 16, 34, .5), rgba(10, 7, 16, .62));
  backdrop-filter: blur(26px) saturate(1.3); -webkit-backdrop-filter: blur(26px) saturate(1.3);
  animation: side-in .32s cubic-bezier(.2, .8, .2, 1);
}
.side-chat[hidden] { display: none; }
@keyframes side-in { from { opacity: 0; translate: 0 14px; } }
.side-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 16px; border-bottom: 1px solid rgba(233, 196, 126, .12); }
.side-emblem { width: 22px; height: 22px; flex: none; color: var(--gold); fill: none; stroke: currentColor; stroke-width: 1.6; filter: drop-shadow(0 0 8px rgba(233, 196, 126, .4)); }
.side-title { flex: 1; min-width: 0; }
.side-title h3 { margin: 0; font-family: var(--caps); font-size: 15px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.side-title p { margin: 1px 0 0; font-family: var(--display); font-style: italic; font-size: 13.5px; color: var(--faint); }
.side-head .icon-btn { width: 36px; height: 36px; flex: none; background: rgba(255, 255, 255, .03); }
#sideVoice[aria-pressed='true'] { color: var(--gold); border-color: rgba(233, 196, 126, .4); background: rgba(233, 196, 126, .08); }
#sideVoice[aria-pressed='false'] { opacity: .55; }

.side-log { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; scrollbar-width: thin; }
.side-log .msg { position: relative; max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; animation: rise .3s cubic-bezier(.2, .8, .2, 1); }
.side-log .msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.side-log .msg.you { align-self: flex-end; border-bottom-right-radius: 5px; color: var(--text); background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .08); }
/* his words: the display serif, a glass card edged in the session's colour */
.side-log .msg.him {
  align-self: flex-start; border-bottom-left-radius: 5px; padding-right: 46px;
  font-family: var(--display); font-size: 17px; line-height: 1.45; color: #f3ead9;
  background: linear-gradient(120deg, color-mix(in srgb, var(--prog, #8b5cf6) 14%, rgba(255, 255, 255, .03)), rgba(255, 255, 255, .03));
  border: 1px solid color-mix(in srgb, var(--prog-hi, #c4b5fd) 22%, transparent);
}
.side-log .msg.him.speaking { border-color: color-mix(in srgb, var(--prog-hi, #c4b5fd) 55%, transparent); box-shadow: 0 0 18px color-mix(in srgb, var(--prog, #8b5cf6) 30%, transparent); }
.side-log .msg.failed { font-family: inherit; font-size: 13px; color: #fca5a5; border-color: rgba(252, 165, 165, .3); background: rgba(252, 165, 165, .06); padding-right: 14px; }
.msg-play {
  position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  color: color-mix(in srgb, var(--prog-hi, #c4b5fd) 85%, #fff); background: color-mix(in srgb, var(--prog, #8b5cf6) 18%, transparent); border: 1px solid color-mix(in srgb, var(--prog-hi, #c4b5fd) 25%, transparent);
}
.msg-play svg { width: 13px; height: 13px; fill: currentColor; }
.msg-play .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
/* thinking: three soft dots */
.side-log .msg.pending { padding: 14px 18px; }
.side-log .msg .dots { display: inline-flex; gap: 5px; }
.side-log .msg .dots::before, .side-log .msg .dots::after, .side-log .msg .dots { --d: currentColor; }
.side-log .msg.pending .dots { width: 34px; height: 8px; background: radial-gradient(circle, var(--gold) 3px, transparent 3.5px) 0 50% / 12px 8px repeat-x; animation: side-think 1.2s ease-in-out infinite; opacity: .8; }
@keyframes side-think { 50% { opacity: .3; } }
.side-empty { margin: auto 0; text-align: center; padding: 10px 6px; }
.side-empty p { margin: 0 auto 14px; max-width: 280px; font-family: var(--display); font-style: italic; font-size: 16px; line-height: 1.45; color: var(--muted); }
.side-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.side-chip { padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text); background: rgba(255, 255, 255, .04); border: 1px solid color-mix(in srgb, var(--prog-hi, #c4b5fd) 22%, transparent); transition: background .2s, border-color .2s; }
.side-chip:hover { background: color-mix(in srgb, var(--prog, #8b5cf6) 16%, transparent); border-color: color-mix(in srgb, var(--prog-hi, #c4b5fd) 45%, transparent); }

.side-ask { display: flex; gap: 8px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid rgba(255, 255, 255, .06); }
.side-ask input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--prog-hi, #c4b5fd) 28%, transparent); background: rgba(10, 7, 18, .55); color: var(--text); font-size: 16px; }
.side-ask input:focus { outline: none; border-color: color-mix(in srgb, var(--prog-hi, #c4b5fd) 60%, transparent); }
.side-ask .icon-btn { width: 46px; height: 46px; flex: none; }
#askBtn.on { color: var(--gold); border-color: rgba(233, 196, 126, .45); background: rgba(233, 196, 126, .1); }

/* phones and narrow windows: the whole screen, like a menu */
@media (max-width: 979px) {
  .side-chat { inset: 0; padding-top: env(safe-area-inset-top); }
}
/* wide screens: docked on the left, and the session moves over to make room */
@media (min-width: 980px) {
  .side-chat { left: 0; top: 0; bottom: 0; width: 360px; z-index: 6; border-right: 1px solid rgba(233, 196, 126, .16); box-shadow: 20px 0 60px rgba(0, 0, 0, .35); animation-name: side-dock; }
  @keyframes side-dock { from { opacity: 0; translate: -24px 0; } }
  body.side-open .app { margin-left: calc(360px + max(16px, (100vw - 360px - 580px) / 2)); }
  body.side-open .dock, body.side-open #viz.negative { left: 360px; }
  .app, .dock { transition: margin-left .32s cubic-bezier(.2, .8, .2, 1), left .32s cubic-bezier(.2, .8, .2, 1); }
}
@media (prefers-reduced-motion: reduce) { .side-chat { animation: none; } }
