/* Recoverable
   Flat 2D, no shadows. Bright leaf green and wood brown, fire orange for
   streaks, gold for coins. Tappable things get a solid darker "lip" on the
   bottom edge that flattens when pressed. */

:root {
  --bg: #FFFDF7;
  --surface: #FFFFFF;
  --line: #EAE2D3;
  --line-dark: #D9CDB8;

  --ink: #3B2A1D;
  --muted: #8C7B69;

  --green: #58B530;
  --green-lip: #43901F;
  --green-dark: #2F6B12;
  --green-light: #E5F6D8;

  --brown: #9A6436;
  --brown-lip: #77491F;
  --brown-light: #F5E8D8;

  --fire: #FF8A00;
  --fire-lip: #DB6A00;
  --fire-light: #FFF0DB;

  --gold: #FFC21A;
  --gold-lip: #DDA000;
  --gold-light: #FFF6D4;

  --red: #EE5A4C;
  --red-lip: #C8402F;
  --red-light: #FFE5E1;

  /* names the app's JS uses for the health bar */
  --complete: var(--green);
  --accent: var(--gold);
  --danger: var(--red);

  --display: "Baloo 2", "Arial Rounded MT Bold", sans-serif;
  --body: "Nunito", "Arial Rounded MT Bold", sans-serif;

  --rail: 240px;
  --gutter: 16px;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 700 16px/1.45 var(--body);
}

h1, h2, h3 { margin: 0; }
h2 { font-family: var(--display); font-weight: 800; font-size: 1.75rem; line-height: 1.15; margin-bottom: 12px; }
h3 { font-family: var(--display); font-weight: 800; font-size: 1.2rem; line-height: 1.2; }
img { display: block; }

.ic { width: 1.25em; height: 1.25em; flex-shrink: 0; }
.ic.fill { fill: currentColor; stroke: none; }
i[data-icon] { display: inline-flex; font-style: normal; }

.sub { color: var(--muted); margin: -6px 0 16px; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 6px 0 0; font-weight: 600; }
.hint.small { font-size: 0.82rem; }
.fine { color: var(--muted); font-size: 0.82rem; margin-top: 16px; font-weight: 600; }
.section-title { margin: 24px 0 10px; }
.empty { color: var(--muted); padding: 16px; text-align: center; }

