/* Apple (iPadOS) look: system grouped background, white inset cards with no outlines, SF system font,
   system blue for the one main action, system red / green / orange for status, a blurred bottom bar with
   a hairline, large-title greeting. Landscape iPad gets two columns. The orange countdown bar keeps the colour
   from the user's reference picture. */
:root {
  --bg: #f2f2f7; --card: #ffffff; --fg: #000000; --muted: #6c6c70;
  --sep: rgba(60, 60, 67, 0.2); --fill: rgba(120, 120, 128, 0.12);
  --tint: #007aff; --tint-text: #0066d6; --tint-soft: rgba(0, 122, 255, 0.12); --tint-fg: #ffffff;
  --red: #d70015; --red-bg: rgba(255, 59, 48, 0.10); --green: #248a3d; --green-bg: rgba(52, 199, 89, 0.14);
  --orange: #c93400; --orange-bg: rgba(255, 149, 0, 0.14);
  --pill-fg: #ffffff;
  --bar: rgba(242, 242, 247, 0.82); --material: rgba(255, 255, 255, 0.86);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  --countdown: #f9834b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --bg: #000000; --card: #1c1c1e; --fg: #ffffff; --muted: #98989f;
    --sep: rgba(84, 84, 88, 0.6); --fill: rgba(120, 120, 128, 0.24);
    --tint: #0a84ff; --tint-text: #64a8ff; --tint-soft: rgba(10, 132, 255, 0.2); --tint-fg: #ffffff;
    --red: #ff6961; --red-bg: rgba(255, 69, 58, 0.18); --green: #30d158; --green-bg: rgba(48, 209, 88, 0.16);
    --orange: #ff9f0a; --orange-bg: rgba(255, 159, 10, 0.18);
    --pill-fg: #1c1c1e;
    --bar: rgba(28, 28, 30, 0.82); --material: rgba(44, 44, 46, 0.88);
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-scheme="dark"] {
  --bg: #000000; --card: #1c1c1e; --fg: #ffffff; --muted: #98989f;
  --sep: rgba(84, 84, 88, 0.6); --fill: rgba(120, 120, 128, 0.24);
  --tint: #0a84ff; --tint-text: #64a8ff; --tint-soft: rgba(10, 132, 255, 0.2); --tint-fg: #ffffff;
  --red: #ff6961; --red-bg: rgba(255, 69, 58, 0.18); --green: #30d158; --green-bg: rgba(48, 209, 88, 0.16);
  --orange: #ff9f0a; --orange-bg: rgba(255, 159, 10, 0.18);
  --pill-fg: #1c1c1e;
  --bar: rgba(28, 28, 30, 0.82); --material: rgba(44, 44, 46, 0.88);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
:root[data-scheme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--fg);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
main { max-width: 680px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px 0; display: flex; flex-direction: column; }
section { display: flex; flex-direction: column; flex: 1; gap: 14px; }
#app { justify-content: flex-start; }

/* title row: large greeting on the left, theme switcher on the right */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .greeting { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 10px; flex: none; }
.theme-switch { flex: none; }
.test-pill { padding: 4px 12px; border-radius: 999px; background: var(--orange-bg); color: var(--orange); font-size: 14px; font-weight: 700; }
button.gear { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border-radius: 50%; background: var(--fill); color: var(--fg); }
button.gear svg { width: 24px; height: 24px; }
.theme-switch { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.theme-switch button { min-height: 36px; padding: 0 12px; border-radius: 7px; background: transparent; color: var(--fg);
  font-size: 13px; font-weight: 500; }
.theme-switch button[aria-pressed="true"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }
.theme-switch button:active { opacity: 1; }

/* large title */
.greeting { margin: 4px 4px 2px; font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: 0.3px; }

.cards { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border-radius: 18px; padding: 16px 18px 18px; }
.label { font-size: 15px; font-weight: 600; color: var(--muted); }
.headline { margin-top: 2px; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums; }
.detail { margin-top: 6px; font-size: 17px; color: var(--muted); font-variant-numeric: tabular-nums; }
.detail:empty { display: none; }

/* dose and restrictions share one shape, like an iPadOS widget: label, headline with the time left,
   a rounded countdown bar, then the small print at the foot of the card */
#dose-card, #protein-card { display: flex; flex-direction: column; }
.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 14px; min-height: 46px; margin-top: 2px; }
.status .headline { margin: 0; }
.left-text { margin-left: auto; font-size: 19px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.left-text:empty { display: none; }
.bar { flex: none; height: 12px; margin-top: 10px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--countdown); }
.bar.idle { visibility: hidden; }
.foot { margin: auto 0 0; padding-top: 14px; font-size: 16px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.last-time { margin-left: 4px; font-weight: 600; color: var(--fg); }
#dose-card[data-mode="missed"] .headline { color: var(--orange); }
.start-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; font-size: 17px; }
.start-row input { width: auto; padding: 6px 10px; border-radius: 8px; background: var(--fill); }
#dose-card[data-mode="due"] { background: var(--orange-bg); }
#dose-card[data-mode="due"] .headline { color: var(--orange); }
#dose-card[data-mode="overdue"] { background: var(--orange-bg); box-shadow: inset 0 0 0 2px var(--orange); }
#dose-card[data-mode="overdue"] .headline { color: var(--orange); }

/* restrictions */
#protein-card[data-mode="stop"] { background: var(--red-bg); }
#protein-card[data-mode="ok"] { background: var(--green-bg); }
#p-headline { font-size: 26px; }
#protein-card[data-mode="stop"] #p-headline { color: var(--red); }
#protein-card[data-mode="stop"] .bar i { background: var(--red); }
#protein-card[data-mode="ok"] #p-headline { color: var(--green); }

/* bottom bar: blurred material with a hairline, like a toolbar; the button stays on screen */
.actions { display: flex; flex-direction: column; gap: 4px; position: sticky; bottom: 0; z-index: 2;
  margin: auto -16px 0; padding: 12px 16px max(10px, env(safe-area-inset-bottom));
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-top: 0.5px solid var(--sep); }
button { font: inherit; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity 0.12s ease; }
button:active { opacity: 0.6; }
button.big { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 72px;
  border-radius: 16px; font-size: 22px; font-weight: 600; letter-spacing: 0.2px; color: var(--tint-fg); background: var(--tint); }
button.big .ico { width: 28px; height: 28px; flex: none; }
/* too early for the next dose: still tappable (it asks first), but visibly not the thing to do now */
button.big.early { background: var(--fill); color: var(--muted); }
.took-text { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
#took-due { font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--fg); }
button.big.done { background: var(--green); color: var(--pill-fg); cursor: default; }
button.big.done:active { opacity: 1; }
/* the second-most important action: a full-width tinted button, clearly bigger than the plain text links below it */
button.secondary { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; border-radius: 16px;
  background: var(--tint-soft); color: var(--tint-text); font-size: 18px; font-weight: 600; }
button.secondary .ico { width: 24px; height: 24px; flex: none; }
.row { display: flex; justify-content: center; gap: 12px; }
.row:not(:has(button:not([hidden]))) { display: none; }
button.link { background: transparent; color: var(--tint-text); font-size: 17px; font-weight: 400; min-height: 44px; padding: 0 16px; border-radius: 12px; }
button.link.soft { background: var(--tint-soft); font-weight: 600; }
input { font: inherit; padding: 14px 16px; border-radius: 12px; border: 0; background: var(--card); color: var(--fg); width: 100%; }
.error { color: var(--red); margin: 0; text-align: center; font-size: 15px; }
#notice { background: var(--orange-bg); color: var(--orange); padding: 8px 14px; border-radius: 12px; font-size: 15px; font-weight: 500; }
/* confirmation message: takes the place of the "Last dose logged" line for a few seconds, then the line returns */
.toast { display: flex; align-items: center; gap: 8px; min-height: 21px; font-size: 16px; font-weight: 600; color: var(--fg);
  animation: rise 0.3s ease both; }
.toast::before { content: "\2713"; flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green); color: var(--pill-fg); font-size: 12px; font-weight: 900; line-height: 1; }
.toast:not([hidden]) ~ #last-dose { display: none; }
#dose-foot:not(:has(> :not([hidden]))) { display: none; }
.group > .toast { padding: 12px 16px; border-top: 0.5px solid var(--sep); }
[hidden] { display: none !important; }

/* gentle motion */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* .side groups the timeline and restrictions; it takes no box of its own */
.side { display: contents; }
.cards > *, .side > * { animation: rise 0.4s ease both; }
.side > :nth-child(1) { animation-delay: 0.06s; }
.side > :nth-child(2) { animation-delay: 0.12s; }
@media (prefers-reduced-motion: reduce) { .cards > *, .side > *, .toast, .su-body { animation: none !important; } button { transition: none; } }

/* iPad (portrait and landscape) and other roomy screens: content at the top under the large title, bar not pinned */
@media (min-width: 700px) and (min-height: 800px) {
  main { padding-top: max(28px, env(safe-area-inset-top)); }
  #app { justify-content: flex-start; gap: 18px; }
  .greeting { font-size: 36px; }
  .card { padding: 20px 24px 22px; }
  .headline { font-size: 38px; }
  #p-headline { font-size: 28px; }
  .actions { position: static; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border-top: 0;
    margin: 4px auto 0; width: 100%; max-width: 520px; padding: 6px 0; }
  button.big { min-height: 80px; font-size: 24px; }
  button.secondary { min-height: 60px; font-size: 19px; }
}
/* Phones: tighter sizes so the dose card, the restrictions status and the button fit one screen */
@media (max-width: 480px) {
  .greeting { font-size: clamp(18px, 5.1vw, 24px); }
  .theme-switch button { padding: 0 9px; }
  .top { gap: 8px; }
  .top-right { gap: 6px; }
  button.gear { width: 38px; height: 38px; }
  button.gear svg { width: 22px; height: 22px; }
  .card { padding: 14px 16px 16px; border-radius: 16px; }
  .cards { gap: 10px; }
  .label { font-size: 14px; }
  .headline { font-size: 30px; }
  .status { min-height: 38px; }
  #p-headline { font-size: 22px; }
  .left-text { font-size: 16px; }
  .bar { height: 10px; margin-top: 8px; }
  .foot { padding-top: 10px; font-size: 15px; }
  button.big { min-height: 64px; font-size: 20px; }
  button.big .ico { width: 24px; height: 24px; }
  button.secondary { min-height: 50px; font-size: 17px; border-radius: 14px; }
  button.link { min-height: 40px; }
  .actions { padding-top: 10px; }
}

/* iPad landscape (and other wide screens): dose and restrictions side by side at the same height, then the
   two buttons and the timeline across the full width. Phones are too short to match. */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 600px) {
  main:has(#app:not([hidden])) { max-width: 1240px; padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 18px; align-content: start; }
  #app > .top { grid-column: 1 / -1; grid-row: 1; margin-bottom: 14px; }
  #debug-banner { grid-column: 1 / -1; grid-row: 2; }
  .cards { display: contents; }
  #dose-card { grid-column: 1; grid-row: 3; }
  #protein-card { grid-column: 2; grid-row: 3; }
  #app:has(#protein-card[hidden]) #dose-card { grid-column: 1 / -1; }
  #dose-card, #protein-card { padding: 20px 24px; }
  .status { min-height: 52px; }
  #dose-card .headline { font-size: clamp(32px, 3.5vw, 44px); }
  #dose-card:not([data-mode="waiting"]) .headline { font-size: clamp(26px, 2.6vw, 38px); }   /* the longer wording stays on one line */
  #p-headline { font-size: clamp(20px, 2.05vw, 26px); }
  .left-text { font-size: 17px; }
  .bar { height: 14px; margin-top: 12px; }

  .actions { grid-column: 1 / -1; grid-row: 4; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 18px;
    position: relative; width: auto; max-width: none; margin: 14px 0 0; padding: 0;
    background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border-top: 0; }
  #notice, .actions .row { grid-column: 1 / -1; }
  #notice { margin-bottom: 6px; }
  button.big, button.secondary { min-height: 76px; font-size: 22px; }
  .actions button.link { min-height: 36px; }
  #timeline-card { grid-column: 1 / -1; grid-row: 5; margin-top: 14px; }
  .tl-bar { height: 64px; }
}
/* the shortest iPads (mini): tighten so everything stays on one screen */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 600px) and (max-height: 760px) {
  button.big, button.secondary { min-height: 66px; }
  .tl-bar { height: 54px; }
  .tl-nav { margin: 0 0 6px; }
  #app > .top { margin-bottom: 10px; }
  #dose-card, #protein-card { padding: 14px 20px; }
  .foot { padding-top: 10px; }
}
/* the large iPads have height to spare */
@media (orientation: landscape) and (min-width: 900px) and (min-height: 900px) {
  #dose-card, #protein-card { padding: 28px 30px; }
  .bar { height: 18px; margin-top: 18px; }
  .foot { padding-top: 24px; font-size: 18px; }
  button.big, button.secondary { min-height: 96px; font-size: 25px; }
  .tl-bar { height: 96px; }
}

