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

:root {
  --navy: #0f172a;
  --navy-light: #1e293b;
  --navy-muted: #334155;
  --teal: #0d9488;
  --teal-hover: #0f766e;
  --teal-light: #14b8a6;
  --teal-pale: #ccfbf1;
  --teal-wash: #f0fdfa;
  --warm-white: #fafaf8;
  --warm-50: #f8f7f4;
  --warm-100: #f0efec;
  --warm-200: #e2e0db;
  --warm-300: #c8c5be;
  --warm-400: #9c9890;
  --warm-500: #78716c;
  --warm-600: #57534e;
  --warm-700: #44403c;
  --warm-800: #292524;
  --warm-900: #1c1917;
  --red: #dc2626;
  --red-pale: #fef2f2;
  --red-muted: #fca5a5;
  --amber: #d97706;
  --amber-pale: #fffbeb;
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 6px rgba(15,23,42,0.05), 0 2px 4px rgba(15,23,42,0.03);
  --shadow-lg: 0 10px 15px rgba(15,23,42,0.06), 0 4px 6px rgba(15,23,42,0.03);
  --radius: 8px;
  --radius-lg: 12px;
}

html { font-size: 15px; }
body {
  font-family: var(--font-body);
  color: var(--warm-800);
  background: var(--warm-white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Login Page ────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(13,148,136,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 20%, rgba(13,148,136,0.05) 0%, transparent 40%);
  animation: loginBgShift 20s ease-in-out infinite alternate;
}
@keyframes loginBgShift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-5%, 3%); }
}
.login-card {
  position: relative;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  text-align: center;
}
.login-logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: white;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.login-logo span { color: var(--teal-light); }
.login-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.45);
  margin-bottom: 2.5rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}
.login-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}
.login-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  color: white;
  font-size: 1rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input::placeholder { color: rgba(255,255,255,0.25); }
.login-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}
.login-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.login-btn:hover { background: var(--teal-hover); }
.login-btn:active { transform: scale(0.985); }

.login-sent {
  animation: fadeUp 0.4s ease-out;
}
.login-sent-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(13,148,136,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 1.8rem;
}
.login-sent h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: white;
  margin-bottom: 0.5rem;
}
.login-sent p {
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.login-sent .email-highlight {
  color: var(--teal-light);
  font-weight: 500;
}
.login-open-email {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-body);
}
.login-open-email:hover { background: rgba(255,255,255,0.1); }
.login-expire {
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
}
.login-skip {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.login-skip button {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.15);
  text-underline-offset: 2px;
}
.login-skip button:hover { color: rgba(255,255,255,0.6); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── App Shell ─────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: white;
  padding: 0 1.5rem;
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}
.sidebar-logo span { color: var(--teal-light); }
.sidebar-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  padding: 0 1.5rem;
  margin-bottom: 2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sidebar-switcher { padding: 0 1rem 0.25rem; }
.sidebar-switcher-label {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 0.5rem;
  margin-bottom: 0.35rem;
}
.sidebar-briefing-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.5rem;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: none;
  color: rgba(255,255,255,0.45);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-briefing-btn:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.04);
}
.sidebar-briefing-btn.active {
  color: white;
  background: rgba(13,148,136,0.12);
  border-left-color: var(--teal);
}
.sidebar-nav { flex: 1; }
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: rgba(255,255,255,0.5);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  user-select: none;
}
.sidebar-nav-item:hover {
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.03);
}
.sidebar-nav-item.active {
  color: white;
  background: rgba(13,148,136,0.1);
  border-left-color: var(--teal);
}
.sidebar-nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.8;
}
.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 0.75rem 1.5rem;
}
.sidebar-user {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 2rem 2.5rem;
  min-height: 100vh;
  transition: margin-right 0.3s ease;
}
.main-content.has-preview {
  margin-right: 380px;
}

/* Page header */
.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-header p {
  color: var(--warm-500);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

/* ── Cards ─────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--warm-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.pref-row-2 > .card + .card { margin-top: 0; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
}

/* ── Dashboard ─────────────────────────────────── */
.dash-greeting {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--navy);
  margin-bottom: 0.25rem;
}
.dash-greeting strong { font-weight: 600; }
.dash-date {
  font-size: 0.85rem;
  color: var(--warm-400);
  margin-bottom: 2rem;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: white;
  border: 1px solid var(--warm-200);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warm-400);
  margin-bottom: 0.35rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navy);
}
.stat-value small {
  font-size: 0.65em;
  font-weight: 400;
  color: var(--warm-400);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Quick actions */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.quick-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--warm-50);
  border: 1px solid var(--warm-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--warm-700);
}
.quick-action:hover {
  border-color: var(--teal);
  background: var(--teal-wash);
  color: var(--teal-hover);
}
.quick-action .qa-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.quick-action .qa-arrow {
  margin-left: auto;
  color: var(--warm-300);
  transition: color 0.15s;
}
.quick-action:hover .qa-arrow { color: var(--teal); }

