/* ---------- themes ---------- */
:root, [data-theme="neon"] {
  --bg: #05080f; --bg2: #0a1020; --card: rgba(14, 22, 40, .78); --card-b: rgba(34, 229, 255, .16);
  --text: #e6f6ff; --muted: #8aa3b8; --accent: #22e5ff; --accent2: #ff3df2; --accent-ink: #001218;
  --glow: 0 0 0 1px rgba(34,229,255,.25), 0 0 22px rgba(34,229,255,.12);
  --pill: rgba(34,229,255,.1); --pill-b: rgba(34,229,255,.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --head: "Rajdhani", "Orbitron", "Inter", system-ui, sans-serif;
  --c-center: #39ffb0; --c-lean: #ffd166; --c-none: #8aa3b8;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f7f9; --bg2: #ffffff; --card: #ffffff; --card-b: #e3e6eb;
  --text: #15181d; --muted: #5f6b78; --accent: #0a66d9; --accent2: #0a66d9; --accent-ink: #fff;
  --glow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --pill: #eef3fb; --pill-b: #cfdcf0;
  --head: var(--font);
  --c-center: #0f8a5f; --c-lean: #a36a00; --c-none: #6b7480;
  color-scheme: light;
}
[data-theme="sepia"] {
  --bg: #f3ead8; --bg2: #f8f1e3; --card: #fbf5e8; --card-b: #e2d3b5;
  --text: #3b2f22; --muted: #7a6650; --accent: #9c4f1c; --accent2: #9c4f1c; --accent-ink: #fff8ec;
  --glow: 0 1px 2px rgba(80,50,20,.08);
  --pill: #f1e4c9; --pill-b: #dcc59b;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; --head: var(--font);
  --c-center: #4d7a2a; --c-lean: #9c5d12; --c-none: #7a6650;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.45; min-height: 100vh;
}
[data-theme="neon"] body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,61,242,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(34,229,255,.12), transparent 60%),
    linear-gradient(rgba(34,229,255,.035) 1px, transparent 1px) 0 0/100% 32px,
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; padding: max(8px, env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-b);
}
.bar, .controls, .top5, main, .foot { max-width: 1100px; margin-inline: auto; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logo { font-family: var(--head); font-weight: 800; letter-spacing: .12em; text-decoration: none; color: var(--text); font-size: 1.15rem; white-space: nowrap; }
.logo-mark { color: var(--accent); margin-right: 6px; }
.slash { color: var(--accent); }
[data-theme="neon"] .logo { text-shadow: 0 0 14px rgba(34,229,255,.45); }
.themes { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--card-b); border-radius: 999px; background: var(--card); }
.themes button { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 10px; border-radius: 999px; cursor: pointer; font-size: .8rem; color: var(--muted); }
.themes button i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(128,128,128,.5); }
.themes [data-theme-btn="neon"] i { background: #05080f; box-shadow: inset 0 0 0 2px #22e5ff; }
.themes [data-theme-btn="light"] i { background: #fff; }
.themes [data-theme-btn="sepia"] i { background: #f1e4c9; }
.themes button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.controls { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.topic-wrap { flex: 0 0 auto; }
select, .search input {
  height: 40px; border-radius: 10px; border: 1px solid var(--card-b); background: var(--card); padding: 0 12px;
}
select { padding-right: 30px; font-weight: 600; min-width: 150px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
[data-theme="neon"] select, [data-theme="neon"] .search input { box-shadow: var(--glow); }
select option { background: var(--bg2); color: var(--text); }
.search { flex: 1; min-width: 0; }
.search input { width: 100%; }
.saved-link { display: flex; align-items: center; gap: 4px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--card-b); background: var(--card); text-decoration: none; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ---------- top 5 ---------- */
.top5 { padding: 14px 14px 0; }
.top5 h2 { font-family: var(--head); font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.top5 h2 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; font-family: var(--font); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent2); box-shadow: 0 0 10px var(--accent2); }
.top5 ol { list-style: none; margin: 0; padding: 0 0 8px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; }
.top5 li { scroll-snap-align: start; }
.t5 { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--card-b); border-radius: 14px; padding: 10px; cursor: pointer; box-shadow: var(--glow); height: 100%; }
.t5 .rank { font-family: var(--head); font-size: 1.6rem; font-weight: 800; color: var(--accent); line-height: 1; min-width: 20px; }
[data-theme="neon"] .t5 .rank { text-shadow: 0 0 12px rgba(34,229,255,.6); }
.t5 img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg2); }
.t5 b { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: .88rem; line-height: 1.3; }
.t5 small { display: block; color: var(--accent); font-size: .74rem; margin-top: 4px; font-weight: 600; }

/* ---------- list ---------- */
main { padding: 10px 14px 30px; }
.status { color: var(--muted); padding: 30px 4px; text-align: center; }
.heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 8px 2px 6px; }
.heading h1 { font-family: var(--head); font-size: 1.25rem; margin: 0; letter-spacing: .04em; }
.heading span { color: var(--muted); font-size: .8rem; }
.list { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .list { grid-template-columns: 1fr 1fr; } }
.card { background: var(--card); border: 1px solid var(--card-b); border-radius: 16px; padding: 12px; box-shadow: var(--glow); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
[data-theme="neon"] .card:hover { border-color: rgba(34,229,255,.45); }
.story { display: grid; grid-template-columns: 96px 1fr; gap: 12px; text-decoration: none; color: inherit; }
@media (min-width: 600px) { .story { grid-template-columns: 132px 1fr; } }
.thumb { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; background: linear-gradient(135deg, var(--pill), var(--bg2)); display: block; }
@media (min-width: 600px) { .thumb { aspect-ratio: 4 / 3; } }
.thumb.ph { display: grid; place-items: center; color: var(--accent); font-family: var(--head); font-weight: 800; font-size: 1.4rem; letter-spacing: .08em; }
.story h3 { margin: 0 0 4px; font-size: 1.02rem; line-height: 1.28; font-family: var(--head); font-weight: 700; }
[data-theme="neon"] .story h3 { letter-spacing: .01em; }
.story p { margin: 0; color: var(--text); opacity: .86; font-size: .9rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .78rem; color: var(--muted); }
.meta .src { font-weight: 700; color: var(--text); }
.ai { font-size: .7rem; color: var(--accent); border: 1px solid var(--pill-b); border-radius: 6px; padding: 0 5px; }
.bias { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 4px 1px 8px; border: 1px solid var(--pill-b); background: var(--pill); font-size: .72rem; font-weight: 700; cursor: pointer; }
.bias.center { color: var(--c-center); }
.bias.lean { color: var(--c-lean); }
.bias.none { color: var(--c-none); }
.bias .i { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid currentColor; font-size: .62rem; font-style: normal; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--pill-b); background: var(--pill); color: var(--text); border-radius: 10px; padding: 7px 12px; font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 36px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
[data-theme="neon"] .btn.primary { box-shadow: 0 0 16px rgba(34,229,255,.35); }
.btn[aria-pressed="true"] { color: var(--accent2); border-color: var(--accent2); }
.also { border-top: 1px dashed var(--card-b); padding-top: 8px; font-size: .84rem; }
.also summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.also summary::-webkit-details-marker { display: none; }
.also summary::before { content: "▸ "; }
.also[open] summary::before { content: "▾ "; }
.also ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.also li a { color: var(--text); text-decoration: none; }
.also li a:hover { text-decoration: underline; }
.also li .meta { margin-top: 2px; }

/* ---------- popover / sheet / toast ---------- */
.pop { position: fixed; z-index: 50; max-width: min(340px, calc(100vw - 20px)); background: var(--bg2); color: var(--text); border: 1px solid var(--pill-b); border-radius: 12px; padding: 12px 14px; font-size: .84rem; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.pop h4 { margin: 0 0 6px; font-size: .95rem; }
.pop p { margin: 6px 0; }
.pop .row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--card-b); }
.pop .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); }
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--bg2); width: min(720px, 100%); max-height: 86vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px 14px 24px; border: 1px solid var(--card-b); }
@media (min-width: 720px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; } }
.sheet-card h2 { font-family: var(--head); margin: 0 0 10px; font-size: 1.1rem; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .9rem; box-shadow: 0 8px 30px rgba(0,0,0,.3); }

/* ---------- saved / sign-in ---------- */
.panel { background: var(--card); border: 1px solid var(--card-b); border-radius: 16px; padding: 14px; margin-bottom: 12px; font-size: .9rem; }
.panel form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.panel input[type="email"] { flex: 1; min-width: 200px; height: 40px; border-radius: 10px; border: 1px solid var(--card-b); background: var(--bg2); padding: 0 12px; }
.muted { color: var(--muted); }
.foot { padding: 10px 16px 40px; color: var(--muted); font-size: .76rem; }
.foot p { margin: 6px 0; }
.btn.disabled { opacity: .55; cursor: not-allowed; font-weight: 500; }
/* Phones: keep the header inside the screen (shorter logo spacing, icon-only theme buttons). */
@media (max-width: 480px) {
  .logo { font-size: 1rem; letter-spacing: .06em; }
  .themes button { padding: 6px 8px; min-height: 32px; }
  .themes button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .themes button i { width: 16px; height: 16px; }
}
html, body { overflow-x: hidden; }
