/* World Cortisol Index — global stylesheet.
   Variables, homepage, app shell, panels, gauge, tooltips. */

/* ── Reset & Root ── */
:root {
  --bg: #04060e;
  --bg-2: #0a1020;
  --panel: rgba(8, 16, 36, 0.85);
  --panel-border: rgba(100, 160, 240, 0.12);
  --text: #dce4f2;
  --text-dim: #7a8aa4;
  --accent: #4da8ff;
  --accent-2: #a47cff;
  --good: #2dd47a;
  --bad: #f0503c;
  --mid: #e8c840;
  --font-display: 'Space Mono', monospace;
  --font-body: 'Outfit', -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  /* Prevent elastic over-scroll on macOS Safari from exposing background */
  overscroll-behavior: none;
}

/* ═══════════════════════════════════════
   HOMEPAGE
═══════════════════════════════════════ */
#homepage {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
  transition: opacity 0.9s cubic-bezier(0.4,0,0.2,1), transform 0.9s cubic-bezier(0.4,0,0.2,1);
}
#homepage.exiting { opacity: 0; transform: scale(1.04); pointer-events: none; }

/* Canvas particle background */
#hp-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Scanline grid overlay */
.hp-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(77, 168, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 168, 255, 0.035) 1px, transparent 1px);
  background-size: 64px 64px;
}

/* Vignette */
.hp-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(4,6,14,0.75) 100%);
}

/* Content */
.hp-content {
  position: relative; z-index: 1;
  text-align: center;
  max-width: 720px;
  padding: 40px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 0;
}

/* Logo ring */
.hp-logo-ring {
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 1.5px solid rgba(77, 168, 255, 0.2);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  margin-bottom: 28px;
  animation: ringPulse 3s ease-in-out infinite;
}
.hp-logo-ring::before {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(77, 168, 255, 0.08);
}
.hp-logo-ring::after {
  content: '';
  position: absolute; inset: -16px;
  border-radius: 50%;
  border: 1px solid rgba(77, 168, 255, 0.04);
}
@keyframes ringPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(77,168,255,0.15), 0 0 40px rgba(77,168,255,0.1); }
  50% { box-shadow: 0 0 0 12px rgba(77,168,255,0), 0 0 60px rgba(77,168,255,0.2); }
}
.hp-logo-emoji {
  font-size: 40px;
  filter: drop-shadow(0 0 16px rgba(77,168,255,0.6));
  animation: emojiFloat 4s ease-in-out infinite;
}
@keyframes emojiFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Title */
.hp-eyebrow {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  opacity: 0.7;
}

.hp-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 10px;
}