/* Recent briefings */
.recent-list {
  display: flex;
  flex-direction: column;
}
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--warm-100);
  font-size: 0.88rem;
}
.recent-item:last-child { border-bottom: none; }
.recent-date {
  font-weight: 500;
  color: var(--warm-700);
}
.recent-count {
  color: var(--warm-400);
  font-size: 0.8rem;
}
.recent-link {
  color: var(--teal);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.82rem;
}
.recent-link:hover { text-decoration: underline; }

/* ── Topics Page ───────────────────────────────── */
.distribution-bar-wrap {
  margin-bottom: 2rem;
}
.distribution-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warm-400);
  margin-bottom: 0.6rem;
}
.distribution-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--warm-100);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
}
.distribution-bar .seg {
  height: 100%;
  transition: flex-basis 0.3s ease;
  position: relative;
  min-width: 2px;
}
.distribution-bar .seg:first-child { border-radius: 6px 0 0 6px; }
.distribution-bar .seg:last-child { border-radius: 0 6px 6px 0; }
.distribution-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.75rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--warm-500);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Topic cards grid */
.topic-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

/* Topic card */
.topic-card {
  background: white;
  border: 1px solid var(--warm-200);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
  max-width: 480px;
}
.topic-card:hover {
  border-color: var(--warm-300);
  box-shadow: var(--shadow);
}
.topic-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.topic-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
}
.topic-name:hover { opacity: 0.7; }
.topic-name-input {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  width: 100%;
  max-width: 250px;
  outline: none;
}
.topic-name-input:focus { border-color: var(--teal); }
.topic-weight-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-pale);
  padding: 0.15rem 0.6rem;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: center;
}
.topic-slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.topic-slider-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.topic-slider-labels span {
  font-size: 0.68rem;
  color: var(--warm-400);
  letter-spacing: 0.02em;
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  --slider-color: var(--topic-color, var(--teal));
  background: linear-gradient(to right,
    var(--slider-color) 0%,
    var(--slider-color) var(--fill, 50%),
    var(--warm-200) var(--fill, 50%),
    var(--warm-200) 100%
  );
  transition: background 0.1s;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--slider-color, var(--teal));
  box-shadow: var(--shadow);
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
}
input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--slider-color, var(--teal));
  box-shadow: var(--shadow);
  cursor: grab;
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--warm-200);
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--slider-color, var(--teal));
}

.topic-lens {
  font-size: 0.82rem;
  color: var(--warm-500);
  line-height: 1.5;
  padding: 0.5rem 0.65rem;
  background: var(--warm-50);
  border: 1px solid transparent;
  border-radius: 4px;
  width: 100%;
  font-family: var(--font-body);
  resize: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.topic-lens:focus {
  border-color: var(--teal);
  background: white;
}
.topic-remove {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--warm-300);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  opacity: 0;
}
.topic-card:hover .topic-remove { opacity: 1; }
.topic-remove:hover { background: var(--red-pale); color: var(--red); }

.add-topic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem;
  margin-top: 1rem;
  background: var(--warm-50);
  border: 2px dashed var(--warm-200);
  border-radius: var(--radius);
  color: var(--warm-400);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.add-topic-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-wash);
}

.add-topic-form {
  background: var(--teal-wash);
  border: 1px solid var(--teal-pale);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
  animation: fadeUp 0.2s ease-out;
}
.add-topic-form .form-row {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--warm-600);
  margin-bottom: 0.3rem;
  display: block;
}
.form-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--warm-200);
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background: white;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--teal); }
.form-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.btn-sm {
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.btn-sm.primary { background: var(--teal); color: white; }
.btn-sm.primary:hover { background: var(--teal-hover); }
.btn-sm.ghost { background: transparent; color: var(--warm-500); }
.btn-sm.ghost:hover { background: rgba(0,0,0,0.04); }

/* ── Preferences Page ──────────────────────────── */
.pref-section {
  margin-bottom: 1.25rem;
}
.pref-section:last-child {
  margin-bottom: 0;
}
.pref-section-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.35rem;
}
.pref-section-desc {
  font-size: 0.82rem;
  color: var(--warm-400);
  margin-bottom: 1rem;
}

