/* The owner app (docs/OWNER_APP.md 1.7, 10.1-10.4). Mobile first: 360 px is the
   main target, 320 px must not break. Colours come only from var(--pet-*) and
   the pill tokens in /themes-<hash>.css; spacing and radii are the tokens.css
   scale (that file is not served on the owner host). Logical properties
   throughout, so RTL (the default) and LTR share every rule. */

@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('/fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('/fonts/cairo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('/fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-7: 28px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 22px; --r-2xl: 32px; --r-full: 9999px;
  --gutter: 16px;
  --tap: 48px;
  --font: 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .10), 0 12px 32px rgba(0, 0, 0, .10);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light dark;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--pet-bg);
  color: var(--pet-ink);
  font: 400 1rem/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 240ms var(--ease);
}
:lang(en) body, body:lang(en) { line-height: 1.5; }

/* The species pattern: a monochrome tile used as a mask and painted in the
   primary at 6%, behind everything. Off for Save-Data, forced colours and print. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--pet-primary);
  opacity: .06;
  -webkit-mask-image: var(--pet-pattern);
  mask-image: var(--pet-pattern);
  -webkit-mask-size: 120px 120px;
  mask-size: 120px 120px;
}
[data-save-data] body::before { display: none; }
@media (forced-colors: active), print { body::before { display: none; } }

.page {
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  padding: var(--sp-4) var(--gutter) calc(var(--sp-12) + env(safe-area-inset-bottom));
}
body:has(.tabbar) .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

h1, h2, h3 { margin: 0 0 var(--sp-3); line-height: 1.3; letter-spacing: 0; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 var(--sp-3); }
.lead { font-size: 1.0625rem; }
.muted { color: var(--pet-muted); }
a { color: var(--pet-accent); text-underline-offset: .2em; }
bdi[dir=ltr] { unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
img, svg { max-width: 100%; }

:focus-visible { outline: 3px solid var(--pet-accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ── buttons and chips ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding: 0 var(--sp-5);
  border: 1.5px solid var(--pet-edge);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  color: var(--pet-ink);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 120ms var(--ease);   /* 10.3: a swipe switches every token but the page's at once */
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--pet-primary); border-color: transparent; color: var(--pet-on-primary); }
.btn-block { display: flex; width: 100%; }
.btn-block + .btn-block { margin-top: var(--sp-3); }
.btn-link {
  min-height: 44px;
  padding: 0 var(--sp-2);
  border-color: transparent;
  background: none;
  color: var(--pet-accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}
.btn-danger { color: var(--pill-late); border-color: currentColor; }
.btn-danger:is(.btn-primary) { background: var(--pill-late); color: var(--pet-surface); }
.btn[disabled], .btn[aria-disabled=true] { opacity: .55; cursor: default; transform: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-4);
  border: 1.5px solid var(--pet-edge);
  border-radius: var(--r-full);
  background: var(--pet-surface);
  color: var(--pet-ink);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;          /* pet chips are links on detail pages (chip_href) */
  cursor: pointer;
  touch-action: manipulation;
}
.chip[aria-current=true], .chip[aria-pressed=true] {
  background: var(--pet-primary);
  border-color: transparent;
  color: var(--pet-on-primary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 1px var(--sp-3);
  border: 1.5px solid currentColor;
  border-radius: var(--r-full);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}
.pill-ok { color: var(--pill-ok); background: var(--pill-ok-bg); }
.pill-soon { color: var(--pill-soon); background: var(--pill-soon-bg); }
.pill-late { color: var(--pill-late); background: var(--pill-late-bg); }
.pill-none { color: var(--pet-muted); }

.icon { width: 24px; height: 24px; flex: none; }
[dir=rtl] .icon-flip { transform: scaleX(-1); }

/* ── cards, lists, banners ─────────────────────────────────────────── */
.card {
  display: block;
  padding: var(--sp-4);
  border-radius: var(--r-xl);
  background: var(--pet-surface);
  color: var(--pet-ink);
  box-shadow: var(--shadow-1);
}
.card + .card, .card + form, form + .card { margin-top: var(--sp-3); }
.card > :last-child { margin-bottom: 0; }

.list { display: grid; gap: var(--sp-3); margin: 0 0 var(--sp-4); padding: 0; list-style: none; }

.banner {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--pill-ok-bg);
  color: var(--pill-ok);
  font-weight: 600;
}
.banner-warn { background: var(--pill-soon-bg); color: var(--pill-soon); }
.field-error {
  margin: 0 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-inline-start: 4px solid currentColor;
  border-radius: var(--r-md);
  background: var(--pill-late-bg);
  color: var(--pill-late);
  font-weight: 600;
}
.rescued { margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--pill-soon-bg); color: var(--pill-soon); }

