/* Aethon Prototype 0 viewer. Aethon's palette and type; one screen: map left,
   panel right (below it on a phone). Text never smaller than 12px. */
:root {
  --abyss: #050d16;
  --deep: #0a1826;
  --shelf: #12283c;
  --line: #1c3650;
  --foam: #e4edf4;
  --slate: #93a7ba;
  --cyan: #35c8d8;
  --gold: #c9a227;
  --banner-h: 32px;
  --bar-h: 60px;
  --display: "Montserrat", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--abyss);
  color: var(--foam);
  font: 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  /* One screen on desktop: banner, bar, then the layout takes the rest. */
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* --- Banner: on every view, never dismissable ------------------------------ */
.banner {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  flex: none;
  min-height: var(--banner-h);
  padding-block: 6px;
  line-height: 1.35;
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  background: #1a1608;
  border-bottom: 1px solid #3a3112;
  color: #f0d77a;
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-align: center;
}

/* --- Top bar --------------------------------------------------------------- */
.bar {
  flex: none;
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--shelf);
  background: var(--abyss);
}
.left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.exit {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--deep);
  color: var(--foam); font-size: 13px; font-weight: 600; text-decoration: none;
}
.exit:hover { border-color: var(--cyan); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { border-radius: 7px; flex: none; }
.brand strong { display: block; font: 700 15px/1.2 var(--display); letter-spacing: 0.02em; }
.brand span { display: block; font-size: 12px; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.layers { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--shelf); border-radius: 999px; background: var(--deep); }
.layers button {
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--slate);
  white-space: nowrap;
}
.layers button[aria-checked="true"] { background: var(--cyan); color: var(--abyss); }
.layers button:not([disabled]):not([aria-checked="true"]):hover { color: var(--foam); }
.layers button[disabled] { cursor: not-allowed; opacity: 0.55; }
.layers small { font-size: 12px; font-weight: 500; }

/* --- Layout ---------------------------------------------------------------- */
.layout {
  flex: 1 1 0; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 420px; grid-template-rows: minmax(0, 1fr);
}
.map-wrap { position: relative; min-width: 0; background: var(--abyss); }
#map { position: absolute; inset: 0; }
.panel {
  overflow-y: auto; min-width: 0;
  border-left: 1px solid var(--shelf);
  background: var(--deep);
  padding: 20px 20px 28px;
}

.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--slate); font-size: 13px; pointer-events: none;
}

/* --- Legend ------------------------------------------------------------------ */
.legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 5;
  max-width: min(320px, calc(100% - 28px));
  padding: 12px 14px;
  border: 1px solid var(--shelf); border-radius: 12px;
  background: rgba(5, 13, 22, 0.88);
  backdrop-filter: blur(6px);
  font-size: 12px; color: var(--slate);
}
.legend h3 { margin: 0 0 8px; font: 600 12px/1.3 var(--body); color: var(--foam); }
.legend .ramp { height: 10px; border-radius: 3px; margin: 2px 0 4px; }
.legend .ends { display: flex; justify-content: space-between; }
.legend .swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; }
.legend .swatches span { height: 10px; border-radius: 2px; }
.legend .keys { display: grid; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--shelf); }
.legend .key { display: flex; align-items: center; gap: 8px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--abyss); }
.legend .dash { width: 16px; height: 0; border-top: 2px solid rgba(228, 237, 244, 0.7); }
.legend .box { width: 12px; height: 10px; border: 2px solid var(--gold); border-radius: 2px; }