.hp-title span {
  background: linear-gradient(135deg, var(--good) 0%, var(--accent) 50%, var(--bad) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hp-sub {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 300;
  color: rgba(220, 228, 242, 0.5);
  letter-spacing: 0.3px;
  margin-bottom: 36px;
}

/* Stats row */
.hp-stats {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.hp-stat {
  padding: 16px 28px;
  text-align: center;
  position: relative;
}
.hp-stat + .hp-stat::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 1px;
  background: var(--panel-border);
}
.hp-stat-val {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.hp-stat-lbl {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 3px;
}

/* Description */
.hp-desc {
  font-size: 13.5px;
  color: rgba(220, 228, 242, 0.45);
  line-height: 1.75;
  max-width: 520px;
  margin-bottom: 36px;
}
.hp-desc .hp-good { color: var(--good); font-weight: 500; }
.hp-desc .hp-bad { color: var(--bad); font-weight: 500; }

/* Enter button */
.hp-enter {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #04060e;
  background: linear-gradient(135deg, #4da8ff 0%, #7b8aff 50%, #a47cff 100%);
  border: none;
  border-radius: 8px;
  padding: 15px 44px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 30px rgba(77, 168, 255, 0.3);
  margin-bottom: 32px;
}
.hp-enter::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.hp-enter:hover { transform: translateY(-2px); box-shadow: 0 8px 50px rgba(77, 168, 255, 0.45); }
.hp-enter:hover::before { opacity: 1; }
.hp-enter:active { transform: translateY(0); }
.hp-enter svg { transition: transform 0.2s; }
.hp-enter:hover svg { transform: translateX(4px); }

/* Legend */
.hp-legend {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 9px;
  color: rgba(220, 228, 242, 0.25);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.hp-legend-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.hp-legend-bar {
  width: 100px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--good), var(--mid), var(--bad));
}

/* Footer */
.hp-footer {
  position: absolute; bottom: 24px; left: 0; right: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(220, 228, 242, 0.12);
}

/* ═══════════════════════════════════════
   MAIN APP
═══════════════════════════════════════ */
#app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;       /* fallback for older browsers */
  height: 100dvh;      /* dvh = dynamic viewport height: excludes Safari browser chrome */
  opacity: 0;
  transition: opacity 0.7s 0.2s ease;
}
#app.visible { opacity: 1; }
#app.app-hidden { display: none !important; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: linear-gradient(180deg, rgba(4,6,14,0.97) 0%, rgba(4,6,14,0.6) 100%);
  border-bottom: 1px solid var(--panel-border);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;  /* never let topbar grow and push globe area down */
  min-width: 0;
}
.brand { display: flex; gap: 12px; align-items: center; flex-shrink: 0; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--good), var(--bad));
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  box-shadow: 0 0 18px rgba(77,168,255,0.2);
}
.brand h1 {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--text);
}
.brand .tagline { font-size: 11px; color: var(--text-dim); font-weight: 300; margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status {
  font-family: var(--font-display); color: var(--text-dim); font-size: 11px;
  min-width: 0; flex-shrink: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) {
  .brand .tagline { display: none; }
  .status { max-width: 180px; }
}
@media (max-width: 600px) {
  .status { display: none; }
  .topbar { padding: 10px 14px; }
}
#refresh {
  font-family: var(--font-display); background: transparent;
  color: var(--accent); border: 1px solid rgba(77,168,255,0.3);
  border-radius: 6px; padding: 6px 13px; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: all 0.2s;
}
#refresh:hover:not(:disabled) { background: rgba(77,168,255,0.1); border-color: var(--accent); }
#refresh:disabled { opacity: 0.4; cursor: wait; }
#home-btn {
  font-family: var(--font-display); background: transparent;
  color: var(--text-dim); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; padding: 6px 13px; font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase; cursor: pointer; transition: all 0.2s;
}
#home-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

/* ── Layout ── */
main {
  display: flex;
  /* Do NOT set height/width here — this is the 1fr grid row of #app.
     100vh on main would add to the topbar height and overflow the viewport. */
  min-height: 0;   /* Safari: flex/grid children must opt-in to shrinking */
  overflow: hidden;
}
@media (max-width: 900px) {
  main { flex-direction: column; }
  #sidebar { flex: 1; min-width: 0; max-height: 46vh; }
}

/* ── Globe (UPDATED: Object-fit containment) ── */
#globe-wrap {
  flex: 1; /* Automatically takes up all remaining space */
  position: relative; 
  min-height: 0;
  overflow: hidden; /* CRUCIAL: Keeps the SVG from stretching the page */
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 55%, rgba(10,40,90,0.3) 0%, transparent 65%);
}

#globe { 
  width: 100%; 
  height: 100%; 
  max-width: 100%;
  max-height: 100%;
  object-fit: contain; /* Keeps aspect ratio perfect on any screen */
}

