:root {
  --paper: #f1efe9;
  --ink: #161616;
  --muted: #6d6a64;
  --rule: #161616;
  --soft-rule: #c9c5bc;
  --accent: #e5603f;
  --hair: 1px;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (min-resolution: 2dppx) { :root { --hair: 0.5px; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121211; --ink: #ecebe6; --muted: #9a978f; --rule: #ecebe6; --soft-rule: #3a3936;
    --accent: #f06d4b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121211; --ink: #ecebe6; --muted: #9a978f; --rule: #ecebe6; --soft-rule: #3a3936;
  --accent: #f06d4b; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--display); font-size: 16px; line-height: 1.4;
  padding: 0 16px calc(72px + env(safe-area-inset-bottom));
  max-width: 1180px; margin-inline: auto;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
[hidden] { display: none !important; }

/* header */
.top { padding-top: calc(20px + env(safe-area-inset-top)); }
.brand { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h1 {
  margin: 0; font-weight: 900; font-stretch: 112%; text-transform: uppercase;
  font-size: clamp(56px, 17vw, 132px); line-height: 0.84; letter-spacing: -0.035em;
}
.account { padding: 8px 0; text-align: right; max-width: 45%; overflow-wrap: anywhere; }
.account.off { color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 18px 0 0; padding: 10px 0; border-top: var(--hair) solid var(--rule); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* the poster glyphs: full / half circles, ink or accent */
.g { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); flex: none; }
.g-adjacent, .g-wild { border-radius: 11px 0 0 11px; width: 6px; }
.g-outside, .g-wild { background: var(--accent); }

.tabs { display: flex; border-top: var(--hair) solid var(--rule); border-bottom: var(--hair) solid var(--rule); overflow-x: auto; }
.tabs button { padding: 12px 14px 11px 0; margin-right: 6px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* cards */
.cards { display: grid; grid-template-columns: 1fr; column-gap: 28px; }
@media (min-width: 720px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1080px) { .cards { grid-template-columns: 1fr 1fr 1fr; } }
.card { padding: 18px 0 0; border-bottom: var(--hair) solid var(--rule); display: flex; flex-direction: column; animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.card.seen { opacity: .45; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 10px; }
.meta .cat { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.thumb { display: block; aspect-ratio: 16 / 9; background: var(--soft-rule); overflow: hidden; border: var(--hair) solid var(--rule); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.thumb:hover img { transform: scale(1.03); }
.card h3 { margin: 12px 0 2px; font-size: 19px; line-height: 1.18; font-weight: 800; font-stretch: 96%; letter-spacing: -0.01em; }
.card h3 a { text-decoration: none; }
.card .channel { color: var(--muted); margin: 2px 0 8px; }
.card .teaser { margin: 0 0 14px; color: var(--ink); font-size: 15px; opacity: .78; }
.actions { margin-top: auto; display: grid; grid-template-columns: 1.1fr 1.4fr 0.6fr 0.6fr 0.9fr; border-top: var(--hair) solid var(--soft-rule); }
.actions > * { padding: 12px 0; text-align: center; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.actions > * + * { border-left: var(--hair) solid var(--soft-rule); }
.actions .on { color: var(--accent); }
.actions .add.on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.actions button:disabled { opacity: .4; cursor: default; }

.more { display: block; width: 100%; padding: 18px 0; margin: 8px 0; border-bottom: var(--hair) solid var(--rule); }

.section-title { font-size: 28px; font-weight: 900; font-stretch: 110%; text-transform: uppercase; letter-spacing: -0.02em; margin: 26px 0 0; padding-bottom: 8px; border-bottom: var(--hair) solid var(--rule); }
.empty { color: var(--muted); padding: 18px 0; border-bottom: var(--hair) solid var(--soft-rule); margin: 0; }

/* compact rows (playlist / history) */
.rows { display: block; }
.row { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: var(--hair) solid var(--soft-rule); }
.row img { width: 96px; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--soft-rule); }
.row .t { font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none; display: block; }
.row .c { color: var(--muted); margin-top: 3px; }
.row button { padding: 10px 0 10px 8px; color: var(--muted); }
.row button:hover { color: var(--accent); }

.bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 0; border-bottom: var(--hair) solid var(--rule); }
.btn { padding: 12px 16px; border: var(--hair) solid var(--ink); border-radius: 999px; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.accent { background: var(--accent); color: #161616; border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.note { color: var(--muted); font-size: 14px; margin: 12px 0; }

/* import: numbers + 200-dot strip */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); border-bottom: var(--hair) solid var(--rule); }
.stat { padding: 14px 0 12px; }
.stat b { display: block; font-size: 44px; font-weight: 900; font-stretch: 110%; line-height: 1; letter-spacing: -0.03em; }
.stat.warn b { color: var(--accent); }
.dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 5px; padding: 16px 0; border-bottom: var(--hair) solid var(--rule); }
.dot { aspect-ratio: 1; border-radius: 50%; border: var(--hair) solid var(--ink); }
.dot.in { background: var(--ink); }
.dot.failed { background: var(--accent); border-color: var(--accent); }
.dot.now { border-radius: 99px 0 0 99px; background: var(--accent); border-color: var(--accent); }
.log { max-height: 240px; overflow: auto; padding: 8px 0; color: var(--muted); }
.log div { padding: 3px 0; }
.log .added { color: var(--ink); }
.log .failed { color: var(--accent); }

/* surprise button + sheet */
.surprise {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--paper); color: var(--ink); border: var(--hair) solid var(--rule); border-radius: 999px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 14px 10px 10px;
}
.surprise::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.surprise:active { transform: scale(.97); }
.sheet { position: fixed; inset: 0; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(6px); z-index: 10; overflow: auto; padding: 16px; }
.sheet-inner { max-width: 560px; margin: 0 auto; padding-top: env(safe-area-inset-top); }
.sheet-head { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: var(--hair) solid var(--rule); }
.sheet .card { border-bottom: 0; }
.sheet .card h3 { font-size: 26px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(68px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--paper); padding: 12px 14px; z-index: 20; text-align: center; }
.toast.err { background: var(--accent); color: #161616; }

@media (prefers-reduced-motion: reduce) { .card { animation: none; } .thumb img { transition: none; } }