/* The cached copy (sw.js stamps data-cached-at) and the newer-version chip. */
.cached-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--gutter)) var(--sp-4);
  padding: var(--sp-2) var(--gutter);
  /* Sticky over the page: the tint sits on an opaque background, as the pill test measures it. */
  background: linear-gradient(var(--pill-soon-bg), var(--pill-soon-bg)), var(--pet-bg);
  color: var(--pill-soon);
  font-size: .875rem;
  font-weight: 700;
  text-align: center;
}
.newer-chip {
  position: fixed;
  top: calc(var(--sp-3) + env(safe-area-inset-top));
  inset-inline: 0;
  z-index: 60;
  width: max-content;
  max-width: calc(100% - 2 * var(--gutter));
  margin-inline: auto;
  box-shadow: var(--shadow-2);
}

/* ── forms ─────────────────────────────────────────────────────────── */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
.field { display: grid; gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.field > span, .field > legend { font-weight: 600; }
.field > legend { margin-bottom: var(--sp-2); }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--sp-4);
  border: 1.5px solid var(--pet-edge);
  border-radius: var(--r-md);
  background: var(--pet-surface);
  color: var(--pet-ink);
  font: inherit;
  font-size: 1.0625rem;          /* 16px or more: iOS does not zoom the page */
}
textarea { padding-block: var(--sp-3); min-height: 104px; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--pet-accent);
  outline: 2px solid var(--pet-accent);
  outline-offset: 0;
}
input::placeholder { color: var(--pet-muted); opacity: 1; }
input[type=radio], input[type=checkbox] {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: none;
  accent-color: var(--pet-accent);
}
.choice, .switch {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 48px;
  cursor: pointer;
}
.switch { justify-content: space-between; flex-direction: row-reverse; margin-bottom: var(--sp-3); }
.switch > span { flex: 1; }
/* Side by side while both time fields fit, else one under the other (320 px). */
.quiet-hours { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr)); gap: var(--sp-3); }
.quiet-hours input[type=time] { padding-inline: var(--sp-2); }   /* beats the input:not(...) rule above */
.quiet-hours > legend { grid-column: 1 / -1; }
.quiet-hours label { display: grid; gap: var(--sp-1); }

.sticky-action {
  position: sticky;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 5;
  margin-top: var(--sp-6);
  box-shadow: var(--shadow-2);
}
/* 1.3: above the tab bar and its raised حجز, and back down when the bar slides away. */
body:has(.tabbar) .sticky-action { bottom: calc(3.5rem + var(--sp-8) + env(safe-area-inset-bottom)); }
body:has(.tabbar[data-away]:not(:focus-within)) .sticky-action { bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }

/* ── bottom sheets: <details class="sheet" data-sheet> ─────────────── */
.sheet > summary { list-style: none; cursor: pointer; }
.sheet > summary::-webkit-details-marker { display: none; }
.sheet:not([data-sheet])[open] > .sheet-body {
  margin-top: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  box-shadow: var(--shadow-1);
}
.sheet[data-sheet][open]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .45);
  animation: fade 160ms var(--ease);
}
.sheet[data-sheet][open] > .sheet-body {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 41;
  max-width: 480px;
  max-height: 85vh;
  max-height: 85dvh;
  margin-inline: auto;
  padding: var(--sp-3) var(--gutter) calc(var(--sp-6) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--pet-surface);
  color: var(--pet-ink);
  box-shadow: var(--shadow-2);
  animation: rise 220ms var(--ease);
}
.sheet[data-sheet][open] > .sheet-body::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  margin: 0 auto var(--sp-3);
  border-radius: var(--r-full);
  background: var(--pet-edge);
}
.sheet .sheet[data-sheet][open]::before { z-index: 42; }
.sheet .sheet[data-sheet][open] > .sheet-body { z-index: 43; }
.sheet-body > legend { float: inline-start; width: 100%; margin-bottom: var(--sp-3); font-size: 1.125rem; font-weight: 700; }
.sheet-search {
  position: sticky;
  top: calc(-1 * var(--sp-3));
  z-index: 1;
  margin-bottom: var(--sp-2);
}
.sheet-body ul, .sheet-body ol { margin: 0; padding: 0; list-style: none; }
.sheet-body .actions > li + li, .actions > li + li { margin-top: var(--sp-4); }
.actions { margin: 0; padding: 0; list-style: none; }
html:has(.sheet[data-sheet][open]) { overflow: hidden; }

