/* ==========================================================================
   Agentic News — Geopolitical Intelligence Terminal
   Aesthetic: Bloomberg Terminal meets Foreign Affairs editorial
   Fonts: JetBrains Mono (data) + Newsreader (editorial) + DM Sans (UI)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400;1,6..72,500&display=swap');

/* ---------- Design Tokens ---------- */
:root {
  /* Palette: deep navy ink with amber signal accents */
  --bg-root: #06090f;
  --bg-surface: #0c1018;
  --bg-surface-2: #111722;
  --bg-surface-hover: #161e2d;
  --bg-elevated: #1a2335;
  --border: #1e2a3d;
  --border-subtle: #152030;

  --text-primary: #d8dce6;
  --text-secondary: #9ba4b5;
  --text-muted: #7a8599;
  --text-inverse: #06090f;

  --accent: #d4a44a;          /* amber gold — signals, alerts, importance */
  --accent-hover: #e4b85a;
  --accent-muted: rgba(212,164,74,0.12);

  --signal-up: #2dd4a8;
  --signal-down: #f06868;
  --signal-neutral: #5e8ab4;
  --info: #5b9bd5;
  --warning: #e4a832;
  --danger: #e85454;

  /* Typography */
  --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-editorial: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;

  --text-xs: 0.7rem;
  --text-sm: 0.8rem;
  --text-base: 0.925rem;
  --text-lg: 1.1rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.4rem;

  --leading-tight: 1.25;
  --leading-normal: 1.55;
  --leading-relaxed: 1.7;

  --tracking-tight: -0.02em;
  --tracking-wide: 0.06em;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --max-w: 1240px;
  --max-w-article: 680px;
  --radius: 4px;
  --radius-lg: 8px;

  /* Transitions */
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --duration: 180ms;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-root);
  /* subtle scan-line texture for terminal feel */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(6,9,15,0.35) 2px,
      rgba(6,9,15,0.35) 4px
    );
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--duration) var(--ease); }
a:hover { color: var(--accent-hover); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--text-inverse); }

/* ---------- Skip Link (screen readers + keyboard nav) ---------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  background: var(--accent);
  color: var(--text-inverse);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  z-index: 200;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  top: var(--sp-2);
}

/* ---------- Focus States ---------- */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Top Navigation ---------- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-6);
  background: rgba(6,9,15,0.92);
  backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
  color: var(--accent) !important;
  text-transform: uppercase;
}
.nav-brand::before {
  content: "▸ ";
  opacity: 0.5;
}

.nav-links {
  display: flex;
  gap: var(--sp-1);
}
.nav-links a {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition: all var(--duration) var(--ease);
}
.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

/* ---------- Main Content ---------- */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
}

/* ---------- Hero Section ---------- */
.hero {
  margin-bottom: var(--sp-12);
  padding: var(--sp-12) 0 var(--sp-10);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: -50vw;
  right: -50vw;
  bottom: 0;
  background: linear-gradient(135deg, rgba(212,164,74,0.03) 0%, transparent 60%);
  pointer-events: none;
}

.hero h1 {
  font-family: var(--font-editorial);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
}

.subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-3);
}

.hero-desc {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 600px;
  line-height: var(--leading-relaxed);
}

/* ---------- Home Layout ---------- */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-10);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ---------- Article Grid & Cards ---------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-6);
  align-items: start;
}

.article-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-8) var(--sp-8) var(--sp-6);
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
}
.article-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.article-card:hover {
  border-color: var(--border);
  background: var(--bg-surface-2);
  transform: translateY(-1px);
}
.article-card:hover::before { opacity: 1; }

.article-card h3 {
  font-family: var(--font-editorial);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  margin-bottom: var(--sp-3);
}
.article-card h3 a { color: var(--text-primary); }
.article-card h3 a:hover { color: var(--accent); }

/* Market icon (small, used in cards and detail panel) */
.card-market-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.market-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.card-market-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.market-panel-title {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.card-market-question {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-root);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
}

