:root {
  color-scheme: dark;
  --bg: #000;
  --elevated: #1c1c1e;
  --field: #2c2c2e;
  --text: #f5f5f7;
  --secondary: rgba(235, 235, 245, 0.6);
  --tertiary: rgba(235, 235, 245, 0.38);
  --accent: #0a84ff;
  --stroke: rgba(255, 255, 255, 0.1);
  --stroke-soft: rgba(255, 255, 255, 0.08);
  --danger: #ff453a;
  --green: #30d158;
  --mint: #63e6e2;
  --orange: #ff9f0a;
  --pink: #ff375f;
  --shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
  --max: 720px;
  --tab: calc(58px + env(safe-area-inset-bottom));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", "Avenir Next", var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.noscript { padding: 24px; }

.icon { width: 22px; height: 22px; display: block; }
.tab .icon { width: 24px; height: 24px; }
.icon.sm { width: 16px; height: 16px; }

.app-scroll {
  min-height: 100dvh;
  padding: calc(8px + env(safe-area-inset-top)) 16px var(--tab);
}
.column {
  width: min(var(--max), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 4px;
}
.screen-head h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 17px;
  min-height: 44px;
}
.back-link .icon { width: 18px; height: 18px; }

.ghost, .text-btn {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  min-height: 44px;
  padding: 8px 4px;
}
.ghost.danger, .text-btn.danger { color: var(--danger); }

.card, .hero {
  background: var(--elevated);
  border: 1px solid var(--stroke-soft);
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  padding: 16px;
}
.hero {
  border-radius: 24px;
  border-color: var(--stroke);
  box-shadow: var(--shadow);
  padding: 20px 16px 12px;
  background:
    radial-gradient(circle at 50% 38%, rgba(10, 132, 255, 0.16), rgba(191, 90, 242, 0.07) 46%, transparent 72%),
    var(--elevated);
}
.hero h2, .card h2, .section-title {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.kicker, .caption, .hint {
  margin: 4px 0 0;
  color: var(--secondary);
  font-size: 13px;
}
.hint { font-size: 13px; line-height: 1.4; }
.wheel-frame { height: 420px; margin: 4px 0 0; }
.wheel-frame.short { height: 280px; opacity: 0.55; }
.wheel { width: 100%; height: 100%; display: block; }
.empty-wheel { position: relative; }
.empty-mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--secondary);
}
.empty-mark .icon { width: 34px; height: 34px; }