@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ── auth screens (B) ──────────────────────────────────────────────── */
.welcome {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-2);
  min-height: calc(100dvh - var(--sp-4) - var(--sp-12));
  text-align: center;
}
.welcome h1 { font-size: 2rem; margin: 0; }
.welcome .lead { margin: 0 auto var(--sp-6); max-width: 30ch; color: var(--pet-muted); }
.brand-mark {
  width: 104px;
  height: 104px;
  margin: 0 auto var(--sp-4);
  border-radius: 30px;
  background: var(--pet-surface) url('/static/icons/icon-192.png') center / 88% no-repeat;
  box-shadow: var(--shadow-2);
}
.lang-switch { display: flex; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-6); }
.country-chip { margin-bottom: var(--sp-4); }
.country-chip > bdi { color: var(--pet-muted); }
.country-chip::after { content: ""; width: 8px; height: 8px; margin-inline-start: var(--sp-1); border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.country-list label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
}
.country-list label > bdi { margin-inline-start: auto; color: var(--pet-muted); }
.country-list label:has(input:checked) { background: var(--pet-bg); font-weight: 700; }
.sheet-body [data-list=clinics] a, .sheet-body [data-list=clinics] .btn { width: 100%; justify-content: space-between; margin-bottom: var(--sp-2); }
.code-form input[data-cells] {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: .4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.resend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-4); }
.no-code { margin-top: var(--sp-4); }
.no-code > summary { display: inline-flex; align-items: center; min-height: 44px; color: var(--pet-accent); font-weight: 700; text-decoration: underline; }

/* ── me and devices (B) ────────────────────────────────────────────── */
.me .card > h2 { margin-bottom: var(--sp-3); }
.lang-form .chip { margin: 0 0 var(--sp-2); }
.privacy { display: grid; gap: var(--sp-3); }
.privacy .sheet > summary { width: 100%; }
.device { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.device p { margin: 0; }
.device .chip { min-height: 28px; padding: 0 var(--sp-2); font-size: .8125rem; margin-inline-start: var(--sp-2); }
.back {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  margin-bottom: var(--sp-2);
  font-weight: 600;
  text-decoration: none;
}
.back::before { content: "\2190"; }
[dir=rtl] .back::before { content: "\2192"; }
.error-card { margin-top: var(--sp-12); text-align: center; }

/* ── offline (S25) ─────────────────────────────────────────────────── */
.offline { padding-top: var(--sp-10); text-align: center; }
.offline-mark { display: block; margin: 0 auto var(--sp-4); color: var(--pet-primary); }
.offline-list { text-align: start; }
.offline-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 56px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  color: var(--pet-ink);
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-1);
}
.offline-list small { flex: none; color: var(--pet-muted); font-weight: 400; white-space: nowrap; }

/* ── the pet avatar (10.4) ─────────────────────────────────────────── */
.avatar { position: relative; display: inline-block; flex: none; line-height: 0; color: var(--pet-ink); vertical-align: middle; }
.avatar > svg { display: block; overflow: visible; }
.avatar-disc { fill: var(--pet-primary); opacity: var(--pet-disc, .14); }
.avatar-badge {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  background: var(--pet-accent);
  color: var(--pet-on-accent);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}
.avatar-memorial { color: var(--pet-muted); }
.avatar .fx { pointer-events: none; }

