/* Karma Compass: a phone-first, colour-coded 16 / 32 zone Vastu compass. */

:root {
  color-scheme: light dark;

  --bg: #f4f1ec;
  --panel: #ffffff;
  --panel-2: #efebe4;
  --ink: #1a1714;
  --ink-2: #453e36;
  --muted: #6b6358;
  --line: rgba(26, 23, 20, 0.12);
  --line-2: rgba(26, 23, 20, 0.24);
  --tick: rgba(26, 23, 20, 0.38);
  --sep: #ffffff;
  --seg-on: #ffffff;

  --accent: #c2410c;
  --accent-press: #9a3412;
  --accent-soft: #fbe6da;
  --pointer: #c2410c;

  --live: #15803d;
  --live-soft: #dcf2e3;
  --held: #a35207;
  --held-soft: #fdecd3;
  --manual: #3d5a80;
  --manual-soft: #e1e9f3;

  --warn-bg: #fff3dd;
  --warn-line: #efc073;
  --warn-ink: #7a4304;


  --water: #1b56a3;
  --air: #1a6d3e;
  --fire: #b02e1c;
  --earth: #835608;
  --space: #523f9e;

  /* Zone-coloured text: full strength on light, lifted toward white on dark. */
  --zone: var(--water);
  --zmix: 100%;
  --zto: #000000;

  --shadow: 0 1px 2px rgba(26, 23, 20, 0.05), 0 10px 28px -16px rgba(26, 23, 20, 0.28);
  --radius: 20px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;

  --dial: min(calc(100vw - 32px), max(250px, calc(100vh - 330px)), 500px);
}

@supports (height: 100svh) {
  :root { --dial: min(calc(100vw - 32px), max(250px, calc(100svh - 330px)), 500px); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --panel: #1d1b18;
    --panel-2: #2a2622;
    --ink: #f5f1ea;
    --ink-2: #d9d1c5;
    --muted: #aba295;
    --line: rgba(245, 241, 234, 0.12);
    --line-2: rgba(245, 241, 234, 0.26);
    --tick: rgba(245, 241, 234, 0.42);
    --sep: #1d1b18;
    --seg-on: #4a443d;

    --accent-soft: #3b2418;
    --pointer: #f07436;

    --live: #4ade80;
    --live-soft: #173323;
    --held: #fbbf5e;
    --held-soft: #3a2b12;
    --manual: #9cc0ea;
    --manual-soft: #1f2b3b;

    --warn-bg: #33270f;
    --warn-line: #7a5a1c;
    --warn-ink: #fbd38d;


    --zmix: 58%;
    --zto: #ffffff;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 30px -18px rgba(0, 0, 0, 0.8);
  }
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html {
  font-size: 106.25%; /* 17px */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* On iPhone, follow the text size chosen in iOS settings, since pinch zoom is off. */
@media (pointer: coarse) {
  @supports (font: -apple-system-body) {
    html { font: -apple-system-body; }
  }
}

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
button, input, output { font: inherit; color: inherit; }
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 24px;
  height: 24px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--inline { width: 1.15em; height: 1.15em; vertical-align: -0.2em; }

/* ---------- app shell ---------- */

.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.views {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.view {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    max(16px, env(safe-area-inset-right, 0px))
    32px
    max(16px, env(safe-area-inset-left, 0px));
}

/* ---------- segmented control ---------- */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
}
.seg button {
  min-height: 46px;
  padding: 6px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.seg button b { font-weight: 800; }
.seg button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--ink);
  font-weight: 750;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16), 0 0 0 1.5px var(--line-2);
}
.seg button:active { background: var(--seg-on); }

.seg--zones { max-width: 460px; }
.seg--inline { margin-top: 16px; }

/* ---------- compass view ---------- */

/* One screen, no scrolling: the dial takes whatever height is left after
   the info strip and the control row. The view still scrolls as a fallback
   on very small screens or when a notice is showing. */
.view--compass {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 14px;
}

.dial-stage {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  container-type: size;
}

.dial {
  position: relative;
  width: var(--dial);
  height: var(--dial);
  border-radius: 50%;
  container-type: inline-size;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
}
@supports (width: 1cqh) {
  .dial {
    width: min(100cqw, 100cqh, 520px);
    height: min(100cqw, 100cqh, 520px);
  }
}
.dial.is-manual { touch-action: none; cursor: grab; }
.dial.is-dragging { cursor: grabbing; }
.dial:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }

