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

:root {
  --green: #3a7d44;
  --green-light: #e8f5e9;
  --green-dark: #1b5e20;
  --brown: #795548;
  --text: #212121;
  --text-muted: #757575;
  --bg: #f9f6f0;
  --card: #ffffff;
  --card-inner: #ffffff;
  --border: #e0e0e0;
  --input-bg: #fafafa;
  --slider-track: #e0e0e0;
  --progress-track: #e0e0e0;
  --recipe-bg: linear-gradient(135deg, #f1f8f2 0%, #ffffff 100%);
  --recipe-notes-border: #e8f5e9;
  --secondary-btn: #f0f0f0;
  --overlay-bg: rgba(8, 25, 10, 0.96);
  --radar-fill: rgba(58, 125, 68, 0.22);
  --radar-stroke: #3a7d44;
  --radar-grid: #e0e0e0;
  --radar-label: #757575;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --green: #4caf50;
  --green-light: #1a2e1b;
  --green-dark: #81c784;
  --brown: #bcaaa4;
  --text: #e8e8e8;
  --text-muted: #9e9e9e;
  --bg: #121212;
  --card: #1e1e1e;
  --card-inner: #2a2a2a;
  --border: #333333;
  --input-bg: #2a2a2a;
  --slider-track: #333333;
  --progress-track: #333333;
  --recipe-bg: linear-gradient(135deg, #1a2a1b 0%, #1e1e1e 100%);
  --recipe-notes-border: #2a3d2b;
  --secondary-btn: #2a2a2a;
  --overlay-bg: rgba(3, 12, 5, 0.97);
  --radar-fill: rgba(76, 175, 80, 0.25);
  --radar-stroke: #4caf50;
  --radar-grid: #2d2d2d;
  --radar-label: #9e9e9e;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 48px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 24px 0 16px;
  position: relative;
}

header h1 {
  font-size: 48px;
  color: var(--green-dark);
  line-height: 1;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.theme-toggle {
  position: absolute;
  top: 24px;
  right: 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.theme-toggle:active { transform: scale(0.9); }

/* ── Section shell ───────────────────────────────────────────────────────── */
.section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.section-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Tea selector – 2×2 grid ─────────────────────────────────────────────── */
.tea-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tea-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 4px;
  min-height: 80px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.tea-btn.active {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-dark);
}

.tea-icon { font-size: 22px; }
.tea-jp   { font-size: 10px; opacity: 0.7; }

/* ── Brew method toggle ──────────────────────────────────────────────────── */
.toggle-row { display: flex; gap: 8px; }

.toggle-btn {
  flex: 1;
  padding: 14px 12px;
  min-height: 48px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--input-bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.toggle-btn.active {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green-dark);
}

/* ── Dials ───────────────────────────────────────────────────────────────── */
.dial-wrap { padding: 0 4px; }

.dial {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(
    to right,
    var(--green) 0%,
    var(--green) var(--fill, 40%),
    var(--slider-track) var(--fill, 40%)
  );
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  /* increase touch area without changing visual height */
  padding: 12px 0;
  margin: -12px 0;
}

.dial::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 2px 6px rgba(58,125,68,0.4);
  cursor: grab;
}

.dial::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.12);
}

.dial-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 18px;
}

.swipe-hint {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  opacity: 0.6;
  letter-spacing: 0.05em;
}

/* ── Recipe card ─────────────────────────────────────────────────────────── */
.recipe-card {
  background: var(--recipe-bg);
  border-left: 4px solid var(--green);
}

.recipe-card h2 {
  font-size: 18px;
  color: var(--green-dark);
  margin-bottom: 10px;
}

/* ── Infusion tracker ────────────────────────────────────────────────────── */
.infusion-tracker {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--green-light);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.infusion-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.infusion-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s, transform 0.2s;
}

.infusion-dot.done    { background: var(--green-dark); opacity: 0.4; }
.infusion-dot.active  { background: var(--green); transform: scale(1.25); }

