/* rss — styles. Themes are sets of CSS variables keyed by [data-theme]; the
   same attribute on a swatch button makes it preview its own theme. */

/* ---------- themes ---------- */

:root,
[data-theme="paper"] {
  color-scheme: light;
  --bg: #fbfaf7; --surface: #ffffff; --surface-2: #f1eee8; --border: #e4dfd5;
  --text: #1f1d1a; --muted: #6b665e; --accent: #2f6fdb; --accent-text: #ffffff;
  --hl: #fff0a6; --hl-word: #ffd23f; --danger: #c0392b;
}
[data-theme="snow"] {
  color-scheme: light;
  --bg: #ffffff; --surface: #f7f8fa; --surface-2: #eceff3; --border: #e2e5ea;
  --text: #111827; --muted: #5f6b7a; --accent: #0f766e; --accent-text: #ffffff;
  --hl: #ccf5ec; --hl-word: #7ce0cb; --danger: #c0392b;
}
[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f4ecd8; --surface: #fbf5e6; --surface-2: #ebe0c5; --border: #dccfae;
  --text: #433422; --muted: #7a6650; --accent: #9c4f24; --accent-text: #fffaf0;
  --hl: #f3d58f; --hl-word: #e7ad55; --danger: #a8321e;
}
[data-theme="sand"] {
  color-scheme: light;
  --bg: #fdf6e3; --surface: #fffbef; --surface-2: #eee8d5; --border: #e3dbc4;
  --text: #36454b; --muted: #6f7f85; --accent: #1f7fc4; --accent-text: #ffffff;
  --hl: #f2e3a3; --hl-word: #e5c35c; --danger: #c0392b;
}
[data-theme="mint"] {
  color-scheme: light;
  --bg: #eef7f1; --surface: #f8fcf9; --surface-2: #dcefe3; --border: #cde3d5;
  --text: #17301f; --muted: #557062; --accent: #1b7f45; --accent-text: #ffffff;
  --hl: #c4efd2; --hl-word: #86dca4; --danger: #b83227;
}
[data-theme="sky"] {
  color-scheme: light;
  --bg: #eef5fc; --surface: #f8fbff; --surface-2: #dde9f7; --border: #cfdff0;
  --text: #13263b; --muted: #546a83; --accent: #1d69c9; --accent-text: #ffffff;
  --hl: #cde5ff; --hl-word: #8cc3ff; --danger: #c0392b;
}
[data-theme="rose"] {
  color-scheme: light;
  --bg: #fcf1f3; --surface: #fff8f9; --surface-2: #f6e1e6; --border: #efd2d9;
  --text: #3b1d26; --muted: #80596a; --accent: #b8185a; --accent-text: #ffffff;
  --hl: #ffd5e2; --hl-word: #ff9fbf; --danger: #b3261e;
}
[data-theme="lavender"] {
  color-scheme: light;
  --bg: #f3f0fb; --surface: #faf8ff; --surface-2: #e6e0f6; --border: #dcd3f0;
  --text: #2a2140; --muted: #685f82; --accent: #6342e8; --accent-text: #ffffff;
  --hl: #e2d9ff; --hl-word: #bba8ff; --danger: #b3261e;
}
[data-theme="contrast-light"] {
  color-scheme: light;
  --bg: #ffffff; --surface: #ffffff; --surface-2: #ececec; --border: #000000;
  --text: #000000; --muted: #2b2b2b; --accent: #0000c8; --accent-text: #ffffff;
  --hl: #ffff00; --hl-word: #ffb000; --danger: #b00000;
}
[data-theme="slate"] {
  color-scheme: dark;
  --bg: #1e232b; --surface: #262c35; --surface-2: #303741; --border: #3a424e;
  --text: #e3e7ed; --muted: #9ba5b3; --accent: #7aa2f7; --accent-text: #0b1020;
  --hl: #3a4a66; --hl-word: #56709f; --danger: #ff8a80;
}
[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0e1320; --surface: #151c2c; --surface-2: #1e2740; --border: #26304a;
  --text: #d8def0; --muted: #8d97b3; --accent: #5eb1ff; --accent-text: #06121f;
  --hl: #1f3a5f; --hl-word: #2f5f99; --danger: #ff8a80;
}
[data-theme="fjord"] {
  color-scheme: dark;
  --bg: #2e3440; --surface: #3b4252; --surface-2: #434c5e; --border: #4c566a;
  --text: #eceff4; --muted: #b0b9c9; --accent: #88c0d0; --accent-text: #1f2530;
  --hl: #4b6782; --hl-word: #5f83a8; --danger: #ffab91;
}
[data-theme="forest"] {
  color-scheme: dark;
  --bg: #17211b; --surface: #1e2b23; --surface-2: #27372d; --border: #304336;
  --text: #dfeadf; --muted: #95aa99; --accent: #6fcf8f; --accent-text: #0e1a12;
  --hl: #2c4a37; --hl-word: #417052; --danger: #ff8a80;
}
[data-theme="plum"] {
  color-scheme: dark;
  --bg: #282a36; --surface: #313442; --surface-2: #3a3d4e; --border: #474a5e;
  --text: #f1f1ec; --muted: #a9adc7; --accent: #bd93f9; --accent-text: #1d1b2a;
  --hl: #4b3f6b; --hl-word: #6c55a6; --danger: #ff8a80;
}
[data-theme="espresso"] {
  color-scheme: dark;
  --bg: #231b16; --surface: #2d231d; --surface-2: #382c25; --border: #46382f;
  --text: #ecdfd2; --muted: #b19e8c; --accent: #e0a46a; --accent-text: #24170e;
  --hl: #5a4030; --hl-word: #845a3c; --danger: #ff9e80;
}
[data-theme="deep-sea"] {
  color-scheme: dark;
  --bg: #002b36; --surface: #073642; --surface-2: #0d4250; --border: #144d5b;
  --text: #dfe6e4; --muted: #93a1a1; --accent: #2aa198; --accent-text: #00191f;
  --hl: #16535f; --hl-word: #23757f; --danger: #ff8a80;
}
[data-theme="black"] {
  color-scheme: dark;
  --bg: #000000; --surface: #0b0b0b; --surface-2: #171717; --border: #262626;
  --text: #e6e6e6; --muted: #8f8f8f; --accent: #ffb000; --accent-text: #000000;
  --hl: #3a2f00; --hl-word: #6b5600; --danger: #ff6b6b;
}
[data-theme="contrast-dark"] {
  color-scheme: dark;
  --bg: #000000; --surface: #000000; --surface-2: #1c1c1c; --border: #ffffff;
  --text: #ffffff; --muted: #e6e6e6; --accent: #ffff00; --accent-text: #000000;
  --hl: #003f88; --hl-word: #0060d0; --danger: #ff7070;
}

