/* Doglogger — mobile-first, one-tap logging. */

:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --surface-2: #efece7;
  --line: #e2ddd5;
  --text: #1c1917;
  --muted: #78706a;
  --accent: #b4531f;
  --danger: #b42318;
  --ink: #fff;               /* text/glyphs on a solid tone fill */
  --shadow: 0 1px 2px rgba(28, 25, 23, .06), 0 8px 24px rgba(28, 25, 23, .06);

  --tone-amber: #c08f10;
  --tone-brown: #8a5a34;
  --tone-orange: #d2691e;
  --tone-blue: #2f7fb5;
  --tone-green: #3f8a55;
  --tone-pink: #c2568a;
  --tone-purple: #7159b8;
  --tone-red: #c2453a;
  --tone-teal: #2c8079;
  --tone-grey: #6b6660;

  --tap: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110f;
    --surface: #201c19;
    --surface-2: #2a2521;
    --line: #35302b;
    --text: #f3efe9;
    --muted: #a39a92;
    --accent: #f0864a;
    --danger: #f27168;
    --ink: #17120e;         /* dark tones flip to light, so ink flips too */
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);

    --tone-amber: #e8bd4a;
    --tone-brown: #b07a4c;
    --tone-orange: #ec8b4e;
    --tone-blue: #58a6d8;
    --tone-green: #5cb079;
    --tone-pink: #e07ba9;
    --tone-purple: #9985d8;
    --tone-red: #e2695f;
    --tone-teal: #4aa79f;
    --tone-grey: #9a938c;
  }
}

* { box-sizing: border-box; }

/* The sheet and toast are display:flex, which would otherwise beat [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  padding:
    calc(env(safe-area-inset-top) + 62px)
    env(safe-area-inset-right)
    calc(env(safe-area-inset-bottom) + 74px)
    env(safe-area-inset-left);
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

button { font: inherit; color: inherit; cursor: pointer; }

svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- chrome ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(env(safe-area-inset-top) + 62px);
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { min-width: 0; flex: 1; }
.topbar h1 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
}
.tab svg { width: 22px; height: 22px; }
.tab[aria-current] { color: var(--accent); }

main { padding: 12px 16px 18px; }

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

/* One full-width row per activity, all of them on one screen: the rows share
   whatever height the phone has, down to a comfortable tap target. */
.grid {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 6px;
  max-width: 560px;
  margin: 0 auto;
  min-height: calc(100dvh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

/* The row is a wrapper so the Undo can sit beside the button rather than
   inside it — a button inside a button is not valid HTML. */
.action-row { position: relative; display: grid; }
.action-row .action { height: 100%; }
.action-row.undoable .action { padding-right: 158px; }

/* The corrections sit on the row, over its right-hand end. */
.just-logged {
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  display: flex;
  gap: 6px;
  animation: rise .16s ease;
}

.just-logged button {
  padding: 0 14px;
  border: 0;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}
.just-logged button:active { transform: scale(.94); }

.undo { background: var(--tone, var(--accent)); color: var(--ink); }
.nudge { background: var(--surface-2); color: var(--text); }

.action {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  /* The rows share the screen, so more buttons means slightly shorter ones.
     This is the floor: comfortably above the 44px a thumb needs. */
  min-height: 46px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .12s ease, background-color .12s ease;
}
.action:active { transform: scale(.965); background: var(--surface-2); }

.action .ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--ink);
  background: var(--tone, var(--muted));
}
.action .ico svg { width: 21px; height: 21px; stroke-width: 1.8; }

