*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f0f0eb;
  --surface:  #e8e8e2;
  --border:   #d0d0c8;
  --text:     #2a2a28;
  --text-dim: #7a7a72;
  --accent:   #3a6a90;
  --rail-w:   200px;
  --header-h: 56px;
  font-size: 13px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* ─── Grid ──────────────────────────────────────────────────────── */

.frame {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-rows: var(--header-h) 1px 1fr auto;
  grid-template-areas:
    "header  header"
    "rule    rule"
    "rail    hero"
    "foot    foot";
  width: 100vw;
  height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────── */

.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-side { width: 140px; flex-shrink: 0; }

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eyebrow { display: none; }

.wordmark {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--text);
  line-height: 1;
}

.subtitle {
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 140px;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg);
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.chip-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #40a070;
}

/* ─── Header Rule ───────────────────────────────────────────────── */

.header-rule {
  grid-area: rule;
  background: var(--border);
  height: 1px;
}

/* ─── Left Rail ─────────────────────────────────────────────────── */

.left-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.view-toggle {
  display: flex;
  gap: 0;
  margin: 10px 10px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}

.toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:first-child { border-right: 1px solid var(--border); }

.toggle-btn:hover { color: var(--text); }

.toggle-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.toggle-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-label {
  padding: 10px 12px 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ─── Variable Cards ────────────────────────────────────────────── */

.var-stack {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.var-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.var-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.var-card.active {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: #fff;
  box-shadow: 0 2px 8px rgba(58,106,144,0.15);
}

.var-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.var-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.var-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.var-val { font-size: 12px; color: var(--accent); font-weight: 600; }
.var-unit { font-size: 9px; color: var(--text-dim); margin-left: 2px; font-weight: 400; }

/* ─── Rail Utilities ────────────────────────────────────────────── */

.rail-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 12px;
}

.rail-spacer { flex: 1; }

/* ─── About Card ───────────────────────────────────────────────── */

.about-card {
  margin: 6px 10px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.about-link {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.02em;
}

.about-link:hover { text-decoration: underline; }

/* ─── Float Card ────────────────────────────────────────────────── */

.float-card {
  cursor: pointer;
  margin: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.float-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.float-id {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.03em;
}

.float-status {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  background: #40a070;
  padding: 2px 7px;
  border-radius: 3px;
}

.float-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.float-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.float-row span:first-child { color: var(--text-dim); }
.float-row span:last-child { color: var(--text); font-weight: 600; }

.float-trail {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.trail-icon { width: 40px; height: 16px; flex-shrink: 0; }

.trail-label {
  font-size: 9px;
  color: var(--text-dim);
  font-style: italic;
}

/* ─── Color Legend Card ─────────────────────────────────────────── */

.legend-card {
  margin: 6px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.legend-bar {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #08306b, #2171b5, #4eb3d3, #41ab5d, #f7dc6f, #e67e22, #c0392b);
  margin-bottom: 4px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ─── Globe Area ────────────────────────────────────────────────── */

.hero-area {
  grid-area: hero;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.globe-container {
  position: absolute;
  inset: 0;
  cursor: grab;
}

.globe-container:active { cursor: grabbing; }

#globe-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-overlay { display: none; }

/* ─── Measure Card ──────────────────────────────────────────────── */

.measure-card {
  position: absolute;
  width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 100;
  pointer-events: all;
  display: none;
}

.measure-card.visible { display: block; }

.measure-card h4 {
  font-size: 10px;
  color: var(--text);
  margin-bottom: 6px;
  padding-right: 16px;
}

.close-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

.close-btn:hover { color: var(--text); }

.measure-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
}

.measure-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
}

.mlabel { color: var(--text-dim); }
.mvalue { color: var(--text); font-weight: 600; }

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

.sparkline i {
  flex: 1;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
  min-height: 3px;
  opacity: 0.5;
}

/* ─── Hidden sections ───────────────────────────────────────────── */
.footer-panels { display: none; }

/* ─── Footer ────────────────────────────────────────────────────── */

.footer {
  grid-area: foot;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 28px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 9px;
  color: var(--text-dim);
}

.footer strong { color: var(--text); font-weight: 600; }

/* ─── Elements the JS writes to (hidden but present in DOM) ────── */
.readings-grid, .clean-list, .queue-list, .tracks { list-style: none; }