/* upright screens (phones and iPads): dose, restrictions and the buttons come first, then the timeline.
   The buttons sit in the page at full width instead of being pinned to the bottom. */
@media (orientation: portrait) {
  main:has(#app:not([hidden])) { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  #app { gap: 12px; }
  #app > .cards { display: contents; }
  #timeline-card { order: 1; }
  .actions { position: static; width: 100%; max-width: none; margin: 0; padding: 0; border-top: 0;
    background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* a full-size touch target that does not make the line (or the card) taller */
.toast-btn { flex: none; margin: -12px -10px -12px auto; min-height: 44px; padding: 0 10px; border-radius: 8px; background: transparent;
  color: var(--tint-text); font-size: 17px; font-weight: 700; }

/* sheets (Took it earlier, History, Settings): a bottom sheet on phones, a centred card on iPad */
body.noscroll { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 0 16px max(16px, env(safe-area-inset-bottom)); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); padding: 10px 0 8px; }
.sheet-title { margin: 0; font-size: 20px; font-weight: 700; }
.group { background: var(--card); border-radius: 14px; margin: 0 0 12px; overflow: hidden; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 16px;
  font-size: 17px; border-top: 0.5px solid var(--sep); }
.field:first-child { border-top: 0; }
#quiet-times { border-top: 0.5px solid var(--sep); }
.field input, .field select { width: auto; font: inherit; background: var(--fill); color: var(--fg); border: 0; border-radius: 8px; padding: 6px 10px; }
.field > span:first-child { flex: 1 1 auto; min-width: 0; }
.field input[type="number"] { width: 66px; padding: 6px 8px; text-align: right; }
.field select { flex: 0 1 auto; min-width: 0; max-width: 58%; text-overflow: ellipsis; }
.pair { display: inline-flex; align-items: center; gap: 6px; }
.pair em { font-style: normal; color: var(--muted); }
input.switch { -webkit-appearance: none; appearance: none; position: relative; width: 51px; height: 31px; padding: 0; border-radius: 999px;
  background: rgba(120, 120, 128, 0.32); transition: background 0.2s ease; cursor: pointer; }
input.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease; }
input.switch:checked { background: #34c759; }
input.switch:checked::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip { background: var(--card); color: var(--tint-text); padding: 9px 14px; border-radius: 999px; font-size: 16px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--tint); color: var(--tint-fg); }
.sheet-note { margin: -4px 4px 12px; color: var(--muted); font-size: 14px; }
.sheet .error { margin: 0 0 10px; }
.sheet button.big.sm { min-height: 52px; font-size: 18px; margin-top: 4px; }
.hist-day { margin: 10px 4px 6px; }
.hist-gap { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.hist-time { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hist-gap { text-align: right; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; max-height: 80vh; max-height: 80dvh; } }

/* guided setup: one task per screen, centred, with the buttons under it */
.setup { width: 100%; max-width: 520px; margin: 0 auto; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.su-top { display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; min-height: 44px; }
.su-top [hidden] { display: block !important; visibility: hidden; }
#su-back { grid-column: 1; justify-self: start; padding: 0 4px; }
.su-dots { grid-column: 2; display: flex; justify-content: center; gap: 8px; }
.su-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--sep); }
.su-dots i.on { background: var(--tint); }
#su-close { grid-column: 3; justify-self: end; padding: 0 4px; }
.su-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 8px 0; animation: rise 0.35s ease both; }
.su-check { width: 80px; height: 80px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--tint); color: #fff1fa; font-size: 40px; font-weight: 800;
  box-shadow: 0 0 18px rgba(255, 77, 210, 0.65), inset 0 0 14px rgba(255, 77, 210, 0.4); }