/* ── the tab bar (1.3) ─────────────────────────────────────────────── */
.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  min-height: calc(3.5rem + env(safe-area-inset-bottom));
  padding: 0 max(var(--sp-1), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--sp-1), env(safe-area-inset-left));
  border-top: 1px solid var(--pet-edge);
  border-top-color: color-mix(in srgb, var(--pet-edge) 40%, transparent);
  background: var(--pet-surface);
  background: color-mix(in srgb, var(--pet-surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  transition: transform 220ms var(--ease);
}
/* Past the raised حجز (20px + 4px ring) and its shadow; a keyboard focus brings it back (WCAG 2.4.11). */
.tabbar[data-away]:not(:focus-within) { transform: translateY(calc(100% + 48px)); }
.tab {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 3.5rem;
  padding: var(--sp-1) 2px;
  color: var(--pet-muted);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
}
.tab-icon { position: relative; display: grid; place-items: center; }
.tab[aria-current=page] { color: var(--pet-ink); }
.tab[aria-current=page] .icon { color: var(--pet-accent); }
.tab[aria-current=page]::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--pet-accent);
}
.tab-book .tab-icon {
  width: 52px;
  height: 52px;
  margin-top: -20px;
  border-radius: var(--r-full);
  background: var(--pet-primary);
  color: var(--pet-on-primary);
  box-shadow: 0 0 0 4px var(--pet-bg), var(--shadow-2);
}
.tab-book .icon, .tab-book[aria-current=page] .icon { color: var(--pet-on-primary); }
.tab-book[aria-current=page]::before { display: none; }
.badge {
  position: absolute;
  top: -6px;
  inset-inline-end: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--pet-accent);
  color: var(--pet-on-accent);
  box-shadow: 0 0 0 2px var(--pet-surface);
  font-size: .6875rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}
@media (max-width: 319.98px) {
  .tab-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}
/* 200% zoom or landscape: the bar would cover the page (WCAG 1.4.10). */
@media (max-height: 479.98px) and (max-width: 599.98px) {
  .tabbar:not(:focus-within) { transform: translateY(calc(100% + 48px)); }
  body:has(.tabbar) .page { padding-bottom: calc(var(--sp-12) + env(safe-area-inset-bottom)); }
  .sticky-action { position: static; }
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--pet-edge);
  border-color: color-mix(in srgb, var(--pet-edge) 55%, transparent);
  border-radius: var(--r-full);
  background: var(--pet-surface);
  color: var(--pet-ink);
  text-decoration: none;
}
.icon-btn .dot {
  position: absolute;
  top: 9px;
  inset-inline-end: 10px;
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--pet-accent);
  box-shadow: 0 0 0 2px var(--pet-surface);
}

/* ── the pet hero (10.3, 10.4): photo first, in a frame cut to its species ── */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
  border-radius: var(--r-2xl);
  background-color: var(--pet-surface);
  background-image: radial-gradient(130% 62% at 50% 0%, color-mix(in srgb, var(--pet-primary) 18%, var(--pet-surface)) 0%, var(--pet-surface) 72%);
  color: var(--pet-ink);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.hero-portrait { position: relative; display: grid; place-items: center; width: 168px; height: 168px; margin-bottom: var(--sp-2); }
