:root {
  --bg: #f4efe6;
  --paper: #fffaf3;
  --ink: #2a2824;
  --mute: #5c574e;
  --line: #e3d9c8;
  --accent: #4f6f52;
  --accent-deep: #3d5840;
  --accent-soft: #e4eee5;
  --warning-bg: #f6e6cc;
  --warning-ink: #6a4a1a;
  --danger-bg: #f3e0dc;
  --danger-ink: #7a3228;
  --nav: #fffaf3;
  --shadow: 0 1px 0 rgba(42, 40, 36, 0.06);
  --radius: 16px;
  --nav-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --max: 40rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
}

img { max-width: 100%; height: auto; display: block; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.wrap {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, white);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0 0.7rem;
}
.site-header h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.site-header p {
  margin: 0.15rem 0 0;
  color: var(--mute);
  font-size: 0.85rem;
}

.banner, .callout, .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0.85rem 0;
}
.callout strong { display: block; margin-bottom: 0.25rem; }
.callout.warning { background: var(--warning-bg); border-color: #e4c99a; color: var(--warning-ink); }
.callout.danger { background: var(--danger-bg); border-color: #e0b6ae; color: var(--danger-ink); }
.callout.info { background: var(--accent-soft); border-color: #c9ddcb; }

.banner { display: flex; gap: 0.75rem; align-items: flex-start; }
.banner p { margin: 0; font-size: 0.92rem; }
.banner .dismiss {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--mute);
  padding: 0.2rem 0.4rem;
}

h2 { font-size: 1.2rem; margin: 1.4rem 0 0.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.02rem; margin: 1rem 0 0.4rem; }
p { margin: 0.5rem 0; }
.lede { color: var(--mute); }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0.9rem 0;
}
.metric {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.metric .value { font-size: 1.15rem; font-weight: 650; }
.metric .label { font-size: 0.78rem; color: var(--mute); }

.figure {
  margin: 0.9rem 0 1.1rem;
}
.figure img, .figure .ph {
  width: 100%;
  border-radius: 14px;
  background: #ece4d6;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.figure figcaption {
  margin-top: 0.45rem;
  font-size: 0.88rem;
  color: var(--mute);
}

ol.steps, ul.plain {
  margin: 0.4rem 0 1rem;
  padding-left: 1.2rem;
}
ol.steps li, ul.plain li { margin: 0.4rem 0; }
ol.steps li title, .step-title { font-weight: 650; }

.week-pills, .tabs-desc { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 0.9rem; }
.pill {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  min-height: 40px;
}
.pill[aria-pressed="true"], .pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-weight: 600;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-deep); }
.btn.row { width: 100%; margin: 0.35rem 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.8rem 0; }

form.grid, .form-grid {
  display: grid;
  gap: 0.7rem;
  margin: 0.8rem 0;
}
.form-grid.three { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-grid.three { grid-template-columns: repeat(3, 1fr); }
  .metrics { grid-template-columns: repeat(4, 1fr); }
}
label.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; font-weight: 600; }
label.field span { color: var(--mute); font-weight: 550; }
input, select, textarea {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.45rem 0.7rem;
  width: 100%;
}
textarea { min-height: 72px; resize: vertical; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: var(--paper);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { font-size: 0.75rem; color: var(--mute); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
tr.today { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; margin: 0.8rem 0; }

blockquote {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  background: var(--accent-soft);
  border-radius: 12px;
  border: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.links a {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 0.95rem;
  margin: 0.45rem 0;
  color: var(--ink);
  text-decoration: none;
}
.links a:hover { border-color: var(--accent); }
.links .site { display: block; color: var(--mute); font-size: 0.8rem; margin-top: 0.15rem; }

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--nav);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.nav button {
  appearance: none;
  background: none;
  border: 0;
  min-height: var(--nav-h);
  padding: 0.35rem 0.2rem 0.45rem;
  color: var(--mute);
  font-size: 0.68rem;
  font-weight: 650;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}
.nav button[aria-current="page"] { color: var(--accent-deep); }
.nav .ico { font-size: 1.15rem; line-height: 1; width: 1.4rem; height: 1.4rem; }

.chart-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem;
  margin: 0.8rem 0;
}
.chart-wrap canvas { width: 100%; height: 200px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 0.8rem; font-size: 0.8rem; color: var(--mute); margin-top: 0.4rem; }
.legend i { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.3rem; vertical-align: -0.05rem; }

.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.28rem;
  margin: 0.6rem 0;
}
.heat .dow { font-size: 0.68rem; color: var(--mute); text-align: center; }
.heat .cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: #e8e0d2;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  color: var(--mute);
}
.heat .cell.s1 { background: #c9ddcb; color: var(--ink); }
.heat .cell.s2 { background: #8fb394; color: #1d2a1e; }
.heat .cell.s3 { background: #4f6f52; color: #fff; }
.heat .cell.today { outline: 2px solid var(--ink); outline-offset: 0; }

#timer-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: color-mix(in srgb, #2a2824 45%, transparent);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
#timer-sheet.open { display: flex; }
.sheet {
  width: min(var(--max), 100%);
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 1rem 1rem calc(1.1rem + var(--safe-bottom));
  max-height: 92dvh;
  overflow: auto;
}
.timer-time {
  font-size: 3rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  text-align: center;
  margin: 0.4rem 0 0.2rem;
  font-variant-numeric: tabular-nums;
}
.timer-progress {
  height: 8px;
  background: #e3d9c8;
  border-radius: 99px;
  overflow: hidden;
  margin: 0.6rem 0 1rem;
}
.timer-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
}
.timer-meta { text-align: center; color: var(--mute); font-size: 0.88rem; }

.hidden { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: #fff; padding: 0.4rem 0.6rem; z-index: 50; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