:root {
  --reader-font: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, Georgia, serif;
  --reader-size: 19px;
  --reader-lh: 1.6;
  --ui-font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --topbar-h: 56px;
  --top-offset: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  --radius: 12px;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.12);
}

/* ---------- base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.6; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; display: block; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & forms ---------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-small { min-height: 34px; padding: 5px 12px; font-size: 14px; }
.btn-block { width: 100%; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; }

.field { display: grid; gap: 6px; font-weight: 550; font-size: 14px; }
.field small { font-weight: 400; color: var(--muted); }
.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px; /* prevents iOS zoom on focus */
  font-weight: 400;
}
.field input:focus,
.field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

.form-grid { display: grid; gap: 14px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }

input[type="range"] { accent-color: var(--accent); width: 100%; min-width: 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  width: 36px;
  height: 22px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent-text); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.spinner {
  width: 28px;
  height: 28px;
  margin: 32px auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar & layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--top-offset);
  padding: env(safe-area-inset-top, 0px) 8px 0;
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
}
.brand span { color: var(--text); }
#refreshBtn.spinning .icon { animation: spin 0.9s linear infinite; }
.offline-badge {
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
body.is-offline #refreshBtn { opacity: 0.4; }

.layout { display: flex; min-height: calc(100vh - var(--top-offset)); }

.sidebar {
  position: sticky;
  top: var(--top-offset);
  display: flex;
  flex-direction: column;
  width: 280px;
  height: calc(100vh - var(--top-offset));
  height: calc(100dvh - var(--top-offset));
  flex: none;
  overflow-y: auto;
  padding: 12px 10px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.feed-nav { flex: 1; }
.sidebar-foot { padding-top: 10px; border-top: 1px solid var(--border); margin-top: 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--surface-2); font-weight: 650; }
.nav-item .icon { color: var(--muted); }
.nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-label { margin: 16px 10px 6px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.nav-empty { margin: 4px 10px; color: var(--muted); font-size: 14px; }
.nav-warn { color: var(--danger); }
.count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}
.nav-item.active .count { background: var(--accent); color: var(--accent-text); }

.feed-badge {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  background: hsl(var(--h, 210) 55% 48%);
  color: #fff;
  font: 700 12px/1 var(--ui-font);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 28px 96px;
  outline: none;
}
body.tts-on .main { padding-bottom: 220px; }
body.tts-on .sidebar { padding-bottom: 92px; }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.4); }