/* ---------- Buttons: flat with a solid lip ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 2px solid var(--line-dark);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 800 0.95rem var(--body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn:active:not(:disabled) { border-bottom-width: 2px; transform: translateY(2px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green-lip); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #61C536; }
.btn.ghost { background: var(--surface); border-color: var(--line-dark); color: var(--brown); }
.btn.ghost:hover:not(:disabled) { background: var(--brown-light); }
.btn.big { padding: 14px 22px; font-size: 1.02rem; }
.btn.wide { width: 100%; }
.btn.link {
  border: none;
  background: none;
  padding: 4px 0;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  gap: 4px;
}
.btn.link:active { transform: none; }
.btn.link:hover { color: var(--brown); }
.small-btn { padding: 7px 12px; font-size: 0.8rem; flex-shrink: 0; }
.back { margin-bottom: 8px; }

/* ---------- Tiles ---------- */
.tile {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.tiles { display: grid; gap: 10px; }
button.tile, .tiles > button.card {
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  border-bottom-width: 4px;
}
button.tile:active, .tiles > button.card:active { border-bottom-width: 2px; transform: translateY(2px); }
.tile-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.tile-icon .ic { width: 26px; height: 26px; }
.tile-icon.brown { background: var(--brown-light); color: var(--brown); }
.tile-icon.fire { background: var(--fire-light); color: var(--fire); }
.tile-icon.green { background: var(--green-light); color: var(--green-lip); }

/* Rows inside .tiles are tiles too */
.tiles > .card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.tiles > .empty { border: 2px dashed var(--line-dark); border-radius: var(--radius); }
.exercise-info { flex: 1; min-width: 0; }
.exercise-name { font-weight: 800; font-size: 1.05rem; }
.exercise-detail { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.exercise-notes { display: flex; gap: 6px; margin-top: 4px; font-size: 0.88rem; color: var(--brown); font-weight: 600; }
.exercise-notes .ic { color: var(--gold-lip); }
.chev { margin-left: auto; color: var(--line-dark); display: inline-flex; }

/* ---------- Forms ---------- */
.form label, .hint-label {
  display: block;
  font-weight: 800;
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.form input, .form textarea, .form select, .hint-input, .search, .join-row input, .chat-form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #FBF8F2;
  color: var(--ink);
  font: 700 1rem var(--body);
}
.form input:focus, .form textarea:focus, .form select:focus, .hint-input:focus,
.search:focus, .join-row input:focus, .chat-form input:focus {
  outline: none;
  border-color: var(--green);
  background: var(--surface);
}
.form h3 { margin-bottom: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.optional { color: var(--muted); font-weight: 600; }
.form-error { color: var(--red); font-size: 0.92rem; margin: 0 0 12px; }
.form-ok { color: var(--green-dark); font-size: 0.92rem; margin: 0 0 12px; }

.role-pick { border: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-pick legend { font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; padding: 0; }
.role-pick label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  cursor: pointer;
}
.role-pick label:has(input:checked) { border-color: var(--green); background: var(--green-light); color: var(--green-dark); }
.role-pick input { display: inline; width: auto; margin: 0; accent-color: var(--green); }

/* ---------- Speech bubbles (Reco talking) ---------- */
.speech {
  position: relative;
  margin: 0;
  padding: 12px 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 1.02rem;
}
.speech::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  background: var(--surface);
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  transform: rotate(45deg);
}
.speech.left::after { bottom: auto; top: 50%; left: -9px; margin: -8px 0 0; transform: rotate(135deg); }

/* ---------- Sign in ---------- */
.signin {
  min-height: 100svh;
  display: grid;
  align-content: center;
  gap: 24px;
  max-width: 440px;
  margin: 0 auto;
  padding: 32px var(--gutter);
}
.wordmark { font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--green); letter-spacing: -0.01em; }
.wordmark.big { display: block; font-size: 2.6rem; text-align: center; line-height: 1; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; }
.wordmark-logo { width: 32px; height: 32px; }
.signin-logo { width: 96px; height: 96px; margin: 0 auto 10px; }
.reco-talk { display: grid; justify-items: center; gap: 14px; margin-top: 12px; }
.reco-talk img { width: 170px; order: 2; }
.reco-talk .speech { order: 1; text-align: center; max-width: 320px; }
.signin-form { background: var(--surface); border: 2px solid var(--line); border-radius: 20px; padding: 18px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; }
.auth-tabs button {
  padding: 10px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font: 800 0.9rem var(--body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
.auth-tabs button.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

.loading { min-height: 70svh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.loading img { width: 140px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px var(--gutter);
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.05rem;
  white-space: nowrap;
}
.chip .ic { width: 22px; height: 22px; }
.streak-chip { color: var(--fire); }
.streak-chip.cold { color: var(--line-dark); }
.coin-chip { color: var(--gold-lip); }
.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 4px;
  color: var(--muted);
  font: 800 0.92rem var(--body);
  cursor: pointer;
}
.user-pill .user-name { color: var(--ink); }
.user-pill:hover { color: var(--red); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}
.avatar.small { width: 30px; height: 30px; font-size: 0.72rem; }

.view { padding: 16px var(--gutter) 110px; max-width: 640px; margin: 0 auto; }
.view.signin { max-width: 440px; padding-bottom: 32px; }

/* Bottom tab bar on phones */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  background: var(--surface);
  border-top: 2px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0 2px;
  padding: 6px 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font: 800 0.66rem var(--body);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}
.tabbar .ic { width: 26px; height: 26px; }

/* Every tab has its own color: icon always, frame + tint when active */
.tabbar button { --c: var(--green); --c-light: var(--green-light); --c-dark: var(--green-dark); }
.tabbar .tab-fire { --c: var(--fire); --c-light: var(--fire-light); --c-dark: var(--fire-lip); }
.tabbar .tab-gold { --c: var(--gold-lip); --c-light: var(--gold-light); --c-dark: #A87800; }
.tabbar .tab-red { --c: var(--red); --c-light: var(--red-light); --c-dark: var(--red-lip); }
.tabbar .tab-brown { --c: var(--brown); --c-light: var(--brown-light); --c-dark: var(--brown-lip); }
.tabbar .tab-ic { display: grid; place-items: center; color: var(--c); }
.tabbar button.active { color: var(--c-dark); background: var(--c-light); border-color: var(--c); }
.rail-card { display: none; }
.tab-badge {
  position: absolute;
  top: 0;
  left: 56%;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font: 800 0.7rem/20px var(--body);
  font-style: normal;
  letter-spacing: 0;
  text-align: center;
}

/* ---------- Home ---------- */
.join-card { margin-bottom: 14px; border-color: var(--gold); background: var(--gold-light); }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.join-row input { margin: 0; flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.2em; }
.join-card .form-error { margin: 10px 0 0; }

.home-main, .home-side { display: grid; gap: 14px; align-content: start; }
.home-side { margin-top: 14px; }

.reco-stage { display: grid; justify-items: center; gap: 6px; text-align: center; }
.reco-stage .speech { max-width: 340px; }
.reco-img { width: min(56vw, 210px); margin-top: 8px; }
.reco-name-row { display: flex; align-items: center; gap: 10px; }
.pet-name {
  padding: 0;
  border: none;
  background: none;
  font: 800 1.9rem/1 var(--display);
  color: var(--ink);
  cursor: pointer;
}
.pet-name:hover { color: var(--green-dark); }
.pet-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--line);
  color: var(--ink);
}
.pet-status.done { background: var(--green-light); color: var(--green-dark); }
.pet-status.rest { background: var(--brown-light); color: var(--brown-lip); }
.pet-status.missed { background: var(--red-light); color: var(--red-lip); }
.pet-status.waiting { background: var(--fire-light); color: var(--fire-lip); }
.health { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 300px; margin-top: 4px; }
.health > i { color: var(--red); }
.health .bar { flex: 1; height: 14px; }
.health-value { font-size: 0.85rem; color: var(--muted); min-width: 52px; text-align: right; }

/* Progress bars */
.bar { position: relative; height: 16px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: var(--green); }
.bar.big { height: 26px; margin: 14px 0; }
.bar-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink);
}

.quest-top { display: flex; align-items: center; gap: 12px; }
.quest-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--green-light); color: var(--green-lip); }
.quest-icon .ic { width: 28px; height: 28px; }
.quest-text { flex: 1; display: grid; }
.quest-label { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.quest-text b { font-size: 1.05rem; }
.reward {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-light);
  color: var(--gold-lip);
  font-weight: 800;
  white-space: nowrap;
}
.reward .ic { width: 18px; height: 18px; }
.quest .bar-fill { background: var(--gold); }
.quest.complete { border-color: var(--green); background: var(--green-light); }
.quest.complete .bar-fill { background: var(--green); }

