:root {
  --ink: #0a0a0b;
  --ink-2: #121214;
  --bone: #efe7d6;
  --bone-dim: #a49b88;
  --gold: #c9a64a;
  --gold-hot: #e8c976;
  --line: rgba(239, 231, 214, 0.14);
  --line-soft: rgba(239, 231, 214, 0.07);
  --serif: "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--bone);
  overscroll-behavior: none;
}

body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  background-image:
    radial-gradient(circle at 50% 22%, rgba(201, 166, 74, 0.07), transparent 55%),
    radial-gradient(circle at 50% 100%, rgba(201, 166, 74, 0.04), transparent 60%);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 18px calc(128px + env(safe-area-inset-bottom));
}

/* ── header ───────────────────────────────────────────── */

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 2px 10px;
}

.brand {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--bone);
}

.brand em {
  font-style: normal;
  color: var(--gold);
}

.pill {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}

/* ── the readout ──────────────────────────────────────── */

.readout {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 2px 14px;
  margin-top: 6px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
}

.r-value {
  font-family: var(--mono);
  font-size: 40px;
  line-height: 1;
  color: var(--gold-hot);
  letter-spacing: -0.02em;
}

.r-label {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 4px;
}

.r-sentence {
  font-size: 13.5px;
  color: var(--bone);
  line-height: 1.4;
  max-width: 34ch;
}

/* ── ring ─────────────────────────────────────────────── */

.stage {
  position: relative;
  margin: 6px 0 0;
}

svg.ring { display: block; width: 100%; height: auto; }

.ring .spoke { stroke: var(--line-soft); stroke-width: 0.5; }
.ring .rim { fill: none; stroke: var(--line); stroke-width: 0.6; }
.ring .rim-inner { fill: none; stroke: var(--line-soft); stroke-width: 0.5; stroke-dasharray: 1 3; }
.ring .sign-glyph {
  fill: var(--bone-dim);
  font-family: var(--serif);
  font-size: 9px;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0.75;
}
.ring .node { cursor: pointer; }
.ring .node circle.core { fill: var(--gold-hot); }
.ring .node circle.halo { fill: var(--gold); opacity: 0.10; }
.ring .node text.label {
  fill: var(--bone-dim);
  font-family: var(--mono);
  font-size: 6.4px;
  letter-spacing: 0.04em;
  text-anchor: middle;
  pointer-events: none;
}
.ring .vector { stroke: var(--gold); stroke-width: 1.3; }
.ring .vector-head { fill: var(--gold); }
.ring .vector-ring { fill: none; stroke: var(--gold); stroke-width: 0.7; opacity: 0.5; }
.ring .basin-arc { fill: none; stroke: var(--gold); stroke-linecap: butt; }

@keyframes breathe { 0%,100% { opacity: .85 } 50% { opacity: 1 } }
.ring .pulse { animation: breathe 7s ease-in-out infinite; }

.axes {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(164, 155, 136, 0.7);
  padding: 2px 0 18px;
}

body[data-tab="atlas"] .stage,
body[data-tab="atlas"] .axes,
body[data-tab="match"] .stage,
body[data-tab="match"] .axes { display: none; }

/* ── controls ─────────────────────────────────────────── */

.seg {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin: 18px 0 8px;
}

.seg button {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 11px 4px;
  cursor: pointer;
}

.seg button[aria-selected="true"] {
  color: var(--ink);
  background: var(--gold);
}

/* ── lists ────────────────────────────────────────────── */

.rows { border-top: 1px solid var(--line-soft); }

.row {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

.row:active { background: rgba(239, 231, 214, 0.03); }

.row .g {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--gold);
  text-align: center;
  opacity: 0.9;
}

.row .nm {
  font-size: 15px;
  color: var(--bone);
  line-height: 1.2;
}

.row .sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  margin-top: 3px;
  text-transform: uppercase;
}

.row .val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--gold-hot);
  text-align: right;
}

.row .val small {
  display: block;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--bone-dim);
  margin-top: 2px;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--bone-dim);
  font-size: 15px;
}

/* ── match ────────────────────────────────────────────── */

.selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.selector::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold-hot);
}

.note {
  font-size: 12.5px;
  color: var(--bone-dim);
  line-height: 1.45;
  padding: 0 2px 14px;
  font-style: italic;
}

.match-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
}

.match-row .pct {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--gold-hot);
}

.match-row .nm { font-size: 15px; }
.match-row .sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--bone-dim);
  margin-top: 3px;
  text-transform: uppercase;
}

/* ── nav ──────────────────────────────────────────────── */

nav.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

nav.tabs .inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
}

nav.tabs button {
  flex: 1;
  background: none;
  border: 0;
  color: var(--bone-dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 16px 0 17px;
  cursor: pointer;
  position: relative;
}

nav.tabs button[aria-selected="true"] { color: var(--gold-hot); }

nav.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 9px;
  width: 18px;
  height: 1px;
  background: var(--gold);
}

/* ── sheet ────────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 30;
}

.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%;
  width: 100%;
  max-width: 560px;
  bottom: 0;
  background: var(--ink-2);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  max-height: 86vh;
  overflow-y: auto;
  transform: translate(-50%, 102%);
  transition: transform 260ms cubic-bezier(0.22, 0.9, 0.3, 1);
  z-index: 31;
  padding: 0 20px calc(28px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
}

.sheet.open { transform: translate(-50%, 0); }

.sheet .close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: 0;
  color: var(--bone-dim);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  padding: 8px;
  cursor: pointer;
}

.sheet .grab {
  width: 34px; height: 3px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px auto 18px;
}

.sheet h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.1;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.sheet .kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.bars { margin: 18px 0 6px; }

.bar {
  display: grid;
  grid-template-columns: 78px 1fr 40px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.bar .lbl {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone-dim);
}

.bar .track {
  height: 3px;
  background: rgba(239, 231, 214, 0.09);
  position: relative;
  overflow: hidden;
}

.bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--gold);
}

.bar .fill.cool { background: #6f8f8a; }
.bar .fill.warn { background: #b4623f; }

.bar .num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--bone);
  text-align: right;
}

.sheet .senses {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0 20px;
}

.sense { text-align: center; }

.sense .t {
  height: 46px;
  background: rgba(239, 231, 214, 0.05);
  position: relative;
  overflow: hidden;
}

.sense .f {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(201, 166, 74, 0.55);
}

.sense .n {
  font-family: var(--mono);
  font-size: 6.4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-top: 5px;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 20px; }

.chips .chip { font-size: 10px; padding: 7px 11px; }

.cta {
  width: 100%;
  background: var(--gold);
  color: var(--ink);
  border: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 15px;
  cursor: pointer;
  border-radius: 2px;
}

.foot {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: rgba(164, 155, 136, 0.55);
  text-align: center;
  padding: 30px 0 14px;
  line-height: 1.7;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .ring .pulse { animation: none; }
  .sheet, .sheet-backdrop { transition: none; }
}