.card-price-context {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.card-arrow { color: var(--text-muted); font-size: var(--text-xs); }

.article-summary {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  flex: 1;
  margin-bottom: var(--sp-4);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-radius: 2px;
  line-height: 1.4;
}

.badge-category {
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid rgba(212,164,74,0.2);
  align-self: flex-start;
  margin-bottom: var(--sp-3);
}

.badge-hcsm {
  position: absolute !important;
  top: var(--sp-3);
  right: var(--sp-3);
  width: auto !important;
  background: rgba(255,200,0,0.15);
  color: #ffc800;
  border: 1px solid rgba(255,200,0,0.3);
  animation: hcsm-pulse 2s ease-in-out infinite;
  z-index: 1;
}
@keyframes hcsm-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,200,0,0.2); }
  50% { box-shadow: 0 0 8px 2px rgba(255,200,0,0.15); }
}
.hcsm-icon {
  font-size: var(--text-sm);
  margin-right: var(--sp-1);
}

.badge-active {
  background: rgba(45,212,168,0.1);
  color: var(--signal-up);
  border: 1px solid rgba(45,212,168,0.2);
}

.badge-blocked {
  background: rgba(240,104,104,0.1);
  color: var(--signal-down);
  border: 1px solid rgba(240,104,104,0.2);
}

/* ---------- Price Change Indicators ---------- */
.price-change { font-family: var(--font-mono); font-weight: 600; font-size: var(--text-sm); }
.price-up { color: var(--signal-up); }
.price-up::before { content: "▲ "; font-size: 0.7em; }
.price-down { color: var(--signal-down); }
.price-down::before { content: "▼ "; font-size: 0.7em; }

/* ---------- Article Detail ---------- */
.article-detail {
  max-width: var(--max-w-article);
  margin: 0 auto;
}

/* Header with decorative geometric element */
.article-header {
  position: relative;
  padding-bottom: var(--sp-8);
  margin-bottom: var(--sp-8);
  border-bottom: 1px solid var(--border);
}
.article-header-deco {
  position: absolute;
  top: -40px; right: -60px;
  width: 200px; height: 200px;
  background:
    radial-gradient(circle at 30% 70%, rgba(212,164,74,0.06) 0%, transparent 60%),
    repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(212,164,74,0.03) 8px, rgba(212,164,74,0.03) 9px);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.article-header .badge-category { position: relative; z-index: 1; }

.article-detail h1 {
  font-family: var(--font-editorial);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--sp-5);
  position: relative;
  z-index: 1;
}

.article-lead {
  font-family: var(--font-editorial);
  font-size: var(--text-lg);
  font-weight: 400;
  font-style: italic;
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  margin-bottom: var(--sp-6);
  padding-left: var(--sp-5);
  border-left: 3px solid var(--accent);
}

.article-byline {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.article-source { color: var(--accent); }

/* ── Market Data Panel ── */
.market-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-10);
  position: relative;
  overflow: hidden;
}
.market-panel::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(212,164,74,0.2), transparent);
}

.market-panel-header {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-3);
}

.market-panel-question {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin-bottom: var(--sp-5);
  line-height: var(--leading-tight);
}

/* Price visualization bars */
.market-price-viz {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.price-row {
  display: grid;
  grid-template-columns: 60px 55px 1fr;
  align-items: center;
  gap: var(--sp-3);
}
.price-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
}
.price-value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
}
.price-value.price-up { color: var(--signal-up); }
.price-value.price-down { color: var(--signal-down); }

.price-bar {
  height: 8px;
  background: var(--bg-root);
  border-radius: 4px;
  overflow: hidden;
}
.price-bar-fill {
  height: 100%;
  background: var(--text-muted);
  border-radius: 4px;
  transition: width 0.6s var(--ease);
}
.price-bar-fill.price-bar-up { background: var(--signal-up); }
.price-bar-fill.price-bar-down { background: var(--signal-down); }

.market-change {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  text-align: center;
  padding: var(--sp-3);
  border-radius: var(--radius);
}
.market-change.price-up {
  background: rgba(45,212,168,0.08);
  border: 1px solid rgba(45,212,168,0.15);
}
.market-change.price-down {
  background: rgba(240,104,104,0.08);
  border: 1px solid rgba(240,104,104,0.15);
}
/* Remove the triangle pseudo-elements inside market-change */
.market-change.price-up::before,
.market-change.price-down::before { content: none; }