/* Source toggle */
.source-toggles {
  display: flex;
  gap: 0;
  border: 1px solid var(--warm-200);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 1rem;
}
.source-toggle {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: white;
  color: var(--warm-500);
  transition: all 0.15s;
  border-right: 1px solid var(--warm-200);
}
.source-toggle:last-child { border-right: none; }
.source-toggle.active {
  background: var(--teal);
  color: white;
}
.source-toggle:hover:not(.active) {
  background: var(--warm-50);
}

/* Format cards */
.format-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
.format-card {
  padding: 1rem;
  border: 2px solid var(--warm-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  background: white;
}
.format-card:hover { border-color: var(--warm-300); }
.format-card.active {
  border-color: var(--teal);
  background: var(--teal-wash);
}
.format-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--navy);
  margin-bottom: 0.15rem;
}
.format-time {
  font-size: 0.75rem;
  color: var(--warm-400);
  margin-bottom: 0.35rem;
}
.format-stories {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--teal);
  background: var(--teal-pale);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  display: inline-block;
}

/* Format preview */
.format-preview-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warm-400);
  margin-bottom: 0.6rem;
}
.format-preview-story {
  background: var(--warm-50);
  border: 1px solid var(--warm-200);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}
.format-preview-cat {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-bottom: 0.25rem;
}
.format-preview-headline {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
}
.format-preview-source {
  font-size: 0.72rem;
  color: var(--warm-400);
  margin: 0.2rem 0 0.5rem;
}
.format-preview-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
  margin-bottom: 0.2rem;
}
.format-preview-body {
  font-size: 0.82rem;
  color: var(--warm-600);
  line-height: 1.6;
}
.format-preview-perspectives {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--warm-500);
  line-height: 1.6;
  font-style: italic;
}

/* Preferences layout grids */
.pref-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.pref-row-2 > .card {
  margin-top: 0 !important;
}
@media (max-width: 900px) {
  .pref-row-2 { grid-template-columns: 1fr; }
}

.pref-format-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: start;
}
.pref-format-row > div:first-child {
  max-width: 340px;
}
@media (max-width: 1000px) {
  .pref-format-row { grid-template-columns: 1fr; }
  .pref-format-row > div:first-child { max-width: none; }
}

/* Schedule row */
.schedule-row {
  display: flex;
  gap: 1rem;
  align-items: end;
}
.schedule-select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--warm-200);
  border-radius: 6px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background: white;
  outline: none;
  cursor: pointer;
  min-width: 140px;
}
.schedule-select:focus { border-color: var(--teal); }

/* Pills/tags */
.pill-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  background: var(--warm-50);
  border: 1px solid var(--warm-200);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--warm-700);
  transition: all 0.15s;
}
.pill .pill-x {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.1s;
  color: var(--warm-400);
}
.pill .pill-x:hover { background: var(--warm-200); color: var(--warm-700); }
.pill.red {
  background: var(--red-pale);
  border-color: var(--red-muted);
  color: var(--red);
}
.pill.red .pill-x:hover { background: var(--red-muted); color: var(--red); }
.pill.blue {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.pill-input-wrap {
  display: flex;
  gap: 0.5rem;
}
.pill-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--warm-200);
  border-radius: 20px;
  font-size: 0.82rem;
  font-family: var(--font-body);
  outline: none;
  background: white;
}
.pill-input:focus { border-color: var(--teal); }
.pill-add-btn {
  padding: 0.5rem 1rem;
  background: var(--teal);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
}
.pill-add-btn:hover { background: var(--teal-hover); }

/* Guidance list */
.guidance-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.guidance-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: var(--warm-50);
  border: 1px solid var(--warm-200);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--warm-700);
}
.guidance-item .g-bullet {
  color: var(--teal);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05rem;
}
.guidance-item .g-text { flex: 1; line-height: 1.5; }
.guidance-item .g-remove {
  color: var(--warm-300);
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  padding: 0.1rem;
}
.guidance-item .g-remove:hover { color: var(--red); }

