:root {
  color-scheme: light dark;
  --bg: #f4f5fa;
  --card: #ffffff;
  --card-2: #eef0f8;
  --text: #15182a;
  --muted: #5d6280;
  --line: rgba(20, 24, 60, 0.10);
  --accent: #2b3fe0;
  --accent-soft: rgba(43, 63, 224, 0.12);
  --danger: #d23b3b;
  --ok: #1f9d55;
  --warn: #c77b0c;
  --radius: 16px;
  --tabbar: 64px;
  --mini: 70px;
  --sab: env(safe-area-inset-bottom, 0px);
  --sat: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101323;
    --card: #1a1f3a;
    --card-2: #232946;
    --text: #eef0ff;
    --muted: #a6acd0;
    --line: rgba(255, 255, 255, 0.10);
    --accent: #7a95ff;
    --accent-soft: rgba(122, 149, 255, 0.18);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

.app { min-height: 100%; display: flex; flex-direction: column; }
.view { flex: 1; padding: calc(var(--sat) + 12px) 16px calc(var(--tabbar) + var(--sab) + 24px); max-width: 1080px; width: 100%; margin: 0 auto; }
.view.has-mini { padding-bottom: calc(var(--tabbar) + var(--mini) + var(--sab) + 24px); }
.view.no-tabs { padding-bottom: calc(var(--sab) + 24px); }

h1 { font-size: 30px; margin: 8px 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 21px; margin: 18px 0 8px; }
h3 { font-size: 17px; margin: 14px 0 6px; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--card-2); cursor: pointer; font-weight: 600; touch-action: manipulation; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: rgba(210, 59, 59, 0.12); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn.block { width: 100%; }
.btn.icon { padding: 10px; border-radius: 50%; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.btn.big-play { width: 64px; height: 64px; font-size: 26px; background: var(--accent); color: #fff; border-radius: 50%; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field label { font-weight: 600; font-size: 14px; }
.input { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; width: 100%; font-size: 16px; }
textarea.input { min-height: 110px; resize: vertical; }
select.input { appearance: none; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.card.soft { background: var(--accent-soft); border-color: transparent; }
.card.warn { background: rgba(199, 123, 12, 0.10); border-color: transparent; }
.card.error { background: rgba(210, 59, 59, 0.10); border-color: transparent; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.suggestion { text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.suggestion:active { transform: scale(0.99); }
.suggestion.chosen { outline: 2px solid var(--accent); }
.suggestion .cat { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.suggestion .num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--card-2); align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 6px; }
.suggestion .title { font-weight: 700; font-size: 17px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.ready { background: rgba(31, 157, 85, 0.14); color: var(--ok); }
.badge.failed { background: rgba(210, 59, 59, 0.14); color: var(--danger); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progressbar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progressbar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }

.tile { width: 48px; height: 48px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 16px; }
.tile.lg { width: 100%; max-width: 300px; aspect-ratio: 1; height: auto; border-radius: 24px; font-size: 96px; margin: 0 auto; box-shadow: 0 20px 40px rgba(0,0,0,0.25); }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.list-row .title { font-weight: 700; }

.digest-text { max-width: 720px; margin: 0 auto; font-size: 17px; line-height: 1.65; }
.digest-text h2 { font-size: 22px; margin: 28px 0 10px; }
.digest-text p { margin: 0 0 16px; }
.digest-text hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.digest-text .byline { color: var(--muted); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + var(--sab)); padding-bottom: var(--sab); display: flex; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); z-index: 20; }
.tabs[hidden] { display: none; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--accent); }
.tab-icon { font-size: 20px; }

.mini { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar) + var(--sab) + 8px); height: var(--mini); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--line); border-radius: 16px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 10px; z-index: 21; box-shadow: 0 8px 30px rgba(0,0,0,0.18); }
.mini .meta { flex: 1; min-width: 0; cursor: pointer; }
.mini .meta .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.mini .bar { position: absolute; left: 12px; right: 12px; top: 0; height: 3px; }
.mini.no-tabs { bottom: calc(var(--sab) + 8px); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: max(24px, var(--sat)); background: var(--bg); border-radius: 22px 22px 0 0; z-index: 31; overflow: auto; padding: 16px 20px calc(var(--sab) + 24px); animation: up 0.25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0.6; } }
.sheet .handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: 36px; margin: 16px 0; }
.scrub { width: 100%; accent-color: var(--accent); }
.times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + var(--mini) + var(--sab) + 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14px; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
.center { text-align: center; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; z-index: 50; }
.overlay .card { display: flex; gap: 12px; align-items: center; }
@media (min-width: 720px) {
  .view { padding-left: 24px; padding-right: 24px; }
  .tabs a { flex-direction: row; gap: 8px; font-size: 14px; }
}