/* ── Article Body ── */
.article-body {
  font-family: var(--font-editorial);
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--text-primary);
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.article-body p {
  margin-bottom: var(--sp-6);
}

/* Drop cap for first paragraph */
.article-dropcap::first-letter {
  font-family: var(--font-editorial);
  font-size: 3.5em;
  font-weight: 700;
  float: left;
  line-height: 0.8;
  margin-right: var(--sp-3);
  margin-top: var(--sp-2);
  color: var(--accent);
}

/* Section headers as editorial markers */
.article-section-header {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: var(--sp-10);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}
/* Ensure the border spans just the text, not full width */
.article-section-header + p { clear: none; }

.article-body strong { color: var(--text-primary); font-weight: 600; }
.article-body em { font-style: italic; }

/* Legacy — keep for backward compat */
.market-info-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-8);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.market-question {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: var(--sp-2);
  color: var(--text-primary);
}
.price-detail {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--text-secondary);
}

.related-markets {
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
}
.related-markets h3 {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-3);
}
.related-link {
  display: block;
  padding: var(--sp-2) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.related-link:hover { color: var(--accent); }

/* ---------- Article Listing & Filters ---------- */
.articles-page { width: 100%; }
.articles-page h1 {
  font-family: var(--font-editorial);
  font-size: var(--text-2xl);
  margin-bottom: var(--sp-6);
}

.article-filters {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.category-tags {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  max-height: 80px;
  overflow-y: auto;
}

.filter-link {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  cursor: pointer;
}
.filter-link:hover {
  color: var(--text-primary);
  border-color: var(--border);
  background: var(--bg-surface-hover);
}
.filter-link.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.article-list { width: 100%; }

/* ---------- Cards (Generic) ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-6);
}
.card h3 {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-4);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* ---------- Stat Cards (Dashboard) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.4;
}

.stat-card h4 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
}

/* ---------- Dashboard ---------- */
.dashboard h2 {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-4);
  margin-top: var(--sp-8);
}
.dashboard h2:first-child { margin-top: 0; }
.dashboard-content { width: 100%; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead {
  border-bottom: 2px solid var(--border);
}
th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
}
td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}
tr:hover td { background: rgba(255,255,255,0.015); }

.ts {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: border-color var(--duration) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}
input::placeholder { color: var(--text-muted); }

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent-muted);
  border: 1px solid rgba(212,164,74,0.25);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition: all var(--duration) var(--ease);
}
button:hover, .btn:hover {
  background: rgba(212,164,74,0.2);
  border-color: var(--accent);
  color: var(--accent-hover);
}
button:active { transform: scale(0.98); }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Login ---------- */
.login-container {
  max-width: 380px;
  margin: 15vh auto;
  padding: var(--sp-10) var(--sp-8);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}
.login-container h2 {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-8);
}
.login-container form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.login-container button {
  width: 100%;
  justify-content: center;
  padding: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-2);
}

.error {
  color: var(--signal-down);
  font-size: var(--text-sm);
  margin-top: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: rgba(240,104,104,0.08);
  border: 1px solid rgba(240,104,104,0.2);
  border-radius: var(--radius);
  text-align: center;
}

/* ---------- Settings ---------- */
.settings-page {
  max-width: 640px;
}
.settings-page h1 {
  font-family: var(--font-editorial);
  font-size: var(--text-2xl);
  margin-bottom: var(--sp-6);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.setting-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- User Management ---------- */
.users-create-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
}
.users-create-form > div { flex: 1; min-width: 150px; }
.users-create-form button { align-self: flex-end; }

.user-action-btn {
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.user-action-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.user-action-btn.danger {
  border-color: rgba(232,84,84,0.3);
  color: var(--danger);
}
.user-action-btn.danger:hover {
  border-color: var(--danger);
  background: rgba(232,84,84,0.08);
}

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); font-size: var(--text-sm); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  margin-top: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

/* ---------- Empty States ---------- */
.empty-state {
  text-align: center;
  padding: var(--sp-16) var(--sp-6);
  color: var(--text-muted);
  font-size: var(--text-lg);
  font-style: italic;
}
.empty-state::before {
  content: "—";
  display: block;
  font-size: var(--text-2xl);
  color: var(--border);
  margin-bottom: var(--sp-4);
  font-style: normal;
}

