:root {
  --bg: #f4efe7;
  --surface: #fbf8f3;
  --surface-2: #ece5da;
  --ink: #1d1915;
  --ink-2: #5e554b;
  --ink-3: #958a7d;
  --line: rgba(60, 45, 30, 0.1);
  --accent: #b0532b;
  --accent-ink: #fff8f1;
  --accent-soft: rgba(176, 83, 43, 0.12);
  --shadow: 0 1px 2px rgba(40, 25, 10, 0.06), 0 8px 24px rgba(40, 25, 10, 0.08);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110e;
    --surface: #1d1915;
    --surface-2: #29231d;
    --ink: #f1e9de;
    --ink-2: #bdb1a3;
    --ink-3: #85796c;
    --line: rgba(255, 240, 220, 0.09);
    --accent: #e48b5f;
    --accent-ink: #1d120b;
    --accent-soft: rgba(228, 139, 95, 0.15);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#app { max-width: 640px; margin: 0 auto; min-height: 100%; padding-bottom: calc(150px + var(--sb)); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(var(--st) + 18px) 20px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.top h1 { font: 600 32px/1.1 var(--serif); letter-spacing: -0.01em; margin: 0; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; color: var(--ink-2);
  transition: transform .15s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.accent { background: var(--accent); color: var(--accent-ink); }
.icon-btn.accent svg { stroke-width: 2.2; }

/* Lists */
.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 20px 8px; display: flex; justify-content: space-between; align-items: center;
}
.section-label button { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 500; }
.list { margin: 0 12px; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px; border-radius: 14px; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 76px; right: 8px; border-top: 1px solid var(--line); }
.row.playing { background: var(--accent-soft); }
.row.playing::before, .row.playing + .row::before { display: none; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; text-align: left; }
.row-text { flex: 1; min-width: 0; }
.row-title {
  font: 500 16px/1.3 var(--serif); color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-sub { font-size: 13px; color: var(--ink-3); margin-top: 3px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.row-sub > span { flex: none; }
.row-sub > span.shrink { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-sub .dot::before { content: "·"; }
.row-sub svg { width: 13px; height: 13px; stroke-width: 2.2; color: var(--accent); flex: none; }
.row-progress { height: 3px; border-radius: 2px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.row-progress span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.row .icon-btn { width: 36px; height: 36px; flex: none; }
.row.done .row-title { color: var(--ink-3); }

.art {
  flex: none; object-fit: cover; background: var(--surface-2);
  border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line);
}
.art.sm { width: 44px; height: 44px; border-radius: 8px; }
.art.md { width: 56px; height: 56px; }
.art.lg { width: 96px; height: 96px; border-radius: 14px; }
.art.xl { width: min(72vw, 320px); aspect-ratio: 1; height: auto; border-radius: 18px; box-shadow: var(--shadow); }
.art.blank { display: grid; place-items: center; color: var(--ink-3); }

.empty { text-align: center; padding: 60px 32px 20px; color: var(--ink-2); }
.empty h2 { font: 500 24px/1.25 var(--serif); color: var(--ink); margin: 18px 0 8px; }
.empty p { margin: 0 auto 22px; max-width: 300px; font-size: 15px; }
.empty .glyph { width: 64px; height: 64px; color: var(--accent); stroke-width: 1.3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 23px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  transition: transform .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btn svg { width: 18px; height: 18px; }

.suggest {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border-radius: 18px; padding: 12px; box-shadow: var(--shadow);
}
.suggest .row-text { flex: 1; }
.suggest .tag { font-size: 13px; color: var(--accent); font-weight: 600; }

/* Shows grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 14px; padding: 4px 20px; }
.tile { text-align: left; }
.tile .art { width: 100%; aspect-ratio: 1; height: auto; border-radius: 14px; box-shadow: var(--shadow); }
.tile-title { font: 500 15px/1.25 var(--serif); margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* Mini player */
.mini {
  position: fixed; z-index: 10; left: 10px; right: 10px;
  bottom: calc(66px + var(--sb));
  max-width: 620px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4);
  border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.mini-hit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.mini-text { min-width: 0; }
.mini-title { font: 500 15px/1.25 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .icon-btn { color: var(--ink); }
.mini .icon-btn svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.mini-progress span { display: block; height: 100%; width: 0; background: var(--accent); }

/* Tabs */
.tabs {
  position: fixed; z-index: 9; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 56px;
  padding: 8px 0 calc(var(--sb) + 8px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--ink-3); min-width: 64px; }
.tabs button.on { color: var(--accent); }

/* Sheets */
.scrim {
  position: fixed; inset: 0; z-index: 20; background: rgba(20, 12, 5, .35);
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  transform: translateY(105%); transition: transform .38s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.sheet.on { transform: none; }
.sheet.panel { max-height: calc(100% - var(--st) - 24px); }
.sheet.player { top: 0; border-radius: 0; z-index: 25; padding-top: var(--st); }
#sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 20px calc(var(--sb) + 24px); }
.grabber { display: grid; place-items: center; height: 26px; flex: none; cursor: grab; touch-action: none; }
.grabber span { width: 38px; height: 5px; border-radius: 3px; background: var(--ink-3); opacity: .4; }
.sheet h3 { font: 600 24px/1.2 var(--serif); margin: 6px 0 16px; }
.sheet .hint { color: var(--ink-3); font-size: 13px; margin: 8px 2px 0; }

.field {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: 14px; padding: 4px 4px 4px 14px; box-shadow: inset 0 0 0 1px var(--line);
}
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; height: 44px; font-size: 16px; }
.field .btn { height: 40px; padding: 0 16px; border-radius: 11px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.show-head { display: flex; gap: 16px; align-items: center; margin: 4px 0 16px; }
.show-head h3 { margin: 0 0 4px; font-size: 22px; }
.show-head .row-sub { white-space: normal; }
.show-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.show-actions .btn { height: 38px; font-size: 14px; padding: 0 14px; }
.sheet .list { margin: 0 -8px; }

.menu { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.menu button { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-radius: 12px; text-align: left; font-size: 16px; }
.menu button:active { background: var(--surface-2); }
.menu button.danger { color: #c4402f; }
.menu button.on { color: var(--accent); font-weight: 600; }
.menu .menu-title { font: 500 17px/1.3 var(--serif); padding: 4px 6px 10px; color: var(--ink-2); }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting div small { display: block; color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 10px 0 6px; }
.meter span { display: block; height: 100%; background: var(--accent); }

/* Full player */
.player-body {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center;
  padding: 12px 28px calc(var(--sb) + 24px);
}
.p-meta { text-align: center; margin: 28px 0 8px; width: 100%; }
.p-show { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.p-title { font: 500 24px/1.25 var(--serif); margin: 8px 0 0; letter-spacing: -0.005em; }
.scrub { width: 100%; margin-top: 22px; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 4px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0;
  --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--surface-2) var(--p));
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; margin-top: -6px;
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); }

.controls { display: flex; align-items: center; justify-content: center; gap: 36px; margin: 18px 0 10px; }
.icon-btn.lg { width: 56px; height: 56px; position: relative; color: var(--ink); }
.icon-btn.lg svg { width: 34px; height: 34px; stroke-width: 1.5; }
.icon-btn.lg b { position: absolute; font-size: 10px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -38%); }
.play-btn {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px var(--accent-soft);
  transition: transform .15s ease;
}
.play-btn:active { transform: scale(.94); }
.play-btn svg { width: 32px; height: 32px; fill: currentColor; stroke: none; }
.p-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px;
  background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.pill svg { width: 16px; height: 16px; }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.p-desc { margin-top: 28px; width: 100%; color: var(--ink-2); font: 16px/1.6 var(--serif); white-space: pre-line; overflow-wrap: anywhere; }

/* Search */
.search-bar { margin: 4px 20px 6px; }
.search-bar svg { color: var(--ink-3); flex: none; width: 18px; height: 18px; }
.search-bar input::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }
.search-hint { padding: 18px 24px 10px; color: var(--ink-2); font-size: 15px; }
.search-hint p { margin: 0 0 6px; }
.search-hint b { color: var(--ink); font-weight: 600; }
.row-source {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px;
}
.searching { display: grid; place-items: center; padding: 22px; color: var(--ink-3); }
.none { color: var(--ink-3); font-size: 14px; margin: 4px 20px 8px; }
.follow-tag { font-size: 14px; font-weight: 600; color: var(--accent); padding: 0 8px; flex: none; }
a.btn, a.pill { text-decoration: none; }

.toast {
  position: fixed; z-index: 50; left: 50%; top: calc(var(--st) + 12px);
  transform: translate(-50%, -150%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 500;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.toast.on { transform: translate(-50%, 0); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ring { position: relative; width: 36px; height: 36px; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 36px; height: 36px; transform: rotate(-90deg); }
.ring circle { stroke-width: 2.5; }
