/* ═══════════════════════════════════════════════════════════
   AI Digest — Design System
   Inspired by Ramotion / Borea AI visual identity
   Aurora gradients · Deep navy · Electric blue · Premium
   ═══════════════════════════════════════════════════════════ */

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens — DARK (default) ──────────────────────── */
:root,
[data-theme="dark"] {
  --bg:           #070d1a;
  --bg-alt:       #0a1220;
  --surface:      #0d1629;
  --surface-2:    #112040;
  --surface-3:    #162a50;
  --border:       #1a2d50;
  --border-light: #233a65;

  --accent:       #3b7fff;
  --accent-glow:  rgba(59, 127, 255, 0.18);
  --accent-hover: #5a93ff;
  --aurora-1:     #00c4b4;
  --aurora-2:     #7c5df5;
  --aurora-3:     #3b7fff;

  --text:         #e8edf8;
  --text-2:       #a8b8d8;
  --muted:        #6b7fa8;
  --muted-2:      #4a5a7a;

  --green:        #00d4a0;
  --green-bg:     rgba(0, 212, 160, 0.1);
  --green-border: rgba(0, 212, 160, 0.3);
  --red:          #ff4d6a;
  --red-bg:       rgba(255, 77, 106, 0.1);
  --red-border:   rgba(255, 77, 106, 0.3);
  --yellow:       #ffd060;

  --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
  --shadow-md:    0 4px 16px rgba(0,0,0,.5);
  --shadow-glow:  0 0 24px rgba(59, 127, 255, 0.15);
  --radius:       10px;
  --radius-sm:    6px;
}

/* ── Design tokens — LIGHT ────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f0f4fc;
  --bg-alt:       #e8eef9;
  --surface:      #ffffff;
  --surface-2:    #f5f8ff;
  --surface-3:    #eaf0fb;
  --border:       #d4dff5;
  --border-light: #e2eafc;

  --accent:       #2563eb;
  --accent-glow:  rgba(37, 99, 235, 0.12);
  --accent-hover: #1d4ed8;
  --aurora-1:     #0891b2;
  --aurora-2:     #7c3aed;
  --aurora-3:     #2563eb;

  --text:         #0f172a;
  --text-2:       #334155;
  --muted:        #64748b;
  --muted-2:      #94a3b8;

  --green:        #059669;
  --green-bg:     rgba(5, 150, 105, 0.08);
  --green-border: rgba(5, 150, 105, 0.25);
  --red:          #dc2626;
  --red-bg:       rgba(220, 38, 38, 0.08);
  --red-border:   rgba(220, 38, 38, 0.25);
  --yellow:       #d97706;

  --shadow-sm:    0 1px 3px rgba(15,23,42,.08);
  --shadow-md:    0 4px 16px rgba(15,23,42,.12);
  --shadow-glow:  0 0 24px rgba(37, 99, 235, 0.08);
  --radius:       10px;
  --radius-sm:    6px;
}

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

/* Aurora background decoration — dark only */
[data-theme="dark"] body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 40% at 10% 0%, rgba(59,127,255,.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 5%, rgba(0,196,180,.05) 0%, transparent 55%),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(124,93,245,.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

/* ── NAV ──────────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] nav {
  background: rgba(13, 22, 41, 0.88);
}

.nav-brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -.01em;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: linear-gradient(135deg, var(--aurora-3), var(--aurora-1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-link {
  font-size: .82rem;
  color: var(--muted);
  white-space: nowrap;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

.nav-user {
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}

.admin-badge {
  font-size: .68rem;
  font-style: normal;
  font-weight: 600;
  color: var(--yellow);
  background: rgba(255, 208, 96, .12);
  border: 1px solid rgba(255, 208, 96, .25);
  padding: .1rem .4rem;
  border-radius: 4px;
  letter-spacing: .02em;
}

.btn-nav-logout {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .82rem;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.btn-nav-logout:hover { color: var(--red); background: var(--red-bg); }

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle {
  width: 36px;
  height: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background .25s, border-color .25s;
  flex-shrink: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .25s, background .25s;
}
[data-theme="light"] .theme-toggle { background: var(--accent); border-color: var(--accent); }
[data-theme="light"] .theme-toggle::after { transform: translateX(16px); background: white; }
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: var(--muted);
}

/* ── TAB BAR ──────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: .25rem;
  padding: .5rem 2rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 53px;
  z-index: 100;
}
.tab-bar::-webkit-scrollbar { height: 3px; }
.tab-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--muted);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.tab.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-color: rgba(59, 127, 255, .25);
  font-weight: 500;
}
[data-theme="light"] .tab.active { border-color: rgba(37, 99, 235, .2); }

.tab-close {
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: .9rem;
  padding: 0;
  margin-left: .1rem;
  border-radius: 3px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.tab:hover .tab-close { color: var(--muted-2); }
.tab-close:hover { color: var(--red) !important; background: var(--red-bg); }

/* ── LAYOUT ───────────────────────────────────────────────── */
main { max-width: 880px; margin: 0 auto; padding: 2.5rem 1.5rem; }

.flash {
  padding: .8rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: .87rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.flash-error   { background: var(--red-bg);   border: 1px solid var(--red-border);   color: var(--red); }
.flash-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }

.empty-state {
  text-align: center;
  padding: 5rem 0;
  color: var(--muted);
}
.empty-state p:first-child { font-size: 2rem; margin-bottom: 1rem; }
.empty-state code {
  font-size: .8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .2rem .5rem;
  border-radius: 4px;
  color: var(--aurora-1);
}

/* ── FETCH GROUP ──────────────────────────────────────────── */
.fetch-group { margin-bottom: 3.5rem; }

.fetch-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}
.fetch-date {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}
.fetch-meta { font-size: .78rem; color: var(--muted); }