/* ---------- Dialog (Password Modal) ---------- */
dialog {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-8);
  max-width: 380px;
  width: 90%;
}
dialog::backdrop { background: rgba(6,9,15,0.8); }

/* ---------- HTMX Indicators ---------- */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

/* ---------- Latest Articles Section ---------- */
.latest-articles h2 {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

/* ---------- Article Date & Category ---------- */
.article-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.article-category {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--accent);
}

/* Scroll to top button */
.scroll-top {
  position: fixed;
  bottom: var(--sp-8);
  right: var(--sp-8);
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 50%;
  font-size: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease), visibility 0.3s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.scroll-top::after {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  border-top: 2.5px solid var(--bg-root);
  border-left: 2.5px solid var(--bg-root);
  transform: rotate(45deg);
  margin-top: 5px;
}
.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}
.scroll-top:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ── CNN-Style Weighted News Grid ── */
.news-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration) var(--ease);
}
.news-card:hover { border-color: var(--border); }

.news-card-img {
  display: block;
  overflow: hidden;
  background: var(--bg-root);
}
.news-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease);
}
.news-card:hover .news-card-img img { transform: scale(1.03); }

.news-card-body {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}
.news-card-body h2 {
  font-family: var(--font-editorial);
  font-size: clamp(1.4rem, 2.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: var(--sp-3);
}
.news-card-body h3 {
  font-family: var(--font-editorial);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  margin-bottom: var(--sp-2);
}
.news-card-body h2 a, .news-card-body h3 a { color: var(--text-primary); }
.news-card-body h2 a:hover, .news-card-body h3 a:hover { color: var(--accent); }

.news-card-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--sp-3);
}

.news-card-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
/* Remove triangle pseudo-elements from price indicators inside cards */
.news-card-meta .price-up::before,
.news-card-meta .price-down::before { content: none; }

/* ── Hero Row: lead (2/3) + sidebar (1/3) ── */
.news-grid-hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.news-card-hero .news-card-img { height: 300px; }
.news-card-side .news-card-img { height: 180px; }
.news-card-side .news-card-body h3 {
  font-size: var(--text-lg);
}

/* ── Medium Row: 3 cards ── */
.news-grid-mid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.news-card-mid .news-card-img { height: 160px; }
.news-card-mid .news-card-body h3 { font-size: var(--text-base); }

/* ── Small Grid: 2 across ── */
.news-grid-small {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.news-card-sm {
  display: grid;
  grid-template-columns: 100px 1fr;
}
.news-card-sm .news-card-img {
  height: 100%;
  min-height: 90px;
}
.news-card-sm .news-card-body {
  padding: var(--sp-3) var(--sp-4);
}
.news-card-sm .news-card-body h3 {
  font-size: var(--text-sm);
  margin-bottom: var(--sp-1);
}
.news-card-sm .news-card-summary { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .news-grid-hero { grid-template-columns: 1fr; }
  .news-grid-mid { grid-template-columns: 1fr; }
  .news-grid-small { grid-template-columns: 1fr; }
  .news-card-sm { grid-template-columns: 80px 1fr; }
  .news-card-hero .news-card-img { height: 200px; }
}

/* ---------- Textarea ---------- */
textarea.setting-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--sp-3);
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  resize: vertical;
}

/* ---------- Search Input ---------- */
.search-input {
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-root);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  min-width: 200px;
}

/* ── News Layout (Homepage) ── */
.category-nav {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
}
.category-nav a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--sp-1) var(--sp-3);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--duration) var(--ease);
  cursor: pointer;
}
.category-nav a:hover { color: var(--text-primary); }
.category-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.lead-story {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-8);
  padding: var(--sp-8) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}
.lead-content { display: flex; flex-direction: column; justify-content: center; }
.lead-content h2 {
  font-family: var(--font-editorial);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: var(--sp-4);
}
.lead-content h2 a { color: var(--text-primary); }
.lead-content h2 a:hover { color: var(--accent); }
.lead-summary {
  font-family: var(--font-editorial);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--sp-4);
}
.lead-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.lead-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-height: 350px;
  min-height: 200px;
  background: var(--bg-surface);
}
.lead-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: smooth;
  filter: contrast(1.02) brightness(0.95);
}

