:root {
  --bg: #f8fafc; --surface: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-soft: #dbeafe; --chip: #f1f5f9;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --surface: #111827; --text: #e5e7eb; --muted: #94a3b8; --line: #1f2937;
          --accent: #60a5fa; --accent-soft: #1e3a5f; --chip: #1f2937; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       padding-bottom: calc(56px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }
button, select { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 2; background: color-mix(in srgb, var(--bg) 92%, transparent);
       backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
       padding: calc(env(safe-area-inset-top) + 8px) 16px 10px; }
.title-row { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; }
h1 { font-size: 28px; margin: 4px 0 8px; letter-spacing: -0.02em; }
.icon-btn { background: none; border: 0; font-size: 24px; padding: 6px 10px; cursor: pointer; color: var(--accent); }
.icon-btn.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs, .regions { display: flex; gap: 6px; max-width: 760px; margin: 0 auto; }
.tabs { background: var(--chip); padding: 3px; border-radius: 10px; }
.tabs button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.regions { margin-top: 8px; }
.regions button { flex: 1; border: 1px solid var(--line); background: var(--surface); padding: 6px; border-radius: 999px; cursor: pointer; font-size: 14px; }
.regions button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px; }
.story { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.headline { color: var(--text); text-decoration: none; font-weight: 650; font-size: 17px; line-height: 1.3; display: block; }
.headline:active { opacity: 0.6; }
.summary { color: var(--muted); font-size: 14.5px; margin: 6px 0 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.summary:empty { display: none; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.meta a { background: var(--chip); color: var(--muted); padding: 2px 8px; border-radius: 999px; text-decoration: none; }
.badge { background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.empty, .error { text-align: center; color: var(--muted); padding: 40px 12px; }

.foot { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
        padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
        font-size: 13px; color: var(--muted); }
.foot select { background: var(--chip); border: 0; border-radius: 8px; padding: 4px 8px; }

.login { max-width: 420px; margin: 40px auto; padding: 0 16px; }
.login h2 { font-size: 24px; margin: 0 0 6px; }
.login .hint { color: var(--muted); margin: 0 0 16px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login input { font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.login button[type="submit"] { font-size: 17px; font-weight: 600; padding: 12px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer; }
.login button:disabled { opacity: 0.6; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; font-size: 14px; }
.login .msg { color: var(--muted); min-height: 1.4em; }