@media (min-width: 900px) {
  #menuBtn { display: none; }
  .scrim { display: none !important; }
}

@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    height: auto;
    width: min(300px, 86vw);
    padding-top: max(12px, env(safe-area-inset-top));
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.drawer-open .sidebar { transform: none; }
  .main { padding: 14px 16px 96px; }
}

.view-title { margin: 4px 0 0; font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; }

/* ---------- article list ---------- */

.list-view { max-width: 780px; margin: 0 auto; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.list-actions { display: flex; align-items: center; gap: 14px; }

.notice {
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 14px;
}

.item-list { list-style: none; margin: 0; padding: 0; }
.item + .item { border-top: 1px solid var(--border); }
.item-link {
  display: block;
  margin: 2px -12px;
  padding: 14px 12px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.item-link:hover { background: var(--surface-2); }
.item-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; }
.item-meta .feed-badge { width: 18px; height: 18px; font-size: 10px; border-radius: 5px; }
.item-feed { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.item-title { margin: 6px 0 4px; font-size: 17.5px; line-height: 1.3; font-weight: 650; }
.item:not(.unread) .item-title { font-weight: 450; color: var(--muted); }
.item.unread .item-title::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 8px 2px 0;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.item-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14.5px;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
.list-foot { padding: 16px 0; text-align: center; }
.end-note { font-size: 14px; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .icon { margin: 0 auto 8px; color: var(--accent); }
.empty h2 { margin: 8px 0 4px; color: var(--text); font-size: 20px; }
.empty p { margin: 0 0 18px; }

/* ---------- article view ---------- */

.article-view { max-width: 760px; margin: 0 auto; }
.article-bar {
  position: sticky;
  top: var(--top-offset);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: -20px -8px 0;
  padding: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 899px) { .article-bar { margin-top: -14px; } }

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
}
.tool-btn:hover { background: var(--surface-2); }
.tool-btn[aria-pressed="true"],
.tool-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.aa { font: 700 18px/1 Georgia, serif; }
.aa small { font-size: 13px; }
@media (max-width: 480px) { .tool-label { display: none; } .tool-btn { padding: 6px 10px; } }

.type-panel {
  position: sticky;
  top: calc(var(--top-offset) + 57px);
  z-index: 9;
  display: grid;
  gap: 16px;
  margin: 8px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.type-group { display: grid; gap: 8px; }
.type-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 650; }
.type-label output { color: var(--text); font-weight: 550; }
.font-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (max-width: 480px) { .font-grid { grid-template-columns: repeat(2, 1fr); } }
.font-opt {
  min-height: 42px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 16px;
}
.font-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-family: Georgia, serif;
  font-weight: 700;
}
.a-small { font-size: 13px; }
.a-large { font-size: 21px; }
.step-icon { color: var(--muted); }

.reader {
  font-family: var(--reader-font);
  font-size: var(--reader-size);
  line-height: var(--reader-lh);
  overflow-wrap: break-word;
}
.art-title { margin: 28px 0 10px; font-size: 1.65em; line-height: 1.2; letter-spacing: -0.01em; }
.art-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 1.6em;
  color: var(--muted);
  font: 14px/1.4 var(--ui-font);
}
.art-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }
.art-body > :first-child { margin-top: 0; }
.art-body img,
.art-body video { max-width: 100%; height: auto; border-radius: 8px; }
.art-body audio { width: 100%; }
.art-body figure { margin: 1.4em 0; }
.art-body figcaption { margin-top: 6px; color: var(--muted); font-size: 0.82em; line-height: 1.45; }
.art-body h1 { font-size: 1.4em; }
.art-body h2 { font-size: 1.28em; }
.art-body h3 { font-size: 1.14em; }
.art-body h4, .art-body h5, .art-body h6 { font-size: 1em; }
.art-body h1, .art-body h2, .art-body h3, .art-body h4 { line-height: 1.25; margin: 1.6em 0 0.5em; }
.art-body blockquote { margin: 1.2em 0; padding: 0.1em 0 0.1em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.art-body pre {
  overflow-x: auto;
  padding: 0.9em 1em;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.82em;
  line-height: 1.5;
}
.art-body code { font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace; font-size: 0.88em; }
.art-body :not(pre) > code { padding: 0.1em 0.3em; border-radius: 4px; background: var(--surface-2); }
.art-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.9em; }
.art-body th, .art-body td { padding: 6px 10px; border: 1px solid var(--border); text-align: left; }
.art-body hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.art-body ul, .art-body ol { padding-left: 1.4em; }
.art-foot { margin: 2.5em 0 1em; font-family: var(--ui-font); }
.art-full-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2em 0 1.4em;
  padding-top: 1.4em;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font: 650 12.5px/1.4 var(--ui-font);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.art-full-note { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font: 14px/1.5 var(--ui-font); }