/* The rotor is a square. A square (not round) clip trims its turning corners
   so they never add scroll space, without clipping the badges on the dial. */
.rotor-clip {
  position: absolute;
  inset: 0;
  contain: paint;
}

/* The whole dial turns as one GPU layer. Nothing is redrawn while it spins. */
.rotor {
  position: absolute;
  inset: 0;
  transform: rotate(0deg);
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: opacity 0.25s ease;
}
.dial.is-tilted .rotor { opacity: 0.4; }
.rotor-svg,
.dial-marks {
  display: block;
  width: 100%;
  height: 100%;
}
.dial-marks {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.d-disc { fill: var(--panel); stroke: var(--line); stroke-width: 1; }
.d-tick { fill: none; stroke: var(--tick); stroke-width: 1.3; stroke-linecap: round; }
.d-tick--major { stroke: var(--ink-2); stroke-width: 2.2; }
.d-tick--north { stroke: var(--pointer); stroke-width: 3.2; }
.d-band path { stroke: var(--sep); stroke-width: 2; stroke-linejoin: round; }
.d-hl { stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }

.d-zone,
.d-pada {
  fill: #ffffff;
  font-family: var(--font);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 0.02em;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.26);
  stroke-width: 2.4px;
  stroke-linejoin: round;
}
.d-zone--main { font-weight: 800; }
.d-pada { stroke-width: 2px; letter-spacing: 0; }

.d-deg {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 650;
  text-anchor: middle;
  dominant-baseline: central;
  font-variant-numeric: tabular-nums;
}

.pointer {
  fill: var(--pointer);
  stroke: var(--bg);
  stroke-width: 2;
  stroke-linejoin: round;
}

/* centre readout: what you face and what it means */
.face {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 59%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8%;
  border-radius: 50%;
  text-align: center;
  line-height: 1.1;
  pointer-events: none;
  background: var(--panel);
  background: color-mix(in srgb, var(--zone) 9%, var(--panel));
  box-shadow: inset 0 0 0 3px var(--zone);
}
.dial.is-32 .face { width: 54%; padding: 7%; }

.face-code {
  font-size: 40px;
  font-size: 11cqw;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--zone);
  color: color-mix(in srgb, var(--zone) var(--zmix), var(--zto));
}
.face-name {
  margin-top: 2px;
  margin-top: 0.6cqw;
  max-width: 100%;
  font-size: 15px;
  font-size: 4.2cqw;
  font-weight: 650;
  color: var(--ink-2);
}
.face-meaning {
  margin-top: 6px;
  margin-top: 1.7cqw;
  max-width: 100%;
  font-size: 18px;
  font-size: 5cqw;
  font-weight: 800;
  line-height: 1.12;
  color: var(--ink);
  text-wrap: balance;
}
.face-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  gap: 1.6cqw;
  margin-top: 6px;
  margin-top: 1.8cqw;
  font-size: 14px;
  font-size: 3.9cqw;
  font-weight: 650;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.face-element {
  font-weight: 800;
  color: var(--zone);
  color: color-mix(in srgb, var(--zone) var(--zmix), var(--zto));
}
.face-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.dial.is-32 .face-code { font-size: 10cqw; }
.dial.is-32 .face-name { font-size: 3.9cqw; }
.dial.is-32 .face-meaning { font-size: 4.5cqw; margin-top: 1.4cqw; }
.dial.is-32 .face-meta { font-size: 3.6cqw; margin-top: 1.4cqw; }

.face-idle,
.face-idle-icon { display: none; }
.dial.is-idle .face-code,
.dial.is-idle .face-name,
.dial.is-idle .face-meaning,
.dial.is-idle .face-meta { display: none; }
.dial.is-idle .face-idle-icon {
  display: block;
  width: 40px;
  height: 40px;
  width: 11cqw;
  height: 11cqw;
  color: var(--accent);
  stroke-width: 1.6;
}
.dial.is-idle .face-idle {
  display: block;
  margin-top: 6px;
  margin-top: 1.6cqw;
  max-width: 88%;
  font-size: 15px;
  font-size: 4.3cqw;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-2);
}
.dial.is-idle .face { box-shadow: inset 0 0 0 2px var(--line-2); background: var(--panel); }