/* ── THEME CARD ───────────────────────────────────────────── */
.theme-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.6rem;
  margin-bottom: 1rem;
  transition: border-color .2s, box-shadow .2s, transform .15s;
  box-shadow: var(--shadow-sm);
}
.theme-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transform: translateY(-1px);
}

.theme-header {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  margin-bottom: .7rem;
}

/* Vote score pill */
.vote-score {
  min-width: 2.6rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  padding: .22rem .5rem;
  border-radius: 20px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  transition: color .2s, background .2s, border-color .2s;
}
.vote-score.pos {
  color: var(--green);
  background: var(--green-bg);
  border-color: var(--green-border);
}
.vote-score.neg {
  color: var(--red);
  background: var(--red-bg);
  border-color: var(--red-border);
}

.theme-title {
  flex: 1;
  font-size: .97rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  letter-spacing: -.01em;
}

.vote-controls { display: flex; gap: .3rem; flex-shrink: 0; }
.btn-vote {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-vote:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-vote.active-up {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}
.btn-vote.active-down {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
}

.theme-summary {
  font-size: .87rem;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 1rem;
}

/* ── SOURCES ──────────────────────────────────────────────── */
.sources-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .77rem;
  color: var(--muted);
  padding: .2rem 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  transition: color .15s;
  margin-bottom: .4rem;
}
.sources-toggle:hover { color: var(--accent); }

.sources-list {
  display: none;
  list-style: none;
  padding: .5rem 0 .5rem .85rem;
  border-left: 2px solid var(--border);
  margin-bottom: .5rem;
}
.sources-list.open { display: block; }
.sources-list li { margin: .28rem 0; }
.sources-list a {
  font-size: .79rem;
  color: var(--aurora-1);
  transition: color .15s;
}
.sources-list a:hover { color: var(--accent); }
.src-label { font-size: .71rem; color: var(--muted-2); margin-left: .35rem; }

/* ── DETAILED SUMMARY ─────────────────────────────────────── */
.btn-detail {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .77rem;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  padding: .3rem .8rem;
  cursor: pointer;
  margin-top: .4rem;
  transition: background .15s, box-shadow .15s;
}
.btn-detail:hover { background: rgba(0, 212, 160, .18); box-shadow: 0 0 12px rgba(0,212,160,.12); }
.btn-detail:disabled { opacity: .5; cursor: wait; }

.detail-box {
  display: none;
  margin-top: .85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  font-size: .85rem;
  color: var(--text-2);
}
.detail-box.open { display: block; }
.detail-box ul { padding-left: 1.1rem; }
.detail-box li { margin: .38rem 0; line-height: 1.55; }

