:root {
  --bg: #f8f6f2;
  --card: #ffffff;
  --text: #17201e;
  --muted: #5f6b68;
  --line: #dfe5e3;
  --accent: #0f766e;
  --accent-soft: #d5ece9;
  --ready: #15803d;
  --early: #c2410c;
  --danger: #b91c1c;
  --go: #16a34a;
  --stop: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413;
    --card: #182120;
    --text: #e8eeec;
    --muted: #9aa8a5;
    --line: #2a3533;
    --accent: #2dd4bf;
    --accent-soft: #163a36;
    --ready: #4ade80;
    --early: #fb923c;
    --danger: #f87171;
    --go: #15803d;
    --stop: #b91c1c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

h1 { font-size: 2rem; margin: 24px 0 8px; color: var(--accent); }
h2 { font-size: 1rem; margin: 0; }
.lead { color: var(--muted); margin: 0 0 24px; }
.fine { color: var(--muted); font-size: 0.85rem; }

/* Welcome */
.welcome { text-align: center; padding-top: 8px; }
.welcome .garden svg { width: min(44vw, 170px); }
.welcome h1 { font-size: 2.4rem; margin: 4px 0 0; letter-spacing: -0.01em; }
.tagline { font-size: 1.2rem; color: var(--text); margin: 6px 0 16px; }
#beginBtn { margin-bottom: 24px; }
.welcome-text { color: var(--muted); margin: 0 auto 12px; max-width: 34ch; }
.promises {
  list-style: none; padding: 16px; margin: 20px 0 8px;
  background: var(--accent-soft); border-radius: 16px; text-align: left;
}
.promises li { padding: 6px 0 6px 28px; position: relative; }
.promises li::before {
  content: ''; position: absolute; left: 4px; top: 12px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #ff6f91; box-shadow: 0 0 0 3px #ffd1dc;
}
.install {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin: -8px 0 20px;
}
.install-title { font-weight: 700; }
.install p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.install b { color: var(--text); }
.install .btn { margin-top: 12px; }
.share-icon { width: 1.1em; height: 1.1em; vertical-align: -0.15em; color: var(--accent); }
.steps {
  text-align: left;
  list-style: none;
  counter-reset: step;
  padding: 16px;
  margin: 8px 0 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.steps li { counter-increment: step; position: relative; padding: 8px 0 8px 40px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--card); font-weight: 700; font-size: 0.9rem;
}
.install-manual, .install-done {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 8px 0 16px;
}
#gateInstallBtn { margin-bottom: 16px; }
#gateSkip { color: var(--muted); font-weight: 400; text-decoration: underline; margin-top: 4px; }
.center { text-align: center; }
.back { margin: 8px 0 0 -4px; }
.setup-title { font-size: 1.6rem; margin-top: 8px; }

/* Privacy policy and other text pages */
.doc h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.doc p, .doc li { line-height: 1.6; }
.doc ul { padding-left: 20px; }
.doc li { margin-bottom: 6px; }
a { color: var(--accent); }

/* Form */
.field { display: block; margin-bottom: 16px; flex: 1; }
.field > span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 12px; }
input, select {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
.stepper { display: flex; gap: 8px; }
.stepper input { text-align: center; font-size: 1.4rem; font-weight: 600; }
.stepper button {
  width: 56px; flex: none;
  font-size: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
.preview {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  margin-top: 10px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 1.1rem; padding: 18px; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #04201d; } }
.btn.danger { color: var(--danger); }
.btn.small { width: auto; display: inline-block; margin: 0; padding: 8px 14px; }
.icon-btn {
  font-size: 1.3rem;
  background: none; border: none; color: var(--muted);
  padding: 8px; cursor: pointer;
}
.link {
  background: none; border: none; padding: 4px;
  color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}

/* Main */
.topbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--accent); }

/* The big green / red button */
.smoke-btn {
  width: min(66vw, 240px);
  aspect-ratio: 1;
  margin: 28px auto 12px;
  border-radius: 50%;
  border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 20px;
  font: inherit;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px -12px var(--shadow);
  transition: background-color 0.4s, transform 0.1s;
}
.smoke-btn:active { transform: scale(0.97); }
.smoke-btn:focus-visible { outline: 3px solid var(--text); outline-offset: 4px; }
.smoke-btn.go { background: var(--go); --shadow: var(--go); }
.smoke-btn.stop { background: var(--stop); --shadow: var(--stop); }
.smoke-btn.neutral { background: var(--card); color: var(--text); border: 2px solid var(--line); --shadow: transparent; }
.smoke-main { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.smoke-sub { font-size: 0.95rem; opacity: 0.92; max-width: 15ch; }
.topbar .icon-btn { flex: none; }

/* The flower */
.garden { text-align: center; margin: 8px 0 4px; }
.garden svg { width: min(60vw, 250px); aspect-ratio: 2 / 3; display: block; margin: 0 auto; transition: filter 0.6s; }
.garden-caption { color: var(--muted); min-height: 1.4em; margin: 0; }
.flower-sway { transform-origin: 100px 232px; animation: sway 7s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(calc(var(--sway) * -1)); }
  50% { transform: rotate(var(--sway)); }
}
@media (prefers-reduced-motion: reduce) { .flower-sway { animation: none; } }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 12px;
}

.banner-actions { display: flex; align-items: center; gap: 4px; flex: none; }

.box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 12px;
}
.box summary {
  padding: 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.box summary::-webkit-details-marker { display: none; }
.box summary::after { content: '▾'; color: var(--muted); transition: transform 0.2s; }
.box[open] summary::after { transform: rotate(180deg); }
.box-body { padding: 0 16px 16px; }
.box-big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.box-body .fine { margin-top: 4px; }

.log-head { display: flex; justify-content: space-between; align-items: center; }
ul.log { list-style: none; padding: 0; margin: 0 0 8px; }
.log li {
  display: flex; justify-content: space-between;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.log li .tag { font-size: 0.85rem; font-weight: 600; }
.log li .tag.on { color: var(--ready); }
.log li .tag.early { color: var(--early); }
.log .empty { color: var(--muted); }

/* Settings sheet */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 10;
}
.sheet-card {
  background: var(--bg);
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
/* Sliding on/off switch (a styled checkbox) */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 16px; font-weight: 600; cursor: pointer;
}
.switch {
  appearance: none; -webkit-appearance: none;
  flex: none; width: 52px; height: 32px; margin: 0; padding: 0;
  border: none; border-radius: 999px;
  background: var(--line);
  position: relative; cursor: pointer;
  transition: background-color 0.2s;
}
.switch::before {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch:checked { background: var(--go); }
.switch:checked::before { transform: translateX(20px); }
.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::before { transition: none; } }

.remind-row {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.remind-note { margin: 6px 4px 0; }

.toggle { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-weight: 600; }
.toggle input { width: 24px; height: 24px; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex; gap: 16px; align-items: center;
  z-index: 20;
  max-width: calc(100% - 32px);
}
.toast .link { color: var(--bg); text-decoration: underline; }