.hero-halo { display: grid; place-items: center; width: 168px; height: 168px; border-radius: var(--r-full); box-shadow: 0 0 0 3px var(--pet-accent), 0 0 0 9px var(--pet-surface); }
.hero-halo .avatar > svg { width: 148px; height: 148px; }
/* The frame: the species shape as a mask, the accent ring behind the photo in the same shape. */
.frame {
  --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='30'/%3E%3C/svg%3E");
  display: block;
  width: 168px;
  height: 168px;
  padding: 4px;
  background: var(--pet-accent);
  -webkit-mask: var(--frame) center / 100% 100% no-repeat;
  mask: var(--frame) center / 100% 100% no-repeat;
}
.frame > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--pet-bg);
  -webkit-mask: var(--frame) center / 100% 100% no-repeat;
  mask: var(--frame) center / 100% 100% no-repeat;
}
[data-species=cat] .frame { --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M9 40 13 3l25 18q12-4 24 0L87 3l4 37q6 13 3 29-5 30-44 30T6 69q-3-16 3-29z'/%3E%3C/svg%3E"); }
[data-species=dog] .frame { --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='55' r='43'/%3E%3Cellipse cx='15' cy='34' rx='14' ry='26' transform='rotate(22 15 34)'/%3E%3Cellipse cx='85' cy='34' rx='14' ry='26' transform='rotate(-22 85 34)'/%3E%3C/svg%3E"); }
[data-species=rabbit] .frame { --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='62' r='37'/%3E%3Cellipse cx='34' cy='24' rx='10' ry='24' transform='rotate(-10 34 24)'/%3E%3Cellipse cx='66' cy='24' rx='10' ry='24' transform='rotate(10 66 24)'/%3E%3C/svg%3E"); }
[data-species=bird] .frame, [data-species=falcon] .frame { --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='56' r='43'/%3E%3Cpath d='M38 16Q42 0 52 2q-4 8 2 12 6-10 16-8-8 6-6 14z'/%3E%3C/svg%3E"); }
[data-species=fish] .frame { --frame: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='50' rx='49' ry='42'/%3E%3C/svg%3E"); }
.hero-mood {
  position: absolute;
  bottom: -8px;
  inset-inline-end: -12px;
  padding: 3px;
  border-radius: var(--r-full);
  background: var(--pet-surface);
  box-shadow: var(--shadow-1);
  line-height: 0;
}
.hero-name { margin: var(--sp-1) 0 0; font-size: 1.625rem; font-weight: 800; line-height: 1.3; }
.hero-name > a, .hero-name > span {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--pet-accent);
  text-decoration-thickness: 3px;
  text-underline-offset: .32em;
  text-decoration-skip-ink: none;
}
.hero-meta { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: var(--sp-1) 0 0; color: var(--pet-muted); font-weight: 600; }
.hero-meta .icon { width: 20px; height: 20px; color: var(--pet-primary); }
:root[lang=en] .hero-meta > span:first-of-type { text-transform: capitalize; }
.dot-sep { width: 4px; height: 4px; border-radius: var(--r-full); background: currentColor; opacity: .6; }
.hero-note { margin: var(--sp-1) 0 0; color: var(--pet-muted); font-weight: 700; }
.hero-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-3); }
.clinic-chip { min-height: 44px; padding-inline: var(--sp-3) var(--sp-4); font-size: .9375rem; }
.clinic-chip .icon { width: 18px; height: 18px; color: var(--pet-primary); }
.hero-memorial { background-image: none; }
.hero-memorial .frame { background: var(--pet-muted); }
.hero-memorial .hero-halo { --pet-accent: var(--pet-muted); }
.hero-memorial .frame > img { filter: grayscale(.7) sepia(.2); }
.hero-memorial .hero-name > a { text-decoration-color: var(--pet-muted); }

/* ── pet chips (1.3): real buttons, each in its pet's own colours ──── */
.pet-chips-wrap { margin: 0 calc(-1 * var(--gutter)) var(--sp-2); }
.pet-chips {
  display: flex;
  gap: var(--sp-2);
  margin: 0;
  padding: var(--sp-1) var(--gutter);
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
}
.pet-chips::-webkit-scrollbar { display: none; }
.pet-chip { padding-inline: var(--sp-1) var(--sp-4); }
.pet-chip-face {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--pet-bg);
  color: var(--pet-primary);
}
.pet-chip-face img { width: 100%; height: 100%; object-fit: cover; }
.pet-chip-face .icon { width: 20px; height: 20px; }
.pet-chip[aria-current=true] .pet-chip-face { background: var(--pet-surface); }
.pet-search { margin: 0 var(--gutter) var(--sp-2); width: calc(100% - 2 * var(--gutter)); }

/* ── what's next (1.4) ─────────────────────────────────────────────── */
.next-list { display: grid; gap: var(--sp-2); margin: 0 0 var(--sp-3); padding: 0; list-style: none; }
.next-item, .strip-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 60px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  color: var(--pet-ink);
  box-shadow: var(--shadow-1);
  text-decoration: none;
}
.next-item > a {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--sp-3);
  min-height: 60px;
  margin: calc(-1 * var(--sp-3)) calc(-1 * var(--sp-4));
  padding: var(--sp-3) var(--sp-4);
  border-radius: inherit;
  color: inherit;
  text-decoration: none;
}
.next-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--pet-bg);
  background: color-mix(in srgb, var(--tone, var(--pet-primary)) 13%, var(--pet-surface));
  color: var(--tone, var(--pet-primary));
}
.next-icon .icon { width: 22px; height: 22px; }
.next-text { flex: 1; min-width: 0; font-weight: 600; line-height: 1.45; }
.next-text small { display: block; color: var(--pet-muted); font-size: .875rem; font-weight: 400; }
.next-go { width: 20px; height: 20px; color: var(--pet-muted); }
.tone-late { --tone: var(--pill-late); }
.tone-soon { --tone: var(--pill-soon); }
.tone-ok, .next-clear { --tone: var(--pill-ok); }
.tone-live { --tone: var(--pet-accent); }
.tone-info { --tone: var(--pet-primary); }
.next-memorial { --tone: var(--pet-muted); }
.next-item.tone-late { box-shadow: inset 4px 0 0 var(--pill-late), var(--shadow-1); }
[dir=rtl] .next-item.tone-late { box-shadow: inset -4px 0 0 var(--pill-late), var(--shadow-1); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); margin: 0 0 var(--sp-4); }
.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-height: 76px;
  padding: var(--sp-2);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  color: var(--pet-ink);
  box-shadow: var(--shadow-1);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
}
.quick-btn .icon { color: var(--pet-primary); }
.quick-book { background: var(--pet-primary); color: var(--pet-on-primary); }
.quick-book .icon { color: inherit; }

