/* Helio Ocean — desktop-app shell (Figma-like rail + panels over full-bleed map).
   Helio brand: indigo #4B5CFF primary, slate neutrals, sun-yellow reserved for warnings.
   Semantic zone colors fixed by spec FR-6.2 — never restyle. */

:root {
  --primary: #4B5CFF;
  --primary-soft: #EEF0FF;
  --ink: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --surface: #F8FAFC;
  --warn: #B45309;
  --warn-bg: #FEF9C3;
  --rail-w: 64px;
  --panel-w: 336px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: 'IBM Plex Sans', sans-serif;
  color: var(--ink);
  overflow: hidden;
}

.mono { font-family: 'IBM Plex Mono', monospace; }
.hidden { display: none !important; }

#map { position: absolute; inset: 0 0 0 var(--rail-w); }

/* ---------- rail ---------- */

.rail {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--rail-w);
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 4px;
  z-index: 30;
}

.rail-logo {
  color: var(--primary);
  width: 34px; height: 34px;
  margin-bottom: 10px;
  display: grid; place-items: center;
}
.rail-logo svg { width: 26px; height: 26px; }

.rail-btn {
  width: 52px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 0 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-btn span { font-size: 0.58rem; font-weight: 500; letter-spacing: 0.02em; }
.rail-btn:hover { background: var(--surface); color: var(--ink); }
.rail-btn.active { background: var(--primary-soft); color: var(--primary); }
.rail-spacer { flex: 1; }

/* ---------- side panel ---------- */

.panel {
  position: absolute;
  left: var(--rail-w); top: 0; bottom: 0;
  width: var(--panel-w);
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  z-index: 20;
  overflow-y: auto;
  box-shadow: 8px 0 24px rgb(15 23 42 / 0.04);
}

.panel-section { display: flex; flex-direction: column; min-height: 100%; padding: 18px 18px 14px; }

.panel-head { margin-bottom: 14px; }
.panel-head h1 {
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin: 0;
}
.panel-head h1 span { color: var(--primary); }
.panel-head p { margin: 4px 0 0; font-size: 0.76rem; color: var(--muted); }

.panel h2 {
  font-family: 'Sora', sans-serif;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

/* readout */
.readout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.stat-num { font-family: 'IBM Plex Mono', monospace; font-size: 1.35rem; font-weight: 500; display: block; }
.stat-label { font-size: 0.6rem; color: var(--muted); line-height: 1.3; }

/* layers */
.layer-row { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; padding: 4px 0; cursor: pointer; }
.layer-row input { accent-color: var(--primary); }

/* legend */
.legend { list-style: none; margin: 0; padding: 0; font-size: 0.78rem; }
.legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.legend em { color: var(--muted); font-size: 0.68rem; margin-left: auto; font-style: normal; }
.swatch { width: 16px; height: 11px; border-radius: 2px; opacity: 0.8; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 3px; }
.rivermark { color: #1d4e5f; font-size: 0.9rem; margin: 0 2px; }

.hint { font-size: 0.72rem; color: var(--muted); margin-top: 14px; }

/* ---------- chat ---------- */

#panel-ask { height: 100%; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 12px; }

.chips { display: flex; flex-direction: column; gap: 6px; }
.chip {
  text-align: left;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.76rem;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

.msg { max-width: 92%; font-size: 0.8rem; line-height: 1.5; }
.msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px 12px 3px 12px;
}
.msg-assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px 12px 12px 3px;
}
.msg-mode {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.msg-mode.offline { color: var(--warn); }
.msg details { margin-top: 8px; }
.msg summary { font-size: 0.68rem; color: var(--primary); cursor: pointer; }
.msg pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  overflow-x: auto;
  max-height: 180px;
}

.thinking { align-self: flex-start; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.74rem; padding: 6px 2px; }
.thinking .dots { display: inline-flex; gap: 3px; }
.thinking .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); animation: pulse 1.2s infinite; }
.thinking .dots i:nth-child(2) { animation-delay: 0.2s; }
.thinking .dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.chat-input { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.8rem;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}
.chat-input input:focus { outline: none; border-color: var(--primary); }
.chat-input input:disabled { background: var(--surface); }
.chat-input button {
  width: 40px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.chat-input button svg { width: 18px; height: 18px; }
.chat-input button:disabled { background: var(--border); cursor: default; }

/* ---------- briefing ---------- */

.briefing-body { font-size: 0.8rem; line-height: 1.6; }
.briefing-body h2 { font-family: 'Sora', sans-serif; font-size: 0.95rem; letter-spacing: 0; text-transform: none; color: var(--ink); margin: 4px 0 10px; }
.briefing-body h3 { font-size: 0.8rem; color: var(--primary); margin: 16px 0 6px; }
.briefing-body table { width: 100%; border-collapse: collapse; font-size: 0.72rem; margin: 8px 0; }
.briefing-body th { background: var(--surface); text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--border); }
.briefing-body td { padding: 4px 7px; border-bottom: 1px solid var(--border); }
.briefing-body blockquote { margin: 10px 0 0; padding: 8px 12px; background: var(--surface); border-left: 3px solid var(--primary); font-size: 0.72rem; color: var(--muted); }

