/* ============================================================
   Cyber Brief — themes
   Set <html data-theme="dark|light|sepia|ocean|solar|system">
   Specificity: html[data-theme="..."] = (0,1,1) beats :root = (0,1,0),
   so any theme always overrides the default.
   ============================================================ */

/* Default theme (when no data-theme is set, or for caching fallback) */
:root {
  --bg: #010409;
  --bg-elev: #0d1117;
  --bg-elev-2: #161b22;
  --border: #30363d;
  --text: #f0f6fc;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-strong: #1f6feb;
  --green: #3fb950;
  --green-bg: rgba(63,185,80,.15);
  --red: #f85149;
  --red-bg: rgba(248,81,73,.15);
  --hero-gradient: linear-gradient(90deg, #f0f6fc 0%, #58a6ff 100%);
  --btn-text: #0d1117;
}

html[data-theme="dark"] {
  --bg: #010409;
  --bg-elev: #0d1117;
  --bg-elev-2: #161b22;
  --border: #30363d;
  --text: #f0f6fc;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-strong: #1f6feb;
  --green: #3fb950;
  --green-bg: rgba(63,185,80,.15);
  --red: #f85149;
  --red-bg: rgba(248,81,73,.15);
  --hero-gradient: linear-gradient(90deg, #f0f6fc 0%, #58a6ff 100%);
  --btn-text: #0d1117;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --bg-elev-2: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #59636e;
  --accent: #0969da;
  --accent-strong: #0550ae;
  --green: #1a7f37;
  --green-bg: rgba(26,127,55,.15);
  --red: #cf222e;
  --red-bg: rgba(207,34,46,.15);
  --hero-gradient: linear-gradient(90deg, #1f2328 0%, #0969da 100%);
  --btn-text: #ffffff;
}

html[data-theme="sepia"] {
  --bg: #f4ecd8;
  --bg-elev: #e8dfc4;
  --bg-elev-2: #ddd2b0;
  --border: #b8a87e;
  --text: #3a2f24;
  --text-muted: #6b5d4f;
  --accent: #a0522d;
  --accent-strong: #8b4513;
  --green: #4a7c2c;
  --green-bg: rgba(74,124,44,.15);
  --red: #a83838;
  --red-bg: rgba(168,56,56,.15);
  --hero-gradient: linear-gradient(90deg, #3a2f24 0%, #a0522d 100%);
  --btn-text: #f4ecd8;
}

html[data-theme="ocean"] {
  --bg: #0a1929;
  --bg-elev: #0f2942;
  --bg-elev-2: #14375a;
  --border: #1e4870;
  --text: #e1f0ff;
  --text-muted: #88aacc;
  --accent: #4fc3f7;
  --accent-strong: #29b6f6;
  --green: #4dd0e1;
  --green-bg: rgba(77,208,225,.15);
  --red: #ff5252;
  --red-bg: rgba(255,82,82,.15);
  --hero-gradient: linear-gradient(90deg, #e1f0ff 0%, #4fc3f7 100%);
  --btn-text: #0a1929;
}

html[data-theme="solar"] {
  --bg: #1a1410;
  --bg-elev: #2a1f18;
  --bg-elev-2: #3a2b21;
  --border: #5a4232;
  --text: #f5e6d3;
  --text-muted: #b89880;
  --accent: #ffb74d;
  --accent-strong: #ff9800;
  --green: #aed581;
  --green-bg: rgba(174,213,129,.15);
  --red: #ff8a65;
  --red-bg: rgba(255,138,101,.15);
  --hero-gradient: linear-gradient(90deg, #f5e6d3 0%, #ffb74d 100%);
  --btn-text: #1a1410;
}

html[data-theme="system"] {
  --bg: #010409;
  --bg-elev: #0d1117;
  --bg-elev-2: #161b22;
  --border: #30363d;
  --text: #f0f6fc;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-strong: #1f6feb;
  --green: #3fb950;
  --green-bg: rgba(63,185,80,.15);
  --red: #f85149;
  --red-bg: rgba(248,81,73,.15);
  --hero-gradient: linear-gradient(90deg, #f0f6fc 0%, #58a6ff 100%);
  --btn-text: #0d1117;
}

@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    --bg: #ffffff;
    --bg-elev: #f6f8fa;
    --bg-elev-2: #eaeef2;
    --border: #d0d7de;
    --text: #1f2328;
    --text-muted: #59636e;
    --accent: #0969da;
    --accent-strong: #0550ae;
    --green: #1a7f37;
    --green-bg: rgba(26,127,55,.15);
    --red: #cf222e;
    --red-bg: rgba(207,34,46,.15);
    --hero-gradient: linear-gradient(90deg, #1f2328 0%, #0969da 100%);
    --btn-text: #ffffff;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Topbar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.topbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand-mark {
  font-size: 22px;
  filter: hue-rotate(60deg);
}
.topbar nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--text-muted); font-size: 14px; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar nav a.cta {
  background: var(--accent-strong);
  color: white;
  padding: 6px 14px;
  border-radius: 8px;
}
.topbar nav a.cta:hover { background: var(--accent); }

.theme-picker {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 13px;
  cursor: pointer;
}
.theme-picker:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Hero */
.hero {
  padding: 60px 0 40px 0;
  text-align: center;
}
.eyebrow {
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 14px 0;
}
.hero h1 {
  font-size: 38px;
  line-height: 1.15;
  margin: 0 0 18px 0;
  font-weight: 700;
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 32px auto;
}

.subscribe-form {
  display: flex;
  gap: 8px;
  max-width: 460px;
  margin: 0 auto 16px auto;
  flex-wrap: wrap;
}
.subscribe-form input[type=email] {
  flex: 1 1 240px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 15px;
  min-width: 200px;
}
.subscribe-form input[type=email]:focus {
  outline: none;
  border-color: var(--accent);
}
.subscribe-form button {
  padding: 12px 22px;
  background: var(--green);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.subscribe-form button:hover { filter: brightness(1.1); }

.honeypot {
  position: absolute !important;
  left: -9999px !important;
  height: 1px;
  width: 1px;
  opacity: 0;
}

.alert {
  max-width: 460px;
  margin: 0 auto 24px auto;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}
.alert.success {
  background: var(--green-bg);
  border: 1px solid var(--green);
  color: var(--text);
}

.small { font-size: 13px; }
.muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 40px 0;
  padding: 30px 0;
  border-top: 1px solid var(--border);
}
.feature h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 12px 0;
}
.feature ul {
  margin: 0;
  padding-left: 22px;
  font-size: 15px;
}
.feature ul li { margin: 6px 0; }

@media (max-width: 640px) {
  .hero h1 { font-size: 28px; }
  .features { grid-template-columns: 1fr; }
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
  margin-top: 40px;
  color: var(--text-muted);
  font-size: 13px;
}
.footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* Archive */
.archive-list {
  list-style: none;
  padding: 0;
  margin: 30px 0;
}
.archive-list li {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.archive-list a {
  font-weight: 600;
  font-size: 16px;
}

/* Privacy */
.prose {
  max-width: 720px;
  margin: 40px auto;
  font-size: 15px;
  line-height: 1.7;
}
.prose h1 { margin-top: 0; font-size: 32px; }
.prose h2 { margin-top: 32px; font-size: 20px; }
.prose ul { padding-left: 22px; }
.prose code { background: var(--bg-elev-2); padding: 1px 6px; border-radius: 4px; }

/* Daily issue page */
.daily-issue { max-width: 720px; margin: 30px auto; }
.daily-issue h1 { font-size: 28px; }
.daily-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin: 16px 0;
}
.daily-item .meta {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.daily-item .meta .cat { color: var(--accent); }
.daily-item h2 { margin: 0 0 8px 0; font-size: 18px; line-height: 1.3; }
.daily-item h2 a { color: var(--text); }
.daily-item h2 a:hover { color: var(--accent); }
.daily-item .summary { color: var(--text-muted); font-size: 14px; margin: 0; line-height: 1.5; }

/* Admin */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.admin-side {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
}
.admin-side h2 { font-size: 18px; margin: 0 0 18px 0; }
.admin-side nav { display: flex; flex-direction: column; gap: 4px; }
.admin-side nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
}
.admin-side nav a:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.admin-main { padding: 30px; }
.admin-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  margin: 0 0 16px 0;
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-size: 11px; font-weight: 600; }
.btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--accent-strong);
  color: white;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--accent); }
.btn.secondary { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); color: white; }
.btn.danger:hover { filter: brightness(1.1); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 0 0 24px 0;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0 16px 0;
}
.theme-card {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease;
}
.theme-card:hover { border-color: var(--accent); }
.theme-card.active { border-color: var(--accent-strong); box-shadow: 0 0 0 2px var(--accent); }
.theme-card .swatch {
  display: block;
  height: 36px;
  border-radius: 4px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.theme-card .name {
  font-size: 13px;
  font-weight: 600;
}
.theme-card .desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.theme-card input[type=radio] {
  position: absolute; opacity: 0; pointer-events: none;
}