:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ebe7de;
  --ink: #171614;
  --ink-2: #6e695f;
  --ink-3: #a8a296;
  --ink-faint: #c9c3b6;
  --line: #e2ddd2;
  --accent: #d24a2b;
  --accent-ink: #ffffff;
  --ok: #2c8a55;
  --warn: #c98a12;
  --err: #c93a2b;
  --scrim: rgba(20, 18, 15, 0.38);
  --glass: rgba(255, 253, 248, 0.78);
  --shadow: 0 10px 40px rgba(40, 32, 20, 0.14), 0 2px 8px rgba(40, 32, 20, 0.06);

  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --dock-h: 56px;
  --dock-space: calc(var(--dock-h) + 20px + var(--safe-b));
  --gutter: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d0c;
    --surface: #1a1917;
    --surface-2: #262421;
    --ink: #f3efe7;
    --ink-2: #a7a197;
    --ink-3: #6f6a61;
    --ink-faint: #45413b;
    --line: #2b2926;
    --accent: #ff6b4a;
    --accent-ink: #1a0b06;
    --ok: #4cc883;
    --warn: #e9b03d;
    --err: #ff6b5b;
    --scrim: rgba(0, 0, 0, 0.55);
    --glass: rgba(30, 28, 26, 0.72);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }
button {
  margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
svg { width: 24px; height: 24px; flex: none; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
input:focus-visible, textarea:focus-visible { outline: none; }

.app { position: fixed; inset: 0; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 22px;
  display: grid; place-items: center; color: var(--ink-2);
  transition: background-color .2s, transform .15s var(--ease);
}
.icon-btn:active { background: var(--surface-2); transform: scale(.92); }

/* ---------- Gate ---------- */
.gate {
  position: absolute; inset: 0; display: grid; place-items: center;
  grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--safe-t) + 24px) var(--gutter) calc(var(--safe-b) + 24px);
}
.gate-inner { width: 100%; max-width: 420px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.wordmark { margin: 0; font-family: var(--serif); font-size: 52px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.gate-form {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border-radius: 22px; padding: 6px 6px 6px 20px;
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: box-shadow .2s;
}
.gate-form:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.gate-input { flex: 1; min-width: 0; border: 0; background: none; font-size: 22px; padding: 10px 0; }
.gate-go {
  width: 52px; height: 52px; border-radius: 17px; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; transition: transform .15s var(--ease);
}
.gate-go:active { transform: scale(.92); }
.gate-msg { margin: 0; font-size: 17px; color: var(--ink-2); min-height: 1.5em; }
.gate-msg[data-kind="error"] { color: var(--err); }

/* ---------- Pager ---------- */
.pager {
  position: absolute; inset: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pager::-webkit-scrollbar { display: none; }
.pane {
  position: relative;
  flex: 0 0 100%; width: 100%; height: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  overflow: hidden;
}
.pane-scroll {
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior-y: contain;
  padding: calc(var(--safe-t) + 18px) var(--gutter) calc(var(--dock-space) + 28px);
  scrollbar-width: none;
}
.pane-scroll::-webkit-scrollbar { display: none; }
.pane-scroll > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; margin-bottom: 18px;
}
.pane-title { margin: 0; font-size: 36px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }

/* ---------- Dock ---------- */
.dock {
  position: fixed; z-index: 20;
  left: 50%; bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(4, 60px);
  height: var(--dock-h); padding: 4px;
  border-radius: 30px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: var(--shadow), inset 0 0 0 .5px var(--line);
}
.dock-lens {
  position: absolute; top: 4px; left: 4px;
  width: 60px; height: calc(100% - 8px);
  border-radius: 26px; background: var(--ink);
  transform: translateX(calc(var(--lens, 0) * 60px));
  will-change: transform;
}
.dock-btn {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: color .25s;
}
.dock-btn[aria-current="page"] { color: var(--bg); }
.dock-btn:active svg { transform: scale(.86); }
.dock-btn svg { transition: transform .15s var(--ease); }
.dock-badge {
  position: absolute; top: 10px; right: 14px;
  width: 8px; height: 8px; border-radius: 4px; background: var(--accent);
  box-shadow: 0 0 0 2px var(--glass);
  animation: pulse 1.6s ease-in-out infinite;
}
.dock-badge.warn { background: var(--warn); animation: none; }
.app[data-playing="true"] .dock-wave { animation: wave 1.1s ease-in-out infinite; transform-origin: center; }
@keyframes wave { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.62); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 60;
  top: calc(var(--safe-t) + 10px); left: 50%;
  transform: translate(-50%, -140%);
  display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 20px; min-height: 52px;
  border-radius: 26px;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 17px; font-weight: 600;
  transition: transform .45s var(--spring);
}
.toast.show { transform: translate(-50%, 0); }
.toast-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
.toast-action {
  flex: none; height: 38px; padding: 0 16px; border-radius: 19px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
}

/* ---------- Empty hero ---------- */
.empty-hero {
  display: grid; justify-items: center; gap: 18px;
  width: 100%; padding: 12vh 0;
  color: var(--ink-3);
}
.empty-icon {
  width: 96px; height: 96px; border-radius: 48px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  transition: transform .2s var(--ease);
}
.empty-icon svg { width: 40px; height: 40px; }
.empty-hero:active .empty-icon { transform: scale(.92); }
.empty-text { font-size: 24px; font-weight: 700; color: var(--ink-2); }

/* ---------- Library ---------- */
.episodes { list-style: none; margin: 0 auto; padding: 0; }
.ep {
  position: relative;
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--line);
  animation: rise .4s var(--ease) both;
}
.ep:last-child { border-bottom: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.ep-main {
  flex: 1; min-width: 0;
  display: grid; gap: 6px;
  padding: 18px 0; text-align: left;
  transition: opacity .15s;
}
.ep-main:active { opacity: .55; }
.ep-title {
  font-size: 20px; font-weight: 700; line-height: 1.35; letter-spacing: -0.005em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ep-meta { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ep-meta .now { color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.ep-meta .now svg { width: 16px; height: 16px; }
.ep-error { font-size: 16px; color: var(--err); line-height: 1.4; }
.ep-bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.ep-bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--ink-2); border-radius: 2px; }
.ep[data-current="true"] .ep-bar i { background: var(--accent); }
.ep[data-current="true"]::before {
  content: ""; position: absolute; left: calc(-1 * var(--gutter) + 6px); top: 22px;
  width: 4px; height: 24px; border-radius: 2px; background: var(--accent);
}
.ep-side { flex: none; display: grid; place-items: center; width: 56px; margin-right: -8px; color: var(--ink-3); }
.ep-side:active { color: var(--ink); }
.ring { width: 44px; height: 44px; position: relative; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 44px; height: 44px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: calc(113.1 * (1 - var(--p, 0))); transition: stroke-dashoffset .6s var(--ease); }
.ring[data-wait="true"] svg { animation: spin 1.2s linear infinite; }
.ring[data-wait="true"] .bar { stroke-dashoffset: 85; }
.ring b { font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.retry { width: 44px; height: 44px; border-radius: 22px; display: grid; place-items: center; background: var(--surface-2); color: var(--err); }
@keyframes spin { to { transform: rotate(270deg); } }

/* ---------- Player ---------- */
.player {
  height: 100%;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 14px) 0 var(--dock-space);
}
.player-head { padding: 0 var(--gutter); }
.player-title {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  width: 100%; max-width: 680px; margin: 0 auto;
  text-align: left; font-family: var(--serif);
  font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: 0.01em;
  color: var(--ink-2); padding: 6px 0;
}
.player-title:active { opacity: .6; }
.player-head { opacity: 0; transform: translateY(-6px); transition: opacity .35s var(--ease), transform .35s var(--ease); pointer-events: none; }
.player-head.show { opacity: 1; transform: none; pointer-events: auto; }

.reader { position: relative; flex: 1; min-height: 0; }
.reader-scroll {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 80%, transparent 100%);
}
.reader-scroll::-webkit-scrollbar { display: none; }
.reader-lines { max-width: 680px; margin: 0 auto; padding: 36vh var(--gutter) 46vh; }
.line {
  display: block; width: 100%; text-align: left;
  padding: 5px 0;
  font-family: var(--serif);
  font-size: 23px; line-height: 1.6; font-weight: 600;
  color: var(--ink-faint);
  transition: color .45s var(--ease), transform .45s var(--ease);
  transform-origin: left center;
  -webkit-user-select: text; user-select: text;
}
.line.para { margin-top: 22px; }
.line.head { font-size: 29px; line-height: 1.4; font-weight: 800; margin-bottom: 18px; }
.line.near { color: var(--ink-3); }
.line.on { color: var(--ink); }
.reader-msg { font-size: 20px; color: var(--ink-3); text-align: center; padding-top: 6vh; }
.recenter {
  position: absolute; right: 18px; bottom: 14px;
  width: 52px; height: 52px; border-radius: 26px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow);
  animation: pop .35s var(--spring);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.player-empty { flex: 1; align-content: center; }
.player[data-empty="true"] .reader,
.player[data-empty="true"] .deck,
.player[data-empty="true"] .player-head { display: none; }
.player[data-empty="false"] .player-empty { display: none; }

.deck { padding: 10px var(--gutter) 6px; max-width: 680px; width: 100%; margin: 0 auto; }
.scrub {
  position: relative; height: 34px;
  display: flex; align-items: center;
  touch-action: none; cursor: pointer;
}
.scrub-track {
  position: relative; width: 100%; height: 6px; border-radius: 3px;
  background: var(--surface-2); overflow: hidden;
  transition: height .2s var(--ease);
}
.scrub-fill { position: absolute; inset: 0 auto 0 0; width: var(--played, 0%); background: var(--ink); border-radius: 3px; }
.scrub.active .scrub-track { height: 14px; border-radius: 7px; }
.scrub.active .scrub-fill { background: var(--accent); }
.scrub-bubble {
  position: absolute; bottom: 44px; left: var(--bubble-x, 50%);
  transform: translate(-50%, 8px) scale(.9); opacity: 0;
  padding: 8px 16px; border-radius: 18px;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums;
  pointer-events: none; white-space: nowrap;
  transition: opacity .15s, transform .2s var(--ease);
}
.scrub.active .scrub-bubble { opacity: 1; transform: translate(-50%, 0) scale(1); }
.times {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 14px; color: var(--ink-3); font-variant-numeric: tabular-nums;
  margin-top: -2px;
}
.controls {
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; justify-items: center;
  margin-top: 6px;
}
.ctl {
  width: 56px; height: 56px; border-radius: 28px;
  display: grid; place-items: center;
  color: var(--ink);
  transition: transform .15s var(--ease), background-color .2s;
}
.ctl:active { transform: scale(.88); background: var(--surface-2); }
.ctl:disabled { opacity: .3; }
.ctl-speed { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ctl-skip { position: relative; }
.ctl-skip svg { width: 34px; height: 34px; }
.ctl-skip span { position: absolute; font-size: 10px; font-weight: 800; top: 50%; left: 50%; transform: translate(-50%, -38%); }
.ctl-play {
  width: 80px; height: 80px; border-radius: 40px;
  background: var(--ink); color: var(--bg);
}
.ctl-play:active { background: var(--ink); transform: scale(.92); }
.ctl-play svg { width: 34px; height: 34px; }
.ctl-play .i-pause, .ctl-play[data-playing="true"] .i-play { display: none; }
.ctl-play[data-playing="true"] .i-pause { display: block; }

/* ---------- Add ---------- */
.pane-add .pane-scroll { padding-bottom: calc(var(--dock-space) + 100px); }
.add[data-state="empty"] .add-clear { visibility: hidden; }
.add:not([data-state="empty"]) .intake,
.add:not([data-state="loading"]) .intake-loading,
.add:not([data-state="draft"]) .draft { display: none; }

.intake { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.paste-hero {
  display: grid; justify-items: center; align-content: center; gap: 14px;
  min-height: min(52vh, 440px); width: 100%;
  border-radius: 32px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.paste-hero:active { transform: scale(.975); box-shadow: inset 0 0 0 2px var(--ink); }
.paste-icon {
  width: 88px; height: 88px; border-radius: 44px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
}
.paste-icon svg { width: 38px; height: 38px; }
.paste-word { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.paste-sub { font-size: 18px; color: var(--ink-2); }
.ghost-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 60px; border-radius: 20px; font-size: 18px; font-weight: 600; color: var(--ink-2);
}
.ghost-row:active { background: var(--surface-2); }

.intake-loading { display: grid; justify-items: center; gap: 20px; padding: 18vh 0; }
.loading-word { font-size: 24px; font-weight: 700; color: var(--ink-2); }
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--surface-2); border-top-color: var(--ink);
  animation: spin2 .8s linear infinite;
}
@keyframes spin2 { to { transform: rotate(360deg); } }

.draft { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.draft-error {
  margin: 0; padding: 14px 18px; border-radius: 18px;
  background: color-mix(in srgb, var(--err) 12%, transparent);
  color: var(--err); font-size: 17px; font-weight: 600;
}
.draft-title, .draft-body {
  width: 100%; border: 0; background: none; resize: none; padding: 0;
  -webkit-user-select: text; user-select: text;
}
.draft-title {
  font-family: var(--serif); font-size: 30px; font-weight: 800; line-height: 1.3;
  overflow: hidden; field-sizing: content; min-height: 1.3em;
}
.draft-meta { margin: 0; font-size: 16px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.draft-body {
  font-family: var(--serif); font-size: 19px; line-height: 1.85; color: var(--ink);
  min-height: 46vh; field-sizing: content;
}
.draft-title::placeholder, .draft-body::placeholder { color: var(--ink-faint); }
.voice-chip {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 16px 0 6px; border-radius: 22px;
  background: var(--surface-2); font-size: 16px; font-weight: 600;
}
.voice-chip .avatar { width: 32px; height: 32px; font-size: 14px; }
.voice-chip small { font-size: 14px; font-weight: 500; color: var(--ink-2); font-family: var(--mono); }
.voice-chip:active { transform: scale(.96); }

.add-action {
  position: absolute; left: 0; right: 0; bottom: var(--dock-space);
  padding: 12px var(--gutter);
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}
.big-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 640px; margin: 0 auto;
  height: 62px; border-radius: 31px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 20px; font-weight: 800; letter-spacing: .02em;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: transform .15s var(--ease), opacity .2s;
}
.big-btn:active { transform: scale(.97); }
.big-btn:disabled { opacity: .45; box-shadow: none; }
.big-btn[data-kind="setup"] { background: var(--ink); color: var(--bg); box-shadow: none; }

/* ---------- Key ---------- */
.block { margin-bottom: 34px; }
.block-title { margin: 0 0 12px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.key-field {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 6px 6px 18px; border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: box-shadow .2s;
}
.key-field:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.key-input { flex: 1; min-width: 0; border: 0; background: none; font-family: var(--mono); font-size: 17px; padding: 12px 0; }
.key-input::placeholder { font-family: var(--sans); color: var(--ink-3); }
.key-status {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 4px;
  font-size: 18px; font-weight: 700; text-align: left;
}
.status-dot { width: 10px; height: 10px; border-radius: 5px; background: var(--ink-faint); flex: none; }
.status-text { flex: 1; }
.balance { font-family: var(--mono); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.status-refresh { width: 20px; height: 20px; color: var(--ink-3); }
.key-status[data-state="ok"] .status-dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.key-status[data-state="bad"] .status-dot,
.key-status[data-state="error"] .status-dot { background: var(--err); }
.key-status[data-state="bad"], .key-status[data-state="error"] { color: var(--err); }
.key-status[data-state="checking"] .status-dot { background: var(--warn); animation: pulse 1s infinite; }
.key-status[data-state="checking"] .status-refresh { animation: spin2 .9s linear infinite; }
.key-status[data-state="empty"] .status-refresh,
.key-status[data-state="empty"] { color: var(--ink-3); }
.key-status[data-state="empty"] .status-refresh { display: none; }
.get-key { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; color: var(--accent); padding: 4px; }
.get-key svg { width: 16px; height: 16px; }

.voice-row {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 14px 14px 14px 14px; border-radius: 24px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: left; transition: transform .15s var(--ease);
}
.voice-row:active { transform: scale(.98); }
.voice-row .avatar { width: 60px; height: 60px; font-size: 24px; }
.voice-name { flex: 1; min-width: 0; font-size: 21px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--ink-3); }

.avatar {
  flex: none; position: relative; overflow: hidden;
  display: grid; place-items: center;
  border-radius: 50%;
  background: hsl(var(--hue, 30) 45% 55%);
  color: #fff; font-weight: 800;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.default { background: var(--ink); color: var(--bg); }
.avatar.default svg { width: 55%; height: 55%; }

.models { display: grid; gap: 8px; }
.model {
  display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: 0 18px; border-radius: 20px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
  text-align: left; transition: box-shadow .2s, transform .15s var(--ease);
}
.model:active { transform: scale(.98); }
.model[aria-checked="true"] { box-shadow: inset 0 0 0 2.5px var(--ink); }
.model-name { flex: 1; font-family: var(--mono); font-size: 18px; font-weight: 700; }
.model-tag { font-size: 14px; font-weight: 800; padding: 4px 10px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.model .tick { width: 26px; height: 26px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); color: transparent; transition: background-color .2s; }
.model .tick svg { width: 16px; height: 16px; }
.model[aria-checked="true"] .tick { background: var(--ink); color: var(--bg); }

.transfer { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  display: grid; justify-items: center; align-content: center; gap: 10px;
  height: 112px; border-radius: 24px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 17px; font-weight: 700;
  transition: transform .15s var(--ease);
}
.tile svg { width: 30px; height: 30px; }
.tile:active { transform: scale(.96); }

/* ---------- Sheets ---------- */
.sheet-layer { position: fixed; inset: 0; z-index: 40; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity .3s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  max-height: 90dvh; overflow-y: auto;
  padding: 0 var(--gutter) calc(var(--safe-b) + 24px);
  border-radius: 30px 30px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(105%);
  transition: transform .42s var(--ease);
  overscroll-behavior: contain;
}
.sheet-layer.open .scrim { opacity: 1; }
.sheet-layer.open .sheet { transform: translateY(var(--drag, 0px)); }
.sheet-layer.dragging .sheet { transition: none; }
.grip { position: sticky; top: 0; z-index: 2; height: 30px; margin: 0 calc(-1 * var(--gutter)); touch-action: none; cursor: grab; background: var(--surface); }
.grip::after { content: ""; position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--ink-faint); }
.sheet-title { margin: 4px 0 6px; font-family: var(--serif); font-size: 24px; font-weight: 800; line-height: 1.35; }
.sheet-sub { margin: 0 0 16px; font-size: 16px; color: var(--ink-2); }
.menu { display: grid; }
.menu-row {
  display: flex; align-items: center; gap: 16px;
  height: 62px; padding: 0 6px; font-size: 19px; font-weight: 600;
  border-top: 1px solid var(--line); text-align: left;
}
.menu-row:active { opacity: .5; }
.menu-row.danger { color: var(--err); }
.menu-row[aria-disabled="true"] { opacity: .35; pointer-events: none; }

.sheet-tall { height: 90dvh; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; border-radius: 18px; background: var(--surface-2);
}
.seg-btn { height: 44px; border-radius: 14px; font-size: 17px; font-weight: 700; color: var(--ink-2); transition: background-color .2s, color .2s; }
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.search {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 4px; padding: 0 16px; height: 50px; border-radius: 16px;
  background: var(--surface-2); color: var(--ink-3);
}
.search input { flex: 1; min-width: 0; border: 0; background: none; font-size: 17px; color: var(--ink); }
.search input::-webkit-search-cancel-button { display: none; }
.voice-list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 calc(-1 * var(--gutter)); padding: 4px var(--gutter) calc(var(--safe-b) + 24px);
}
.vrow { display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.vrow-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px 0; text-align: left; }
.vrow-main:active { opacity: .55; }
.vrow .avatar { width: 52px; height: 52px; font-size: 20px; }
.vrow-text { min-width: 0; display: grid; gap: 2px; }
.vrow-title { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow-sub { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow[data-selected="true"] .vrow-title { color: var(--accent); }
.vrow-check { color: var(--accent); }
.sample-btn {
  flex: none; width: 46px; height: 46px; border-radius: 23px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
  transition: transform .15s var(--ease);
}
.sample-btn:active { transform: scale(.88); }
.sample-btn svg { width: 20px; height: 20px; }
.sample-btn .i-pause, .sample-btn[data-playing="true"] .i-play { display: none; }
.sample-btn[data-playing="true"] { background: var(--ink); color: var(--bg); }
.sample-btn[data-playing="true"] .i-pause { display: block; }
.list-msg { padding: 28px 4px; text-align: center; font-size: 17px; color: var(--ink-2); }
.list-msg[data-kind="error"] { color: var(--err); }
.list-more { display: grid; place-items: center; padding: 20px; }

.text-box {
  width: 100%; margin: 6px 0 16px; padding: 16px; border: 0; border-radius: 18px;
  background: var(--surface-2); font-family: var(--mono); font-size: 15px; line-height: 1.5;
  resize: none; word-break: break-all;
}

@media (min-width: 900px) {
  :root { --gutter: 40px; }
  .reader-lines { padding-left: 40px; padding-right: 40px; }
}

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