/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  --bg0:    #f0f4f8;
  --bg1:    #ffffff;
  --bg2:    #f1f5f9;
  --border: #e2e8f0;
  --text:   #1e293b;
  --muted:  #64748b;
  --accent: #2563eb;
  --cyan:   #0284c7;
  /* Chart colours */
  --cape:   #ff7b35;
  --li:     #39d3f2;
  --jet:     #c084fc;
  --jet-dir: #d4a5ff;
  --precip: #22d3ee;
  --temp:   #fbbf24;
  --cloud:  #94a3b8;
  --wind10: #34d399;
  --mslp:    #f472b6;
  --dewpoint: #4ade80;
  --wdir10:  #2dd4bf;
  --ws850:   #fb923c;
  --wdir850: #e879f9;
  --ws500:   #a78bfa;
  --wdir500: #f43f5e;
  --cin:     #facc15;
  --ws700:   #f97316;
  --wdir700: #fdba74;
  --t700:    #818cf8;
  --t500:    #60a5fa;
  --frzlvl:  #7dd3fc;
  --ws925:   #86efac;
  --wdir925: #bbf7d0;
  /* Risk colours */
  --risk-h: #dc2626;
  --risk-m: #d97706;
  --risk-l: #16a34a;
  --risk-n: #94a3b8;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg0);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

.model-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.model-table thead th {
  background: var(--bg2);
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
}
.model-table th, .model-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.model-table tbody tr:nth-child(even) { background: var(--bg2); }
.model-table tbody tr:hover { background: #eff6ff; }
.model-table .model-name { white-space: nowrap; font-weight: 600; color: var(--accent); }
.model-section-header td {
  background: var(--bg1);
  color: var(--cyan);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-top: 2px solid var(--accent);
  padding: 5px 10px;
  pointer-events: none;
}
.model-name-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.model-name-btn:hover { background: var(--accent); color: #fff; }
.model-name-btn.selected { background: var(--accent); color: #fff; }
.model-table .model-bestuse { max-width: 360px; }

/* ─── Tab nav ────────────────────────────────────────────────── */
.tab-nav {
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  display: flex;
  gap: 0;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 12px 20px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ─── Tab pages ──────────────────────────────────────────────── */
.tab-page { display: none; }
.tab-page.active {
  display: flex;
  flex-direction: column;
}

/* ─── Main layout ────────────────────────────────────────────── */
.app-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  gap: 14px;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .tab-btn { padding: 10px 12px 8px; font-size: 0.78rem; }
  .app-main { padding: 14px 12px 32px; }
}

/* ─── Page 2 full-width override ────────────────────────────── */
#page-models {
  max-width: none;
  margin-left: 0;
}

/* ─── Page 2 split layout ────────────────────────────────────── */
.models-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
}

/* Card header row: title left, button right */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-header .section-title { margin-bottom: 0; }

/* Collapse button */
.collapse-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.collapse-btn:hover { color: var(--text); border-color: var(--accent); }

/* Models card — fills available width, transitions on flex */
.models-card {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  transition: flex-basis 0.3s ease, max-width 0.3s ease;
}

/* When collapsed: shrink to fit only the model-name column */
.models-card.collapsed {
  flex: 0 0 auto;
}
.models-card.collapsed .model-table th:not(.model-name),
.models-card.collapsed .model-table td:not(.model-name) {
  display: none;
}
.models-card.collapsed .model-table .model-name {
  white-space: nowrap;
}

/* Detail card — hidden until collapse triggers it */
.detail-card {
  flex: 1 1 auto;
  min-width: 0;
}
.detail-card[hidden] { display: none !important; }

.detail-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.detail-card-header .section-title { margin: 0; }

#parameter-select {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.param-step-btn {
  background: var(--bg2);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.param-step-btn:hover { background: var(--accent); color: #fff; }
.param-step-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#region-select,
#model-run-select {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.85rem;
  cursor: pointer;
}


.detail-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.detail-card img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
}

.button-row button {
  padding: 2px 3px;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.25s, transform 0.25s;
}
.button-row button:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
}
.button-row button.chosen {
  background-color: #1d4ed8;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(1px);
  color: #fff;
}