.rest-row { display: grid; gap: 4px; }
.rest-row .hint { text-align: center; margin: 0; }

/* Streak card */
.streak-card { border-color: var(--fire); background: var(--fire-light); }
.streak-card.cold { border-color: var(--line); background: var(--surface); }
.streak-top { display: flex; align-items: center; gap: 12px; }
.streak-flame { color: var(--fire); }
.streak-flame .ic { width: 52px; height: 52px; }
.streak-card.cold .streak-flame { color: var(--line-dark); }
.streak-num { display: block; font: 800 2.6rem/1 var(--display); color: var(--fire-lip); }
.streak-card.cold .streak-num { color: var(--muted); }
.streak-label { font-weight: 800; color: var(--fire-lip); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.8rem; }
.streak-card.cold .streak-label { color: var(--muted); }
.streak-line { margin: 10px 0 12px; font-weight: 700; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.wd { display: grid; justify-items: center; gap: 2px; font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.wd-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--line);
  color: transparent;
}
.wd-dot .ic { width: 20px; height: 20px; }
.wd.lit .wd-dot { background: var(--fire); color: #fff; }
.wd.rest .wd-dot { background: var(--brown-light); color: var(--brown); }
.wd.missed .wd-dot { background: var(--red-light); color: var(--red); }
.wd.today .wd-dot { box-shadow: none; outline: 3px solid var(--fire); outline-offset: 2px; }
.wd.today { color: var(--fire-lip); }

.library-link { display: flex; align-items: center; gap: 12px; width: 100%; }
.library-link > span:nth-child(2) { display: grid; flex: 1; }
.library-link small { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.library-link > i:last-child { color: var(--line-dark); }

/* ---------- Today ---------- */
.reco-coach { display: flex; align-items: center; gap: 14px; }
.reco-mini { width: 92px; flex-shrink: 0; }
.reco-coach .speech { flex: 1; }
#view-today .bar.big .bar-fill { background: var(--fire); }
#view-today .bar.big.complete .bar-fill { background: var(--green); }

.exercise { border-bottom-width: 4px !important; }
.exercise.done { border-color: var(--green) !important; background: var(--green-light) !important; }
.exercise.done .exercise-name { color: var(--green-dark); }
.coin-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 0.8rem; color: var(--gold-lip); vertical-align: middle; }
.coin-tag .ic { width: 15px; height: 15px; }
.exercise.done .coin-tag { color: var(--green-dark); }
.exercise-btns { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.check {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid var(--line-dark);
  border-bottom-width: 5px;
  background: var(--surface);
  color: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check .ic { width: 28px; height: 28px; stroke-width: 3; }
.check:hover { color: var(--line); }
.check:active { border-bottom-width: 3px; transform: translateY(2px); }
.exercise.done .check { background: var(--green); border-color: var(--green-lip); color: #fff; }
.howto-btn {
  border: none;
  background: none;
  padding: 2px 0;
  color: var(--brown);
  font-size: 0.72rem;
  gap: 3px;
}
.howto-btn .ic { width: 16px; height: 16px; }
.howto-btn:active { transform: none; }

/* ---------- Progress ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat-tile > .ic { width: 34px; height: 34px; }
.stat-tile b { display: block; font: 800 1.7rem/1 var(--display); }
.stat-tile span { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-tile.fire > .ic { color: var(--fire); }
.stat-tile.gold > .ic { color: var(--gold-lip); }
.stat-tile.green > .ic { color: var(--green); }
.stat-tile.brown > .ic { color: var(--brown); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font: 800 1.2rem var(--display); }
.btn.icon { width: 38px; height: 38px; padding: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { margin-bottom: 6px; text-align: center; font-size: 0.72rem; color: var(--muted); }
/* Scoped to the calendar so "day" can't style anything else */
.cal-grid .day {
  aspect-ratio: 1;
  max-height: 52px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #F6F1E7;
  color: var(--muted);
  font-size: 0.85rem;
}
.cal-grid .day.before, .cal-grid .day.future { background: transparent; color: var(--line-dark); }
.cal-grid .day.complete { background: var(--green); color: #fff; }
.cal-grid .day.partial { background: var(--gold-light); color: var(--gold-lip); }
.cal-grid .day.rest { background: var(--brown-light); color: var(--brown); }
.cal-grid .day.missed { background: var(--red-light); color: var(--red-lip); }
.cal-grid .day.pending { background: transparent; border: 2px dashed var(--line-dark); color: var(--ink); }
.cal-grid .day.today { outline: 3px solid var(--fire); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 0.8rem; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.dot.complete { background: var(--green); }
.dot.partial { background: var(--gold); }
.dot.rest { background: var(--brown-light); border: 1px solid var(--brown); }
.dot.missed { background: var(--red-light); border: 1px solid var(--red); }

/* ---------- People rows ---------- */
.patient-card img { width: 56px; height: 56px; }
.patient-card .pet-status { margin-top: 3px; font-size: 0.64rem; padding: 2px 8px; }
.patient-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; font-size: 0.85rem; color: var(--muted); }
.patient-meta .fire { color: var(--fire-lip); display: inline-flex; align-items: center; gap: 2px; }
.patient-meta .fire .ic { width: 16px; height: 16px; }

/* Leaderboard */
.lb-row.me { border-color: var(--green) !important; background: var(--green-light) !important; }
.rank { width: 28px; text-align: center; font: 800 1.3rem var(--display); color: var(--muted); }
.rank.r1 { color: var(--gold-lip); }
.rank.r2 { color: #9C958A; }
.rank.r3 { color: var(--brown); }
.lb-streak { display: inline-flex; align-items: center; gap: 2px; font: 800 1.3rem var(--display); color: var(--fire); }
.lb-streak .ic { width: 22px; height: 22px; }
.lb-streak.cold { color: var(--line-dark); }

.inbox-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.inbox-time { font-size: 0.78rem; color: var(--muted); }
.inbox-preview { color: var(--muted); font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item.unread .inbox-preview { color: var(--ink); font-weight: 800; }
.badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.78rem;
  line-height: 24px;
  text-align: center;
}

/* PT */
.code-card { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-bottom: 18px; border-color: var(--fire); background: var(--fire-light); }
.code-card .hint { flex-basis: 100%; margin: 4px 0 0; }
.code-label { display: block; font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fire-lip); }
.pt-code { display: block; font: 800 2.2rem/1 var(--display); letter-spacing: 0.1em; color: var(--ink); }
.pt-patient-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.pt-patient-head h2 { margin: 0 0 2px; }
.pt-pet { width: 84px; }

.routine-item .exercise-info { margin-right: 4px; }
.mini {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 2px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--brown);
  cursor: pointer;
}
.mini:disabled { opacity: 0.35; cursor: default; }
.mini.del { color: var(--red); }
.mini .ic { width: 18px; height: 18px; }
#routineForm { margin-top: 18px; }

/* ---------- Library ---------- */
.search { margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
button.chip {
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-bottom-width: 3px;
  background: var(--surface);
  color: var(--muted);
  font: 800 0.82rem var(--body);
  cursor: pointer;
}
button.chip.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }

.tiles > .lib-card { display: block; }
.lib-card summary { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.lib-card summary::-webkit-details-marker { display: none; }
.lib-card[open] .chev { transform: rotate(90deg); }
.lib-tags { display: flex; gap: 6px; margin: 4px 0; }
.tag {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--green-light);
  color: var(--green-dark);
}
.tag:first-child { background: var(--brown-light); color: var(--brown-lip); }
.tag.strength { background: var(--fire-light); color: var(--fire-lip); }
.tag.mine { background: var(--gold-light); color: #A87800; }
#addStretchBtn { margin-bottom: 14px; }
#stretchForm { margin-bottom: 18px; }
.custom-actions { display: flex; gap: 8px; margin-top: 12px; }
.lib-body { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--line); }
.steps { margin: 0 0 12px; padding-left: 22px; font-weight: 600; }
.steps li { margin-bottom: 6px; }
.steps li::marker { font-weight: 800; color: var(--green); }
.tip {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 2px solid var(--gold);
  border-radius: 12px;
  background: var(--gold-light);
  font-size: 0.92rem;
}
.tip .ic { color: var(--gold-lip); }
.video-btn { background: var(--brown); border-color: var(--brown-lip); color: #fff; text-decoration: none; }
.video-btn:hover { background: #A86F3E; }
.hint-label { margin: 16px 0 0; }
.hint-input { resize: vertical; }
.assign-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-weight: 800; font-size: 0.9rem; }
.btn.assigned { background: var(--green-light); border-color: var(--green); color: var(--green-dark); }
.current-hint { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #F6F1E7; font-size: 0.86rem; font-weight: 600; }

/* ---------- Chat ---------- */
.chat-view { padding-bottom: 150px; }
.chat-head h2 { margin: 0 0 10px; }
.chat-thread { display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.bubble.theirs { align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.mine { align-self: flex-end; background: var(--green); border-color: var(--green-lip); color: #fff; border-bottom-right-radius: 6px; }
.bubble-time { margin-top: 2px; font-size: 0.7rem; opacity: 0.75; text-align: right; }
.chat-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 9;
  display: flex;
  gap: 8px;
  padding: 10px var(--gutter);
  background: var(--bg);
  border-top: 2px solid var(--line);
}
.chat-form input { flex: 1; min-width: 0; margin: 0; }
.chat-form .btn { padding: 0 16px; }

/* ---------- Quest complete ---------- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
  background: var(--bg);
}
.celebration-inner { width: 100%; max-width: 400px; display: grid; justify-items: center; gap: 12px; text-align: center; }
.celebration img { width: 200px; }
.celebration h2 { font-size: 2.4rem; color: var(--gold-lip); margin: 0; }
.celebration p { margin: 0; font-size: 1.1rem; }
.cel-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin: 8px 0 12px; }
.cel-stat { display: grid; justify-items: center; gap: 2px; padding: 14px 10px; border: 2px solid; border-radius: var(--radius); }
.cel-stat .ic { width: 34px; height: 34px; }
.cel-stat b { font: 800 2rem/1 var(--display); }
.cel-stat span { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.cel-stat.fire { border-color: var(--fire); background: var(--fire-light); color: var(--fire-lip); }
.cel-stat.gold { border-color: var(--gold); background: var(--gold-light); color: var(--gold-lip); }

/* ---------- Extra tiles: up next, milestone, PT note, meta ---------- */
.tile-icon.gold { background: var(--gold-light); color: var(--gold-lip); }
.tile-icon.red { background: var(--red-light); color: var(--red); }
.bar-fill.gold { background: var(--gold); }

.up-next {
  display: grid;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 2px dashed var(--line-dark);
  border-radius: 12px;
}
.up-next span { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fire-lip); }
.up-next small { color: var(--muted); font-weight: 600; }

.milestone { display: flex; align-items: center; gap: 12px; }
.milestone-body { flex: 1; display: grid; gap: 6px; }
.milestone .bar { height: 12px; }
.milestone .bar-fill { background: var(--gold); }
.milestone small { color: var(--muted); font-weight: 600; }

.pt-note { display: flex; align-items: center; gap: 12px; width: 100%; }
.pt-note-body { flex: 1; min-width: 0; display: grid; }
.pt-note-body small { color: var(--muted); font-weight: 600; }
.pt-note-body b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.today-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
}
.meta-pill .ic { width: 17px; height: 17px; color: var(--brown); }
.meta-pill.gold { border-color: var(--gold); background: var(--gold-light); color: var(--gold-lip); }
.meta-pill.gold .ic { color: var(--gold-lip); }
.exercise.next { border-color: var(--fire) !important; }
.next-tag {
  display: inline-block;
  margin-bottom: 2px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fire-lip);
}

/* Calendar month summary */
.cal-title { text-align: center; }
.cal-title small { display: block; font: 700 0.8rem var(--body); color: var(--muted); }

/* Badges */
.count { font: 800 0.9rem var(--body); color: var(--muted); margin-left: 6px; }
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge-tile {
  --c: var(--line-dark); --c-light: #F6F1E7;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 14px 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.badge-medal {
  width: 54px;
  height: 54px;
  margin-bottom: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--c-light);
  color: var(--c);
  border: 3px solid var(--c);
}
.badge-medal .ic { width: 28px; height: 28px; }
.badge-tile b { font-size: 0.9rem; }
.badge-tile small { color: var(--muted); font-size: 0.76rem; font-weight: 600; }
.badge-tile.locked { opacity: 0.6; }
.badge-tile.locked .badge-medal { border-style: dashed; }
.badge-tile.got.green { --c: var(--green); --c-light: var(--green-light); border-color: var(--green-light); }
.badge-tile.got.fire { --c: var(--fire); --c-light: var(--fire-light); border-color: var(--fire-light); }
.badge-tile.got.red { --c: var(--red); --c-light: var(--red-light); border-color: var(--red-light); }
.badge-tile.got.gold { --c: var(--gold-lip); --c-light: var(--gold-light); border-color: var(--gold-light); }
.badge-tile.got.brown { --c: var(--brown); --c-light: var(--brown-light); border-color: var(--brown-light); }
.badge-tile.got small { color: var(--c); }

/* Leaderboard rank */
.rank-card { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; border-color: var(--gold); background: var(--gold-light); }
.rank-big { font: 800 2.4rem/1 var(--display); color: var(--gold-lip); }
.rank-card b { display: block; }
.rank-card small { color: var(--muted); font-weight: 600; }

/* PT summary and nudges */
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.three .stat-tile { flex-direction: column; text-align: center; gap: 4px; padding: 12px 6px; }
.stat-tile.red > .ic { color: var(--red); }
.pet-status.nudge { background: var(--red); color: #fff; margin-left: 4px; }

/* Chat quick replies */
.chat-form { flex-direction: column; }
.chat-row { display: flex; gap: 8px; }
.quick-replies { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick-replies::-webkit-scrollbar { display: none; }
button.chip.quick { flex-shrink: 0; color: var(--brown); }
button.chip.quick:hover { border-color: var(--green); color: var(--green-dark); }
.chat-view { padding-bottom: 200px; }

/* ---------- Rest day scene ---------- */
/* A popup over the app: the app stays visible behind a dimmed backdrop */
.scene {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px var(--gutter);
  background: rgba(59, 42, 29, 0.5);
}
.scene-inner {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 24px;
  background: var(--bg);
  text-align: center;
}
.scene-skip {
  position: absolute;
  top: 26px;
  right: 26px;
  z-index: 2;
  padding: 4px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 800 0.75rem var(--body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.room {
  position: relative;
  height: 330px;
  border: 2px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  background: #FFF4DC;
  transition: background 900ms ease;
}
.room.night { background: #E8DAC0; }

/* Window with the sky */
.window {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 120px;
  height: 96px;
  border: 6px solid var(--brown);
  border-radius: 14px;
  overflow: hidden;
  background: #FFE7A3;
  transition: background 900ms ease;
}
.window::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 5px; margin-left: -2px; background: var(--brown); }
.room.night .window { background: #3B2A1D; }
.sun, .moon { position: absolute; width: 34px; height: 34px; border-radius: 50%; transition: transform 900ms ease, opacity 900ms ease; }
.sun { left: 14px; top: 16px; background: var(--fire); }
.room.night .sun { transform: translateY(80px); opacity: 0; }
.moon { right: 14px; top: 14px; background: #FFF2C4; transform: translateY(80px); opacity: 0; }
.moon::after { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; top: -4px; left: 12px; background: #3B2A1D; }
.room.night .moon { transform: none; opacity: 1; }
.star { position: absolute; width: 6px; height: 6px; background: #FFF2C4; transform: rotate(45deg); opacity: 0; transition: opacity 600ms ease 500ms; }
.st1 { left: 12px; top: 58px; } .st2 { left: 38px; top: 20px; } .st3 { right: 20px; bottom: 14px; }
.room.night .star { opacity: 1; animation: twinkle 1.6s ease-in-out infinite; }
.room.night .st2 { animation-delay: 0.5s; } .room.night .st3 { animation-delay: 1s; }
@keyframes twinkle { 50% { opacity: 0.3; } }

.bed { position: absolute; left: 50%; bottom: 14px; width: 300px; margin-left: -150px; }
.scene-reco {
  position: absolute;
  left: 50%;
  bottom: 52px;
  width: 190px;
  margin-left: -82px;
  mix-blend-mode: multiply;
  transform-origin: 50% 100%;
}
/* Reco's moves */
.scene-reco.yawn { animation: yawn 900ms ease-in-out; }
@keyframes yawn {
  0% { transform: none; }
  35% { transform: scale(1.04, 1.1) rotate(-3deg); }
  70% { transform: scale(0.98, 0.94) rotate(2deg); }
  100% { transform: none; }
}
.scene-reco.settle { animation: settle 800ms cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes settle {
  0% { transform: translateY(-40px); }
  60% { transform: translateY(0) scale(1.08, 0.88); }
  100% { transform: none; }
}
.scene-reco.hop { animation: hop 800ms cubic-bezier(0.3, 0, 0.4, 1); }
@keyframes hop {
  0% { transform: none; }
  20% { transform: scale(1.06, 0.9); }
  55% { transform: translateY(-60px) scale(0.95, 1.08); }
  80% { transform: scale(1.06, 0.92); }
  100% { transform: none; }
}
.scene-reco.bounce { animation: bounce 600ms ease-in-out 2; }
@keyframes bounce {
  50% { transform: translateY(-22px) rotate(-4deg); }
}

/* Floating Zzz */
.zzz { position: absolute; left: 62%; bottom: 190px; font: 800 1.6rem var(--display); color: var(--brown); }
.zzz span { position: absolute; opacity: 0; }
.zzz.on span { animation: zfloat 2.4s ease-out infinite; }
.zzz span:nth-child(2) { left: 18px; font-size: 1.3rem; animation-delay: 0.8s; }
.zzz span:nth-child(3) { left: 36px; font-size: 1.9rem; animation-delay: 1.6s; }
@keyframes zfloat {
  0% { opacity: 0; transform: translate(0, 10px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(18px, -60px) rotate(12deg); }
}

/* Morning sparkles */
.sparkles i { position: absolute; width: 12px; height: 12px; background: var(--gold); transform: rotate(45deg) scale(0); }
.sparkles i:nth-child(1) { left: 26%; bottom: 210px; }
.sparkles i:nth-child(2) { right: 22%; bottom: 230px; }
.sparkles i:nth-child(3) { left: 20%; bottom: 120px; }
.sparkles i:nth-child(4) { right: 18%; bottom: 140px; }
.sparkles.on i { animation: sparkle 900ms ease-out infinite; }
.sparkles.on i:nth-child(2) { animation-delay: 0.2s; }
.sparkles.on i:nth-child(3) { animation-delay: 0.45s; }
.sparkles.on i:nth-child(4) { animation-delay: 0.65s; }
@keyframes sparkle {
  0% { transform: rotate(45deg) scale(0); opacity: 1; }
  50% { transform: rotate(45deg) scale(1.2); opacity: 1; }
  100% { transform: rotate(45deg) scale(0.4); opacity: 0; }
}

.scene-speech { position: absolute; top: 52px; right: 14px; max-width: 54%; font-size: 0.95rem; }
.scene-speech::after { left: 30%; }
.scene-caption { display: grid; gap: 8px; }
.scene-caption h2 { margin: 0; font-size: 2rem; }
.scene-caption p { margin: 0 0 8px; color: var(--muted); }
.scene[data-kind="sleep"] .scene-caption h2 { color: var(--brown); }
.scene[data-kind="wake"] .scene-caption h2 { color: var(--fire-lip); }

@media (prefers-reduced-motion: reduce) {
  .scene-reco, .zzz.on span, .sparkles.on i, .room.night .star { animation: none !important; }
  .zzz.on span { opacity: 1; }
}

/* ---------- Demo account day control ---------- */
.demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px var(--gutter);
  background: var(--gold-light);
  border-bottom: 2px solid var(--gold);
}
.demo-tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.demo-day { display: grid; line-height: 1.2; }
.demo-day small { color: var(--muted); font-size: 0.78rem; }
.demo-actions { display: flex; gap: 6px; margin-left: auto; }
.demo-actions .btn { padding: 6px 10px; }
.demo-actions .ic { width: 16px; height: 16px; }
.demo-reset { color: var(--red); }
.pet-status.demo { background: var(--gold); color: var(--ink); margin-left: 4px; }

/* ---------- Install as an app (phones) ---------- */
.install-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter);
  background: var(--green-light);
  border-bottom: 2px solid var(--green);
}
.install-bar > img { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.install-text { display: grid; line-height: 1.25; min-width: 0; }
.install-text b { font-size: 0.95rem; }
.install-text small { color: var(--muted); font-size: 0.8rem; }
.install-text .ic { width: 15px; height: 15px; vertical-align: -2px; color: var(--ink); }
.install-bar .btn { margin-left: auto; padding: 8px 14px; flex-shrink: 0; }
.install-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.install-bar .btn + .install-close { margin-left: 0; }
.install-close .ic { width: 18px; height: 18px; }

/* ---------- PT overview ---------- */
.view.wide { max-width: 980px; }
.stats.four { grid-template-columns: repeat(2, 1fr); }
.ov-sort { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.ov-sort > span { font-size: 0.8rem; color: var(--muted); margin-right: 4px; }
.ov-table { display: grid; gap: 8px; }
.ov-head { display: none; }
.ov-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ov-row:active { border-bottom-width: 2px; transform: translateY(2px); }
.ov-row.nudge { border-color: var(--red-light); background: #FFF8F6; }
.ov-name { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.ov-name img { width: 48px; height: 48px; }
.ov-name b { display: block; }
.ov-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ov-tags .pet-status { font-size: 0.62rem; padding: 2px 7px; margin: 0; }
.ov-row > span[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 2px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.ov-streak { font: 800 1.3rem var(--display); color: var(--fire); display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.ov-streak::before { flex-basis: 100%; font-family: var(--body); }
.ov-streak .ic { width: 20px; height: 20px; }
.ov-streak.cold { color: var(--line-dark); }
.ov-week { display: flex; flex-wrap: wrap; gap: 3px; }
.ov-week::before { flex-basis: 100%; }
.ov-day {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #F6F1E7;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}
.ov-day.complete { background: var(--green); color: #fff; }
.ov-day.partial { background: var(--gold-light); color: var(--gold-lip); }
.ov-day.rest { background: var(--brown-light); color: var(--brown); }
.ov-day.missed { background: var(--red-light); color: var(--red-lip); }
.ov-day.pending { background: transparent; border: 2px dashed var(--line-dark); }
.ov-day.before, .ov-day.future { background: transparent; color: var(--line-dark); }
.ov-rate b { font: 800 1.1rem var(--display); }
.ov-rate .bar, .ov-health .bar { display: block; height: 8px; margin-top: 2px; }
.ov-rate .bar-fill, .ov-health .bar-fill { display: block; }
.ov-rate .bar-fill { background: var(--gold); }
.ov-health { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 6px; }
.ov-health::before { grid-column: 1 / -1; }
.ov-health small { color: var(--muted); font-size: 0.78rem; }
.ov-today { font-weight: 800; }

/* ---------- Library picker (categories, then stretches) ---------- */
.picker-field { margin-bottom: 12px; }
.picker-title { display: block; font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; }
.picker-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  background: #FBF8F2;
  color: var(--ink);
  font: 700 1rem var(--body);
  text-align: left;
  cursor: pointer;
}
.picker-toggle small { color: var(--muted); font-weight: 600; }
.picker-toggle[aria-expanded="true"] { border-color: var(--green); background: var(--surface); }
.picker-toggle[aria-expanded="true"] .ic { transform: rotate(180deg); }
.picker-panel {
  margin-top: 6px;
  padding: 6px;
  max-height: 360px;
  overflow-y: auto;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.pick-area, .pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  font: 800 0.95rem var(--body);
  text-align: left;
  cursor: pointer;
}
.pick-area:hover, .pick-row:hover { background: #F6F1E7; }
.pick-area > span { flex: 1; }
.pick-area small {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brown-light);
  color: var(--brown-lip);
  font-size: 0.75rem;
  text-align: center;
}
.pick-area .ic { width: 18px; height: 18px; color: var(--muted); }
.pick-area.open { background: var(--green-light); color: var(--green-dark); }
.pick-area.open .ic { transform: rotate(90deg); color: var(--green-dark); }
.pick-items { display: grid; gap: 2px; margin: 4px 0 6px 14px; padding-left: 10px; border-left: 3px solid var(--green-light); }
.pick-row > span:first-child { flex: 1; display: grid; }
.pick-row small { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.pick-row.selected { background: var(--green-light); color: var(--green-dark); }
.pick-row.custom { color: var(--brown); }
.pick-row .ic { width: 18px; height: 18px; }

@media (min-width: 640px) {
  .stats.four { grid-template-columns: repeat(4, 1fr); }
  .stats.four .stat-tile { flex-direction: column; text-align: center; gap: 4px; }
}
@media (min-width: 860px) {
  .ov-head, .ov-row {
    grid-template-columns: minmax(180px, 2fr) 0.8fr 1.9fr 1.1fr 1.1fr 0.9fr;
  }
  .ov-head {
    display: grid;
    gap: 14px;
    padding: 0 16px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .ov-name { grid-column: auto; }
  .ov-week { flex-wrap: nowrap; gap: 2px; }
  .ov-day { width: 19px; height: 19px; font-size: 0.6rem; border-radius: 5px; }
  .ov-row > span[data-label]::before { display: none; }
  .ov-week::before, .ov-streak::before, .ov-health::before { display: none; }
}

/* ---------- PT activity chart ---------- */
.activity { margin-bottom: 18px; display: grid; gap: 14px; }
.act-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.act-hero { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.act-hero b { font: 800 2.6rem/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.act-hero span { color: var(--muted); font-weight: 700; }
.act-change { margin-top: 4px; font-size: 0.88rem; color: var(--muted); font-weight: 700; }
.act-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; }
.act-delta .ic { width: 16px; height: 16px; stroke-width: 2.6; }
.act-delta.up { color: var(--green-dark); }
.act-delta.down { color: var(--red-lip); }
.act-delta.flat { color: var(--muted); }
.act-ranges { display: flex; gap: 6px; flex-wrap: wrap; }

.act-chart { position: relative; min-height: 120px; }
.act-svg { display: block; max-width: 100%; overflow: visible; }
.act-svg .grid { stroke: var(--line); stroke-width: 1; }
.act-svg .axis { fill: var(--muted); font: 700 11px var(--body); }
.act-svg .area { fill: var(--green-light); }
.act-svg .line { fill: none; stroke: var(--green); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.act-svg .end { fill: var(--green); stroke: var(--surface); stroke-width: 2; }
.act-svg .cross { stroke: var(--line-dark); stroke-width: 1.5; stroke-dasharray: 3 3; }
.act-svg .hover-dot { fill: var(--surface); stroke: var(--green); stroke-width: 3; }
.act-svg .hit { fill: transparent; cursor: crosshair; outline: none; }
.act-svg .hit:focus-visible { stroke: var(--green); stroke-width: 2; stroke-dasharray: 4 3; }
.act-tip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 1px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 0.82rem;
  white-space: nowrap;
  pointer-events: none;
}
.act-tip b { font-size: 0.85rem; }
.act-tip small { color: var(--muted); font-weight: 600; }

/* Today: stacked bar */
.act-stack { display: flex; gap: 2px; height: 26px; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.act-stack .seg { min-width: 6px; }
.seg.done, .key.done { background: var(--green); }
.seg.partial, .key.partial { background: var(--gold); }
.seg.rest, .key.rest { background: var(--brown-light); border: 1px solid var(--brown); }
.seg.missed, .key.missed { background: var(--line-dark); }
.act-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 0.88rem; color: var(--muted); font-weight: 700; }
.act-legend b { color: var(--ink); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.act-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.act-stat { padding: 10px 12px; border-radius: 12px; background: #F6F1E7; display: grid; gap: 2px; }
.act-stat b { font: 800 1.25rem var(--display); font-variant-numeric: tabular-nums; }
.act-stat span { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }

.act-table summary { cursor: pointer; color: var(--brown); font-weight: 800; font-size: 0.88rem; }
.act-table-wrap { margin-top: 8px; max-height: 260px; overflow: auto; border: 2px solid var(--line); border-radius: 12px; }
.act-table table { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.act-table th, .act-table td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.act-table th:first-child { text-align: left; }
.act-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- PT home: stats left, people right (mirrors the patient Home) ---------- */
.pt-main, .pt-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.pt-side { margin-top: 14px; }
.pt-main .stats, .pt-main .activity, .pt-side .code-card { margin: 0; }
.side-title { margin: 4px 0 -4px; }
.pt-side .patient-card { padding: 10px 12px; }
.pt-side .patient-card img { width: 46px; height: 46px; }
.pt-side .pt-code { font-size: 1.9rem; }

@media (min-width: 1000px) {
  .view.pt-home {
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 0 28px;
    align-items: start;
  }
  .pt-side { margin-top: 0; position: sticky; top: 80px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: min(440px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 0.92rem;
}

/* ---------- The one animation: a staggered rise on load ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
.revealing .reveal-item {
  animation: rise 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@media (prefers-reduced-motion: reduce) {
  .revealing .reveal-item { animation: none; }
}

/* ---------- Small phones ---------- */
@media (max-width: 380px) {
  :root { --gutter: 12px; }
  .wordmark { font-size: 1.2rem; }
  .user-pill .user-name { display: none; }
  .chip { padding: 4px 6px; }
}
@media (max-width: 480px) {
  .user-pill .user-name { display: none; }
}

@media (min-width: 640px) {
  .badges { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Desktop: left rail, main column + side panel ---------- */
@media (min-width: 1000px) {
  .signin {
    max-width: 920px;
    grid-template-columns: 1fr 400px;
    align-items: center;
    gap: 64px;
  }
  .view.signin { max-width: 920px; }
  .reco-talk img { width: 230px; }

  .signed-in .app { padding-left: var(--rail); }
  .topbar { padding: 12px 32px; justify-content: flex-end; }
  .topbar .wordmark { display: none; }
  .view { padding: 24px 32px 64px; }

  .tabbar {
    top: 0;
    right: auto;
    width: var(--rail);
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 84px 14px 24px;
    border-top: none;
    border-right: 2px solid var(--line);
  }
  .tabbar::before {
    content: "recoverable";
    position: absolute;
    top: 20px;
    left: 18px;
    padding-left: 46px;
    line-height: 38px;
    background: url("images/logo.png") left center / 38px 38px no-repeat;
    font: 800 1.6rem/38px var(--display);
    color: var(--green);
  }
  .tabbar button {
    flex-direction: row;
    gap: 12px;
    margin: 0;
    padding: 8px 12px 8px 8px;
    font-size: 0.86rem;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--c-light);
    border-bottom-width: 4px;
  }
  .tabbar .tab-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--c-light); }
  .tabbar .ic { width: 26px; height: 26px; }
  .tabbar button:hover:not(.active) { border-color: var(--c); }
  .tabbar button.active .tab-ic { background: var(--c); color: #fff; }
  .tab-badge { position: static; margin-left: auto; }

  .rail-card {
    display: grid;
    gap: 6px;
    margin-top: 14px;
    padding: 14px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg);
  }
  .rail-card img { width: 84px; justify-self: center; }
  .rail-label { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .rail-card b { font-size: 0.95rem; }
  .rail-card .bar { height: 12px; }
  .rail-card small { color: var(--muted); font-size: 0.8rem; }
  .rail-card .rail-warn { color: var(--red); }
  .rail-stats { display: flex; gap: 14px; font: 800 1.1rem var(--display); }
  .rail-stats span { display: inline-flex; align-items: center; gap: 3px; }
  .rail-stats .fire { color: var(--fire); }
  .rail-stats .gold { color: var(--gold-lip); }
  .rail-stats .ic { width: 20px; height: 20px; }

  /* Home: main column and a side panel, like a game dashboard */
  .view.home {
    max-width: 980px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-areas: "join join" "main side";
    gap: 0 28px;
    align-items: start;
  }
  .join-card { grid-area: join; }
  .home-main { grid-area: main; }
  .home-side { grid-area: side; margin-top: 0; position: sticky; top: 80px; }

  .chat-form { left: var(--rail); bottom: 0; padding: 14px 32px 18px; }
  .chat-view { padding-bottom: 110px; }
  .toast { bottom: 32px; }
  .signed-in .toast { left: calc(50% + var(--rail) / 2); }
}

[hidden] { display: none !important; }
