:root {
  --bg: #e9eef5;
  --bg-accent: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent-red: #ef4444;
  --accent-cyan: #0284c7;
  --chip: #e2e8f0;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
}

html[data-theme="night"] {
  --bg: #0b1220;
  --bg-accent: #0f172a;
  --surface: #0f172a;
  --surface-muted: #111827;
  --border: #1f2937;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent-red: #ef4444;
  --accent-cyan: #22d3ee;
  --chip: #111827;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.6);
}

body.local-theme {
  --bg: #f2f4f7;
  --bg-accent: #f7f9fc;
  --surface: #ffffff;
  --surface-muted: #ffffff;
  --border: #d9e0e8;
  --text: #243041;
  --text-muted: #5b6778;
  --accent-red: #3b82f6;
  --accent-cyan: #3b82f6;
  --chip: #eef2f7;
  --shadow: 0 16px 40px rgba(36, 48, 65, 0.08);
  background: #f2f4f7;
}

body.local-theme a {
  color: var(--accent-cyan);
}

body.local-theme a:hover {
  color: #2f6fe0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, var(--bg-accent), var(--bg));
  min-height: 100vh;
}

h2,
h3 {
  margin: 0;
  font-family: "Newsreader", serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: static;
}

.brand-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.1;
  display: block;
  transition: color 0.3s ease;
}

.brand-sub {
  font-size: 13px;
  color: currentColor;
  opacity: 0.7;
  transition: color 0.3s ease;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: #2563eb;
  text-shadow: 0 2px 12px rgba(59, 130, 246, 0.35);
  animation: brandSlide 11.5s ease-in-out infinite, brandHue 13s linear infinite;
  will-change: transform, filter, color;
}

.brand-text {
  display: flex;
  flex-direction: column;
}


.brand:hover .brand-title,
.brand:hover .brand-sub {
  color: var(--accent-cyan);
}

@keyframes brandSlide {
  0% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(var(--brand-shift, 0px));
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes brandHue {
  0% {
    filter: hue-rotate(0deg) saturate(180%) brightness(115%);
  }
  50% {
    filter: hue-rotate(180deg) saturate(200%) brightness(125%);
  }
  100% {
    filter: hue-rotate(360deg) saturate(180%) brightness(115%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand {
    animation: none;
  }
}

.sections {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.category-bar {
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface-muted);
}

.section-link {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.section-link:hover,
.section-link.active {
  color: var(--text);
  border-bottom-color: var(--accent-cyan);
}

.controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.segmented {
  display: inline-flex;
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.seg {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.seg.active {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.seg:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layout {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 24px;
  padding: 24px 32px 40px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.feed-header {
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}

.feed-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feed-subnote {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.feed-section {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.feed-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.feed-section-count {
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  color: var(--text-muted);
}

.feed-section-list {
  display: grid;
  gap: 12px;
}

.tag {
  background: var(--chip);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.update-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface-muted);
  font-size: 12px;
  color: var(--text);
}

.story-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.story-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-muted);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.story-rank {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-red);
}

.story-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.score-pill {
  background: var(--accent-cyan);
  color: #00111f;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.news-feed .feed {
  display: grid;
  gap: 12px;
}

.feed-item {
  background: var(--surface-muted);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.feed-title {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.35;
}

.feed-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.rail {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel-note {
  font-size: 12px;
  color: var(--text-muted);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
}

.btn.primary {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

.btn.ghost {
  background: transparent;
}

.local-input {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.local-input input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

.local-display {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.local-suggestions {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

.local-suggestion {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}

.local-suggestion strong {
  display: block;
  font-size: 12px;
  color: var(--text);
}

.local-suggestion span {
  color: var(--text-muted);
  font-size: 11px;
}

.local-feed {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.local-item {
  background: var(--surface-muted);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px 12px;
}

.local-item a {
  color: inherit;
  text-decoration: none;
}

.local-item a:hover {
  text-decoration: underline;
}

.local-summary {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.local-status {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.local-deep {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.local-deep .btn {
  justify-self: start;
}

.local-deep-note {
  font-size: 11px;
  color: var(--text-muted);
}

.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.local-page {
  max-width: 1080px;
  margin: 24px auto 48px;
  padding: 0 32px;
  display: grid;
  gap: 20px;
}

.local-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.local-page-controls {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.local-page-controls .btn {
  justify-self: start;
}

.community-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.community-preview {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 10px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px 32px;
  font-size: 12px;
  color: var(--text-muted);
}

.consent-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.consent-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.consent-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 24px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow);
}

.consent-note {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--surface-muted);
  font-size: 12px;
  margin-top: 12px;
}

.consent-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.consent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.consent-row h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.consent-row p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.consent-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.consent-footnote {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 2px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--accent-cyan);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

@media (max-width: 980px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-wrap: wrap;
  }
}