/* status badge, sitting on the bottom edge of the dial */
.dial-status {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 13px 5px 9px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
  background: var(--panel);
  color: var(--ink-2);
  box-shadow: 0 0 0 1px var(--line), 0 4px 12px -6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.dial-status .icon { width: 16px; height: 16px; }
.dial-status.is-live { background: var(--live-soft); color: var(--live); }
.dial-status.is-live .icon { animation: pulse 1.8s ease-in-out infinite; }
.dial-status.is-held { background: var(--held-soft); color: var(--held); }
.dial-status.is-manual { background: var(--manual-soft); color: var(--manual); }
.dial-status.is-warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
  box-shadow: 0 0 0 1.5px var(--warn-line), 0 4px 12px -6px rgba(0, 0, 0, 0.35);
}

/* ---------- below the dial ---------- */

.compass-side {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.info {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 11px 16px 11px 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  background: color-mix(in srgb, var(--zone) 8%, var(--panel));
  box-shadow: var(--shadow);
}
.info::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: var(--zone);
}
.info-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
/* two lines are always reserved so the dial never jumps between zones */
.info-use {
  display: flex;
  align-items: center;
  min-height: 2.6em;
  font-size: 1.1rem;
  font-weight: 650;
  line-height: 1.3;
}
.info-meta { margin-top: 4px; font-size: 0.9rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.control-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 58px;
}
.seg--compact {
  flex: none;
  width: auto;
  grid-auto-columns: minmax(60px, auto);
}
.seg--compact button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 2px 10px;
  line-height: 1.05;
}
.seg--compact b { font-size: 1.15rem; }
.seg--compact span { margin-top: 1px; font-size: 0.78rem; font-weight: 650; }
.control-row .btn { flex: 1 1 auto; min-width: 0; padding: 0 14px; }
.row-hint {
  flex: 1 1 auto;
  align-self: center;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px;
  border: 0;
  border-radius: 16px;
  font-size: 1.06rem;
  font-weight: 700;
  line-height: 1.2;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn--block { width: 100%; }
.btn--small { min-height: 46px; padding: 0 18px; font-size: 0.98rem; }
.btn--primary { background: var(--accent); color: #ffffff; }
.btn--primary:active { background: var(--accent-press); }
.btn--secondary {
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--line-2), var(--shadow);
}
.btn--secondary:active { background: var(--panel-2); }
.btn .icon { width: 22px; height: 22px; }

/* ---------- notice (problems) ---------- */

.notice {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--warn-line);
  border-radius: 16px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.notice-icon { margin-top: 1px; }
.notice-title { font-weight: 750; color: var(--ink); }
.notice-text { margin-top: 4px; font-size: 0.95rem; color: var(--ink-2); }
.notice .btn { margin-top: 12px; }

/* ---------- cards ---------- */

.card {
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.start-card { padding: 14px 16px; }
.start-card h2 { font-size: 1.05rem; font-weight: 750; }
.howto {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 0;
  list-style: none;
}
.howto li {
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 0.98rem;
  line-height: 1.3;
  color: var(--ink-2);
}
.howto b { color: var(--ink); }
.howto-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  .howto-icon, .guide-icon { color: var(--pointer); }
}

/* ---------- view headers ---------- */

.view-head h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.view-head p { margin-top: 6px; color: var(--ink-2); }

.group-title {
  margin: 28px 4px 10px;
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--muted);
}

.fine { font-size: 0.92rem; line-height: 1.5; color: var(--muted); }
.fine--center { margin: 28px 8px 0; text-align: center; }

/* ---------- zones view ---------- */

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.95rem;
  font-weight: 650;
}
.legend-swatch {
  width: 28px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--a) 50%, var(--b) 50%);
}
.legend-note { margin: 10px 4px 0; font-size: 0.9rem; color: var(--muted); }

.zone-list { display: grid; gap: 12px; margin-top: 16px; }