/* --- Hover tooltip: value first, label second ------------------------------- */
.tip {
  position: absolute; z-index: 10; pointer-events: none;
  min-width: 180px; max-width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: rgba(10, 24, 38, 0.96);
  font-size: 12px; color: var(--slate);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.tip b { display: block; font-size: 15px; color: var(--foam); }
.tip .row { display: flex; justify-content: space-between; gap: 12px; }
.tip .row strong { color: var(--foam); font-weight: 600; }

/* --- Panel content -------------------------------------------------------------- */
.panel h1 { margin: 0 0 4px; font: 700 20px/1.25 var(--display); }
.panel h2 {
  display: flex; align-items: baseline; gap: 10px;
  margin: 26px 0 10px; font: 600 14px/1.3 var(--display); letter-spacing: 0.01em;
}
.panel h2 .n { font: 600 12px/1 var(--body); color: var(--cyan); }
.panel p { margin: 0 0 10px; }
.muted { color: var(--slate); }
.small { font-size: 12px; }
.lead { color: var(--slate); margin-bottom: 14px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.fact { padding: 10px 12px; border: 1px solid var(--shelf); border-radius: 10px; background: var(--abyss); }
.fact strong { display: block; font: 700 18px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.fact span { font-size: 12px; color: var(--slate); }

.clist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.clist button {
  width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--shelf); border-radius: 10px; background: var(--abyss);
}
.clist button:hover { border-color: var(--gold); }
.clist .id { font: 700 13px/1 var(--display); color: var(--gold); }
.clist .where { font-size: 13px; }
.clist .km { font-size: 12px; color: var(--slate); font-variant-numeric: tabular-nums; }

.back { cursor: pointer; border: 0; background: none; padding: 0; margin: 0 0 12px; color: var(--cyan); font-size: 13px; font-weight: 600; min-height: 32px; }

.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 4px; font-size: 13px; color: var(--slate); font-variant-numeric: tabular-nums; }
.meta strong { color: var(--foam); font-weight: 600; }

/* Stacked evidence bar: 2px gaps between segments, labels inside when wide */
.stack { display: flex; gap: 2px; height: 26px; margin: 4px 0 8px; }
.stack span {
  display: flex; align-items: center; justify-content: center; min-width: 0;
  border-radius: 3px; font-size: 12px; font-weight: 600; color: var(--abyss);
  overflow: hidden; white-space: nowrap;
}
.stack span:first-child { border-radius: 4px 3px 3px 4px; }
.stack span:last-child { border-radius: 3px 4px 4px 3px; }
.rows { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.rows li { display: flex; align-items: center; gap: 8px; }
.rows .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.rows .v { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--foam); }

.kgrid { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 13px; }
.kgrid li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; }
.kgrid .k { font: 700 12px/1.6 var(--display); color: var(--cyan); }
.kgrid .later .k { color: var(--slate); }
.kgrid .later span:last-child { color: var(--slate); }

.card { padding: 12px 14px; border: 1px solid var(--shelf); border-radius: 10px; background: var(--abyss); margin-bottom: 8px; }
.card.next { border-color: rgba(201, 162, 39, 0.55); }
.card h3 { margin: 0 0 4px; font: 600 13px/1.35 var(--body); }

details.src { border: 1px solid var(--shelf); border-radius: 10px; background: var(--abyss); margin-bottom: 8px; }
details.src summary { cursor: pointer; padding: 10px 12px; list-style: none; display: grid; gap: 2px; }
details.src summary::-webkit-details-marker { display: none; }
details.src summary strong { font-size: 13px; }
details.src summary span { font-size: 12px; color: var(--slate); }
details.src dl { margin: 0; padding: 0 12px 12px; display: grid; gap: 6px; font-size: 12px; }
details.src dt { color: var(--slate); }
details.src dd { margin: 0; color: var(--foam); overflow-wrap: anywhere; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); font-size: 12px; color: var(--slate); }

.checks { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; }
.checks .ok { color: var(--cyan); }
.checks .no { color: #ff9a8a; }

.cite { font-size: 12px; color: var(--slate); margin: 0 0 8px; overflow-wrap: anywhere; }
.foot { margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--shelf); font-size: 12px; color: var(--slate); }

/* --- Phones and small tablets: map above, panel below ------------------------- */
@media (max-width: 960px) {
  :root { --bar-h: auto; }
  .bar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .layers { width: 100%; overflow-x: auto; }
  .layers button { flex: 1 0 auto; padding: 7px 10px; }
  body { display: block; }
  .layout { display: block; }
  .map-wrap { height: auto; }
  #map { position: relative; height: 56vh; height: 56dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--shelf); padding: 18px 16px 32px; }
  /* Below the map on a phone, so it never covers the data. */
  .legend { position: static; max-width: none; border-radius: 0; border-width: 1px 0 0; backdrop-filter: none; padding: 12px 16px; }
  .legend .keys { grid-template-columns: repeat(3, auto); justify-content: start; gap: 6px 14px; }
}
@media (max-width: 420px) {
  .banner { font-size: 12px; letter-spacing: 0.02em; }
  .facts { grid-template-columns: 1fr; }
}

/* Rule switch inside the panel */
.seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 10px; border: 1px solid var(--shelf); border-radius: 999px; background: var(--abyss); }
.seg button { flex: 1; border: 0; background: transparent; cursor: pointer; padding: 7px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--slate); min-height: 32px; }
.seg button[aria-checked="true"] { background: var(--gold); color: var(--abyss); }
.checks .na { color: var(--slate); }
.card.warn { border-color: rgba(255, 154, 138, 0.45); }
.card.warn h3 { color: #ffb3a7; }
.legend .dot.ring { background: var(--abyss); box-shadow: 0 0 0 2px var(--gold); }
.legend .dot.off { width: 7px; height: 7px; background: var(--slate); }
