:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1c1d20;
  --muted: #6b6d74;
  --line: #e3e1dc;
  --accent: #c2410c;
  --accent-text: #ffffff;
  --soft: #f1ede6;
  --danger: #b42318;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --card: #202226;
    --text: #ecebe8;
    --muted: #9a9ca3;
    --line: #2f3137;
    --accent: #fb923c;
    --accent-text: #1b1206;
    --soft: #2a2c31;
    --danger: #f97066;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.clamp1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(var(--dock-h, 80px) + 24px);
}
h1 { font-size: 28px; margin: 8px 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }

.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bar .grow { flex: 1; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 8px 14px; min-height: 40px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; min-height: 34px;
}
input[type=text], input[type=search], input[type=password], input[type=url], select {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; min-height: 40px;
  font-size: 16px; /* stops iOS zooming on focus */
  max-width: 100%;
}
input[type=text], input[type=search], input[type=password], input[type=url] { width: 100%; }

.notice { background: var(--soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.notice.error { color: var(--danger); }

/* Lists */
.list { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; gap: 12px; padding: 10px 12px; align-items: center; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .art { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; background: var(--soft); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { font-size: 13px; color: var(--muted); }
.row.current { background: var(--soft); }
.row.done .title { color: var(--muted); font-weight: 400; }
.acts { display: flex; gap: 6px; flex: none; }
.ib {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; font-size: 16px; padding: 0;
}
.ib.play { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); margin-left: 4px; }
.tag.part { background: var(--accent); color: var(--accent-text); }
.link { background: none; border: 0; padding: 0; text-align: left; color: inherit; width: 100%; }

.level-head { display: flex; align-items: center; gap: 8px; margin: 22px 0 8px; }
.level-head h2 { margin: 0; flex: 1; }
.level-head input { flex: 1; }
.empty-level { padding: 12px; font-size: 14px; color: var(--muted); }

/* Four buttons per episode: keep room for the title on phones. */
@media (max-width: 420px) {
  .acts { gap: 4px; }
  .ib { width: 34px; height: 34px; font-size: 15px; }
}

.detail-head { display: flex; gap: 14px; align-items: center; margin: 8px 0 12px; }
.detail-head img { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; flex: none; background: var(--soft); }

/* Dock: player + tabs, fixed to the bottom */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#player { max-width: 720px; margin: 0 auto; padding: 10px 16px 4px; }
.p-row { display: flex; gap: 10px; align-items: center; }
#p-art { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--soft); flex: none; }
.p-text { min-width: 0; flex: 1; }
#p-title { font-weight: 600; }
#p-show { font-size: 13px; }
#p-seek { width: 100%; margin: 8px 0 0; accent-color: var(--accent); }
.p-times { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; }
.p-controls { display: flex; justify-content: center; align-items: center; gap: 28px; margin: 2px 0 6px; }
.ctl { background: none; border: 1px solid var(--line); border-radius: 50%; font-size: 15px; font-weight: 700; width: 52px; height: 52px; padding: 0; }
.ctl.play { background: var(--accent); color: var(--accent-text); border-radius: 50%; width: 58px; height: 58px; font-size: 24px; }
.p-extras { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; padding-bottom: 6px; }
.p-extras select { min-height: 34px; padding: 4px 8px; border-radius: 999px; font-size: 14px; }

#tabs { display: flex; max-width: 720px; margin: 0 auto; }
#tabs button {
  flex: 1; background: none; border: 0; padding: 12px 4px; font-size: 14px; color: var(--muted);
  border-top: 2px solid transparent;
}
#tabs button.on { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login form { display: grid; gap: 10px; }

.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; }

.switch { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 0; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.switch input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
