:root {
  --bg:#F7EFE5; --surface:#FFFCF7; --surface-2:#F1E6D8; --ink:#2A241F; --muted:#6D6157;
  --line:#E4D6C5; --accent:#A9482A; --accent-ink:#FFFCF7; --accent-soft:#F3DCCF;
  --done:#5E8466; --done-soft:#E2EBDD;
  --danger:#B3261E;
  --radius: 20px;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#1C1714; --surface:#27201B; --surface-2:#302721; --ink:#F2E8DC; --muted:#B6A796;
    --line:#3B3029; --accent:#E2795A; --accent-ink:#1C1714; --accent-soft:#3E2A22;
    --done:#8DB592; --done-soft:#2A3529;
    --danger:#F2B8B5;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
h1, h2 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(1.4rem, 5vw, 1.9rem); }
h2 { font-size: 1.05rem; font-weight: 500; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-left)) 14px max(16px, env(safe-area-inset-right));
  max-width: 760px; width: 100%; margin: 0 auto;
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.logo svg { width: 36px; height: 25px; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 8px; text-decoration: underline; }

.wrap { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 32px; }
.foot {
  max-width: 760px; width: 100%; margin: 0 auto; padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between;
  color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line);
}
.foot a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 16px; }
.narrow { max-width: 440px; margin-inline: auto; }
.crumbs { margin-bottom: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; padding: 0; }
.req { color: var(--accent); font-weight: 600; }
.opt { color: var(--muted); font-style: normal; font-weight: 400; font-size: .8rem; margin-left: 4px; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px: iPhone не приближает поле при вводе */
  color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
textarea { resize: vertical; min-height: 88px; }
input.short { max-width: 140px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
::placeholder { color: var(--muted); opacity: .7; }
.err-text { color: var(--danger); font-style: normal; font-size: .875rem; }
.field.has-error input, .field.has-error textarea { border-color: var(--danger); }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 10px 18px; border: 1.5px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--bg); }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.species-other { display: none; margin-top: 10px; }
.species:has(input[value=other]:checked) .species-other { display: flex; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 1rem var(--font-body); color: var(--accent-ink); background: var(--accent);
  border: 1.5px solid var(--accent); border-radius: 999px; padding: 12px 22px; cursor: pointer; text-decoration: none;
  min-height: 48px;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: .6; cursor: default; }

.notice { background: var(--accent-soft); border-radius: 14px; padding: 12px 16px; }
.notice.ok { background: var(--done-soft); }
.notice.err { background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--danger); }
.badge { font-size: .78rem; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); white-space: nowrap; }
.badge.done { background: var(--done-soft); color: var(--done); }

.pet-list { list-style: none; padding: 0; margin: 0 0 16px; }
.pet-row { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); padding: 14px; }
.pet-row img, .ph-empty { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; font-size: 1.6rem; }
.pet-row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pet-row-text strong { font-size: 1.05rem; }

.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.photo { position: relative; margin: 0; aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; display: block; }
.photo-del {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(28, 23, 20, .7); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 14px; display: grid; place-items: center;
  text-align: center; color: var(--accent); font-weight: 600; cursor: pointer; padding: 8px;
}
.photo-add[hidden] { display: none; }
.photo-add input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-add:focus-within { box-shadow: 0 0 0 3px var(--accent-soft); }
.photo.uploading { opacity: .5; }

.save-bar {
  position: sticky; bottom: 0; margin: 4px -20px -20px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.save-bar.error #save-status { color: var(--danger); }

.share-row { display: flex; gap: 8px; margin-bottom: 12px; }
.share-row input { flex: 1; min-width: 0; font-size: 14px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.danger { margin: 24px 0; color: var(--muted); }
.danger summary { cursor: pointer; padding: 8px 0; }

/* Анкета для ситтера */
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.facts span { background: var(--surface-2); padding: 6px 12px; border-radius: 999px; font-weight: 500; }
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 80%); gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 16px; padding: 0 16px; }
.gallery img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); scroll-snap-align: start; }
@media (min-width: 700px) { .gallery { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; padding: 0; } }
.text { white-space: pre-line; margin: 0; }
.text + .text { margin-top: 10px; }
.card.alert { border-color: var(--accent); background: var(--accent-soft); }

/* Админка */
.admin-user { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.admin-pets { margin: 12px 0 0; padding-left: 18px; }
.admin-pets li { margin-bottom: 6px; }
.admin-pets .small { display: block; }

.prose h2 { margin-top: 20px; }
.prose ul { padding-left: 20px; }

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

.stats { display: grid; gap: 10px; margin-top: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); }
.stat strong { font-weight: 500; }
.stat.bad { box-shadow: inset 4px 0 0 var(--danger); }
.notice.err p { margin: 0; }
.notice.err p + p { margin-top: 6px; }
