:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --warn: #ffcc44;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
  padding: 18px; gap: 12px;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex: 0 0 auto;
}
.title { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.status {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-secondary);
  max-width: 280px; text-align: right;
}
.status.muted { color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot-counting { background: var(--accent-secondary); animation: dotpulse 1.6s infinite; }
.dot-demo { background: var(--accent); animation: dotpulse 1.6s infinite; }
.dot-paused { background: var(--text-muted); }
.dot-need { background: var(--warn); }
.dot-nosensor { background: var(--danger); }
@keyframes dotpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(0, 255, 136, 0); }
}

/* ---------- hero ring ---------- */
.hero { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; }
.ring-wrap { position: relative; width: 232px; height: 232px; }
.ring { width: 232px; height: 232px; display: block; }
.ring-track { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 14; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round;
  transform: rotate(-90deg); transform-box: fill-box; transform-origin: center;
  transition: stroke-dashoffset 0.3s ease;
  filter: drop-shadow(0 0 5px rgba(0, 212, 255, 0.5));
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.step-num {
  font-size: 62px; font-weight: 800; line-height: 1; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.step-num.bump { animation: bump 0.18s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.step-label {
  font-size: 12px; font-weight: 600; letter-spacing: 3px;
  color: var(--text-secondary); margin-top: 4px;
}
.step-of { font-size: 13px; color: var(--accent); margin-top: 8px; font-weight: 600; }

/* ---------- stat tiles ---------- */
.stats { display: flex; gap: 10px; flex: 0 0 auto; }
.stat {
  flex: 1; background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 12px 8px; text-align: center; border: 1px solid rgba(255, 255, 255, 0.04);
}
.stat-val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-lab { font-size: 11px; color: var(--text-secondary); margin-top: 3px; letter-spacing: 0.3px; }

/* ---------- nav bar ---------- */
.navbar { display: flex; gap: 10px; flex: 0 0 auto; }
.navbtn {
  flex: 1; min-height: 88px;
  background: var(--bg-tertiary); border-radius: var(--radius-md);
  color: var(--text-primary);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit;
}
.navbtn.wide { flex: 1; }
.navbtn-icon { font-size: 24px; line-height: 1; }
.navbtn-label { font-size: 14px; font-weight: 600; }
.navbtn.primary { background: #10283a; }
.navbtn.primary .navbtn-icon, .navbtn.primary .navbtn-label { color: var(--accent); }

/* ---------- history chart ---------- */
.chart {
  flex: 1 1 auto; position: relative;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 20px 14px 10px; border: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 0;
}
.bars { height: 100%; display: flex; align-items: flex-end; gap: 8px; }
.bar-col {
  flex: 1; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px;
  border-radius: 8px; padding: 2px;
}
.bar-val { font-size: 11px; color: var(--text-secondary); height: 14px; font-variant-numeric: tabular-nums; }
.bar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; min-height: 0; }
.bar-fill {
  width: 100%; min-height: 3px; border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2a6f8a, #163847);
}
.bar-fill.today { background: linear-gradient(180deg, var(--accent), #0a7da0); }
.bar-day { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.goal-line {
  position: absolute; left: 14px; right: 14px;
  border-top: 1px dashed rgba(0, 255, 136, 0.45);
  pointer-events: none; z-index: 1;
}
.goal-tag {
  position: absolute; right: 0; top: -8px;
  font-size: 9px; color: var(--accent-secondary);
  background: var(--bg-secondary); padding: 0 4px; letter-spacing: 0.5px;
}

/* ---------- settings rows ---------- */
.rows {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}
.row {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 54px; padding: 8px 14px;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  scroll-margin: 12px;
}
.row-lab { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.row-val { font-size: 15px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.row.action .row-val { color: var(--text-secondary); }
.row.danger .row-val { color: var(--danger); }
.row-stepper { display: flex; align-items: center; gap: 12px; }
.row-stepper .row-val { min-width: 64px; text-align: center; }
.chev { font-size: 20px; color: var(--text-muted); font-weight: 700; }
.row.focusable:focus .chev { color: var(--accent); }
