:root {
  --bg: #ffffff;
  --ink: #000000;
  --line: #000000;
  --fill: #000000;
  --invert-text: #ffffff;
}

/* Color scheme (toggled by the corner) — dark background + accents */
.color {
  --bg: #0e0e14;
  --ink: #f5f5f5;
  --line: rgba(245, 245, 245, 0.55);
  --fill: #f5f5f5;
  --invert-text: #0e0e14;
  --water: #38bdf8;
  --sugar: #fbbf24;
  --salt: #ffffff;
  --kcal: #34d399;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

/* 1-bit halftone dither across the whole app */
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(var(--ink) 1px, transparent 1.3px),
    radial-gradient(var(--ink) 1px, transparent 1.3px);
  background-size: 5px 5px;
  background-position: 0 0, 2.5px 2.5px;
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* HERO (optional) */
.hero { text-align: center; margin: 0; }
.hero h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hero .sub { display: none; }

/* CARD */
.card {
  background: var(--bg);
  border: none;
  border-radius: 0;
  padding: 12px;
}
.card-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.card-title.centered { text-align: center; }

/* SETUP: three equal dials in a row + zones below */
.setup { position: relative; display: flex; flex-direction: column; gap: 10px; }
.setup-top { display: flex; gap: 8px; align-items: center; justify-content: center; }

/* DIAL */
.dial { position: relative; flex: 1 1 0; max-width: 134px; aspect-ratio: 1; }
.dialsvg { width: 100%; height: 100%; touch-action: none; cursor: pointer; display: block; }
.dial-track {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: butt;
  stroke-dasharray: 3 7;
}
.dial-progress {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: butt;
}
.dial-knob { fill: var(--ink); cursor: grab; }
.dial-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dial-num { font-weight: 800; font-size: 26px; line-height: 1; }

/* ZONES */
.zones {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border: 2px dotted var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 2px;
  border: none;
  border-left: 2px dotted var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.zone:first-child { border-left: none; }
.zone span { font-weight: 800; font-size: 15px; }
.zone small { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; }
.zone.active { background: var(--fill); color: var(--invert-text); }
.zone:active { opacity: 0.7; }

/* Color-mode heart-rate zones */
.color .zone[data-zone="1"].active { background: #60a5fa; color: #0e0e14; }
.color .zone[data-zone="2"].active { background: #34d399; color: #0e0e14; }
.color .zone[data-zone="3"].active { background: #fbbf24; color: #0e0e14; }
.color .zone[data-zone="4"].active { background: #fb923c; color: #0e0e14; }
.color .zone[data-zone="5"].active { background: #ef4444; color: #0e0e14; }

/* UNITS */
.unit { font-size: 11px; font-weight: 700; margin-top: 2px; opacity: 0.55; }

/* RESULTS */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.stat {
  border: 2px solid var(--line);
  border-left-width: 0;
  border-radius: 0;
  padding: 12px 4px;
  text-align: center;
}
.stat:first-child { border-left-width: 2px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.stat-val { font-size: 21px; font-weight: 800; line-height: 1; margin-top: 6px; }
.stat-u { font-size: 11px; font-weight: 700; margin-left: 1px; }
.stat-hi { background: var(--fill); color: var(--invert-text); }
.color .stats .stat:nth-child(1) .stat-val { color: var(--water); }
.color .stats .stat:nth-child(2) .stat-val { color: var(--sugar); }
.color .stats .stat:nth-child(3) .stat-val { color: var(--salt); }
.color .stat-hi { background: var(--kcal); color: #07140d; }

/* TIMELINE */
.timeline { display: flex; flex-direction: column; }
.tl-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 16px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.tl-divider::before,
.tl-divider::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 2px dashed var(--line);
}
.tl-divider span { white-space: nowrap; }

.tl-item {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  position: relative;
  padding-bottom: 16px;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-time { font-size: 11px; font-weight: 700; text-align: right; padding-top: 2px; }
.tl-body { position: relative; padding-left: 20px; }
.tl-body::before {
  content: "";
  position: absolute;
  left: 3px; top: 3px;
  width: 10px; height: 10px;
  border-radius: 0;
  background: var(--ink);
}
.tl-item:not(:last-child) .tl-body::after {
  content: "";
  position: absolute;
  left: 7px; top: 14px; bottom: -16px;
  width: 2px;
  background: var(--ink);
}
.tl-item.pre .tl-body::before { background: var(--bg); box-shadow: inset 0 0 0 2px var(--ink); }
.tl-item.espresso .tl-body::before { background: var(--ink); box-shadow: inset 0 0 0 2px var(--bg), 0 0 0 1px var(--ink); }
.tl-title { font-weight: 700; font-size: 14px; }
.tl-desc { font-size: 12px; margin-top: 2px; }

.foot {
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  padding: 4px 8px 0;
}

/* ============================================================
   COLOR MODE — vibrant, modern, gradient styling (CSS only).
   Scoped under .color so white 1-bit mode stays untouched.
   ============================================================ */
.color body {
  background-color: #0b0a1f;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.3px),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.3px),
    radial-gradient(70% 55% at 12% -5%, rgba(56, 189, 248, 0.30), transparent 70%),
    radial-gradient(70% 55% at 110% 10%, rgba(251, 191, 36, 0.20), transparent 70%),
    radial-gradient(90% 70% at 50% 115%, rgba(168, 85, 247, 0.28), transparent 70%),
    linear-gradient(160deg, #1a1038 0%, #0b1228 55%, #06121f 100%);
  background-size: 5px 5px, 5px 5px, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  background-position: 0 0, 2.5px 2.5px, 0 0, 0 0, 0 0, 0 0;
}

/* Glassy cards */
.color .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.color .card-title { color: rgba(245, 245, 245, 0.7); }

/* Dials — each gets its own accent + soft glow */
.color .dial-track { stroke: rgba(255, 255, 255, 0.22); }
.color #dial-weight .dial-progress { stroke: #38bdf8; filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.7)); }
.color #dial-weight .dial-knob { fill: #7dd3fc; }
.color #dial-duration .dial-progress { stroke: #a78bfa; filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.7)); }
.color #dial-duration .dial-knob { fill: #c4b5fd; }
.color #dial-temp .dial-progress { stroke: #fb923c; filter: drop-shadow(0 0 4px rgba(251, 146, 60, 0.7)); }
.color #dial-temp .dial-knob { fill: #fdba74; }
.color .dial-num {
  background: linear-gradient(180deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Heart-rate pill — gradient fills when active */
.color .zones { border-color: rgba(255, 255, 255, 0.2); }
.color .zone { border-left-color: rgba(255, 255, 255, 0.2); }
.color .zone[data-zone="1"].active { background: linear-gradient(180deg, #60a5fa, #2563eb); color: #fff; }
.color .zone[data-zone="2"].active { background: linear-gradient(180deg, #34d399, #059669); color: #04231a; }
.color .zone[data-zone="3"].active { background: linear-gradient(180deg, #fde047, #f59e0b); color: #2a1c00; }
.color .zone[data-zone="4"].active { background: linear-gradient(180deg, #fb923c, #ea580c); color: #fff; }
.color .zone[data-zone="5"].active { background: linear-gradient(180deg, #f87171, #dc2626); color: #fff; }
.color .zone.active { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }

/* Result numbers — gradient text */
.color .stats .stat { border-color: rgba(255, 255, 255, 0.12); }
.color .stats .stat:nth-child(1) .stat-val {
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.color .stats .stat:nth-child(2) .stat-val {
  background: linear-gradient(180deg, #fde047, #fbbf24);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.color .stats .stat:nth-child(3) .stat-val {
  background: linear-gradient(180deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.color .stat-hi {
  background: linear-gradient(180deg, #34d399, #10b981);
  color: #04231a;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

/* Timeline accents */
.color .tl-body::before {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.6);
}
.color .tl-item.pre .tl-body::before {
  background: #0b0a1f;
  box-shadow: inset 0 0 0 2px #38bdf8, 0 0 8px rgba(56, 189, 248, 0.5);
}
.color .tl-item:not(:last-child) .tl-body::after { background: rgba(255, 255, 255, 0.18); }
.color .tl-divider { color: #a78bfa; }
.color .tl-divider::before,
.color .tl-divider::after { border-top-color: rgba(167, 139, 250, 0.5); }