#globe-legend {
  position: absolute; left: 16px; bottom: 24px; /* Shifted up to prevent cut-offs */
  z-index: 100; /* Forces it above the map */
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 9px 14px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-family: var(--font-display); font-size: 10px; color: var(--text-dim);
  letter-spacing: 0.5px; text-transform: uppercase;
}
.lg-row { display: flex; align-items: center; gap: 7px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lg-bar {
  flex: 1; height: 5px; width: 100px; border-radius: 3px;
  background: linear-gradient(90deg, var(--good) 0%, var(--mid) 50%, var(--bad) 100%);
}
.lg-cap { margin-top: 4px; font-size: 9px; text-align: center; }

/* Loading overlay */
#loading-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); z-index: 20; transition: opacity 0.6s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-ring {
  width: 44px; height: 44px;
  border: 3px solid rgba(77,168,255,0.12);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-family: var(--font-display); font-size: 10px; color: var(--text-dim);
  margin-top: 14px; letter-spacing: 1.5px; text-transform: uppercase;
  text-align: center; max-width: 280px;
}
.loader-progress {
  margin-top: 10px; width: 200px; height: 2px;
  background: rgba(77,168,255,0.1); border-radius: 1px; overflow: hidden;
}
.loader-fill {
  height: 100%; background: var(--accent); border-radius: 1px;
  width: 0%; transition: width 0.4s ease;
}

/* ── Sidebar ── */
#sidebar {
  flex: 0 0 32%;
  min-width: 300px;
  max-width: 450px;
  min-height: 0;   /* Safari: allow sidebar to shrink within the flex row */
  display: flex; flex-direction: column; gap: 11px;
  padding: 13px; overflow-y: auto;
  border-left: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(4,6,14,0.5), rgba(4,6,14,0.85));
}
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(100,160,240,0.13); border-radius: 2px; }
#sidebar::-webkit-scrollbar-thumb:hover { background: rgba(100,160,240,0.27); }

.panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 13px 15px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.panel h2 {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase; color: var(--text-dim);
  margin-bottom: 9px;
}
.hint { font-size: 12px; color: var(--text-dim); font-weight: 300; line-height: 1.5; }

