:root {
  --bg: #fbf6ef;
  --surface: #ffffff;
  --text: #2a211b;
  --muted: #7a6c60;
  --border: #eee3d6;
  --accent: #b5652b;        /* golden cocker */
  --accent-soft: #f8e9da;
  --accent-text: #ffffff;
  --good: #2f7d4f;
  --good-soft: #e3f3e8;
  --warn: #b7791f;
  --warn-soft: #fdf1d8;
  --danger: #b3261e;
  --danger-soft: #fde7e5;
  --shadow: 0 1px 2px rgba(90, 50, 20, .05), 0 4px 14px rgba(90, 50, 20, .06);
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: light only;
}

* { box-sizing: border-box; }

html, body { overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
  line-height: 1.2;
}
h2 { font-size: 20px; }
h3 { font-size: 17px; }

p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }
.error:empty { display: none; }

/* ---------- buttons & inputs ---------- */

.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn.link { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 500; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .6; cursor: default; }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* anything smaller makes iPhone Safari zoom in on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; min-height: 70px; }

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- login ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 10%, #f6dcc0 0, transparent 40%),
    radial-gradient(circle at 90% 85%, #f3e3c8 0, transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; text-align: left; }
.login-dog { font-size: 56px; line-height: 1; margin-bottom: 8px; }
.login-card h1 { font-size: 30px; margin-bottom: 6px; }
.who { display: flex; gap: 10px; }
.who label {
  flex: 1;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  font-weight: 600;
}
.who input { position: absolute; opacity: 0; pointer-events: none; }
.who label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------- app shell ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-title { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 19px; display: flex; gap: 8px; align-items: center; }
.top-age { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 99px; }
.top-age:empty { display: none; }

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1;
  max-width: 128px;
  height: var(--tabs-h);
  border: 0;
  background: none;
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}
.tabs button span { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .65; }
.tabs button.active { color: var(--accent); }
.tabs button.active span { filter: none; opacity: 1; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-head h2, .card-head h3 { min-width: 0; }

.hero {
  background: linear-gradient(135deg, #c27235, #a1531f);
  color: #fff;
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}
.hero .eyebrow { font-size: 13px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.hero h1 { font-size: 28px; }
.hero p { opacity: .95; }
.hero .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.hero .chip { background: rgba(255,255,255,.18); color: #fff; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.grey { background: #f1ece6; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { padding: 10px 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }

.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.steps li::marker { font-weight: 600; color: var(--accent); }

.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 99px;
  white-space: nowrap;
  cursor: pointer;
}
.filters button.active { background: var(--text); color: #fff; border-color: var(--text); }

.empty { text-align: center; color: var(--muted); padding: 18px 8px; }

.progress { height: 8px; border-radius: 99px; background: #f1ece6; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- today ---------- */

.potty { display: flex; flex-direction: column; gap: 12px; }
.potty-status { display: flex; gap: 12px; align-items: center; }
.potty-status .big { font-size: 34px; line-height: 1; }
.potty-status b { display: block; font-size: 17px; }
.potty.due { border: 2px solid var(--warn); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.2;
  text-align: center;
}
.quick button span { font-size: 24px; line-height: 1; }
.quick button:active { transform: scale(.96); background: var(--accent-soft); }

.skill-row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.skill-emoji {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.skill-row .grow { flex: 1; min-width: 0; }
.skill-row b { display: block; }
.skill-row.locked { opacity: .55; }

.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #e7ddd2; }
.dots i.on { background: var(--accent); }
.dots.l3 i.on { background: var(--good); }

/* ---------- levels / ratings ---------- */

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 4px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.25;
}
.seg button span { display: block; font-size: 20px; }
.seg button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------- log ---------- */

.log-day h3 { font-family: Inter, system-ui, sans-serif; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.log-entry {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  padding: 9px 0;
  cursor: pointer;
}
.log-entry:first-of-type { border-top: 0; }
.log-entry .t { width: 50px; font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.log-entry .e { font-size: 18px; flex: none; }
.log-entry .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-entry.bad .grow { color: var(--danger); }

.week { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.week th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 0 2px 6px; }
.week th:first-child, .week td:first-child { text-align: left; }
.week td { text-align: center; padding: 6px 2px; border-top: 1px solid var(--border); }
.week td.good { color: var(--good); font-weight: 600; }
.week td.bad { color: var(--danger); font-weight: 600; }

/* ---------- timeline ---------- */

.tl { position: relative; list-style: none; margin: 0; padding: 0 0 0 26px; }
.tl::before { content: ''; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl > li { position: relative; margin-bottom: 12px; }
.tl-dot {
  position: absolute;
  left: -26px; top: 14px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid #d9cbbb;
  display: grid; place-items: center;
  font-size: 11px;
  color: #fff;
}
.tl-item {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 0;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-item .when { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tl-item b { font-size: 15.5px; }
.tl > li.done .tl-dot { background: var(--good); border-color: var(--good); }
.tl > li.now .tl-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl > li.now .tl-item { outline: 2px solid var(--accent-soft); }
.tl > li.missed .tl-dot { background: var(--warn-soft); border-color: var(--warn); }
.tl > li.memory .tl-dot { background: #e6a23c; border-color: #e6a23c; }
.tl > li.memory .tl-item { background: #fff9ef; }
.tl > li.past:not(.done):not(.memory) .tl-item { opacity: .75; }
.tl-today { position: relative; margin: 6px 0 18px; }
.tl-today .tl-dot { background: var(--text); border-color: var(--text); top: 2px; }
.tl-today span { font-weight: 600; font-size: 13.5px; background: var(--text); color: #fff; padding: 4px 10px; border-radius: 99px; }

/* ---------- socialisation ---------- */

.soc-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.soc-item:first-of-type { border-top: 0; }
.soc-item .grow { flex: 1; min-width: 0; font-size: 14.5px; }
.soc-item .grow small { display: block; color: var(--muted); font-size: 12px; }
.soc-item .count { font-size: 12px; font-weight: 600; min-width: 26px; text-align: center; color: var(--muted); }
.soc-btns { display: flex; gap: 4px; flex: none; }
.soc-btns button {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}
.soc-btns button:active { transform: scale(.92); background: var(--accent-soft); }
.soc-item.met .grow { font-weight: 500; }

/* ---------- guides ---------- */

details.guide { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
details.guide summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: center;
}
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary::after { content: '›'; margin-left: auto; font-size: 20px; color: var(--muted); transition: transform .15s; }
details.guide[open] summary::after { transform: rotate(90deg); }
.guide-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; }
.guide-body h4 { margin: 4px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.callout { background: var(--warn-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.callout.tip { background: var(--accent-soft); }
.callout.goal { background: var(--good-soft); }

/* ---------- sheet ---------- */

.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 640px;
  max-height: 92dvh;
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  color: var(--text);
}
.sheet::backdrop { background: rgba(40, 25, 15, .4); }
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 22px; }
}
.sheet-inner { position: relative; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--border);
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
}
#sheet-body { display: flex; flex-direction: column; gap: 16px; }
#sheet-body > h2 { padding-right: 40px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  max-width: calc(100% - 32px);
}
.toast button { font: inherit; font-weight: 600; color: #f6c48f; background: none; border: 0; cursor: pointer; padding: 0; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; font-family: Fraunces, Georgia, serif; }
.stat span { font-size: 12px; color: var(--muted); }