.spinner { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AUTH ─────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* Aurora background for login page */
[data-theme="dark"] .auth-wrap::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 20% 30%, rgba(59,127,255,.1) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 80% 70%, rgba(0,196,180,.07) 0%, transparent 55%);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

[data-theme="dark"] .auth-card {
  box-shadow: var(--shadow-md), 0 0 60px rgba(59,127,255,.06);
}

.auth-logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--aurora-3), var(--aurora-1));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .3rem;
}

.auth-tagline {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.auth-divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .4rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

input[type=text],
input[type=password] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: .7rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: .5rem;
  letter-spacing: .01em;
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(59,127,255,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.auth-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .82rem;
  color: var(--muted);
}
.auth-link a { color: var(--accent); font-weight: 500; }

/* ── SETTINGS ─────────────────────────────────────────────── */
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 2rem;
}

.settings-section { margin-bottom: 2.5rem; }

.settings-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}

.topic-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  transition: border-color .15s, box-shadow .15s;
}
.topic-row:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }

.topic-icon { font-size: 1.2rem; width: 1.8rem; text-align: center; flex-shrink: 0; }
.topic-name { flex: 1; font-size: .9rem; font-weight: 500; color: var(--text); }
.topic-status { font-size: .75rem; color: var(--muted); margin-right: .5rem; }

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-icon:disabled { opacity: .3; cursor: default; }
.btn-show {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-bg);
  font-size: .74rem;
  width: auto;
  padding: 0 .7rem;
}

.hint { color: var(--muted); font-size: .8rem; margin-top: 1rem; line-height: 1.5; }

/* ── ADMIN ────────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  margin-top: 1rem;
}
.admin-table th {
  text-align: left;
  padding: .6rem .85rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.admin-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
.admin-table tr:hover td { background: var(--surface-2); }

.badge-admin {
  font-size: .72rem;
  font-weight: 600;
  color: var(--yellow);
  background: rgba(255, 208, 96, .12);
  border: 1px solid rgba(255, 208, 96, .25);
  padding: .15rem .45rem;
  border-radius: 4px;
}
.badge-user {
  font-size: .72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .15rem .45rem;
  border-radius: 4px;
}

.btn-sm { font-size: .75rem; padding: .25rem .6rem; border-radius: 4px; cursor: pointer; border: none; }
.btn-danger  { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border);   }
.btn-promote { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.btn-filter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-size: .78rem;
  padding: .3rem .85rem;
  transition: all .15s;
}
.btn-filter:hover { border-color: var(--accent); color: var(--accent); }
.btn-filter.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

/* ── Theme actions ────────────────────────────────────────── */
.theme-actions {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex-shrink: 0;
  margin-left: auto;
}
.btn-status {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-status:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-favorite.active { color: var(--yellow); border-color: rgba(255,208,96,.4); background: rgba(255,208,96,.1); }
.btn-read.active    { color: var(--green);  border-color: var(--green-border); background: var(--green-bg); }
.btn-hide:hover     { color: var(--red);    border-color: var(--red-border);   background: var(--red-bg); }

/* ── Status badge ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .71rem;
  padding: .15rem .5rem;
  border-radius: 10px;
  margin-bottom: .6rem;
  font-weight: 500;
}
.status-read     { color: var(--green);  background: var(--green-bg); border: 1px solid var(--green-border); }
.status-favorite { color: var(--yellow); background: rgba(255,208,96,.1); border: 1px solid rgba(255,208,96,.3); }
.status-hidden   { color: var(--muted);  background: var(--surface-2); border: 1px solid var(--border); }

/* ── Hidden cards ─────────────────────────────────────────── */
.theme-card[data-status="hidden"] { opacity: .45; }
.theme-card.filter-hidden { display: none; }

/* ── Feed manager ─────────────────────────────────────────── */
.feed-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
  cursor: default;
}
.feed-status--ok      { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.feed-status--error   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }
.feed-status--unknown { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.feed-row { gap: .6rem; }
.feed-type-badge {
  font-size: .68rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: .1rem .45rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.feed-url {
  flex: 1;
  font-size: .73rem;
  color: var(--muted-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.btn-toggle-on  { border-color: var(--green-border); color: var(--green); background: var(--green-bg); }
.btn-toggle-off { border-color: var(--border); color: var(--muted); }
.add-feed-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.add-feed-row .form-group { margin-bottom: 0; }