/* ── Admin Page ────────────────────────────────── */
.admin-table-wrap {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}
.admin-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warm-400);
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--warm-200);
  text-align: left;
  white-space: nowrap;
}
.admin-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.admin-table tbody tr:hover { background: var(--warm-50); }
.admin-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--warm-100);
  color: var(--warm-700);
}
.admin-table .user-name {
  font-weight: 600;
  color: var(--navy);
}
.admin-table .user-email {
  color: var(--warm-400);
  font-size: 0.78rem;
}
.admin-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-badge.speed { background: #dbeafe; color: #1d4ed8; }
.admin-badge.standard { background: var(--teal-pale); color: var(--teal-hover); }
.admin-badge.deep { background: #fae8ff; color: #9333ea; }
.admin-badge.ultra_deep { background: #fef3c7; color: var(--amber); }

/* ── Preview Panel ─────────────────────────────── */
.preview-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 380px;
  background: white;
  border-left: 1px solid var(--warm-200);
  box-shadow: -4px 0 12px rgba(15,23,42,0.04);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: transform 0.3s ease;
}
.preview-panel.hidden {
  transform: translateX(100%);
}
.preview-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--warm-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.preview-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--navy);
}
.preview-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--warm-400);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-close:hover { background: var(--warm-100); }
.preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}
.preview-disclaimer {
  font-size: 0.72rem;
  color: var(--warm-400);
  text-align: center;
  padding: 0.6rem 1rem;
  background: var(--amber-pale);
  border-radius: 6px;
  margin-bottom: 1.25rem;
  line-height: 1.45;
}
.preview-masthead {
  text-align: center;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--navy);
}
.preview-masthead-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.02em;
}
.preview-masthead-date {
  font-size: 0.7rem;
  color: var(--warm-400);
  margin-top: 0.15rem;
}

.preview-story {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--warm-100);
}
.preview-story:last-child { border-bottom: none; }
.preview-story-cat {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-bottom: 0.3rem;
}
.preview-story-headline {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.35;
  margin-bottom: 0.25rem;
}
.preview-story-meta {
  font-size: 0.72rem;
  color: var(--warm-400);
}
.preview-story-summary {
  font-size: 0.78rem;
  color: var(--warm-500);
  line-height: 1.5;
  margin-top: 0.3rem;
}

/* ── Save Bar ──────────────────────────────────── */
.save-bar {
  position: fixed;
  bottom: 0;
  left: 240px;
  right: 0;
  background: white;
  border-top: 1px solid var(--warm-200);
  padding: 0.85rem 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 95;
  box-shadow: 0 -2px 8px rgba(15,23,42,0.04);
  transform: translateY(100%);
  transition: transform 0.25s ease, right 0.3s ease;
}
.save-bar.visible { transform: translateY(0); }
.save-bar.has-preview { right: 380px; }
.save-bar-msg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--amber);
  font-weight: 500;
}
.save-bar-dot {
  width: 8px;
  height: 8px;
  background: var(--amber);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.save-bar-actions { display: flex; gap: 0.5rem; }
.save-btn {
  padding: 0.55rem 1.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.save-btn.primary { background: var(--teal); color: white; }
.save-btn.primary:hover { background: var(--teal-hover); }
.save-btn.ghost {
  background: transparent;
  color: var(--warm-500);
  border: 1px solid var(--warm-200);
}
.save-btn.ghost:hover { background: var(--warm-50); }

/* ── Mobile header ─────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--navy);
  z-index: 110;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
}
.mobile-menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.mobile-logo {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: white;
}
.mobile-logo span { color: var(--teal-light); }
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 105;
}
.mobile-overlay.visible { display: block; }

/* ── Mobile preview FAB ────────────────────────── */
.preview-fab {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 89;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.preview-fab:hover { background: var(--teal-hover); }
.preview-fab:active { transform: scale(0.92); }

/* Mobile overlay backdrop */
.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 89;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 900px) {
  /* Mobile header */
  .mobile-header { display: flex; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 108;
  }
  .sidebar.open { transform: translateX(0); }

  /* Main content adjustments */
  .main-content { margin-left: 0; padding: 4rem 1rem 1.25rem; }
  .main-content.has-preview { margin-right: 0; }
  .save-bar { left: 0; }
  .save-bar.has-preview { right: 0; }
  .stats-row { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.4rem; }

  /* Preview panel becomes a slide-in drawer */
  .preview-panel {
    width: 100%;
    max-width: 380px;
    box-shadow: -8px 0 24px rgba(15,23,42,0.12);
  }
  .preview-panel.hidden { transform: translateX(100%); }

  /* Show FAB instead of inline toggle */
  .preview-fab { display: flex; }
  .preview-overlay.visible { display: block; }

  /* Bump save bar up above FAB */
  .save-bar.visible { bottom: 0; }
}

/* ── Utility ───────────────────────────────────── */
.fade-in { animation: fadeUp 0.3s ease-out; }
.mb-1 { margin-bottom: 1rem; }
.mt-half { margin-top: 0.5rem; }
.text-muted { color: var(--warm-400); }
.text-sm { font-size: 0.82rem; }
.pb-save { padding-bottom: 5rem; }
