:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface-1: #ffffff;
  --surface-2: #efefef;
  --border: #dcdcdc;
  --text-primary: #191919;
  --text-secondary: #666666;
  --grid: #e6e6e6;
  --accent: #257de0;
  --danger: #d03b3c;
  --ok: #008a17;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --mark-neutral: #6b7a8f;
  --seq-0: #f3f6fa; --seq-1: #b6d5f8; --seq-2: #6aabf1; --seq-3: #2370cd; --seq-4: #0e3d7e;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f0f10;
    --surface-1: #191919;
    --surface-2: #242424;
    --border: #333333;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --grid: #2c2c2c;
    --accent: #338ced;
    --danger: #eb6263;
    --ok: #0aac23;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --mark-neutral: #8796ab;
    --seq-0: #222326; --seq-1: #0f4a96; --seq-2: #1b64be; --seq-3: #338ced; --seq-4: #9dc8f7;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-primary); }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(24px + env(safe-area-inset-bottom)) env(safe-area-inset-left); line-height: 1.4; font-size: 16px; }
main { max-width: 760px; margin: 0 auto; padding: 0 14px; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 6px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 0 10px; }
.top nav { display: flex; gap: 8px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.muted { color: var(--text-secondary); font-size: 13px; }
.mono, .num { font-variant-numeric: tabular-nums; }
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); border-radius: 10px; padding: 8px 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; text-decoration: none; display: inline-block; }
button:active { transform: scale(.98); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button.small { padding: 4px 9px; font-size: 13px; }
button:disabled { opacity: .5; }
input, select, textarea { font: inherit; font-size: 16px; /* prevents iOS zoom */ color: var(--text-primary); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; margin: 10px 0; }
label.field > span { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 0; min-width: 0; }

/* segmented control */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 4px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button.on { background: var(--surface-1); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* big action buttons */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.action { position: relative; display: flex; align-items: center; justify-content: center; padding: 16px 10px; min-height: 120px; border-radius: 20px; border: 0; color: #fff; text-align: center; }
.action[data-t="play"]   { background: #7c3aed; }
.action[data-t="food"]   { background: #c2410c; }
.action[data-t="litter"] { background: #0f766e; }
.action[data-t="pee"]    { background: #1d4ed8; }
.action .t { font-weight: 700; font-size: clamp(15px, 5vw, 20px); line-height: 1.2; hyphens: auto; -webkit-hyphens: auto; }
.action[data-t="pee"] .t { font-size: 52px; font-weight: 500; font-family: "Times New Roman", Georgia, serif; font-style: italic; line-height: 1; }
.action .cnt { position: absolute; top: 10px; right: 10px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px; background: rgba(255,255,255,.25); color: #fff; font-size: 14px; font-weight: 700; line-height: 26px; font-variant-numeric: tabular-nums; }
.action .cnt.zero { opacity: .5; }
.linkish { background: none; border: 0; padding: 6px 2px; color: var(--accent); font-size: 14px; }
details.card > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 17px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--text-secondary); transition: transform .2s; }
details.card[open] > summary::after { transform: rotate(180deg); }
details.card[open] > summary { margin-bottom: 10px; }
.action.flash { outline: 3px solid var(--text-primary); outline-offset: 2px; }

/* tables */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 6px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }

/* log list */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.log li .when { font-variant-numeric: tabular-nums; color: var(--text-secondary); width: 46px; }
.log li .what { flex: 1; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; padding: 7px 12px; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text-secondary); font-size: 10px; font-family: inherit; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hover-band { fill: var(--text-primary); opacity: .06; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; margin: 4px 0 6px; color: var(--text-primary); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.25); min-width: 120px; font-variant-numeric: tabular-nums; }
.tip b { display: block; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text-primary); color: var(--bg); padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 60; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 92vw; }
.toast button { background: transparent; color: inherit; border-color: currentColor; padding: 4px 10px; }

.tabs { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 6px 0; }
.hidden { display: none !important; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.preview img, .preview video { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; margin-top: 8px; }
.err { color: var(--danger); font-size: 14px; margin-top: 6px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .h { text-align: center; font-size: 12px; color: var(--text-secondary); padding: 4px 0; }
.cal .d { aspect-ratio: 1 / 1; border-radius: 8px; background: var(--surface-2); border: 1px solid transparent; padding: 3px; font-size: 13px; display: flex; flex-direction: column; justify-content: space-between; text-align: left; }
.cal .d.out { opacity: .35; }
.cal .d.today { border-color: var(--accent); }
.cal .d.sel { background: var(--accent); color: #fff; }
.cal .d .marks { display: flex; gap: 2px; flex-wrap: wrap; }
.cal .d .marks i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); display: block; }
.cal .d.sel .marks i { background: #fff; }
.entry { border-top: 1px solid var(--grid); padding: 10px 0; }
.entry img, .entry video { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin-top: 6px; background: #000; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: auto; }

.seg.compact button { flex: 0 0 auto; padding: 7px 11px; overflow: visible; }
.top h1 { white-space: nowrap; font-size: 20px; }
.top .btn, .top button { padding: 7px 10px; font-size: 14px; white-space: nowrap; }