/* Archive panel */
.archive-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 4px;
}
.archive-cell {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 7px; padding: 9px 11px;
}
.archive-val {
  font-family: var(--font-display); font-size: 17px;
  font-weight: 700; color: var(--accent);
}
.archive-lbl {
  font-size: 10px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-top: 2px;
}
.api-badges {
  display: flex; flex-wrap: nowrap; gap: 4px; margin-top: 9px;
}
.api-badge {
  font-family: var(--font-display); font-size: 8px;
  letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 5px; border-radius: 4px;
  border: 1px solid; white-space: nowrap;
}
.api-badge.gdelt      { color: #4da8ff; border-color: rgba(77,168,255,0.3); }
.api-badge.gnews      { color: #a47cff; border-color: rgba(164,124,255,0.3); }
.api-badge.newsdata   { color: #2dd47a; border-color: rgba(45,212,122,0.3); }
.api-badge.newsapi    { color: #e8c840; border-color: rgba(232,200,64,0.3); }
.api-badge.guardian   { color: #ff6b6b; border-color: rgba(255,107,107,0.3); }
.api-badge.mediastack { color: #ff9900; border-color: rgba(255,153,0,0.3); }

/* Article panel */
.loc-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; color: #fff; }
.loc-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin: 8px 0 12px; font-size: 11px;
}
.country { color: var(--text-dim); font-size: 12px; }
.count { color: var(--text-dim); font-size: 11px; font-family: var(--font-display); }
.badge {
  display: inline-block; padding: 4px 9px; border-radius: 4px;
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  color: #000; letter-spacing: 0.5px; white-space: nowrap;
}
.badge.big { font-size: 11px; padding: 5px 11px; }
.articles { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.articles::-webkit-scrollbar { width: 3px; }
.articles::-webkit-scrollbar-thumb { background: rgba(100,160,240,0.15); border-radius: 2px; }
.article {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 7px; padding: 10px 12px; transition: all 0.15s;
}
.article:hover { border-color: rgba(77,168,255,0.25); background: rgba(77,168,255,0.04); }
.article.article-detail { padding: 12px 14px; }
.article-title {
  display: block; color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 400; line-height: 1.45;
}
.article-title:hover { color: var(--accent); }
.article-meta {
  margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center;
  gap: 7px; font-size: 11px; color: var(--text-dim);
}
.article-meta .src { font-style: italic; }
.article-meta .api-tag {
  font-family: var(--font-display); font-size: 9px;
  padding: 2px 6px; border-radius: 3px; text-transform: uppercase;
}

/* Open-article CTA inside the single-article panel */
.open-article-btn {
  display: inline-block; margin-top: 12px;
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: #04060e;
  background: linear-gradient(135deg, #4da8ff 0%, #7b8aff 100%);
  border-radius: 6px;
  padding: 9px 19px;
  text-decoration: none;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: 0 4px 18px rgba(77,168,255,0.25);
}
.open-article-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(77,168,255,0.4); }

/* Cortisol semicircle gauge */
.meter-wrap {
  display: flex; justify-content: center; align-items: center;
  margin: 4px 0 16px; /* Increased bottom margin to make room */
}

.meter-svg {
  width: 100%; max-width: 240px; height: auto;
  overflow: visible; /* CRUCIAL: Stops the SVG from cutting off the numbers */
  transform: translateY(-8px); /* Moves the whole diagram up slightly */
}
.meter-lbl {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: 1.2px; fill: #1a3566;
}
.meter-lbl-low  { fill: #2c8a3a; }
.meter-lbl-mid  { fill: #b89726; }
.meter-lbl-high { fill: #c63131; }
.meter-val {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  fill: #dce4f2;
}

/* Chart */
#chart-wrap { position: relative; height: 340px; }
.chart-summary {
  margin-top: 7px; font-size: 11px; color: var(--text-dim);
  font-family: var(--font-display); letter-spacing: 0.3px;
}

/* Tooltips */
.tt {
  background: rgba(4,6,14,0.95);
  border: 1px solid rgba(100,160,240,0.22);
  border-radius: 6px; padding: 7px 11px;
  font-size: 12px; color: var(--text); font-family: var(--font-body);
  pointer-events: none; box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.tt b { color: #fff; }
.tt-sub { color: var(--text-dim); margin-left: 4px; font-size: 10px; }

/* ═══════════════════════════════════════
   MAP INTERACTION FIXES (NEW)
═══════════════════════════════════════ */
/* 1. Make the country slightly see-through when hovered */
.country {
  transition: fill-opacity 0.2s ease;
}

.country:hover {
  fill-opacity: 0.6; /* 0.6 means 60% solid. Adjust this so you can see through it! */
}

/* 2. Tell the mouse to ignore the dots */
.dot {
  pointer-events: none;
}

/* ═══════════════════════════════════════
   GLOBE OVERLAY PANELS — stacked top-left
   Both the Brief panel and Ask AI panel
   live inside this positioned container.
═══════════════════════════════════════ */
.globe-panels {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 50;
  display: flex;
  flex-direction: row;      /* Brief and Chat side-by-side on wide screens */
  align-items: flex-start;  /* each expands downward independently */
  gap: 8px;
  max-width: calc(100% - 32px);
  pointer-events: none;     /* clicks pass through gaps to the globe */
}
.globe-panels > * {
  pointer-events: auto;
}

/* ── Brief panel ── */
.brief-panel {
  width: 260px;
  flex-shrink: 0;
}

/* ── Stack vertically on Mac laptops and smaller ── */
@media (max-width: 1200px) {
  .globe-panels { flex-direction: column; }
}
@media (max-width: 720px) {
  .brief-panel { width: 240px; }
}

.brief-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
  text-align: left;
}

.brief-toggle:hover {
  background: rgba(77, 168, 255, 0.08);
  border-color: rgba(77, 168, 255, 0.3);
}

.brief-chevron {
  margin-left: auto;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brief-panel.open .brief-toggle {
  border-radius: 8px 8px 0 0;
  border-bottom-color: transparent;
}

.brief-panel.open .brief-chevron {
  transform: rotate(180deg);
}

.brief-content {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.brief-panel.open .brief-content {
  max-height: 580px;
  opacity: 1;
  pointer-events: auto;
}

.brief-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--panel-border);
}

.brief-title {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.brief-subtitle {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  opacity: 0.5;
  margin-top: 2px;
}

.brief-list {
  list-style: none;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 490px;
  overflow-y: auto;
}

.brief-list::-webkit-scrollbar { width: 3px; }
.brief-list::-webkit-scrollbar-track { background: transparent; }
.brief-list::-webkit-scrollbar-thumb { background: rgba(100, 160, 240, 0.15); border-radius: 2px; }
.brief-list::-webkit-scrollbar-thumb:hover { background: rgba(100, 160, 240, 0.27); }

.brief-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 7px;
  padding: 9px 11px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.brief-item:hover {
  border-color: rgba(77, 168, 255, 0.25);
  background: rgba(77, 168, 255, 0.04);
}

.brief-rank {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 14px;
  padding-top: 1px;
  line-height: 1;
}

.brief-body { flex: 1; min-width: 0; }

.brief-headline {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}

.brief-item:hover .brief-headline { color: var(--accent); }

.brief-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  flex-wrap: wrap;
}

.brief-where {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.3px;
  color: var(--text-dim);
}

.brief-score-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  color: #000;
  letter-spacing: 0.5px;
}

.brief-placeholder {
  font-size: 12px;
  color: var(--text-dim);
  padding: 14px 4px;
  text-align: center;
  font-style: italic;
}

.brief-summary {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.65;
  margin-top: 6px;
  letter-spacing: 0.15px;
  min-height: 14px;
  opacity: 0.8;
}

/* ═══════════════════════════════════════
   CHAT PANEL — Ask About an Article
═══════════════════════════════════════ */
.chat-panel {
  width: 260px;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .chat-panel { width: 240px; }
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 13px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent-2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
  text-align: left;
}
.chat-toggle:hover {
  background: rgba(164, 124, 255, 0.08);
  border-color: rgba(164, 124, 255, 0.3);
}

.chat-chevron {
  margin-left: auto;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-panel.open .chat-toggle {
  border-radius: 8px 8px 0 0;
  border-bottom-color: transparent;
}
.chat-panel.open .chat-chevron { transform: rotate(180deg); }

/* Slide-down content — same mechanics as brief-content */
.chat-content {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.chat-panel.open .chat-content {
  max-height: 440px;
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.chat-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--panel-border);
}
.chat-title {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.chat-subtitle {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  opacity: 0.5;
  margin-top: 2px;
}

/* Message history */
.chat-messages {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(100,160,240,0.15); border-radius: 2px; }

.chat-msg { display: flex; }
.chat-msg-ai   { justify-content: flex-start; }
.chat-msg-user { justify-content: flex-end; }

.chat-bubble {
  max-width: 88%;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg-ai .chat-bubble {
  background: rgba(77, 168, 255, 0.07);
  border: 1px solid rgba(77, 168, 255, 0.15);
  border-radius: 3px 10px 10px 10px;
  color: var(--text);
  font-family: var(--font-body);
}
.chat-msg-user .chat-bubble {
  background: rgba(164, 124, 255, 0.2);
  border: 1px solid rgba(164, 124, 255, 0.35);
  border-radius: 10px 3px 10px 10px;
  color: #fff;
  font-family: var(--font-body);
}
.chat-msg-error .chat-bubble {
  background: rgba(240, 80, 60, 0.1);
  border-color: rgba(240, 80, 60, 0.25);
  color: var(--bad);
}

/* Typing indicator */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px;
}
.typing-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input row */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px 11px;
  border-top: 1px solid var(--panel-border);
}
.chat-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
}
.chat-input::placeholder { color: var(--text-dim); opacity: 0.55; }
.chat-input:focus { border-color: rgba(164, 124, 255, 0.45); }
.chat-input:disabled { opacity: 0.45; cursor: not-allowed; }

.chat-send {
  flex-shrink: 0;
  width: 33px; height: 33px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #04060e;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 2px 12px rgba(164, 124, 255, 0.3);
}
.chat-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(164, 124, 255, 0.5);
}
.chat-send:active:not(:disabled) { transform: translateY(0); }
.chat-send:disabled { opacity: 0.35; cursor: not-allowed; }