/* ─── Timestep view toggle button ────────────────────────────── */
.timestep-view-btn {
  margin-left: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.timestep-view-btn:hover { color: var(--text); border-color: var(--accent); }
.timestep-view-btn.active { color: var(--accent); border-color: var(--accent); }

/* ─── Timestep scrubber ──────────────────────────────────────── */
.timestep-scrubber { margin: 4px 0 6px; }
.timestep-scrubber[hidden] { display: none !important; }

.scrubber-track {
  position: relative;
  width: 100%;
  padding-top: 26px;   /* room for floating tooltip */
  cursor: crosshair;
  user-select: none;
}

/* Date band — labels for each day boundary */
.scrubber-date-band { position: relative; height: 20px; }
.scrubber-date-label {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  line-height: 1;
}

/* Rail — the coloured bar with tick marks */
.scrubber-rail-band { position: relative; }
.scrubber-rail {
  height: 8px;
  background: linear-gradient(to right, var(--accent), var(--cyan));
  border-radius: 4px;
  position: relative;
  overflow: visible;
}
.scrubber-step-tick {
  position: absolute;
  top: -1px;
  width: 1px;
  height: 10px;
  background: rgba(0,0,0,0.35);
  transform: translateX(-50%);
}
.scrubber-day-tick {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 14px;
  background: rgba(0,0,0,0.55);
  transform: translateX(-50%);
}

/* Hour band — labels every 6 h */
.scrubber-hour-band { position: relative; height: 20px; }
.scrubber-hour-label {
  position: absolute;
  top: 3px;
  transform: translateX(-50%);
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1;
}

/* Cursor — vertical hairline that follows the mouse */
.scrubber-cursor {
  position: absolute;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: rgba(30,41,59,0.6);
  border-radius: 1px;
  pointer-events: none;
  display: none;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(30,41,59,0.2);
  z-index: 2;
}

/* Tooltip — floating label above the cursor */
.scrubber-tooltip {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  background: var(--bg0);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  z-index: 3;
}

/* ══════════════════════════════════════════════════════════════
   FORECAST PAGE — imported from gfs-forecast
══════════════════════════════════════════════════════════════ */

.section-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: -10px;
  margin-bottom: 14px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  width: 100%;
  padding: 11px;
  font-size: 0.95rem;
  margin-top: 16px;
  border-radius: 6px;
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ─── Search ─────────────────────────────────────────────────── */
.search-row { display: flex; gap: 8px; }

input[type="text"] {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus { border-color: var(--accent); }

.dropdown {
  margin-top: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.result-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: rgba(88,166,255,0.1); }
.result-name { font-weight: 500; }
.result-admin { font-size: 0.78rem; color: var(--muted); }
.dropdown-msg { padding: 10px 14px; color: var(--muted); font-size: 0.82rem; }

.location-badge {
  margin-top: 10px;
  padding: 9px 14px;
  background: rgba(37,99,235,0.05);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}
#locName { font-weight: 600; color: var(--cyan); }
.coords { font-size: 0.75rem; color: var(--muted); font-family: monospace; }

/* ─── Controls ───────────────────────────────────────────────── */
.controls-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.ctrl-group { display: flex; flex-direction: column; gap: 6px; }
.ctrl-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  cursor: pointer;
}
select:focus { border-color: var(--accent); }

/* ─── Loader ─────────────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px;
  color: var(--muted);
  font-size: 0.9rem;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Messages ───────────────────────────────────────────────── */
.error-box {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.3);
  color: #f85149;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
}
.model-note {
  background: rgba(88,166,255,0.07);
  border: 1px solid rgba(88,166,255,0.2);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
}

/* ─── Risk grid ──────────────────────────────────────────────── */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.risk-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 6px;
  text-align: center;
  border-top: 3px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.risk-card.risk-high { border-top-color: var(--risk-h); }
.risk-card.risk-mod  { border-top-color: var(--risk-m); }
.risk-card.risk-low  { border-top-color: var(--risk-l); }
.risk-card.risk-none { border-top-color: var(--risk-n); }
.risk-day  { font-size: 0.7rem; color: var(--muted); }
.risk-score { font-size: 1.25rem; font-weight: 700; }
.risk-card.risk-high .risk-score { color: var(--risk-h); }
.risk-card.risk-mod  .risk-score { color: var(--risk-m); }
.risk-card.risk-low  .risk-score { color: var(--risk-l); }
.risk-card.risk-none .risk-score { color: var(--risk-n); }
.risk-label {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.risk-card.risk-high .risk-label { background: rgba(220,38,38,0.12);   color: var(--risk-h); }
.risk-card.risk-mod  .risk-label { background: rgba(217,119,6,0.12);   color: var(--risk-m); }
.risk-card.risk-low  .risk-label { background: rgba(22,163,74,0.12);   color: var(--risk-l); }
.risk-card.risk-none .risk-label { background: rgba(148,163,184,0.15); color: var(--risk-n); }
.risk-detail { font-size: 0.6rem; color: var(--muted); line-height: 1.4; }
.risk-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.72rem; }
.rl-item { display: flex; align-items: center; gap: 4px; }
.rl-item.risk-high { color: var(--risk-h); }
.rl-item.risk-mod  { color: var(--risk-m); }
.rl-item.risk-low  { color: var(--risk-l); }
.rl-item.risk-none { color: var(--risk-n); }