/* ── skeletons (1.3): static under reduced motion ──────────────────── */
.skeleton { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-lg); background: var(--pet-surface); }
.sk-disc { flex: none; width: 48px; height: 48px; border-radius: var(--r-full); }
.sk-lines { display: grid; flex: 1; gap: var(--sp-2); }
.sk-line { height: 12px; border-radius: var(--r-sm); }
.sk-line:last-child { width: 60%; }
.sk-disc, .sk-line {
  background: var(--pet-bg);
  background: linear-gradient(90deg, var(--pet-bg) 30%, var(--pet-surface) 50%, var(--pet-bg) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

/* ── the clinic contact sheet (1.3) ────────────────────────────────── */
.contact-sheet .sheet-body h2 { margin-bottom: var(--sp-4); }
.contact-number { margin: var(--sp-4) 0 0; text-align: center; }

/* ── pull to refresh (owner.js, standalone only) ───────────────────── */
.pull {
  --pull: 0px;
  position: fixed;
  top: calc(env(safe-area-inset-top) - 40px);
  inset-inline: 0;
  z-index: 50;
  width: 36px;
  height: 36px;
  margin-inline: auto;
  border: 3px solid var(--pet-edge);
  border-top-color: var(--pet-primary);
  border-radius: var(--r-full);
  background: var(--pet-surface);
  box-shadow: var(--shadow-1);
  transform: translateY(var(--pull));
  pointer-events: none;
}
.pull[data-ready] { border-color: var(--pet-primary); }
.pull[data-busy] { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: translateY(var(--pull)) rotate(360deg); } }

/* ── motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:active { transform: none; }
}

@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .page { padding-top: var(--sp-8); }
  /* 1.3: the tab bar becomes a rail at inset-inline-start. */
  body:has(.tabbar) { padding-inline-start: 96px; }
  body:has(.tabbar) .page { padding-bottom: var(--sp-12); }
  .tabbar {
    top: 0;
    inset-inline-end: auto;
    width: 96px;
    flex-direction: column;
    justify-content: center;
    gap: var(--sp-2);
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    border-top: 0;
    border-inline-end: 1px solid var(--pet-edge);
    border-inline-end-color: color-mix(in srgb, var(--pet-edge) 40%, transparent);
  }
  .tabbar[data-away]:not(:focus-within) { transform: none; }      /* the rail never slides away */
  .tab { flex: 0 0 auto; min-height: 72px; }
  .tab[aria-current=page]::before { top: 50%; inset-inline-start: 0; width: 3px; height: 28px; transform: translateY(-50%); border-radius: 3px; }
  .tab-book .tab-icon { margin-top: 0; }
  body:has(.tabbar) .sticky-action { bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }
}