.zcard {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.zcard.is-here { box-shadow: 0 0 0 3px var(--ink), var(--shadow); }
.zcard-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--zone);
  color: #ffffff;
}
.zcard-code {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 54px;
  height: 46px;
  padding: 0 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.08rem;
  font-weight: 800;
}
.zcard-titles { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.zcard-name { font-size: 1.1rem; font-weight: 750; line-height: 1.2; }
.zcard-sub { margin-top: 2px; font-size: 0.86rem; opacity: 0.94; font-variant-numeric: tabular-nums; }
.zcard-here {
  display: none;
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: #ffffff;
  color: #1a1714;
  font-size: 0.8rem;
  font-weight: 800;
}
.zcard.is-here .zcard-here { display: inline-block; }
.zcard-body { padding: 12px 16px 14px; }
.zcard-quality { font-size: 1.08rem; font-weight: 750; }
.zcard-use { margin-top: 6px; color: var(--ink-2); }
.zcard-use span { display: block; font-size: 0.86rem; font-weight: 700; color: var(--muted); }
.zcard-padas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pada-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 0.88rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.pada-chip b {
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--zone);
  color: #ffffff;
  font-size: 0.92rem;
}
.pada-chip.is-here { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- help view ---------- */

.guide {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 0;
  list-style: none;
}
.guide li {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.guide-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.guide-icon .icon { width: 28px; height: 28px; }
.guide h2 { font-size: 1.08rem; font-weight: 750; line-height: 1.25; }
.guide p { margin-top: 4px; color: var(--ink-2); }

.faq { display: grid; gap: 10px; }
.faq details {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.faq summary {
  position: relative;
  min-height: 56px;
  padding: 16px 52px 16px 18px;
  font-size: 1.02rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2.5px solid var(--muted);
  border-bottom: 2.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s ease;
}
.faq details[open] summary::after { transform: translateY(-25%) rotate(-135deg); }
.faq details p { padding: 0 18px 14px; color: var(--ink-2); }

.t-water { color: var(--water); color: color-mix(in srgb, var(--water) var(--zmix), var(--zto)); }
.t-air { color: var(--air); color: color-mix(in srgb, var(--air) var(--zmix), var(--zto)); }
.t-fire { color: var(--fire); color: color-mix(in srgb, var(--fire) var(--zmix), var(--zto)); }
.t-earth { color: var(--earth); color: color-mix(in srgb, var(--earth) var(--zmix), var(--zto)); }
.t-space { color: var(--space); color: color-mix(in srgb, var(--space) var(--zmix), var(--zto)); }

/* ---------- settings view ---------- */

.setting { padding: 16px; }
.setting .fine { margin-top: 12px; }
.setting-text { color: var(--ink-2); }
.setting-text + .btn { margin-top: 14px; }

.stepper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-top: 16px;
}
.stepper-label { font-weight: 700; }
.stepper-box {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.stepper-btn {
  width: 52px;
  height: 46px;
  border: 0;
  border-radius: 11px;
  background: var(--panel);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.stepper-btn:active { background: var(--panel-2); }
.stepper-value {
  min-width: 6.4em;
  font-weight: 750;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.setting--list { padding: 2px 16px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
}
.row + .row { border-top: 1px solid var(--line); }
.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 700; }
.row-sub { margin-top: 2px; font-size: 0.9rem; color: var(--muted); }

.switch {
  position: relative;
  flex: none;
  width: 58px;
  height: 34px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--line-2);
  transition: background-color 0.18s ease;
}
.switch-knob {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease;
}
.switch[aria-checked="true"] { background: var(--live); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(24px); }
@media (prefers-color-scheme: dark) {
  .switch[aria-checked="true"] { background: #16a34a; }
}

/* ---------- tab bar ---------- */

.tabbar {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  padding:
    5px
    max(6px, env(safe-area-inset-right, 0px))
    calc(5px + env(safe-area-inset-bottom, 0px))
    max(6px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 58px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}
.tabbar .icon {
  width: 60px;
  height: 32px;
  padding: 4px 18px;
  border-radius: 16px;
  transition: background-color 0.15s ease;
}
.tabbar button[aria-selected="true"] { color: var(--ink); font-weight: 750; }
.tabbar button[aria-selected="true"] .icon { background: var(--accent-soft); color: var(--accent); }
@media (prefers-color-scheme: dark) {
  .tabbar button[aria-selected="true"] .icon { color: var(--pointer); }
}

.noscript {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 40;
  padding: 16px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--panel);
  text-align: center;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- larger screens ---------- */

@media (min-width: 640px) {
  body { background: var(--panel-2); }
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Phone on its side: dial on the left, details on the right. */
@media (orientation: landscape) and (max-height: 540px) {
  .app { max-width: none; }
  .view--compass {
    flex-direction: row;
    align-items: center;
    gap: 24px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    padding-bottom: 6px;
  }
  .view--compass > .dial-stage { flex: 0 0 46%; align-self: stretch; min-height: 0; }
  .compass-side { flex: 1 1 0; min-width: 0; max-width: 520px; margin: 0; }
  .tabbar button { min-height: 46px; flex-direction: row; gap: 6px; }
  .tabbar .icon { width: 26px; height: 26px; padding: 0; background: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