/* ─── Charts ─────────────────────────────────────────────────── */
.chart-block {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.chart-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.chart-block-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.chart-canvas-wrap { position: relative; height: 190px; }

/* ─── Reference card ─────────────────────────────────────────── */
.ref-card { margin-top: 4px; }
.ref-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ref-item { display: flex; align-items: flex-start; gap: 10px; font-size: 0.8rem; }
.ref-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.cape-dot     { background: var(--cape); }
.li-dot       { background: var(--li); }
.jet-dot      { background: var(--jet); }
.jet-dir-dot  { background: var(--jet-dir); }
.precip-dot   { background: var(--precip); }
.temp-dot     { background: var(--temp); }
.dew-dot      { background: var(--dewpoint); }
.cloud-dot    { background: var(--cloud); }
.wind10-dot   { background: var(--wind10); }
.wdir10-dot   { background: var(--wdir10); }
.ws925-dot    { background: var(--ws925); }
.wdir925-dot  { background: var(--wdir925); }
.mslp-dot     { background: var(--mslp); }
.ws850-dot    { background: var(--ws850); }
.wdir850-dot  { background: var(--wdir850); }
.ws700-dot    { background: var(--ws700); }
.wdir700-dot  { background: var(--wdir700); }
.t700-dot     { background: var(--t700); }
.ws500-dot    { background: var(--ws500); }
.wdir500-dot  { background: var(--wdir500); }
.t500-dot     { background: var(--t500); }
.cin-dot      { background: var(--cin); }
.frzlvl-dot   { background: var(--frzlvl); }
.ref-vals { color: var(--muted); font-size: 0.74rem; }
.ref-source { font-size: 0.75rem; color: var(--muted); }

/* ─── How-it-works ───────────────────────────────────────────── */
.how-heading { font-size: 0.95rem; font-weight: 700; color: #1e293b; margin: 0 0 6px 0; }
.how-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #e2e8f0; }
.how-section:last-of-type { border-bottom: none; margin-bottom: 0; }
.how-list { margin: 6px 0 0 18px; padding: 0; }
.how-list li { margin-bottom: 5px; }
#how-it-works p, #how-it-works li,
#page-howthisworks p, #page-howthisworks li { font-size: 0.88rem; color: #475569; line-height: 1.65; }
#how-it-works code, #page-howthisworks code {
  font-family: monospace; font-size: 0.82rem; background: #f1f5f9; color: #2563eb;
  padding: 1px 5px; border-radius: 3px;
}
.htsw-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.htsw-step-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 0.71rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.htsw-fn {
  background: #f1f5f9; border-left: 3px solid var(--accent); padding: 4px 12px;
  margin: 5px 0; border-radius: 0 4px 4px 0; font-size: 0.81rem; color: #7c3aed; font-family: monospace;
}
.htsw-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin: 8px 0; }
.htsw-table th {
  background: #f1f5f9; color: #1e293b; padding: 6px 10px; text-align: left;
  font-size: 0.77rem; font-weight: 600; border-bottom: 1px solid #e2e8f0;
}
.htsw-table td { padding: 5px 10px; border-bottom: 1px solid #e2e8f0; color: #64748b; vertical-align: top; line-height: 1.5; }
.htsw-table td:first-child { color: #2563eb; font-family: monospace; font-size: 0.79rem; white-space: nowrap; }
.htsw-table tr:last-child td { border-bottom: none; }

/* ─── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Forecast responsive ────────────────────────────────────── */
@media (max-width: 900px) { .risk-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px) {
  .controls-top { grid-template-columns: 1fr; }
  .risk-grid    { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Chart hover tooltip ────────────────────────────────────── */
.chart-hover-tooltip {
  position: fixed;
  z-index: 9999;
  background: rgba(255,255,255,0.85);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0;
  display: flex;
  align-items: stretch;
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  font-size: 0.8rem;
  overflow: hidden; /* prevent content escaping when max-height is active */
}
/* Inner panels scroll when the tooltip is height-constrained on small viewports */
.cht-data-panel { padding: 10px 14px; min-width: 210px; overflow-y: auto; }
.cht-right-panel { border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; min-width: 260px; overflow-y: auto; }

/* ── sm tier (≤ 600 px): stacked panels, compact text, fully scrollable ─ */
.chart-hover-tooltip.tt-sm {
  flex-direction: column;
  font-size: 0.72rem;
  width: calc(100vw - 12px);
  pointer-events: auto;
  overflow-y: auto !important;         /* override base overflow:hidden */
  -webkit-overflow-scrolling: touch;   /* smooth momentum scroll on Android/iOS */
  overscroll-behavior-y: contain;      /* don't scroll the page behind the tooltip */
  touch-action: pan-y;                 /* tell Android Chrome this element scrolls vertically */
}
/* cht-scroll-col: flex column only — parent tooltip handles all scrolling */
.cht-scroll-col {
  display: flex;
  flex-direction: column;
  touch-action: pan-y;
}
.chart-hover-tooltip.tt-sm .cht-data-panel {
  min-width: unset;
  padding: 8px 10px;
  overflow-y: visible;
  max-height: unset;
  flex: unset;
}
.chart-hover-tooltip.tt-sm .cht-right-panel {
  border-left: none;
  border-top: 1px solid #e2e8f0;
  min-width: unset;
  overflow-y: visible;
  max-height: unset;
  flex: unset;
  min-height: unset;
}
.chart-hover-tooltip.tt-sm .cht-score-label { font-size: 0.72rem; }
.chart-hover-tooltip.tt-sm .cht-eval-detail { font-size: 0.62rem; }
.chart-hover-tooltip.tt-sm .cht-hodo-panel { justify-content: center; padding: 8px 0; }
.chart-hover-tooltip.tt-sm .hodo-canvas { width: 160px !important; height: 160px !important; }

/* ── md tier (≤ 1000 px): side-by-side but narrower columns ─ */
.chart-hover-tooltip.tt-md {
  font-size: 0.76rem;
}
.chart-hover-tooltip.tt-md .cht-data-panel { min-width: 180px; }
.chart-hover-tooltip.tt-md .cht-right-panel { min-width: 210px; }
.chart-hover-tooltip.tt-md .cht-score-label { font-size: 0.76rem; }

.cht-time { margin-bottom: 8px; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; }
.cht-time-main { font-size: 0.78rem; color: #1e293b; font-weight: 700; }
.cht-time-model { font-size: 0.7rem; color: #7c3aed; font-weight: 600; margin-top: 1px; }
.cht-time-fetched { font-size: 0.65rem; color: #64748b; margin-top: 1px; }
.cht-time-utc-badge { font-size: 0.6rem; color: #64748b; font-weight: 400; vertical-align: middle; }
.cht-time-local { font-size: 0.7rem; color: #2563eb; margin-top: 1px; }
.cht-time-local-label { color: #64748b; font-size: 0.65rem; }
.cht-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cht-row:last-child { margin-bottom: 0; }
.cht-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cht-label { flex: 1; color: #64748b; }
.cht-val { font-weight: 600; font-family: monospace; white-space: nowrap; }
.cht-wind-arrow { display: inline-block; line-height: 1; vertical-align: middle; }
.cht-scores { padding-bottom: 4px; border-bottom: 1px solid #e2e8f0; }
.cht-score-row { display: flex; align-items: center; gap: 5px; font-size: 0.75rem; margin-bottom: 3px; color: #64748b; }
.cht-score-row:last-child { margin-bottom: 0; }
.cht-score-icon  { flex-shrink: 0; width: 14px; text-align: center; }
.cht-score-label { flex: 1; font-weight: 700; font-size: 0.8rem; }
.cht-score-pct   { font-family: monospace; font-weight: 600; color: #1e293b; min-width: 34px; text-align: right; }
.cht-score-badge { font-weight: 700; font-family: monospace; min-width: 36px; text-align: right; }
.cht-eval { padding-top: 4px; }
.cht-eval-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 0.75rem; }
.cht-eval-label { color: #64748b; flex-shrink: 0; }
.cht-eval-verdict { font-family: monospace; text-align: right; }
.cht-eval-detail { font-size: 0.67rem; color: #64748b; font-style: italic; margin-bottom: 1px; line-height: 1.3; }
.cht-hodo-panel { padding: 6px; display: flex; align-items: center; justify-content: center; }
.cht-right-panel > .cht-scores,
.cht-right-panel > .cht-eval { padding: 8px 12px; }
.cht-hodo-panel canvas { display: block; border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════
   TELECONNECTIONS PAGE
══════════════════════════════════════════════════════════════ */
.tc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(540px, 1fr));
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
}
.tc-attribution { font-size: 0.72rem; color: var(--muted); text-align: center; margin: 4px 0 8px; }
.tc-card { background: var(--bg1); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.tc-card-header { display: flex; align-items: flex-start; gap: 10px; }
.tc-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.tc-title { font-size: 0.92rem; font-weight: 700; color: var(--text); line-height: 1.25; }
.tc-short { font-size: 0.72rem; color: var(--muted); font-family: monospace; margin-top: 1px; }
.tc-current { margin-left: auto; text-align: right; white-space: nowrap; font-size: 0.78rem; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex-shrink: 0; }
.tc-val { font-size: 1.1rem; font-weight: 700; font-family: monospace; letter-spacing: -0.5px; }
.tc-phase { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.tc-month { font-size: 0.68rem; color: var(--muted); }
.tc-loading-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: tc-pulse 1s ease-in-out infinite; margin-right: 4px; vertical-align: middle; }
@keyframes tc-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.tc-error { color: #f85149; font-size: 0.72rem; }
.tc-summary { font-size: 0.78rem; color: var(--muted); line-height: 1.45; margin: 0; }
.tc-chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tc-range-label { font-size: 0.72rem; color: var(--muted); margin-right: 2px; }
.tc-range-btn { background: var(--bg2); border: 1px solid var(--border); border-radius: 4px; color: var(--muted); cursor: pointer; font-size: 0.7rem; padding: 2px 6px; transition: background 0.15s, color 0.15s; }
.tc-range-btn:hover { background: #e2e8f0; color: var(--text); }
.tc-range-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tc-chart-wrap { position: relative; height: 130px; }
.tc-fetch-error { font-size: 0.75rem; color: var(--muted); text-align: center; padding: 20px 0; line-height: 1.7; }
.tc-fetch-error a { color: var(--accent); }
.tc-impacts { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 8px; margin-top: 10px; }
.tc-impact-block { background: var(--bg2); border-radius: 6px; padding: 8px 10px; border: 1px solid var(--border); }
.tc-impact-badge { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 5px; padding: 2px 6px; border-radius: 3px; display: inline-block; }
.pos-badge { background: rgba(63,185,80,0.18); color: #3fb950; }
.neg-badge { background: rgba(248,81,73,0.18); color: #f85149; }
.tc-impact-text { font-size: 0.74rem; color: #475569; line-height: 1.5; margin: 0; }
.tc-impact-text strong { color: var(--text); }
.tc-forecast-section { max-width: 1240px; margin: 0 auto 14px; width: 100%; }
.tc-forecast-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.tc-fcst-card { background: var(--bg1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.tc-fcst-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.tc-fcst-title { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.tc-fcst-tag { font-size: 0.68rem; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tc-fcst-controls { display: flex; align-items: center; gap: 4px; }
.tc-fcst-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); font-size: 0.72rem; padding: 3px 8px; border-radius: 4px; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.tc-fcst-btn:hover  { border-color: var(--accent); color: var(--text); }
.tc-fcst-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tc-fcst-chart-wrap { position: relative; height: 155px; }
.tc-fcst-chart-wrap canvas { width: 100% !important; }
.tc-fcst-loading, .tc-fcst-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--muted); text-align: center; padding: 8px; line-height: 1.5; }
.tc-fcst-error { color: #f85149; }
.tc-fcst-legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.7rem; color: var(--muted); }
.tc-fcst-leg { display: flex; align-items: center; gap: 4px; }
.tc-fcst-swatch { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }
.tc-xtooltip {
  position: fixed; z-index: 9998; background: #ffffff; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 6px 10px; pointer-events: none; font-size: 0.75rem;
  color: #1e293b; box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.tc-xtooltip-date { font-size: 0.7rem; color: #64748b; margin-bottom: 3px; }
.tc-xtooltip-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.tc-xtooltip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tc-xtooltip-label { color: #64748b; flex: 1; }
.tc-xtooltip-val { font-family: monospace; font-weight: 600; }

@media (max-width: 600px) {
  .tc-grid     { grid-template-columns: 1fr; }
  .tc-impacts  { grid-template-columns: 1fr; }
  .tc-forecast-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   CROSS-CHART HOVER TOOLTIP
─────────────────────────────────────────────────────────────────────────── */

#tc-hover-tooltip {
  position:       fixed;
  z-index:        9999;
  display:        none;
  background:     #ffffff;
  border:         1px solid var(--border);
  border-radius:  8px;
  padding:        10px 14px;
  font-size:      0.73rem;
  pointer-events: none;
  min-width:      170px;
  max-width:      250px;
  box-shadow:     0 4px 20px rgba(0,0,0,0.55);
  color:          var(--text);
}

.tc-tt-header {
  font-weight:   700;
  font-size:     0.8rem;
  color:         var(--text);
  margin-bottom: 8px;
  display:       flex;
  align-items:   center;
  gap:           6px;
}

.tc-tt-badge {
  font-size:     0.6rem;
  font-weight:   600;
  background:    rgba(245,158,11,0.2);
  color:         #f59e0b;
  border-radius: 3px;
  padding:       1px 5px;
  white-space:   nowrap;
}

.tc-tt-section-label {
  font-size:      0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color:          var(--muted);
  margin:         6px 0 3px;
}

.tc-tt-rows {
  display:        flex;
  flex-direction: column;
  gap:            2px;
}

.tc-tt-row {
  display:     flex;
  align-items: center;
  gap:         6px;
}

.tc-tt-name {
  color:     var(--muted);
  flex:      1;
  font-size: 0.71rem;
}

.tc-tt-val {
  font-weight:  700;
  font-family:  monospace;
  font-size:    0.75rem;
  min-width:    44px;
  text-align:   right;
}

.tc-tt-stale {
  font-size:  0.6rem;
  color:      var(--muted);
  opacity:    0.65;
  font-style: italic;
}
/* ══════════════════════════════════════════════════════════════
   PARAMETER MATRIX PAGE
══════════════════════════════════════════════════════════════ */

/* Scroll wrapper so the table can overflow on small screens */
.pm-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pm-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ── Header cells ── */
.pm-th-meta {
  background: var(--bg2);
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}

.pm-th-param {
  background: var(--bg2);
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: center;
  line-height: 1.3;
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 68px;
}

/* ── Body cells ── */
.pm-td-name {
  padding: 8px 14px;
  border: 1px solid var(--border);
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--bg1);
  z-index: 1;
}

.pm-td-meta {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
}

/* ─── Links page ─────────────────────────────────────────────── */
.links-card {
  margin-bottom: 2px;
  padding: 6px 10px;
}

.links-card .card-header {
  margin-bottom: 4px;
}

/* Wider collapse button scoped to links cards only */
.links-card .collapse-btn {
  padding: 4px 30px;
}

/* Main section title — blue text on white pill */
.links-card .links-table-title {
  color: #1e6fbf;
  background: #ffffff;
  border-radius: 5px;
  padding: 2px 10px;
  margin-bottom: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.links-table-wrap {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  max-height: 4000px;
  opacity: 1;
}

.links-table-wrap.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Shrink the card itself when its table is collapsed */
.links-card:has(.links-table-wrap.collapsed) {
  padding-top: 5px;
  padding-bottom: 5px;
  margin-bottom: 2px;
}

.links-card:has(.links-table-wrap.collapsed) .card-header {
  margin-bottom: 0;
}

.links-table {
  width: calc(100% - 10px);
  margin-left: 10px;
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: fixed;       /* enforces column widths uniformly across all rows */
}

.links-table td {
  padding: 3px 7px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow: hidden;
}

.links-td-title {
  width: 18%;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* description: overflow handled by inner div, not the td, so vertical-align works */
.links-td-desc { width: 42%; color: var(--muted); }
.links-td-clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.links-td-link  { width: 22%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.links-th-actions,
.links-row-actions { width: 72px; text-align: center; white-space: nowrap; }

.links-table tbody tr:hover td {
  background: var(--bg2);
}

.links-table a {
  color: var(--accent);
  text-decoration: none;
}

.links-table a:hover {
  text-decoration: underline;
}

/* ── Links toolbar (Add new table) ── */
.links-toolbar {
  margin-bottom: 6px;
}

/* ── Generic action button ── */
.links-act-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 5px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.2;
}
.links-act-btn:hover           { color: var(--text); border-color: var(--accent); }
.links-act-btn.links-act-danger        { color: #f85149; border-color: #f8514944; }
.links-act-btn.links-act-danger:hover  { background: #f8514922; border-color: #f85149; }

/* ── Card header button cluster ── */
.links-card-btns {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* ── Actions column ── */
.links-row-actions .links-act-btn { margin: 0 1px; }

/* ── Move-to button — subtle accent colour ── */
.links-btn-move {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.links-btn-move:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
}

/* ── Sub-section block ── */
.links-subsection {
  border-top: 1px solid var(--border);
  padding: 4px 0 0;
}
.links-subsection:first-child {
  border-top: none;
  padding-top: 0;
}

.links-subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 2px;
}

.links-subsection-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.links-subsection-btns {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* ── Inline sub-section title input ── */
.links-subtitle-input {
  font-size: 0.68rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  width: 160px !important;
}

/* ── Modal select (Move-to dropdown) ── */
.links-modal-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 5px 8px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.links-modal-select:focus { border-color: var(--accent); }

/* ── Inline title input ── */
.links-title-input {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 2px 6px;
  text-transform: uppercase;
  width: 260px;
  outline: none;
}

/* ── Modal overlay ── */
.links-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.links-modal {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  min-width: 340px;
  max-width: 520px;
  width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.links-modal-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}

.links-modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.links-modal-field label {
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 600;
}
.links-modal-hint {
  font-weight: 400;
  font-style: italic;
}
.links-modal-field input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.85rem;
  padding: 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.links-modal-field input:focus { border-color: var(--accent); }

.links-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.links-modal-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 16px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.links-modal-btn:hover   { color: var(--text); border-color: var(--accent); }
.links-modal-save        { color: var(--accent); border-color: var(--accent); }
.links-modal-save:hover  { background: rgba(88,166,255,0.12); }
.links-modal-danger      { color: #f85149; border-color: #f8514944; }
.links-modal-danger:hover { background: #f8514922; border-color: #f85149; color: #f85149; }

/* ── Confirm box ── */
.links-confirm-box {
  max-width: 360px;
}
.links-confirm-msg {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.5;
}



.pm-table tbody tr:nth-child(even) .pm-td-name,
.pm-table tbody tr:nth-child(even) .pm-td-meta,
.pm-table tbody tr:nth-child(even) .pm-cell {
  background: var(--bg2);
}

.pm-table tbody tr:nth-child(even) .pm-td-name {
  background: var(--bg2);
}

.pm-table tbody tr:hover .pm-td-name,
.pm-table tbody tr:hover .pm-td-meta,
.pm-table tbody tr:hover .pm-cell {
  background: #eff6ff;
}

/* ── Support cells ── */
.pm-cell {
  padding: 8px 6px;
  border: 1px solid var(--border);
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: default;
}

.pm-yes     { color: #16a34a; background: rgba(22,163,74,0.08); }
.pm-partial { color: #d97706; background: rgba(217,119,6,0.08); }
.pm-no      { color: #94a3b8; background: transparent; }

/* ── Type badges ── */
.pm-badge {
  display: inline-block;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  text-transform: uppercase;
}

.pm-badge-nwp { background: rgba(88,166,255,0.15); color: var(--accent); border: 1px solid rgba(88,166,255,0.35); }
.pm-badge-ens { background: rgba(57,211,242,0.12); color: var(--cyan);   border: 1px solid rgba(57,211,242,0.30); }
.pm-badge-cpm { background: rgba(210,153,34,0.12); color: #d29922;       border: 1px solid rgba(210,153,34,0.30); }

/* ── Legend ── */
.pm-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-bottom: 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

.pm-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pm-legend-item .pm-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  padding: 0;
  font-size: 0.82rem;
}

.pm-legend-sep { color: var(--border); font-size: 1.1rem; }

@media (max-width: 600px) {
  .pm-th-param { min-width: 52px; font-size: 0.62rem; padding: 6px 4px; }
  .pm-td-name  { padding: 6px 8px; font-size: 0.74rem; }
}

/* ══════════════════════════════════════════════════════════════
   CURRENT CONDITIONS PAGE
══════════════════════════════════════════════════════════════ */

/* Full-width layout identical to the models page */
#page-howthisworks {
  max-width: none;
  margin-left: 0;
}

/* Side-by-side layout */
.cc-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
}

/* ─── Left menu card ────────────────────────────────────────── */
.cc-menu-card {
  flex: 0 0 300px;
  min-width: 0;
  overflow: hidden;
  transition: flex-basis 0.25s ease;
}

/* Collapsed: only show section header buttons (no bodies) */
.cc-menu-card.collapsed {
  flex: 0 0 auto;
}
.cc-menu-card.collapsed .cc-section-body {
  display: none !important;
}
.cc-menu-card.collapsed .cc-section-label {
  writing-mode: initial;
}

/* ─── Accordion ─────────────────────────────────────────────── */
.cc-accordion {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cc-section {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

/* Section header button */
.cc-section-hdr {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.cc-section-hdr:hover            { background: #eff6ff; color: var(--accent); }
.cc-section-hdr.open             { color: var(--accent); background: rgba(37,99,235,0.06); }

.cc-section-icon   { font-size: 1rem; flex-shrink: 0; }
.cc-section-label  { flex: 1; }
.cc-section-arrow  {
  font-size: 0.6rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.cc-section-hdr.open .cc-section-arrow { transform: rotate(180deg); }

/* Section body (links list) — collapsed by default */
.cc-section-body {
  display: none;
  flex-direction: column;
  padding: 4px 6px 8px;
  background: var(--bg1);
  gap: 2px;
}
.cc-section-body.open { display: flex; }

/* Individual link buttons */
.cc-link-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1.3;
}
.cc-link-btn:hover  { background: var(--bg2); color: var(--text); border-color: var(--border); }
.cc-link-btn.active { background: rgba(37,99,235,0.08); color: var(--accent); border-color: rgba(37,99,235,0.25); }

/* ─── Right content card ────────────────────────────────────── */
.cc-content-card {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

/* Placeholder */
.cc-placeholder {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 21px;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 8px 0;
}
.cc-placeholder-icon { font-size: 1rem; }
.cc-resource[hidden] { display: none !important; }

/* Resource header */
.cc-resource {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cc-resource-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.cc-resource-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.cc-resource-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  max-width: 600px;
}

/* Open-in-new-tab button */
.cc-open-btn {
  display: inline-block;
  flex-shrink: 0;
  background: var(--accent);
  color: #000;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.cc-open-btn:hover { background: #79b8ff; text-decoration: none; }

/* Embed iframe */
.cc-embed-area {
  flex: 1 1 auto;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 500px;
}
.cc-embed-area[hidden] { display: none !important; }

#cc-iframe {
  width: 100%;
  height: 100%;
  min-height: 500px;
  border: none;
  display: block;
  background: #fff;
}

/* No-embed notice */
.cc-no-embed {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 40px;
}
.cc-no-embed[hidden] { display: none !important; }
.cc-no-embed-icon    { font-size: 2.2rem; }
.cc-no-embed p       { max-width: 380px; line-height: 1.6; }

@media (max-width: 700px) {
  .cc-layout        { flex-direction: column; }
  .cc-menu-card     { flex: none; width: 100%; }
  .cc-content-card  { min-height: 400px; }
}

/* ─── Login button (in tab nav) ──────────────────────────────── */
.login-btn {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: auto 0 auto auto;
  padding: 5px 14px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.login-btn:hover                { background: var(--accent); color: #fff; }
.login-btn.login-btn--active    { background: var(--accent); color: #fff; }

/* ─── Login modal overlay ────────────────────────────────────── */
.login-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.login-modal {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 320px;
  max-width: 90vw;
  padding: 28px 28px 24px;
}

.login-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.login-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -4px;
}

.login-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  padding: 9px 12px;
  transition: border-color 0.15s;
  width: 100%;
}
.login-input:focus { border-color: var(--accent); }

.login-error {
  color: #dc2626;
  font-size: 0.8rem;
  min-height: 1.2em;
}

.login-modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.login-modal-submit {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 0;
  transition: background 0.15s;
}
.login-modal-submit:hover { background: #1d4ed8; }

.login-modal-cancel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 0;
  transition: background 0.15s, color 0.15s;
}
.login-modal-cancel:hover { background: #f1f5f9; color: var(--text); }