@media print {
  body { background: #fff; color: #000; }
  .sticky-action, .lang-switch, .tabbar, .newer-chip { display: none !important; }
}

/* ── install the app (4.8): _install.html, shown by js/install.js ──── */
.welcome .install { margin-top: var(--sp-4); text-align: start; }
.install > :is(.btn, .sheet, [data-install-menu], [data-install-inapp]) { margin-top: var(--sp-3); }
.install > [data-install-skip] { margin-top: var(--sp-1); }
.install-steps { display: grid; gap: var(--sp-3); margin: 0 0 var(--sp-4); padding: 0; list-style: none; counter-reset: step; }
.install-steps li { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; font-weight: 700; counter-increment: step; }
.install-steps li::before {
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  background: var(--pet-bg);
  color: var(--pet-muted);
  font-size: .875rem;
}
.install-key { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--pet-bg); color: var(--pet-accent); }

/* ── a wide screen's shape: <html data-layout> from auth.layout's cookie ─
   phone = the app in a phone-width frame with the bottom tab bar, as on a
   phone; wide = the side rail above. Phones have one shape: no control. */
.shape-toggle, .layout-form { display: none; }
.layout-form .chip { margin: 0 0 var(--sp-2); }
.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 64px;
  min-height: 56px;
  padding: var(--sp-1) 2px;
  border: 1.5px solid color-mix(in srgb, var(--pet-edge) 55%, transparent);
  border-radius: var(--r-lg);
  background: var(--pet-surface);
  color: var(--pet-muted);
  font: inherit;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
}
.shape-btn[aria-pressed=true] { border-color: transparent; background: var(--pet-primary); color: var(--pet-on-primary); }
@media (min-width: 600px) {
  .layout-form { display: block; }
  :root[data-layout=phone] { --gutter: 16px; --frame: 430px; background: color-mix(in srgb, var(--pet-bg) 88%, var(--pet-ink)); }
  :root[data-layout=phone] body {
    max-width: var(--frame);
    margin-inline: auto;
    padding-inline-start: 0;
    isolation: isolate;                       /* the pattern paints over the frame's own background */
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--pet-edge) 50%, transparent), var(--shadow-2);
  }
  :root[data-layout=phone] body::before { inset-inline: max(0px, calc((100% - var(--frame)) / 2)); }
  :root[data-layout=phone] .page { max-width: none; padding-top: var(--sp-4); }
  :root[data-layout=phone] body:has(.tabbar) .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  :root[data-layout=phone] .tabbar {
    top: auto;
    inset-inline: 0;
    width: auto;
    max-width: var(--frame);
    margin-inline: auto;
    flex-direction: row;
    justify-content: normal;
    gap: 0;
    padding: 0 var(--sp-1) env(safe-area-inset-bottom);
    border-top: 1px solid color-mix(in srgb, var(--pet-edge) 40%, transparent);
    border-inline-end: 0;
  }
  :root[data-layout=phone] .tabbar[data-away]:not(:focus-within) { transform: translateY(calc(100% + 48px)); }
  :root[data-layout=phone] .tab { flex: 1 1 0; min-height: 3.5rem; }
  :root[data-layout=phone] .tab[aria-current=page]::before { top: 0; inset-inline-start: auto; width: 28px; height: 3px; transform: none; border-radius: 0 0 3px 3px; }
  :root[data-layout=phone] .tab-book .tab-icon { margin-top: -20px; }
  :root[data-layout=phone] body:has(.tabbar) .sticky-action { bottom: calc(3.5rem + var(--sp-8) + env(safe-area-inset-bottom)); }
  :root[data-layout=phone] body:has(.tabbar[data-away]:not(:focus-within)) .sticky-action { bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  :root[data-layout=phone] .sheet[data-sheet][open] > .sheet-body { max-width: var(--frame); }
}
/* At the top of the rail, or beside the phone frame; too short a screen keeps only Me's row. */
@media (min-width: 600px) and (min-height: 560px) {
  .shape-toggle { display: block; position: fixed; top: calc(var(--sp-3) + env(safe-area-inset-top)); inset-inline-start: 16px; z-index: 21; }
}
@media (min-width: 1024px) {                    /* css/home.css's two columns stay a phone's one */
  :root[data-layout=phone] .home { display: block; }
  :root[data-layout=phone] .hero-track > .hero:not(:only-child) { flex-basis: 84%; }
}
@media print {
  .shape-toggle { display: none !important; }
  :root[data-layout=phone] body { max-width: none; box-shadow: none; }
}