.week-strip {
  display: flex;
  align-items: center;
  gap: 12px;
}
.week-strip .grow { flex: 1; min-width: 0; }
.week-strip strong { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avg {
  text-align: right;
}
.avg b {
  display: block;
  font-family: var(--rounded);
  font-size: 22px;
  letter-spacing: -0.03em;
}
.status {
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.status.green { color: var(--green); background: rgba(48, 209, 88, 0.16); }
.status.mint { color: var(--mint); background: rgba(99, 230, 226, 0.16); }
.status.orange { color: var(--orange); background: rgba(255, 159, 10, 0.16); }
.status.pink { color: var(--pink); background: rgba(255, 55, 95, 0.16); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
}
.bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.bubble .icon { width: 18px; height: 18px; }
.metric .label { color: var(--secondary); font-size: 12px; }
.metric .name { font-weight: 650; font-size: 15px; }
.metric .meta { min-width: 0; flex: 1; }
.pill {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 999px;
}

.stats { display: flex; gap: 12px; }
.stat { flex: 1; min-width: 0; }
.stat b { display: block; font-size: 15px; margin-top: 2px; }
.stat span, .eyebrow {
  color: var(--secondary);
  font-size: 12px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.compass-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.compass-mini { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.compass-mini .icon { width: 16px; height: 16px; margin-top: 2px; }
.compass-mini b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-step {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}
.next-step p { margin: 4px 0 0; font-weight: 650; }

.insight-head { display: flex; align-items: center; gap: 8px; }
.insight-head .icon { width: 16px; height: 16px; color: var(--accent); }
.prose { margin: 8px 0 0; color: var(--secondary); font-size: 15px; line-height: 1.45; }

.primary, .secondary-btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 16px;
  min-height: 50px;
  font-weight: 700;
  font-size: 17px;
}
.primary { background: var(--accent); color: white; }
.primary:disabled { opacity: 0.45; }
.secondary-btn { background: #3a3a3c; color: var(--text); }
.footnote { text-align: center; color: var(--secondary); font-size: 13px; margin: 0; }
.stack-center { text-align: center; }
.stack-center h2 { font-size: 22px; margin-top: 8px; }

.history-link, .area-block, .reflect {
  display: block;
  color: inherit;
}
.history-link { padding: 14px 16px; }
.row-top, .area-top, .inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.score-cap {
  font-variant-numeric: tabular-nums;
  background: #3a3a3c;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 14px;
}
.mini-lines { margin-top: 8px; color: var(--text); font-size: 13px; }
.mini-lines span { color: var(--secondary); }

.area-block { margin-top: 12px; background: #000; border-radius: 16px; }
.area-block h3 { margin: 0; font-size: 15px; }
.area-copy { margin: 10px 0 0; }
.area-copy strong { display: block; color: var(--secondary); font-size: 12px; font-weight: 500; }

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.field span, .slider-label { color: var(--secondary); font-size: 12px; }
input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--stroke-soft);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  min-height: 44px;
}
textarea { min-height: 72px; resize: vertical; }
select { appearance: none; }
.slider {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.areas { display: grid; grid-template-columns: 1fr; gap: 16px; }
.area-form { background: #000; }
.area-form h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.warn { color: var(--orange); }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  height: var(--tab);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(28, 28, 30, 0.92);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--stroke-soft);
  display: flex;
  justify-content: center;
}
.tabbar nav {
  width: min(var(--max), 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--secondary);
  font-size: 10px;
  font-weight: 600;
  min-height: 50px;
}
.tab.active { color: var(--accent); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  display: flex;
  flex-direction: column;
}
.sheet-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid var(--stroke-soft);
}
.sheet-bar h2 { margin: 0; font-size: 17px; text-align: center; }
.sheet-bar .text-btn:last-child { justify-self: end; }
.sheet-scroll {
  overflow: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}
body.locked { overflow: hidden; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal {
  width: min(320px, 100%);
  background: #2c2c2e;
  border-radius: 16px;
  padding: 20px 16px 12px;
  text-align: center;
}
.modal h3 { margin: 0; font-size: 17px; }
.modal p { color: var(--secondary); font-size: 14px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }

.banner {
  background: rgba(10, 132, 255, 0.16);
  border: 1px solid rgba(10, 132, 255, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
}
.login-card { width: min(420px, 100%); }
.login-brand { text-align: center; margin-bottom: 8px; }
.login-brand h1 { margin: 8px 0 0; font-size: 32px; letter-spacing: -0.03em; }
.login-wheel { height: 180px; }
.error {
  color: #ffd1cc;
  background: rgba(255, 69, 58, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}
.login-note { color: var(--tertiary); font-size: 12px; text-align: center; }

.chart-head, .range-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.range-row select, .chart-head select { width: auto; min-width: 120px; }
.compare {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: #3a3a3c;
  white-space: nowrap;
}
.compare.up { color: var(--green); }
.compare.down { color: var(--orange); }
.chart { width: 100%; height: 180px; display: block; margin-top: 8px; }
.low-data {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}
.snapshot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.snap {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.bullet {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid transparent;
}
.bullet p { margin: 4px 0 0; font-size: 14px; }
.source { color: var(--tertiary); font-size: 11px; font-weight: 650; margin: 8px 0 0; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.toggle input { width: 22px; height: 22px; }

@media (min-width: 760px) {
  .areas { grid-template-columns: 1fr 1fr; }
  .wheel-frame { height: 460px; }
}
@media (max-width: 640px) {
  .pair, .compass-row, .stats { grid-template-columns: 1fr; display: grid; }
  .screen-head h1 { font-size: 28px; }
  .week-strip { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