.su-title { margin: 0 4px 10px; font-size: clamp(26px, 6vw, 34px); line-height: 1.15; font-weight: 700; text-align: center; outline: none; }
.su-text { margin: 0 8px 18px; text-align: center; color: var(--muted); font-size: 18px; line-height: 1.4; }
.su-title:has(+ .su-text[hidden]) { margin-bottom: 22px; }
.su-actions { display: flex; flex-direction: column; gap: 8px; }
.su-actions .link { align-self: center; }

/* the setup's look follows the Yitma neon logo: deep plum, pink tube light, a purple halo. It applies in
   Light and Dark alike, and only while the setup is on screen. */
html:has(body.onboarding) { background: #16101f; }
body.onboarding {
  --bg: #16101f; --card: #241a35; --fg: #fff1fa; --muted: #c9b9e0; --sep: rgba(201, 185, 224, 0.24);
  --fill: rgba(201, 185, 224, 0.16); --tint: #ff9ce6; --tint-text: #ff9ce6; --tint-fg: #16101f;
  --tint-soft: rgba(255, 77, 210, 0.16); --red: #ff9b93; --orange: #ffb457; --shadow: none;
  color: var(--fg); color-scheme: dark;
  background: radial-gradient(ellipse 90% 55% at 50% 30%, rgba(109, 74, 255, 0.28), transparent 70%) fixed, #16101f; }
.onboarding .setup .big { box-shadow: 0 0 22px rgba(255, 77, 210, 0.45); }
.onboarding .su-dots i.on { box-shadow: 0 0 8px #ff4dd2; }
.onboarding .su-title { text-shadow: 0 0 18px rgba(255, 77, 210, 0.35); }
/* welcome lockup: the name, with the typed line on one row to the right of the Y's tail. Everything is sized from
   the lockup's own width (cqw), so the line keeps its place on every screen. 33.8cqw and 35cqw follow the artwork:
   the tail ends 0.358 across the logo, and the space under the lettering is centred 0.82 down it. */
.su-brand { margin-bottom: 32px; }
.su-lockup { position: relative; container-type: inline-size; }
.su-logo { display: block; width: 90cqw; height: auto; }
.su-tag { position: absolute; left: 33.8cqw; top: 35cqw; transform: translateY(-50%); margin: 0; white-space: nowrap;
  font-size: 4.7cqw; font-weight: 700; line-height: 1.2; }
#su-typed { white-space: pre; color: #ff9ce6; text-shadow: 0 0 6px #ff4dd2, 0 0 18px rgba(109, 74, 255, 0.9); }
.su-caret { display: inline-block; width: 0.1em; height: 1em; margin-left: 0.1em; vertical-align: -0.12em; border-radius: 2px;
  background: #fff1fa; box-shadow: 0 0 8px #ff4dd2; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .su-caret { display: none; } }
.setup[data-step="welcome"] { max-width: 640px; }
.setup[data-step="welcome"] .su-title { font-size: clamp(28px, 7.4vw, 40px); white-space: pre-line; }
.setup[data-step="welcome"] .su-text { font-size: clamp(20px, 5.4vw, 25px); margin-bottom: 8px; }
.setup[data-step="welcome"] .big { font-size: clamp(23px, 6vw, 28px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 700px) { .su-brand { margin-bottom: 18px; } }

/* Add to Home Screen, shown as a 5 second loop: the Share button is pressed, the menu slides up and its row is
   pressed, then the new icon lands on a Home Screen. Reduced motion shows the last picture, still. */
.su-demo { position: relative; flex: none; width: min(100%, 320px); height: 186px; margin: 0 auto 16px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--sep); overflow: hidden; }
.demo-page { position: absolute; left: 22px; right: 22px; top: 26px; display: grid; gap: 12px; }
.su-demo.for-ipad .demo-page { top: 66px; }
.demo-page i, .demo-sheet > i, .demo-address { display: block; height: 10px; border-radius: 6px; background: var(--fill); }
.demo-page i:nth-child(2) { width: 82%; }
.demo-page i:nth-child(3) { width: 60%; }
.demo-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: var(--fill); }
.su-demo.for-ipad .demo-bar { top: 0; bottom: auto; }
.demo-address { flex: 1; height: 24px; border-radius: 9px; }
.demo-share { position: relative; display: grid; place-items: center; color: var(--tint); }
.demo-share svg { width: 26px; height: 26px; }
.demo-tap { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--tint); opacity: 0; pointer-events: none; }
.demo-tap.one { animation: demo-tap-one 5s ease-out infinite; }
.demo-sheet { position: absolute; left: 10px; right: 10px; bottom: 0; display: grid; gap: 10px; padding: 14px 14px 16px;
  border-radius: 16px 16px 0 0; background: #35294e; box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.4); transform: translateY(110%);
  animation: demo-sheet 5s ease infinite; }
.demo-sheet > i { width: 55%; }
.demo-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px;
  border-radius: 10px; background: var(--fill); font-size: 15px; font-weight: 600; color: var(--fg); }
.demo-row svg { width: 22px; height: 22px; flex: none; }
.demo-tap.two { right: 6px; top: 50%; margin-top: -17px; animation: demo-tap-two 5s ease-out infinite; }
.demo-home { position: absolute; inset: 0; z-index: 1; display: grid; grid-template-columns: repeat(3, 56px); grid-auto-rows: 74px;
  gap: 10px 26px; place-content: center; background: radial-gradient(circle at 50% 30%, #3a2670, #16101f); opacity: 0;
  animation: demo-home 5s ease infinite; }
.demo-home > i { height: 56px; border-radius: 13px; background: rgba(201, 185, 224, 0.2); }
.demo-home figure { margin: 0; text-align: center; animation: demo-icon 5s ease infinite; }
.demo-home img { display: block; border-radius: 13px; box-shadow: 0 0 14px rgba(255, 77, 210, 0.6); }
.demo-home figcaption { margin-top: 4px; font-size: 12px; font-weight: 600; color: #fff1fa; }
@keyframes demo-tap-one { 0%, 8% { opacity: 0; transform: scale(0.3); } 13% { opacity: 0.7; transform: scale(0.7); } 24%, 100% { opacity: 0; transform: scale(1.5); } }
@keyframes demo-sheet { 0%, 24% { transform: translateY(110%); } 34%, 96% { transform: none; } 100% { transform: translateY(110%); } }
@keyframes demo-tap-two { 0%, 45% { opacity: 0; transform: scale(0.3); } 50% { opacity: 0.7; transform: scale(0.8); } 61%, 100% { opacity: 0; transform: scale(1.7); } }
@keyframes demo-home { 0%, 61% { opacity: 0; } 68%, 95% { opacity: 1; } 100% { opacity: 0; } }
@keyframes demo-icon { 0%, 66% { transform: scale(0.2); } 75% { transform: scale(1.18); } 81%, 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .su-demo * { animation: none !important; } .demo-home { opacity: 1; } }
@media (max-height: 700px) { .su-demo { height: 142px; margin-bottom: 8px; } .demo-home { grid-template-columns: repeat(3, 46px); grid-auto-rows: 62px; gap: 2px 26px; }
  .demo-home > i { height: 46px; border-radius: 11px; } .demo-home img { width: 46px; height: 46px; border-radius: 11px; }
  .demo-bar { height: 40px; } .demo-sheet { gap: 8px; padding: 10px 14px 12px; } .su-demo.for-ipad .demo-page { top: 56px; } }

/* debug tools */
.debug-banner { display: block; width: 100%; margin: 0 0 12px; padding: 8px 14px; border-radius: 12px; background: var(--orange-bg);
  color: var(--orange); font-size: 15px; font-weight: 600; text-align: center; min-height: 0; }
.dbg-info .field { min-height: 36px; padding: 4px 16px; font-size: 15px; }
.dbg-info .field span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
#sheet-debug .label { margin: 8px 4px 6px; }
.danger-row { display: block; width: 100%; min-height: 48px; padding: 8px 16px; background: transparent; color: var(--red); font-size: 17px; font-weight: 600; }

/* access code keypad: as large as the screen allows */
#login { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5dvh; min-height: calc(100dvh - 56px); }
.code-dots { display: flex; gap: min(5vw, 28px); height: 28px; align-items: center; }
.code-dots i { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--tint); box-sizing: border-box; transition: background 0.1s; }
.code-dots i.on { background: var(--tint); }
.code-dots.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
#login .error { min-height: 22px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: min(2.4vw, 16px); width: min(94vw, 64dvh); }
.key { aspect-ratio: 1.2; border-radius: 22px; background: var(--card); color: var(--fg); font-size: min(11vw, 7dvh); font-weight: 500;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 0 var(--sep); }
.key:active { background: var(--fill); opacity: 1; }
.key.del { color: var(--tint-text); background: transparent; box-shadow: none; }
.key svg { width: 38%; height: 38%; }
@media (prefers-reduced-motion: reduce) { .code-dots.shake { animation: none; } }
main:has(#login:not([hidden])) { max-width: none; }

/* timeline */
.tl-nav { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
button.tl-step { font-size: 40px; font-weight: 300; line-height: 1; min-width: 64px; min-height: 52px; padding: 0 12px; }
button.tl-step:disabled { opacity: 0.25; }
.tl-title { text-align: center; }
.tl-day { font-size: 19px; font-weight: 700; }
.tl-pill { display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px; background: var(--orange-bg); color: var(--orange); font-size: 13px; font-weight: 600; }
.tl-chart { position: relative; margin: 0 0 8px; }
.tl-bar { position: relative; height: 56px; border-radius: 8px; background: var(--fill); overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; min-width: 2px;
  font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; white-space: nowrap; border-right: 1px solid rgba(0, 0, 0, 0.25); }
.tl-seg.wait { background: #8e8e93; padding-left: 12px; }
.tl-seg.late { background: #ff9500; color: #1c1c1e; }
.tl-seg.missed { background: var(--red); color: var(--pill-fg); }
.tl-wash { position: absolute; top: 0; bottom: 0; z-index: 1; pointer-events: none; background: rgba(88, 86, 214, 0.5);
  display: flex; align-items: flex-end; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; letter-spacing: 0.04em;
  text-transform: uppercase; padding-bottom: 3px; overflow: hidden; white-space: nowrap; }
.tl-dot { z-index: 2; position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; box-sizing: border-box; border-radius: 50%;
  background: #34c759; border: 3px solid var(--card); }
.tl-dot.manual { background: var(--card); border-color: #34c759; }
.tl-now { position: absolute; top: 0; bottom: 26px; width: 2px; margin-left: -1px; background: var(--red); z-index: 3; pointer-events: none; }
.tl-axis { position: relative; height: 20px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tl-axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.tl-axis span:first-child { transform: none; }
.tl-events { margin: 0 0 4px; padding: 0 2px; }
.tl-ev { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 0 12px 26px; border-top: 1px solid var(--sep); }
.tl-ev:first-child { border-top: 0; }
.tl-ev::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--sep); }
.tl-ev:first-child::before { top: 50%; }
.tl-ev:last-child::before { bottom: 50%; }
.tl-ev::after { content: ""; position: absolute; left: 0; top: 50%; width: 14px; height: 14px; margin-top: -7px; box-sizing: border-box; border-radius: 50%; background: var(--card); }
.tl-ev.due::after { border: 2.5px solid #8e8e93; }
.tl-ev.alert::after { background: #ff9500; }
.tl-ev.missed::after { background: var(--red); }
.tl-ev.dose::after { background: #34c759; }
.tl-ev.dose.manual::after { border: 2.5px solid #34c759; }
.tl-ev .what { flex: 1 1 auto; min-width: 0; }
.tl-ev .what b { display: block; font-weight: 600; }
.tl-ev .what small { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; }
.tl-ev time { color: var(--muted); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-head { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--sep); }

/* care team view and its Settings controls */
.care .actions, .care #settings-open, .care #debug-banner { display: none !important; }
.care-url { font-size: 14px; color: var(--muted); word-break: break-all; user-select: all; -webkit-user-select: all; }
.care-actions { justify-content: flex-start; gap: 4px; padding: 0 8px; }
.care-off { text-align: center; color: var(--muted); margin: 30vh 0 0; font-size: 18px; }