.secondary-stories {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-6);
  padding-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}
.secondary-card h3 {
  font-family: var(--font-editorial);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
  margin-bottom: var(--sp-2);
}
.secondary-card h3 a { color: var(--text-primary); }
.secondary-card h3 a:hover { color: var(--accent); }
.secondary-summary {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-normal);
  margin-bottom: var(--sp-3);
}

.story-list {
  display: flex;
  flex-direction: column;
}
.story-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: background var(--duration) var(--ease);
  text-decoration: none;
}
.story-row:hover { background: var(--bg-surface); border-radius: var(--radius); }
.story-headline {
  flex: 1;
  font-family: var(--font-editorial);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: var(--leading-tight);
}
.story-cat {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  min-width: 80px;
}
.story-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Category management page */
.category-form {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-end;
  margin-bottom: var(--sp-6);
}
.category-form input { flex: 1; }

/* ========== Responsive Breakpoints ========== */

/* Tablet (768px) */
@media (max-width: 768px) {
  :root {
    --text-3xl: 1.9rem;
    --text-2xl: 1.5rem;
  }

  .top-nav { padding: var(--sp-3) var(--sp-4); }
  .nav-links a { padding: var(--sp-1) var(--sp-2); font-size: var(--text-xs); }

  main { padding: var(--sp-6) var(--sp-4); }

  .home-layout {
    grid-template-columns: 1fr;
    gap: var(--sp-8);
  }

  .sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    border-top: 1px solid var(--border);
    padding-top: var(--sp-6);
  }
  .sidebar .card { flex: 1; min-width: 200px; margin-bottom: 0; }

  .article-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .users-create-form { flex-direction: column; }

  .lead-story { grid-template-columns: 1fr; }
  .lead-image { max-height: 200px; }
  .secondary-stories { grid-template-columns: 1fr; }
}

/* Mobile (375px) */
@media (max-width: 480px) {
  :root {
    --text-3xl: 1.6rem;
    --text-2xl: 1.3rem;
    --text-xl: 1.15rem;
  }

  .top-nav {
    flex-direction: column;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
  }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .nav-links a { padding: var(--sp-1); font-size: 0.65rem; }

  main { padding: var(--sp-4) var(--sp-3); }

  .hero { padding: var(--sp-6) 0; margin-bottom: var(--sp-6); }

  .article-grid {
    grid-template-columns: 1fr;
  }
  .article-card { padding: var(--sp-5) var(--sp-4) var(--sp-4); }

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

  .login-container {
    margin: var(--sp-8) var(--sp-3);
    padding: var(--sp-6) var(--sp-5);
  }

  .article-detail h1 { font-size: var(--text-2xl); }

  table { font-size: var(--text-xs); }
  th, td { padding: var(--sp-1) var(--sp-2); }

  .article-filters { gap: var(--sp-1); }
  .filter-link { font-size: var(--text-xs); padding: var(--sp-1) var(--sp-2); }
}

/* ========== Print Styles ========== */
@media print {
  .top-nav, .sidebar, .article-filters, button { display: none; }
  body { background: white; color: #111; }
  .article-detail { max-width: 100%; }
  .article-body { font-size: 12pt; line-height: 1.6; }
  a { color: #111; text-decoration: underline; }
}

/* ========== Markets Page ========== */
.markets-page { max-width: 1280px; margin: 0 auto; padding: var(--sp-6); }

.tag-pill {
  background: var(--surface-2, #1a1f2e);
  color: var(--text-secondary, #8a95a5);
  border: 1px solid var(--border, #2a3040);
  border-radius: 999px;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tag-pill:hover { border-color: var(--accent, #4a9eff); color: var(--text-primary, #e0e4ea); }
.tag-pill.active {
  background: var(--accent, #4a9eff);
  color: #fff;
  border-color: var(--accent, #4a9eff);
}

.market-tags { display: flex; flex-wrap: wrap; gap: 0.2rem; }

.price-neutral { color: var(--text-secondary, #8a95a5); }

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