.action .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.action .name {
  font-size: 15.5px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action .since {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action .count {
  flex: none;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- shared blocks ---------- */

.section-title {
  margin: 22px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Only the page's own first heading hugs the top — one inside a panel is
   still a new section and keeps its full spacing. */
main > .section-title:first-child { margin-top: 4px; }

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.empty {
  margin: 40px auto;
  max-width: 260px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- history ---------- */

.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  text-align: left;
}
.entry:first-child { border-top: 0; }
.entry:active { background: var(--surface-2); }

.entry .ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--ink);
  background: var(--tone, var(--muted));
}
.entry .ico svg { width: 19px; height: 19px; }

.entry .body { flex: 1; min-width: 0; }
.entry .body b { font-weight: 650; font-size: 15px; }
.entry .body span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry time { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- stats ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.heat { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.heat th { padding: 8px 4px; font-weight: 600; color: var(--muted); font-size: 11px; }
.heat th:first-child { text-align: left; padding-left: 14px; }
.heat td { padding: 3px 4px; text-align: center; }
.heat td:first-child { text-align: left; padding-left: 14px; color: var(--muted); white-space: nowrap; }
.heat tr:last-child td { padding-bottom: 12px; }
.heat .cell {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.heat .cell.on { color: var(--text); }

.trend { display: block; width: 100%; height: 130px; padding: 12px 14px 4px; }
.trend path { stroke: var(--tone-teal); stroke-width: 2.2; }
.trend circle { fill: var(--tone-teal); stroke: none; }
.trend text { fill: var(--muted); stroke: none; font-size: 10px; }

/* ---------- settings ---------- */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row label { flex: 1; font-size: 15px; }
.row input[type="text"], .row select {
  flex: 1;
  min-width: 0;
  max-width: 58%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: right;
}
.row select { text-align: left; }

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 15.5px;
  font-weight: 620;
}
.btn.primary { border-color: transparent; background: var(--accent); color: var(--ink); }
.btn.ghost { background: var(--surface-2); }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn.danger-link {
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 14.5px;
  width: 100%;
}
.btn:active { transform: scale(.985); }

.about { margin: 22px 2px 0; font-size: 12.5px; color: var(--muted); }
.about.bad { color: var(--danger); }

.sync-value {
  max-width: 60%;
  font-size: 14px;
  font-weight: 650;
  text-align: right;
  overflow-wrap: anywhere;
}
.sync-value.bad { color: var(--danger); }
.sync-value.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- activity editor ---------- */

.act {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-top: 1px solid var(--line);
}
.act:first-child { border-top: 0; }

.act .ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--tone, var(--muted));
}
.act .ico svg { width: 18px; height: 18px; }

.act-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:disabled { opacity: .3; }
/* Keeps the controls in line whether or not a row has an edit button. */
.icon-slot { flex: none; width: 38px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:active:not(:disabled) { background: var(--surface-2); }

.note-row { margin: 0; padding: 14px; color: var(--muted); font-size: 14px; }

.tagline {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- gate ---------- */

/* Sign-in and dog-picking replace the app, so its chrome steps aside. */
body.gated .tabbar,
body.gated #today-chip { display: none; }

.gate {
  max-width: 420px;
  margin: 8px auto;
  animation: rise .2s ease;
}
.gate h2 { margin-bottom: 8px; font-size: 22px; }
.gate p {
  margin: 0 2px 18px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
}
.gate .card { margin-bottom: 12px; }
.gate .btn.block { margin-top: 0; margin-bottom: 10px; }
.gate code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.gate .row input { max-width: 62%; }
.gate-problem:empty { display: none; }

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

.toast {
  position: fixed;
  z-index: 40;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 78px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 16px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: rise .18s ease;
}
.toast span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button {
  flex: none;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  color: inherit;
  font-size: 13.5px;
  font-weight: 700;
}

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

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

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, .38);
  animation: fade .15s ease;
}

.sheet {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 16px);
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  animation: rise .2s ease;
}
.sheet-grip { width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: var(--line); }
.sheet h2 { margin-bottom: 14px; font-size: 18px; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
}
.field textarea { min-height: 76px; resize: vertical; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
}
.pill[aria-pressed="true"] { border-color: transparent; background: var(--accent); color: var(--ink); }

.pill.glyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
}
.pill.glyph svg { width: 22px; height: 22px; }

.swatch {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--tone);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }

.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 4px; }

@keyframes fade { from { opacity: 0; } }

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