.art-full > .btn { font-family: var(--ui-font); }
.spinner-sm { width: 16px; height: 16px; margin: 0; border-width: 2px; }

/* read-aloud highlighting */
.tts-seg.tts-current {
  background: var(--hl);
  color: var(--text);
  border-radius: 0.2em;
  box-shadow: 0 0 0 0.12em var(--hl);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
::highlight(tts-word) { background-color: var(--hl-word, #ffd23f); color: var(--text, inherit); }
.reader.tts-active .art-title,
.reader.tts-active .art-body { cursor: pointer; }

/* ---------- read-aloud player ---------- */

.player {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.1);
}
.player-progress { position: absolute; top: -1px; right: 0; left: 0; height: 3px; background: transparent; }
.player-progress-bar { width: 0; height: 100%; background: var(--accent); transition: width 0.3s ease; }
.player-inner { max-width: 760px; margin: 0 auto; }
.player-row { display: flex; align-items: center; gap: 4px; }
.play-btn {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
}
.player.nudge .play-btn { animation: nudge 0.9s ease-in-out 3; }
@keyframes nudge { 50% { transform: scale(1.14); box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent); } }
.player-info { display: grid; flex: 1; min-width: 0; padding: 0 8px; line-height: 1.3; }
.player-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.player-pos { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.speed-btn {
  min-width: 52px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.player-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  padding: 6px 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.player-settings .field span { display: flex; justify-content: space-between; }
@media (max-width: 600px) {
  .player-settings { grid-template-columns: 1fr; }
  .player-info .player-status { font-size: 12px; }
}
@media (max-width: 380px) { .player-info { display: none; } .player-row { justify-content: space-between; } }

/* ---------- pages: manage & settings ---------- */

.page { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.card { padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card > p:first-of-type { margin-top: 0; }

.manage-list { list-style: none; margin: 0; padding: 0; }
.manage-item { padding: 12px 0; }
.manage-item + .manage-item { border-top: 1px solid var(--border); }
.mi-row { display: flex; align-items: flex-start; gap: 12px; }
.mi-row .feed-badge { margin-top: 2px; }
.mi-text { flex: 1; min-width: 0; }
.mi-name { color: var(--text); font-weight: 650; text-decoration: none; overflow-wrap: anywhere; }
.mi-name:hover { text-decoration: underline; }
.mi-url { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.mi-error { display: flex; align-items: flex-start; gap: 4px; margin-top: 2px; color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
.mi-error .icon { margin-top: 2px; }
.mi-error span { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.mi-actions { display: flex; gap: 2px; }

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
.swatch {
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
  transition: transform 0.12s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch[aria-checked="true"] { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch-preview { position: relative; display: block; height: 70px; background: var(--bg); }
.sw-aa { position: absolute; top: 9px; left: 11px; font: 700 22px/1 Georgia, serif; color: var(--text); }
.sw-dot { position: absolute; top: 11px; right: 11px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); }
.sw-line { position: absolute; left: 11px; right: 30px; bottom: 24px; height: 5px; border-radius: 3px; background: var(--muted); opacity: 0.45; }
.sw-line.sw-hl { right: 46px; bottom: 11px; height: 8px; border-radius: 4px; background: var(--hl); opacity: 1; }
.sw-check {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: none;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
}
.swatch[aria-checked="true"] .sw-check { display: grid; }
.swatch-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 10px; border-top: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 600; }

.type-box { display: grid; gap: 16px; margin-bottom: 16px; }
.type-sample { margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--bg); }

/* ---------- toast ---------- */

.toast {
  overflow-wrap: anywhere;
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 60;
  max-width: min(92vw, 480px);
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.tts-on .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }

/* ---------- sign in / register ---------- */

.auth { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 20px; font-weight: 700; }
.auth-brand span { color: var(--text); }
.auth-card h1 { margin: 18px 0 16px; font-size: 24px; }
.auth-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.auth-alt { margin: 18px 0 0; text-align: center; font-size: 14px; }
.alert {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
