/* PawReady: mobile-first, light and dark, usable at 375 px. No inline styles (the CSP blocks them). */
:root {
  --accent: #4549b8; --accent-ink: #ffffff; --accent-soft: #e8e8f8;
  --bg: #f7f5f0; --card: #ffffff; --text: #1d1c22; --muted: #5f5e68; --line: #e4e0d8;
  --ok: #1f7a4d; --ok-bg: #e1f3e8; --warn: #9a5b00; --warn-bg: #fdf0d9; --bad: #b3261e; --bad-bg: #fbe3e0; --info: #3d5a80; --info-bg: #e5edf6;
  --link: #3437a5; --chart-line: #4549b8; --chart-band: #dfe9dc; --chart-grid: #ebe7df;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #a5a8ff; --accent-ink: #14142b; --accent-soft: #26264a;
    --bg: #131318; --card: #1c1c23; --text: #eeedf3; --muted: #a9a8b5; --line: #2e2d37;
    --ok: #7dd8a5; --ok-bg: #173325; --warn: #f3c06b; --warn-bg: #3a2b10; --bad: #ffb4ab; --bad-bg: #44201c; --info: #a9c6e8; --info-bg: #1d2a38;
    --link: #b8baff; --chart-line: #a5a8ff; --chart-band: #233528; --chart-grid: #2a2a33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #a5a8ff; --accent-ink: #14142b; --accent-soft: #26264a;
  --bg: #131318; --card: #1c1c23; --text: #eeedf3; --muted: #a9a8b5; --line: #2e2d37;
  --ok: #7dd8a5; --ok-bg: #173325; --warn: #f3c06b; --warn-bg: #3a2b10; --bad: #ffb4ab; --bad-bg: #44201c; --info: #a9c6e8; --info-bg: #1d2a38;
  --link: #b8baff; --chart-line: #a5a8ff; --chart-band: #233528; --chart-grid: #2a2a33;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1 { font-size: 1.5rem; line-height: 1.2; margin: 4px 0 6px; }
h2 { font-size: .85rem; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card h2:first-child { margin-top: 0; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; } .big { font-size: 1.8rem; font-weight: 700; margin: 0; }
.pre { white-space: pre-wrap; }
.warn { color: var(--warn); }
.clip { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* frame */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; min-height: 52px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; padding-left: 4px; white-space: nowrap; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 1rem; }
.top-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.top-title.sub { margin-left: auto; color: var(--muted); font-weight: 500; font-size: .9rem; }
main { padding: 12px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 680px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { padding: 8px 0 7px; font-size: .75rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; min-height: 52px; }
.tabs a span { font-size: 1.3rem; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 700; }

/* building blocks */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; display: block; text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.card.note { border-color: var(--accent); background: var(--accent-soft); }
.card.empty { text-align: center; color: var(--muted); }
.card.list { padding: 2px 14px; }
.btn, button.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; text-decoration: none; text-align: center; cursor: pointer; min-height: 44px; }
.btn.small, button.btn.small { padding: 6px 12px; min-height: 38px; font-size: .9rem; }
.ghost, button.ghost, a.ghost { display: inline-block; background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; text-decoration: none; cursor: pointer; min-height: 44px; text-align: center; }
.ghost.small, button.ghost.small, a.ghost.small { padding: 6px 10px; font-size: .85rem; min-height: 38px; }
button:disabled { opacity: .4; cursor: default; }
.danger { color: var(--bad) !important; }
.iconbtn { background: transparent; border: 0; color: var(--accent); font-size: 1.9rem; line-height: 1; min-width: 44px; min-height: 44px; border-radius: 12px; cursor: pointer; display: inline-grid; place-items: center; text-decoration: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row.wrap .ghost { flex: 0 1 auto; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 44px; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); vertical-align: middle; margin: 0 6px 0 0; flex-shrink: 0; }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; }
label { font-size: .85rem; color: var(--muted); }
.form label { display: block; margin-bottom: 10px; }
.form label input, .form label textarea, .form label select { margin-top: 4px; color: var(--text); font-size: 1rem; }
.form label.check, label.check { display: flex; align-items: center; color: var(--text); font-size: 1rem; min-height: 44px; margin: 0; }
.form h2 { margin-top: 18px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; align-items: end; }
.two > label { min-width: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 8px; margin: 0 0 12px; }
legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
fieldset.tags { display: grid; grid-template-columns: 1fr; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
label.inline select { width: auto; }
details > summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details[open] > summary { margin-bottom: 8px; }
.item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 52px; }
.list > .item:first-child { border-top: 0; }
.item .grow { display: flex; gap: 10px; align-items: center; min-width: 0; flex: 1; }
.item .grow > div { min-width: 0; }
.acts { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.ic { font-size: 1.3rem; width: 30px; text-align: center; flex-shrink: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl td { padding: 6px 0; border-top: 1px solid var(--line); }
.tbl tr:first-child td { border-top: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.linkbox { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; overflow-wrap: anywhere; user-select: all; }
.why { padding-left: 20px; margin: 6px 0; } .why li { margin: 4px 0; }

/* chips (state is never color alone: each chip has its word) */
.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.chip.given, .chip.later { background: var(--ok-bg); color: var(--ok); }
.chip.skipped, .chip.none { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.missed, .chip.overdue { background: var(--bad-bg); color: var(--bad); }
.chip.due, .chip.today, .chip.soon { background: var(--warn-bg); color: var(--warn); }
.item.dose.missed { box-shadow: inset 3px 0 0 var(--bad); padding-left: 8px; }
.item.dose.due { box-shadow: inset 3px 0 0 var(--warn); padding-left: 8px; }

/* pets */
.av { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); flex-shrink: 0; overflow: hidden; }
.av.sm { width: 36px; height: 36px; } .av.lg { width: 56px; height: 56px; } .av.xl { width: 84px; height: 84px; }
.av .avtxt { font-size: 1.2rem; } .av.lg .avtxt { font-size: 1.6rem; } .av.xl .avtxt { font-size: 2.3rem; }
.av img.avimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.av img.avimg.on { opacity: 1; }
.petgrid { display: grid; grid-template-columns: 1fr; gap: 0; }
.petcard { display: flex; gap: 12px; align-items: center; }
.pn { font-size: 1.1rem; }
.pethead { display: flex; gap: 14px; align-items: center; margin: 4px 0 10px; }
.pethead > div { min-width: 0; }
.segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 6px; }
.seg { text-align: center; padding: 8px 2px; border-radius: 9px; text-decoration: none; color: var(--muted); font-size: .85rem; font-weight: 600; min-height: 38px; }
.seg.on { background: var(--accent); color: var(--accent-ink); }
img.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; vertical-align: middle; background: var(--accent-soft); }
img.thumb:not(.on) { visibility: hidden; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
img.docimg { width: 100%; height: auto; border-radius: 10px; margin: 8px 0; }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.hero { background: linear-gradient(160deg, var(--accent-soft), var(--card)); }
.season { border-left: 4px solid var(--warn); }
.season.storm { border-left-color: var(--info); }
.safety { font-size: .92rem; }

/* weight chart */
.chartwrap { width: 100%; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .band { fill: var(--chart-band); }
svg.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; }
svg.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot { fill: var(--chart-line); stroke: var(--card); stroke-width: 2; }
svg.chart .dot.out { fill: var(--card); stroke: var(--chart-line); }
svg.chart .dot.sel { r: 6; }
svg.chart .hit { fill: transparent; cursor: pointer; outline: none; }
svg.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.charttip { min-height: 1.4em; margin: 4px 0 0; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .92rem; max-width: calc(100vw - 32px); transition: opacity .2s, transform .2s; z-index: 10; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* sitter sheet (screen, sitter page and print) */
.sheet h1 { font-size: 1.4rem; }
.sh-head { border-bottom: 2px solid var(--accent); margin-bottom: 8px; padding-bottom: 4px; }
.sh-dates { font-weight: 600; }
.sh-sec, .sh-pet { margin: 12px 0; }
.sh-pet { border-top: 1px solid var(--line); padding-top: 10px; }
.sh-pethead { display: flex; gap: 12px; align-items: center; }
.sh-photo { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; }
.sh-name { font-size: 1.25rem; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.sheet h2 { margin: 8px 0 4px; }
.sheet h3 { font-size: 1rem; margin: 10px 0 2px; }
.sh-list { padding-left: 18px; margin: 4px 0; }
.sh-meds { width: 100%; border-collapse: collapse; font-size: .95rem; }
.sh-meds td { border-top: 1px solid var(--line); padding: 6px 4px 6px 0; vertical-align: top; }
.sh-safety { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
#print { display: none; }
@media print {
  body.printing #app { display: none; }
  body.printing #print { display: block; }
  #print { color: #000; background: #fff; font-size: 12pt; }
  #print a { color: #000; text-decoration: none; }
  #print .muted { color: #444; }
  .sh-pet { break-inside: avoid; }
  .sheet.print { padding: 0; }
}

/* sitter page */
.sitterpage main { padding-bottom: 32px; }
.noscript { padding: 40px 16px; text-align: center; color: var(--muted); }
