/* Hoofprints — mobile-first. One small stylesheet, designed for a phone in
   a yard: big tap targets, one column, and forms that collapse into sections
   so the 30-second entry stays 30 seconds.

   The palette is the purple hoofprint system (design handoff, October): a
   purple splat as the tap target for every action, warm cream paper behind
   it, and a dotted trail joining the icons down the page. Navigation is the
   list on Today rather than a tab bar — every other screen ends with a grey
   hoofprint back to it.

   The tokens below are named twice on purpose. The purple names are the ones
   the design speaks in; the older green-era names are kept as aliases so the
   pages and rules written against them take the new palette without being
   rewritten line by line. */

:root {
  /* Purple — the primary. Icons, selected chips, primary buttons, wordmark. */
  --purple: #7A3FC2;
  --purple-ink: #6A35B0;     /* purple text and links */
  --purple-deep: #4E2486;    /* link hover, info banner text */
  --purple-soft: #F3ECFB;    /* pill and avatar backgrounds */
  --purple-line: #DCCDF0;    /* pill and banner border */
  --lilac: #B79BDD;          /* ".online" in the wordmark */
  --trail: #D9C9EF;          /* the dotted trail behind icon lists */

  /* Paper and ink. */
  --bg: #FBF8F3;
  --card: #FFFFFF;
  --input-bg: #FBF8F3;
  --line: #ECE4F4;
  --input-line: #E5DCEF;
  --divider: #EDE5DA;
  --ink: #2A2238;
  --ink-2: #4A4257;
  --label: #5E556B;
  --muted: #9A90A6;
  --muted-2: #7D7489;        /* grey action labels: Abandon, Cancel, Back */
  --faint: #A79DB3;
  --toast: #2A2238;

  /* Blue stays, as the Energy line on Trends and the "kept" storage band. */
  --blue: #7FBBE3;
  --blue-ink: #4A8CBE;
  --blue-wash: #EDF4FA;
  --blue-line: #D6E6F2;

  --red: #B3462E;
  --amber: #B07D2A;
  --success-bg: #E6F2E9;
  --success-ink: #2C6A3E;
  --danger-bg: #FDF3F0;
  --danger-line: #F0CFC6;

  --radius: 18px;
  --radius-sm: 16px;
  --radius-tile: 12px;

  --display: 'Nunito', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  --body: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Aliases: the green-era names, now purple. */
  --green: var(--purple);
  --green-dark: var(--purple-ink);
  --green-deep: var(--purple-deep);
  --green-soft: var(--ink-2);
  --green-wash: var(--purple-soft);
  --cream: var(--bg);
  --cream-lift: #FFFDFA;
  --border: var(--line);
  --border-soft: #F3EDF8;
  --border-chip: var(--input-line);
  --ink-chip: var(--ink-2);
  --muted-light: var(--faint);
  --brown: var(--purple);
  --brown-dark: var(--purple-ink);
  --tan: var(--purple-ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}
/* Kept so pages that still name it are unaffected: nothing reserves space for
   a tab bar now that navigation is the hoofprint list on Today. */
body.no-tabs { padding-bottom: 0; }

h1, h2, h3, .brand, .title { font-family: var(--display); }

/* ---- Header ---- */
.app-header {
  background: var(--card);
  color: var(--ink);
  padding: 13px 16px;
  /* full-screen (home-screen) insets: status bar above, notch on the sides in landscape */
  padding-top: calc(13px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 20;
}
.app-header .brand {
  font-family: var(--display);
  font-weight: 800; font-size: 1.2rem; letter-spacing: -0.3px; color: var(--green);
  display: flex; align-items: center; gap: 10px;
}
.app-header .brand .dot-online { color: var(--lilac); }
.app-header .sub { font-size: 0.78rem; color: var(--muted); font-weight: 400; margin-top: 1px; }
.app-header a { color: var(--green); }

/* The logo mark, sat in its own white tile. */
.mark {
  width: 54px; height: 38px; border-radius: var(--radius-tile);
  background: #fff url('/img/hoofprints-mark.png') center/contain no-repeat;
  border: 1px solid var(--border); flex: none;
}

/* A green header, for the screens that take over the phone (entry, auth). */
.app-header.on-green {
  background: var(--green); border-bottom-color: var(--green);
  color: #fff;
}
.app-header.on-green .brand, .app-header.on-green a { color: #fff; }
.app-header.on-green .sub { color: rgba(255, 255, 255, 0.62); }
.app-header.on-green .accent { color: var(--blue); font-weight: 700; font-size: 0.82rem; }

/* The first line on every signed-in page: the current horse (left), the
   page's title (centre), today's date and Log out (right). Inside the sticky
   header, first and full width, so it stays with it; whatever else the header
   holds (back/close, a button, a subtitle) sits on a slim row beneath. */
.app-header.has-topline { flex-wrap: wrap; row-gap: 8px; }
/* The two ends share the spare width equally, so the title sits in the
   centre; when space runs short the date and Log out keep their size, the
   horse keeps at least a short name, and a long title gives way with "…". */
.topline {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.78rem; font-weight: 700;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
/* Nothing else in the header: the line is all of it. */
.app-header.topline-only .topline { padding-bottom: 0; border-bottom: 0; }
.topline-start { flex: 1 1 0; min-width: 84px; display: flex; align-items: center; gap: 10px; }
.topline-horse {
  min-width: 0; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topline-nav { flex: none; font-size: 1.25rem !important; line-height: 1; width: auto !important; }
.topline-title { flex: 0 1 auto; min-width: 0; text-align: center; }
.topline-title .brand {
  display: block !important; font-size: 1.05rem !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topline-end { flex: 1 1 0; min-width: max-content; display: flex; justify-content: flex-end; align-items: center; gap: 10px; white-space: nowrap; }
.topline-date { color: var(--muted); font-weight: 600; }
/* A lone close link below the line belongs on the right. */
.app-header.has-topline > a[aria-label="Close"]:last-child { margin-left: auto; }
.app-header.on-green .topline-date { color: rgba(255, 255, 255, 0.7); }
.topline-out {
  background: none; border: 0; padding: 2px 0; cursor: pointer; flex: none;
  font: inherit; color: var(--muted); text-decoration: underline;
}
.app-header.on-green .topline { border-bottom-color: rgba(255, 255, 255, 0.2); }
.app-header.on-green .topline-out { color: rgba(255, 255, 255, 0.75); }
/* A page with no header of its own gets the line on its own. */
.topline.standalone {
  background: var(--card); padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.topline.standalone .topline-horse { color: var(--green); }

/* Avatar chip at the top right of Today. */
.you-chip {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--blue-wash); border: 1px solid var(--blue-line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 0.82rem; color: var(--blue-ink);
  text-decoration: none;
}

/* ---- Layout ---- */
.page { max-width: 640px; margin: 0 auto; padding: 16px 16px 28px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 0.97rem; font-weight: 800; letter-spacing: -0.1px; }
.card h3 { margin: 14px 0 8px; font-size: 0.9rem; font-weight: 800; }
.muted { color: var(--muted); font-size: 0.85rem; }
.small { font-size: 0.8rem; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
a { color: var(--blue-ink); }
.link-blue { color: var(--purple-ink); font-weight: 700; font-size: 0.78rem; text-decoration: none; }

/* A field label in the entry form's voice: small, spaced, upper. */
.field-label {
  font-family: var(--body); font-weight: 700; font-size: 0.75rem;
  letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted);
  margin: 0 0 9px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.field-label .value { text-transform: none; letter-spacing: 0; font-size: 0.75rem; color: var(--green); }
.field-group { margin-bottom: 18px; }

/* ---- Buttons & forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--display); font-size: 0.97rem; font-weight: 800;
  padding: 12px 18px; min-height: 50px;
  background: var(--green); color: #fff; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, color .15s ease;
}
.btn:active { background: var(--green-dark); }
.btn.secondary {
  background: var(--card); color: var(--green); border-color: var(--border);
  font-family: var(--body); font-weight: 700; font-size: 0.88rem;
}
.btn.secondary:active { background: var(--cream); }
.btn.blue { background: var(--blue); color: var(--green-deep); }
.btn.blue:active { background: #95C8EA; }
.btn.danger { background: var(--card); color: var(--red); border-color: #ECC4B8; font-family: var(--body); font-weight: 700; }
.btn.small { padding: 8px 13px; min-height: 36px; font-size: 0.78rem; font-family: var(--body); font-weight: 700; border-radius: 999px; }
.btn.pill { border-radius: 999px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* The blue "switch horse" pill that sits on white. */
.btn.tint {
  background: var(--blue-wash); color: var(--blue-ink); border-color: #D8E9F5;
  border-radius: 999px; min-height: 36px; padding: 8px 13px;
  font-family: var(--body); font-weight: 700; font-size: 0.72rem;
}

label { display: block; font-size: 0.8rem; font-weight: 700; margin: 12px 0 5px; color: var(--label); }
input, select, textarea {
  width: 100%; padding: 12px 13px; min-height: 46px;
  border: 1px solid var(--input-line); border-radius: var(--radius-tile);
  font-size: 16px; /* stops iOS zooming */ font-family: var(--body); background: var(--card); color: var(--ink);
}
.card input, .card select, .card textarea { background: var(--input-bg); }
textarea { min-height: 80px; border-radius: var(--radius-sm); resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--purple); border-color: var(--purple); }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238A8478' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}

/* ---- Chips: the one-tap answer rows ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.even { flex-wrap: nowrap; }
.chips.even .chip { flex: 1; padding: 11px 4px; min-width: 0; }
.chip {
  border: 1px solid var(--border-chip); border-radius: 999px;
  background: var(--card); color: var(--ink-chip);
  padding: 11px 16px; min-height: 44px;
  font-family: var(--body); font-weight: 600; font-size: 0.88rem; line-height: 1.1;
  cursor: pointer; text-align: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.chip.ghost {
  border: 1px dashed #D9CFBB; background: transparent; color: #7A7263;
  padding: 7px 12px; min-height: 0; font-size: 0.78rem; font-weight: 400;
}
.chip.ghost:active { background: var(--cream); }

/* The 1–5 scales: square-ish, evenly spread, with the ends spelled out. */
.score-row { display: flex; gap: 7px; }
.score-row button {
  flex: 1; min-height: 46px; border: 1px solid var(--border-chip); border-radius: 13px;
  background: var(--card); font-family: var(--body); font-size: 0.94rem; font-weight: 600;
  color: var(--ink-chip); cursor: pointer; padding: 12px 2px; line-height: 1.1;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.score-row button.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.score-hint {
  display: flex; justify-content: space-between;
  font-size: 0.69rem; color: var(--muted-light); margin-top: 6px;
}

/* ---- Alerts & badges ---- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 0.88rem; }
.alert.error { background: var(--danger-bg); color: var(--red); border: 1px solid var(--danger-line); }
.alert.success { background: var(--success-bg); color: var(--success-ink); border: 1px solid #C9E3D2; }
.alert.info { background: var(--purple-soft); color: var(--purple-deep); border: 1px solid var(--purple-line); }
.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 700; padding: 4px 10px;
  border-radius: 999px; background: var(--cream); color: var(--green); border: 1px solid var(--border);
}
.badge.green { background: var(--success-bg); color: var(--success-ink); border-color: #C9E3D2; }
.badge.amber { background: #F8EFDD; color: var(--amber); border-color: #E8D5AC; }
.badge.red { background: var(--danger-bg); color: var(--red); border-color: var(--danger-line); }

/* The blue "Worth a look" note. */
.note-blue {
  background: var(--blue-wash); border: 1px solid var(--blue-line); border-radius: var(--radius);
  padding: 15px 16px; margin-bottom: 14px;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 0.82rem; line-height: 1.45; color: var(--green-soft);
}
.note-blue .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex: none; }
.note-blue .note-title {
  font-family: var(--display); font-weight: 800; font-size: 0.84rem;
  color: var(--green); margin-bottom: 3px;
}
.note-blue .body { flex: 1; min-width: 0; }

/* ---- Collapsible form sections ---- */
details.section {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); margin-bottom: 10px;
}
details.section > summary {
  cursor: pointer; list-style: none; padding: 15px 16px;
  font-family: var(--display); font-weight: 800; font-size: 0.92rem; color: var(--green);
  display: flex; justify-content: space-between; align-items: center;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: '＋'; color: var(--muted); font-size: 1rem; font-weight: 400; }
details.section[open] > summary::after { content: '－'; }
details.section > .section-body { padding: 0 16px 16px; }

/* ---- Lists ---- */
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-top: 1px solid var(--border-soft); text-decoration: none; color: inherit;
}
.item:first-child { border-top: none; }
.item .avatar {
  width: 44px; height: 44px; border-radius: 14px; background: #F4EFE4;
  display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
  flex-shrink: 0; overflow: hidden; border: 1px solid var(--border-soft);
}
.item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-family: var(--display); font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.item .meta { font-size: 0.78rem; color: var(--muted); }
.item .chev { flex: none; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; font-size: 0.88rem; }

/* A striped stand-in wherever a horse has no photo yet. */
.photo-blank {
  background: repeating-linear-gradient(135deg, #E7D8BE, #E7D8BE 5px, #DCCBAC 5px, #DCCBAC 10px);
}

/* ---- The week trail: seven days, filled when logged ---- */
.week-dots { display: flex; align-items: center; gap: 7px; }
.week-dots .day {
  flex: 1; height: 34px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--body); font-weight: 700; font-size: 0.72rem;
  background: transparent; color: #B5AC9C; border: 1px dashed #DDD3C0;
}
.week-dots .day.on { background: var(--green); color: #fff; border: 1px solid var(--green); }
.week-dots .day.today { box-shadow: 0 0 0 2px var(--blue-wash), 0 0 0 3px var(--blue); }

.meter { height: 8px; border-radius: 99px; background: #EFE7D8; margin-top: 9px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }

/* ---- Photo grid ---- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-grid .ph { position: relative; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-tile); border: 1px solid var(--border); display: block; }
.photo-grid .primary img { border: 2px solid var(--blue); }

/* Square photo tiles on the entry form. */
.tiles { display: flex; gap: 9px; flex-wrap: wrap; }
.tile {
  width: 78px; height: 78px; border-radius: 16px; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  overflow: hidden; position: relative; border: 1px solid var(--border-soft); background: var(--card);
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.add {
  border: 1.5px dashed #CFC4AE; background: var(--card); cursor: pointer;
  color: var(--muted); font-family: var(--body); font-weight: 600; font-size: 0.66rem;
}
.tile.add .plus { font-size: 1.35rem; line-height: 1; font-weight: 400; }
.tile .kill {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(30, 51, 37, 0.66); color: #fff; font-size: 0.72rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ---- Sparklines ---- */
.spark { width: 100%; height: 56px; }
.spark-label { display: flex; justify-content: space-between; font-size: 0.8rem; margin-top: 8px; }

/* ---- Bottom tab bar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex; padding: 8px 4px 6px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  padding-left: calc(4px + env(safe-area-inset-left));
  padding-right: calc(4px + env(safe-area-inset-right));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 4px 2px; text-decoration: none;
  color: var(--muted-light); font-family: var(--body); font-size: 0.66rem; font-weight: 600;
}
.tabbar a .ico { display: block; width: 22px; height: 22px; position: relative; }
.tab-badge {
  position: absolute; top: -6px; right: -12px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 0.62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.tabbar a .ico svg { display: block; width: 100%; height: 100%; }
.tabbar a.on { color: var(--green); }

/* ---- A sticky action bar that floats over the page's own colour ---- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 28;
  padding: 12px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 62%, rgba(250, 245, 236, 0));
  display: flex; gap: 9px;
}
.action-bar .btn { flex: 1; min-height: 54px; border-radius: 16px; box-shadow: 0 8px 18px rgba(44, 74, 52, 0.28); }
.action-bar .btn.square {
  flex: none; width: 54px; height: 54px; padding: 0; font-size: 1.35rem; font-weight: 400;
  background: var(--blue-wash); color: var(--blue-ink); border: 1px solid #CFDCE9; box-shadow: none;
}
body.has-action-bar { padding-bottom: 104px; }

/* ---- Bottom sheet ---- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(42, 34, 56, 0.45);
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; background: var(--card); border-radius: 26px 26px 0 0;
  padding: 24px 20px; padding-bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  max-height: 86vh; overflow: auto;
}
.sheet.centred { align-items: center; text-align: center; gap: 14px; }
.sheet h2 { font-size: 1.2rem; font-weight: 800; margin: 0; }
.sheet .tick {
  width: 62px; height: 62px; border-radius: 50%; background: var(--green-wash);
  display: flex; align-items: center; justify-content: center;
}
.sheet .btn { width: 100%; }

/* ---- Auth pages ---- */
.auth-wrap { max-width: 400px; margin: 0 auto; padding: 40px 20px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo .paw {
  width: 96px; height: 96px; margin: 0 auto 6px;
  background: url('/img/hoof.png') center/contain no-repeat;
}
.auth-logo h1 {
  margin: 6px 0 2px; color: var(--green); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.4px;
}
.auth-logo h1 .dot-online { color: var(--lilac); }
.auth-logo p { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* Floating add button */
.fab {
  position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 25;
  width: 58px; height: 58px; border-radius: 20px; background: var(--green); color: var(--blue);
  font-size: 1.7rem; display: flex; align-items: center; justify-content: center;
  text-decoration: none; box-shadow: 0 10px 24px rgba(44, 74, 52, 0.3);
}

/* ---- Chat ---- */
.chat-list .item { align-items: flex-start; }
.chat-list .unread-pill {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--green); color: #fff;
  font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none;
}
.chat-list .preview { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list .stamp { font-size: 0.7rem; color: var(--muted-light); flex: none; }
.bubbles { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 8px; }
.bubble {
  max-width: 82%; align-self: flex-start; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px; padding: 9px 12px; font-size: 0.92rem; line-height: 1.4; position: relative;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble.mine { align-self: flex-end; background: var(--purple); color: #fff; border-color: var(--purple); border-radius: 16px 16px 4px 16px; }
.bubble .who { font-size: 0.72rem; font-weight: 700; color: var(--purple-ink); margin-bottom: 2px; }
.bubble .when { font-size: 0.66rem; color: var(--muted-light); margin-top: 3px; text-align: right; }
.bubble.mine .when { color: rgba(255, 255, 255, 0.7); }
.bubble img, .bubble video { display: block; max-width: 100%; width: 260px; max-height: 320px; object-fit: cover; border-radius: 12px; margin: 2px 0 4px; background: #000; }
.bubble img { object-fit: contain; background: var(--cream); }
.bubble .kill { border: none; background: transparent; color: inherit; opacity: 0.55; font-size: 0.72rem; cursor: pointer; padding: 0 0 0 6px; }
.bubble .kill:active { opacity: 1; }
.day-sep { text-align: center; font-size: 0.7rem; color: var(--muted-light); margin: 8px 0 2px; }
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 28;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: flex-end;
}
.composer textarea {
  flex: 1; min-height: 68px; max-height: 140px; padding: 10px 12px;
  border-radius: 18px; resize: none; line-height: 1.4;
}
.composer .btn { min-height: 44px; padding: 0 14px; border-radius: 22px; }
.composer .btn.square { width: 44px; padding: 0; font-size: 1.2rem; flex: none; }
.composer .pending { position: absolute; left: 12px; top: -34px; }
.pending { font-size: 0.75rem; background: var(--blue-wash); color: var(--blue-ink);
  border: 1px solid var(--blue-line); border-radius: 999px; padding: 5px 10px; display: flex; gap: 8px; align-items: center; }
body.has-composer { padding-bottom: 92px; }
/* A chat's message box at the top of the conversation, under the first line. */
.composer.composer-top {
  position: static; z-index: auto; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 22px; padding: 8px;
}
.composer-top + .pending { align-self: flex-start; display: inline-flex; margin: 0 0 10px 6px; }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.person:first-child { border-top: none; }
.person .name { flex: 1; min-width: 0; font-weight: 700; font-size: 0.92rem; }
.person .name .sub { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.person .btn.small { min-height: 32px; padding: 6px 11px; }
.post { padding: 12px 0; border-top: 1px solid var(--border-soft); }
.post:first-child { border-top: none; }
.post .who { font-weight: 700; font-size: 0.85rem; }
.post .when { font-size: 0.72rem; color: var(--muted); }
.post .body { white-space: pre-wrap; font-size: 0.92rem; margin-top: 4px; }
.post img { display: block; max-width: 100%; max-height: 360px; border-radius: 12px; margin-top: 8px; border: 1px solid var(--border); }

/* ---- Offline and sync ---- */
.sync-banner {
  font-size: 0.78rem; font-weight: 700; text-align: center;
  padding: 7px 14px; padding-top: calc(7px + env(safe-area-inset-top));
  background: var(--blue-wash); color: var(--blue-ink); border-bottom: 1px solid var(--blue-line);
  position: sticky; top: 0; z-index: 40;
}
.sync-banner.offline { background: #F8EFDD; color: var(--amber); border-bottom-color: #E8D5AC; }
.tile-flag {
  position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(30, 51, 37, 0.66); color: #fff; font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.storage-bar {
  display: flex; height: 12px; border-radius: 99px; overflow: hidden;
  background: #EFE7D8; margin: 10px 0 8px;
}
.storage-bar span { display: block; height: 100%; }
.storage-bar .used { background: var(--green); }
.storage-bar .waiting { background: var(--amber); }
.storage-bar .kept { background: var(--blue); }
.storage-key { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.76rem; color: var(--muted); }
.storage-key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

@media (min-width: 700px) {
  .page { padding-top: 20px; }
  .action-bar { max-width: 640px; margin: 0 auto; }
  .composer:not(.composer-top) { max-width: 640px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ---- The purple hoofprint system ----------------------------------------
   The October design handoff. Three things carry it: the centred page
   heading, the hoofprint button, and the icon list with its dotted trail. */

/* The heading every screen opens with: wordmark, eyebrow, the big name, and
   (where the screen is about one horse) the Change pill below it. 60px of top
   padding clears the status bar on a phone with the app installed. */
.page-heading {
  padding: calc(60px + env(safe-area-inset-top)) 22px 22px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px;
}
.wordmark {
  font-family: var(--display); font-weight: 800; font-size: 15px; line-height: 1;
  color: var(--purple); letter-spacing: -0.2px;
}
.wordmark .dot-online { color: var(--lilac); }
.heading-main { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.eyebrow {
  font-family: var(--body); font-weight: 700; font-size: 11.5px; line-height: 1;
  letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted);
}
.heading-name {
  font-family: var(--display); font-weight: 800; font-size: 36px; line-height: 1.05;
  color: var(--ink); letter-spacing: -0.8px;
}
/* The name is a button where tapping it changes the horse, and plain text
   where it does not — both read the same. */
button.heading-pick {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border: none; background: transparent; padding: 6px 0; min-height: 48px;
  cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent;
}
.change-pill {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  border: 1px solid var(--purple-line); background: var(--purple-soft); color: var(--purple-ink);
  border-radius: 999px; padding: 7px 12px;
  font-family: var(--body); font-weight: 700; font-size: 12.5px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
/* A screen can offer more than one choice from its heading — the Diary picks
   both a horse and a date range — and they sit on one row as the same pill. */
.heading-pills { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* Entry's "Today · 17:40 · tap to change" line. */
.heading-when {
  border: none; background: transparent; padding: 0; cursor: pointer;
  font-family: var(--body); font-size: 13.5px; color: var(--muted-2);
  text-decoration: underline; text-underline-offset: 3px;
}
.heading-rule { height: 1px; background: var(--divider); margin: 0 22px; }

/* The hoofprint. Always a real button with an aria-label, 64px by default and
   56px inside a sheet. The grey variant marks the way out of a screen — log
   out, back to home, abandon — so a negative action never reads as primary. */
.hoof-btn {
  width: 64px; height: 64px; flex: none; padding: 0; border: none; border-radius: 50%;
  background: transparent url('/img/hoof.png') center/contain no-repeat;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease;
}
.hoof-btn:active, .hoof-btn.pressed { transform: scale(.88) rotate(-6deg); }
.hoof-btn.grey { filter: grayscale(1) brightness(1.35); }
.hoof-btn.sm { width: 56px; height: 56px; }
.hoof-btn.xs { width: 38px; height: 38px; }

/* The composer's own actions: Send and Back, as hoofprints no taller than the
   message box they sit beside. */
.hoof-action.inline { gap: 2px; flex: none; }
.hoof-action.inline .label { font-size: 10.5px; line-height: 1.1; }

/* Icon row: the hoofprint, 16px, then label over description. The row itself
   is the button, so the words are as tappable as the icon. */
.hoof-row {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 0; font: inherit; color: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
/* Pressing anywhere on the row presses its hoofprint. */
.hoof-row:active .hoof-btn, .hoof-row.pressed .hoof-btn { transform: scale(.88) rotate(-6deg); }
.hoof-row:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; border-radius: 14px; }
.hoof-row .hoof-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.hoof-row .hoof-label .label, .hoof-row .hoof-label .sub { display: block; }
.hoof-row .hoof-label .label { font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1.2; }
.hoof-row .hoof-label .sub { font-family: var(--body); font-weight: 400; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.card .hoof-row .hoof-label .label { font-size: 17px; }
.hoof-row.exit { margin-top: 14px; }
/* Two ways out in a row — Chat then Back to home — stay a pair rather than
   each pushing off the one above. */
.hoof-row.exit + .hoof-row.exit { margin-top: 0; }
.hoof-row.exit .hoof-label { color: var(--muted-2); }
.hoof-row.purple-label .hoof-label .label { color: var(--purple-ink); }

/* Icon list: rows 12px apart, with the dotted trail running behind the icon
   centres from the first to the last. */
.hoof-list { position: relative; display: flex; flex-direction: column; gap: 12px; }
.hoof-list .trail {
  position: absolute; left: 29px; top: 32px; bottom: 32px; width: 6px; z-index: 0;
  background-image: radial-gradient(circle, var(--trail) 2px, transparent 2.3px);
  background-size: 6px 12px; background-repeat: repeat-y;
}
.hoof-list .hoof-row { position: relative; z-index: 1; }
.hoof-list-heading {
  font-family: var(--body); font-weight: 700; font-size: 11.5px; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted); margin: 10px 0 2px 80px;
}

/* The page body under a heading: the lists sit at 22px, card stacks at 18px. */
.page.listing { padding: 18px 22px 40px; }
.page.carded { padding: 18px 18px 40px; }

/* Entry's action bar: two hoofprints with their labels, over a cream fade. */
.action-bar.hoof-bar {
  justify-content: center; gap: 56px; background: linear-gradient(to top, var(--bg) 62%, rgba(251, 248, 243, 0));
}
.hoof-action { display: flex; flex-direction: column; align-items: center; gap: 6px; border: none; background: transparent; padding: 0; cursor: pointer; }
.hoof-action .label { font-family: var(--display); font-weight: 800; font-size: 13px; color: var(--purple-ink); }
.hoof-action.grey .label { font-family: var(--body); font-weight: 700; color: var(--muted-2); }

/* Sheets: the grabber, and the horse-picker rows. */
.sheet .grabber { width: 40px; height: 5px; border-radius: 99px; background: #E3DAEE; align-self: center; margin-bottom: 4px; }
.sheet h2 { font-family: var(--display); font-weight: 800; font-size: 19px; }
.horse-pick {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 64px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card);
  cursor: pointer; width: 100%; text-align: left;
}
.horse-pick.on { border-color: var(--purple); background: #F5EFFC; }
.horse-pick .thumb {
  width: 44px; height: 44px; border-radius: 14px; flex: none; overflow: hidden;
  background: repeating-linear-gradient(135deg, #E9E0F3, #E9E0F3 5px, #DFD3EE 5px, #DFD3EE 10px);
}
.horse-pick .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.horse-pick .who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.horse-pick .who .name { font-family: var(--display); font-weight: 800; font-size: 16px; color: var(--ink); }
.horse-pick .who .meta { font-size: 12px; color: var(--muted); }
.horse-pick .tick {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 13px;
  background: transparent; color: transparent;
}
.horse-pick.on .tick { background: var(--purple); color: #fff; }
.sheet .dashed {
  min-height: 48px; border: 1px dashed #CDBDE4; background: transparent; border-radius: var(--radius-sm);
  color: var(--purple-ink); font-family: var(--body); font-weight: 700; font-size: 14px; cursor: pointer; margin-top: 4px;
}

/* A toast, for the actions that confirm without going anywhere. */
.toast {
  position: fixed; left: 22px; right: 22px; bottom: calc(40px + env(safe-area-inset-bottom)); z-index: 70;
  background: var(--toast); color: #fff; border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: var(--body); font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 10px 24px rgba(42, 34, 56, 0.25);
}
.toast button { border: none; background: transparent; color: #C9B2EC; font-weight: 700; cursor: pointer; font-size: 14px; }

/* The yard a horse stands at, on My horses. */
.yard-badge {
  display: inline-block; background: #EDE3F8; color: #5B2C99; border-radius: 999px;
  padding: 2px 9px; font-weight: 700; font-size: 11px;
}