/* ---------- data sources ---------- */

.source-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.source-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.82rem; }
.stamp {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 1px 7px;
  border-radius: 3px;
  border: 1.2px solid;
  margin-left: auto;
}
.stamp.live { color: #15803D; border-color: #15803D; }
.stamp.fixture { color: var(--warn); border-color: var(--warn); }
.source-meta { font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: var(--muted); margin-top: 5px; }
.source-detail { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }

/* ---------- topbar ---------- */

.topbar {
  position: absolute;
  top: 14px;
  left: calc(var(--rail-w) + var(--panel-w) + 16px);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 15;
}

.seg {
  display: flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.08);
}
.seg button {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg button.active { background: var(--primary); color: #fff; }

.storm-chip {
  font-size: 0.66rem;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.08);
}

/* ---------- detail panel ---------- */

.detail {
  position: absolute;
  top: 14px; right: 14px; bottom: 14px;
  width: 320px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgb(15 23 42 / 0.14);
  z-index: 25;
  overflow-y: auto;
  padding: 16px;
}

.detail-close {
  position: absolute;
  top: 10px; right: 10px;
  border: none; background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.detail-close:hover { color: var(--ink); }

.detail h3 {
  font-family: 'Sora', sans-serif;
  font-size: 0.9rem;
  margin: 0 26px 2px 0;
}
.detail .sub { font-size: 0.7rem; color: var(--muted); margin-bottom: 10px; }

.pill {
  display: inline-block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  border-radius: 10px;
  padding: 2px 9px;
  margin-bottom: 8px;
}

.kv { width: 100%; border-collapse: collapse; font-size: 0.76rem; margin: 6px 0; }
.kv td { padding: 4px 0; border-bottom: 1px solid var(--surface); vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 44%; }
.kv td:last-child { font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; }

.items-table { width: 100%; border-collapse: collapse; font-size: 0.74rem; margin: 6px 0 4px; }
.items-table th { text-align: left; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 3px 0; border-bottom: 1px solid var(--border); }
.items-table td { padding: 3px 0; border-bottom: 1px solid var(--surface); }
.items-table td:last-child { font-family: 'IBM Plex Mono', monospace; text-align: right; }

.detail .note {
  font-size: 0.74rem;
  background: var(--surface);
  border-left: 3px solid var(--primary);
  padding: 7px 10px;
  border-radius: 0 6px 6px 0;
  margin: 8px 0;
  font-style: italic;
  color: var(--muted);
}

.review-flag {
  font-size: 0.7rem;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 8px 0;
}

.detail .links { display: flex; gap: 8px; margin-top: 12px; }
.detail .links a {
  flex: 1;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 7px;
  padding: 8px 6px;
  text-decoration: none;
}
.detail .links a:hover { background: var(--primary); color: #fff; }

.explain-status { font-size: 0.74rem; color: var(--muted); margin: 4px 0 10px; line-height: 1.5; }

/* ---------- explainer ---------- */

.explainer {
  position: absolute;
  left: calc(var(--rail-w) + var(--panel-w) + 16px);
  bottom: 40px;
  width: 380px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 32px rgb(15 23 42 / 0.18);
  padding: 16px 18px;
  z-index: 26;
  font-size: 0.78rem;
  line-height: 1.5;
}
.explainer h3 { font-family: 'Sora', sans-serif; margin: 0 0 8px; font-size: 0.9rem; }
.explainer p { margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; }
.explainer .dot, .explainer .swatch { flex: none; transform: translateY(1px); }
.explainer button {
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.76rem;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
  margin-top: 4px;
}

/* ---------- coords ---------- */

.coords {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 15;
  font-size: 0.64rem;
  color: var(--muted);
  background: rgb(255 255 255 / 0.85);
  border-radius: 6px;
  padding: 3px 8px;
}
.detail:not(.hidden) ~ .coords { display: none; }

@media (max-width: 900px) {
  .panel { width: 280px; }
  :root { --panel-w: 280px; }
  .storm-chip { display: none; }
}