.infusion-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-dark);
  flex: 1;
}

.infusion-label.complete {
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Recipe grid ─────────────────────────────────────────────────────────── */
.recipe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.recipe-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card-inner);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.recipe-icon  { font-size: 20px; margin-bottom: 4px; }
.recipe-val   { font-size: 17px; font-weight: 700; color: var(--green-dark); line-height: 1.2; }
.recipe-key   { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-top: 2px; }

.recipe-notes {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  border-top: 1px solid var(--recipe-notes-border);
  padding-top: 10px;
}

/* ── Radar chart ─────────────────────────────────────────────────────────── */
#radar-chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}

.radar-grid  { fill: none; stroke: var(--radar-grid); stroke-width: 1; }
.radar-axis  { stroke: var(--radar-grid); stroke-width: 1; }
.radar-value {
  fill: var(--radar-fill);
  stroke: var(--radar-stroke);
  stroke-width: 2;
  stroke-linejoin: round;
  transition: d 0.35s ease;
}
.radar-label {
  font-size: 10px;
  fill: var(--radar-label);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── Timer ───────────────────────────────────────────────────────────────── */
.timer-section { text-align: center; }

.timer-display {
  font-size: 72px;
  font-weight: 200;
  color: var(--green-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -3px;
  line-height: 1;
  margin-bottom: 14px;
  transition: color 0.3s;
}

.timer-display.running { color: var(--green); }
.timer-display.done    { color: var(--brown); }

.timer-progress-wrap {
  height: 6px;
  background: var(--progress-track);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 4px 10px;
}

.timer-progress {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 3px;
  transition: width 1s linear;
}

.timer-status {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 20px;
  margin-bottom: 14px;
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.timer-btn {
  padding: 15px 28px;
  min-height: 52px;
  border: none;
  border-radius: 50px;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(58,125,68,0.3);
}

.timer-btn:active { transform: scale(0.95); }

.timer-btn.secondary {
  background: var(--secondary-btn);
  color: var(--text-muted);
  box-shadow: none;
}

.next-steep-btn {
  background: var(--green-dark);
}

/* ── Brewing Now Overlay ─────────────────────────────────────────────────── */
.brew-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.brew-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.brew-overlay-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.brew-header {
  text-align: center;
}

.brew-tea-name {
  font-size: 22px;
  font-weight: 600;
  color: #c8e6c9;
  letter-spacing: 0.02em;
}

.brew-infusion-label {
  font-size: 14px;
  color: rgba(200, 230, 201, 0.6);
  margin-top: 2px;
  min-height: 20px;
}

.brew-temp-label {
  font-size: 16px;
  color: #a5d6a7;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.brew-timer-display {
  font-size: 96px;
  font-weight: 100;
  color: #e8f5e9;
  font-variant-numeric: tabular-nums;
  letter-spacing: -4px;
  line-height: 1;
  transition: color 0.3s;
}

.brew-timer-display.done { color: #ffcc80; }

.brew-progress-wrap {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
}

.brew-progress {
  height: 100%;
  width: 0%;
  background: #66bb6a;
  border-radius: 2px;
  transition: width 1s linear;
}

.brew-status {
  font-size: 15px;
  color: rgba(200, 230, 201, 0.75);
  min-height: 22px;
  text-align: center;
}

.brew-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
  width: 100%;
}

.brew-btn {
  flex: 1;
  min-width: 110px;
  min-height: 52px;
  padding: 14px 20px;
  border: none;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.brew-btn:active { transform: scale(0.95); }

.brew-btn-pause {
  background: rgba(102, 187, 106, 0.2);
  color: #a5d6a7;
  border: 2px solid rgba(102, 187, 106, 0.4);
}

.brew-btn-next {
  background: #388e3c;
  color: white;
}

.brew-btn-stop {
  background: rgba(255,255,255,0.08);
  color: rgba(200,230,201,0.6);
  border: 1px solid rgba(255,255,255,0.12);
}
