:root {
  --desc-color: #1f6feb;
  --gpc-color: #e8590c;
  --bg: #0d1117;
  --panel-bg: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #f2c744;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app {
  display: grid;
  grid-template-columns: 1fr 380px;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

header {
  grid-column: 1 / 3;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 14px;
  background: var(--panel-bg);
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

header .subtitle {
  color: var(--text-dim);
  font-size: 13px;
}

header {
  flex-wrap: wrap;
  row-gap: 8px;
}

header .legend {
  margin-left: auto;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#map-area {
  position: relative;
  min-height: 0;
}

#map {
  height: 100%;
  background: #0a0d12;
}

#holo {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #0b1a2e 0%, #05080d 70%);
  overflow: hidden;
}

#holo[hidden] { display: none; }

.holo-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 2;
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
}

/* ---- header view controls ---- */
.view-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--accent); cursor: pointer; }

.toggle-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #79c0ff;
  background: #0d1a2b;
  border: 1px solid #1f6feb;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 139, 253, 0.35);
}

.toggle-btn:hover { background: #12243b; }
.toggle-btn.on { color: #0d1117; background: #79c0ff; }
.toggle-btn:disabled { opacity: 0.6; cursor: wait; }

/* ---- weather risk ---- */
.risk-legend {
  position: absolute;
  left: 12px;
  bottom: 24px;
  z-index: 1000;
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.risk-legend[hidden] { display: none; }
.risk-legend b { color: var(--text); font-weight: 600; }
.risk-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}

.risk-low { background: #1b3a24; color: #56d364; }
.risk-moderate { background: #3d2e0f; color: #e3b341; }
.risk-high { background: #4a1c1c; color: #ff7b72; }
.risk-legend i.risk-low { background: #3fb950; }
.risk-legend i.risk-moderate { background: #d29922; }
.risk-legend i.risk-high { background: #f85149; }

#weather-risk {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

#weather-risk h2 { margin-bottom: 8px; }

.wx-side + .wx-side {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.wx-title { font-weight: 600; font-size: 12px; line-height: 1.4; }
.wx-meta { color: var(--text-dim); font-size: 11px; margin-top: 3px; line-height: 1.45; }
.wx-meta b { color: var(--text); font-weight: 600; }

.risk-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 6px;
  border-radius: 3px;
  margin-left: 4px;
}

.wx-strip {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  margin-top: 6px;
}

.wx-cell {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 0;
  border-radius: 2px;
  cursor: default;
}

.wx-summary {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
}

.wx-status { color: var(--text-dim); font-size: 12px; }
.wx-status code { color: var(--text); font-size: 11px; }

#panel {
  border-left: 1px solid var(--border);
  background: var(--panel-bg);
  overflow-y: auto;
  padding: 16px;
}

#panel h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 0 0 10px 0;
}

.overlap-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: #0d1117;
}

.overlap-card:hover, .overlap-card.active {
  border-color: var(--accent);
  background: #1c2128;
}

.overlap-rank {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
}

.overlap-dist {
  float: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.overlap-pair {
  font-size: 13px;
  line-height: 1.5;
  margin-top: 6px;
}

.overlap-pair .a { color: var(--desc-color); }
.overlap-pair .b { color: var(--gpc-color); }

.overlap-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

.tier-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 6px;
  font-weight: 600;
}

.tier-coordinate { background: #3f1d1d; color: #ff7b72; }
.tier-land { background: #3d2f11; color: #f2c744; }
.tier-logistics { background: #123a2b; color: #56d364; }
.tier-crew { background: #16232f; color: #79c0ff; }

#cost-estimate {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

#cost-estimate h2 { margin-bottom: 8px; }

.cost-box {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
}

.cost-box .figure {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.cost-box .note {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 8px;
}

.leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--text);
}
.leaflet-popup-tip { background: var(--panel-bg); }
.leaflet-popup-content b { color: var(--text); }

.overlap-line {
  stroke-dasharray: 6 5;
}

/* ---- dataset switch / auto ingest ---- */
.toggle select {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 4px;
}

#dataset-switch[hidden] { display: none; }

.dataset-note {
  font-size: 11px;
  color: var(--text-dim);
  margin: -4px 0 10px;
}

.dataset-note:empty { display: none; }

.conf-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin: 6px 0 0 4px;
  font-weight: 600;
  background: #3d2e0f;
  color: #e3b341;
}

.empty-state {
  font-size: 12px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
}

/* ---- AI coordination recommendation ---- */
.ai-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.ai-good { color: #3fb950; border-color: rgba(63, 185, 80, 0.5); background: rgba(63, 185, 80, 0.1); }
.ai-warn { color: #d29922; border-color: rgba(210, 153, 34, 0.5); background: rgba(210, 153, 34, 0.1); }
.ai-muted { color: var(--text-dim); }
.ai-text { margin: 10px 0 6px; line-height: 1.5; font-size: 13px; }
.ai-detail { color: var(--text-dim); font-size: 11px; line-height: 1.45; }
.ai-rejected { margin-top: 8px; font-size: 11px; color: var(--text-dim); }
.ai-rejected summary { cursor: pointer; color: #d29922; }
.ai-rejected blockquote {
  margin: 6px 0 0;
  padding: 6px 8px;
  border-left: 3px solid #d29922;
  background: rgba(210, 153, 34, 0.08);
  color: var(--text);
  text-decoration: line-through;
  text-decoration-color: rgba(248, 81, 73, 0.7);
}
.ai-draft-label { margin-top: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
