/* ============================================================
   ElderCare Check-In — Family Dashboard
   Design tokens: warm, grounded, calm — this is a safety tool
   for a worried adult child, not a marketing page. Traffic-light
   status: green = recently checked in, amber = approaching the
   alert threshold, brick-red = overdue. Red is reserved ONLY for
   the overdue/urgent state, never used decoratively elsewhere.
   ============================================================ */

:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --ink: #22282A;
  --ink-soft: #5B6360;
  --hairline: #DDD8CC;

  --brand: #2B5F5C;
  --brand-dark: #1E4341;
  --good: #4C8C5B;
  --good-soft: #DCEBD3;
  --positive: #C98A3E;
  --positive-soft: #F3E3CC;
  --urgent: #C44536;
  --urgent-soft: #F6DAD5;

  --radius: 16px;
  --shadow-soft: 0 1px 2px rgba(30, 67, 65, .05), 0 6px 20px rgba(30, 67, 65, .06);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Full-height column so the footer sits at the bottom of the window on
   short pages (no scrolling to find About/Privacy/Terms). */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  /* In the iOS app the WebView extends under the status bar (clock,
     battery) — push the header below it. env() is 0 in normal browsers,
     so the web dashboard is unchanged. Needs viewport-fit=cover. */
  padding-top: max(20px, env(safe-area-inset-top));
  padding-left: max(28px, env(safe-area-inset-left));
  padding-right: max(28px, env(safe-area-inset-right));
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--brand-dark);
}

a.wordmark { text-decoration: none; }

.wordmark-icon {
  height: 30px;
  width: auto;
  display: block;
}

.wordmark-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.wordmark-by {
  margin-top: 3px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* ---------- Layout ---------- */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 24px 40px;
  display: flex;
  flex-direction: column;
}

@media (max-width: 600px) {
  main { padding: 8px 16px 24px; }
}

.card {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 40px;
}

@media (max-width: 520px) {
  .card { padding: 28px 20px; }
}

.card--narrow {
  max-width: 440px;
  margin: 40px auto;
}

.display {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.9rem;
  line-height: 1.25;
  margin: 0 0 10px;
  color: var(--brand-dark);
}

.lede {
  color: var(--ink-soft);
  margin: 0 0 32px;
}

/* ---------- Welcome screen (pre-sign-in, first visit) ----------
   Phones: app-style onboarding — one illustration, one headline, one line,
   one primary action, full-bleed. Wider screens: a regular website hero —
   header with a Sign in link, copy on the left, illustration on the right,
   no card. Same markup; the layout is a grid whose areas change. */

/* Soft mint → warm cream wash, welcome screen only. Fixed so it doesn't
   band or end abruptly when the page scrolls on short phones. */
body.welcome-active {
  background:
    radial-gradient(120% 70% at 0% 0%, #CFE5D6 0%, rgba(207, 229, 214, 0) 60%),
    radial-gradient(110% 70% at 100% 100%, #F6DFC4 0%, rgba(246, 223, 196, 0) 60%),
    linear-gradient(180deg, #EEF4EE 0%, #F8F4EC 100%);
  background-attachment: fixed;
}

/* Header "Sign in" button — welcome screen on wider screens only. */
.topbar .topbar-signin {
  display: none;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  padding: 9px 20px;
  border: 1.5px solid var(--brand);
  border-radius: 12px;
}

.topbar .topbar-signin:hover { background: var(--good-soft); }

#welcomeView:not(.hidden) {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.welcome {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  grid-template-areas:
    "brand"
    "art"
    "title"
    "sub"
    "actions";
  justify-items: center;
  text-align: center;
  padding-top: env(safe-area-inset-top);
}

.welcome-brand {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

.welcome-brand img { height: 44px; width: auto; display: block; margin-bottom: 6px; }

.welcome-brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.1;
  color: var(--brand-dark);
}

.welcome-brand-by {
  margin-top: 2px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.welcome-art {
  grid-area: art;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin-bottom: 28px;
}

.welcome-art-blob { fill: rgba(255, 255, 255, 0.7); }

.welcome-ring {
  transform-origin: 160px 104px;
  animation: welcome-pulse 2.4s ease-out infinite;
}

@keyframes welcome-pulse {
  0%   { transform: scale(1);   opacity: .6; }
  80%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-ring { animation: none; opacity: 0; }
}

.welcome-title {
  grid-area: title;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.1rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--brand-dark);
  margin: 0 0 12px;
  text-wrap: balance;
}

.welcome-sub {
  grid-area: sub;
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 320px;
  margin: 0 0 36px;
}

.welcome-actions { grid-area: actions; width: 100%; }

.btn.welcome-cta {
  margin-top: 0;
  padding: 16px 22px;
  font-size: 1.05rem;
  border-radius: 14px;
}

.welcome-signin {
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.welcome-signin .link-btn { font-size: inherit; font-weight: 600; }

/* Phones: no header — the welcome screen carries its own brand block. */
@media (max-width: 899px) {
  .welcome-active .topbar { display: none; }
}

/* Wider screens: regular website hero. */
@media (min-width: 900px) {
  body.welcome-active main { max-width: 1160px; padding-left: 48px; padding-right: 48px; }

  .welcome-active .topbar .topbar-signin { display: inline-block; }

  .welcome {
    max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "title art"
      "sub   art"
      "actions art";
    grid-template-rows: auto auto 1fr;
    column-gap: 64px;
    justify-items: start;
    align-items: start;
    text-align: left;
  }

  .welcome-brand { display: none; } /* the header shows the brand */

  .welcome-title {
    align-self: end;
    font-size: 3.4rem;
    line-height: 1.08;
    margin-bottom: 18px;
  }

  .welcome-sub { font-size: 1.25rem; max-width: 460px; margin-bottom: 32px; }

  .welcome-actions { width: auto; }

  .btn.welcome-cta { width: auto; padding: 16px 40px; }

  .welcome-signin { display: none; } /* "Sign in" lives in the header */

  .welcome-art {
    max-width: 520px;
    margin: 0;
    justify-self: center;
    align-self: center;
  }
}

/* ---------- Tab navigation (dashboard) ----------
   Wide screens: a segmented pill control at the top. Phones (incl. the
   native apps): a fixed bottom tab bar with icons, app-style. */

.tab-bar {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
}

.tab-bar__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding: 9px 16px;
  cursor: pointer;
}

.tab-bar__btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-bar__btn--active {
  color: var(--brand-dark);
  background: var(--good-soft);
}

@media (max-width: 600px) {
  .tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    gap: 0;
    margin: 0;
    padding: 6px 8px max(10px, env(safe-area-inset-bottom));
    border-radius: 0;
    border-top: 1px solid var(--hairline);
    box-shadow: 0 -4px 20px rgba(30, 67, 65, .05);
  }

  .tab-bar__btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    font-size: 0.72rem;
    padding: 6px 4px;
  }

  .tab-bar__btn svg { width: 22px; height: 22px; }

  .tab-bar__btn--active {
    background: none;
    color: var(--brand);
  }

  /* Room for the fixed bar so the last panel / footer isn't hidden under it. */
  body.signed-in { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}

.tab-panel > .panel,
.tab-panel > .invite-result {
  margin-bottom: 24px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 24px;
  margin-bottom: 20px;
}

/* No card chrome - its children (person cards) are the cards. */
.panel--plain {
  background: none;
  box-shadow: none;
  padding: 0;
}

@media (max-width: 600px) {
  .panel { padding: 20px 18px; }
  .panel--plain { padding: 0; }
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--brand-dark);
}

.panel-sub {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

/* ---------- Form elements ---------- */

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 18px 0 6px;
  color: var(--ink);
}

.field-label:first-child { margin-top: 0; }

.text-input {
  width: 100%;
  padding: 13px 14px;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}

.text-input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  background: var(--surface);
}

.hint {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 6px 0 0;
}

.slider {
  width: 100%;
  accent-color: var(--brand);
}

/* Text captions under a 3-stop slider (currently just the threshold
   control) — the native range input's `list`/<datalist> gives tick marks
   in supporting browsers, but no text labels of its own, so these are a
   separate row positioned to line up with the same 3 evenly-spaced stops. */
.slider-stop-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

.btn {
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 24px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  margin-top: 22px;
}

.btn--primary {
  background: var(--brand);
  color: white;
}

.btn--primary:hover { background: var(--brand-dark); }

.btn--secondary {
  background: var(--positive-soft);
  color: var(--brand-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--brand);
}

.btn--ghost:hover { background: var(--good-soft); }

.btn--full { width: 100%; }

@media (max-width: 600px) {
  /* Thumb-friendly: primary actions span the width on phones. */
  .btn--primary { width: 100%; }
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1rem;
  padding: 6px 10px;
}

.error-text {
  color: var(--urgent);
  font-size: 0.85rem;
  margin-top: 10px;
}

/* ---------- Family members list ---------- */

.family-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.family-member-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr auto;
  /* Explicit areas rather than relying on auto-placement: this row now has
     4 children (name, phone, consent checkbox, remove button) but only 3
     column tracks — auto-placement would push the 4th item (consent) into
     the 3rd ("auto") column instead of wrapping, forcing that column to
     grow to fit the checkbox's long label text and squeezing name/phone
     down in the process. Naming areas explicitly keeps name/phone/remove
     on their original row at their original widths, with consent always on
     its own full-width row below regardless of DOM/auto-placement quirks. */
  grid-template-areas:
    "name phone remove"
    "consent consent consent";
  gap: 6px;
  align-items: center;
}

.family-member-row .fm-name { grid-area: name; }
.family-member-row .phone-input-row { grid-area: phone; }
.family-member-row .fm-remove { grid-area: remove; }

.family-member-row .consent-checkbox-label {
  grid-area: consent;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 2px 0 0;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.family-member-row .consent-checkbox-label input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 2px;
}

@media (max-width: 520px) {
  .family-member-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "phone"
      "consent"
      "remove";
  }
}

/* ---------- Country-code + local-number phone input ---------- */

.phone-input-row {
  display: flex;
  gap: 6px;
}

.phone-country-select {
  flex: 0 0 108px;
  padding-left: 8px;
  padding-right: 4px;
}

.phone-local-input {
  flex: 1;
  min-width: 0;
}

/* ---------- Linked people list & signature check-in strip ---------- */

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brand);
}

.refresh-icon {
  display: inline-block;
  font-size: 1rem;
  transition: transform 0.5s ease;
}

.refresh-icon.spinning {
  transform: rotate(360deg);
}

.empty-state {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.empty-sub { font-size: 0.82rem; }

/* Home with no one linked yet: a friendly call to action, not just text. */
.empty-state--hero {
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 36px 24px 28px;
  margin-top: 12px;
}

.empty-state__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--good-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state__icon svg { width: 34px; height: 34px; fill: var(--good); }

.empty-state__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--brand-dark);
  margin: 0 0 6px;
}

.empty-state--hero .empty-sub { font-size: 0.95rem; margin: 0; }

.linked-people-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.person-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
}

.person-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.person-card__avatar {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--positive-soft);
  color: var(--positive);
  font-weight: 600;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.person-card__identity { flex: 1; min-width: 0; }

.person-card__header .status-pill { flex: 0 0 auto; }

.person-card__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.status-pill--green {
  background: var(--good-soft);
  color: #2F5C3B;
}

.status-pill--yellow {
  background: var(--positive-soft);
  color: #8A5B1E;
}

.status-pill--overdue {
  background: var(--urgent-soft);
  color: var(--urgent);
}

.person-card__meta {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin: 2px 0 0;
}

/* The signature element: a 14-day check-in history strip. Each mark is a
   day; filled amber = checked in, hollow = missed. Encodes something real
   (the actual reliability pattern) rather than decorating. */
.checkin-strip {
  display: flex;
  gap: 4px;
}

.checkin-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--hairline);
}

.checkin-mark--ok { background: var(--positive); }
.checkin-mark--missed { background: var(--urgent-soft); border: 1px solid var(--urgent); }

/* ---------- Past invite codes ---------- */

.invites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 12px;
}

.invite-row__name {
  font-weight: 600;
  font-size: 0.92rem;
  margin-right: 8px;
}

.invite-row__code {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.invite-row__expiry {
  display: block;
  margin-top: 2px;
}

.invite-row__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill--used {
  background: var(--hairline);
  color: var(--ink-soft);
}

/* ---------- Invite result ---------- */

.invite-result {
  margin-top: 8px;
  box-shadow: 0 0 0 2px var(--brand), var(--shadow-soft);
}

.code-display__expiry {
  display: block;
  margin-top: 6px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--ink-soft);
}

.invite-result .btn--full { margin-top: 4px; }

.invite-result__copy-code {
  display: block;
  margin: 12px auto 0;
}

/* Collapsed-by-default alert preview at the foot of the invite card. */
.preview-tile {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.preview-tile summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
  list-style: none;
}

.preview-tile summary::-webkit-details-marker { display: none; }
.preview-tile summary::after { content: "›"; display: inline-block; margin-left: 6px; transition: transform 0.2s; }
.preview-tile[open] summary::after { transform: rotate(90deg); }

.preview-tile__intro { margin: 14px 0 10px; }


.code-display {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--bg);
  border-radius: 14px;
  padding: 18px 24px;
  text-align: center;
  margin: 16px 0;
}

/* ---------- Alert message preview ---------- */



/* ---------- Dismissible tiles (Account tab) ---------- */

.panel--dismissible {
  position: relative;
}

.panel__dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
}

#showHiddenTilesBtn {
  display: block;
  margin-top: 4px;
}

/* ---------- Manage-parent edit panel ---------- */

#managePersonBackBtn {
  display: inline-block;
  margin-bottom: 16px;
}

.person-card__manage {
  margin-top: 10px;
  font-size: 0.82rem;
}

#editReminderFields {
  padding-left: 4px;
  border-left: 2px solid var(--hairline);
  margin: 8px 0 0 6px;
}

#editReminderFields .field-label:first-child {
  margin-top: 14px;
}

.passive-signal-status {
  padding-bottom: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
}

/* ---------- Per-contact alert delivery windows ---------- */

.family-alert-windows-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.alert-window-row {
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 14px;
}

.alert-window-row__summary-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-window-row__identity {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.alert-window-row__name {
  font-weight: 600;
  font-size: 0.9rem;
}

.alert-window-row__phone {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.alert-window-row__summary {
  color: var(--ink-soft);
  font-size: 0.82rem;
  flex: 1;
}

.alert-window-row__remove {
  font-size: 0.9rem;
  padding: 2px 6px;
}

.alert-window-row__fields {
  margin-top: 10px;
  padding-left: 4px;
  border-left: 2px solid var(--hairline);
}

.alert-window-row__time-fields {
  margin-top: 6px;
}

/* ---------- Footer ---------- */

.site-footer {
  flex-shrink: 0;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 24px max(18px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.site-footer a {
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--brand);
}

/* ---------- Plans & billing (web) ---------- */

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.banner p { margin: 0; flex: 1 1 260px; }
.banner .btn { margin-top: 0; }

/* Red is reserved for the urgent state — alerts being off qualifies. */
.banner--warn {
  background: var(--urgent-soft);
  color: #7A2A20;
}

.plan-gate { text-align: center; }

.plan-gate__icon {
  width: 64px;
  height: 64px;
  margin: 4px auto 14px;
  border-radius: 50%;
  background: var(--good-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.plan-gate__icon svg { width: 30px; height: 30px; fill: var(--good); }

.alert-slots-hint { margin: 0 0 10px; }

.own-alert-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: 12px;
}

.own-alert-row__tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--good-soft);
  color: var(--brand-dark);
}

.own-alert-row__phone {
  font-size: 0.85rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .own-alert-row { grid-template-columns: auto 1fr; }
  .own-alert-row__phone { grid-column: 1 / -1; }
}

.alert-window-row--own .alert-window-row__phone { color: var(--brand); }

/* Account tab → Your plan */
.plan-details { margin: 4px 0 6px; }

.kv {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  padding: 7px 0;
  border-bottom: 1px solid var(--bg);
}

.kv span:first-child { color: var(--ink-soft); }

.usage { margin-top: 14px; }

.usage__label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.usage__bar {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
}

.usage__bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--brand);
  transition: width 0.3s ease;
}

#subscriptionPanel .btn + .btn { margin-left: 8px; }

@media (max-width: 600px) {
  #subscriptionPanel .btn { width: 100%; }
  #subscriptionPanel .btn + .btn { margin-left: 0; margin-top: 8px; }
}

/* #plans */
#plansView {
  max-width: 480px;
  margin: 0 auto;
}

.plans-title { margin-top: 12px; }
.plans-sub { margin-bottom: 22px; }

.plans-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.plan-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  cursor: pointer;
}

.plan-card:hover:not(:disabled) { border-color: var(--hairline); }

.plan-card--selected,
.plan-card--selected:hover:not(:disabled) { border-color: var(--brand); }

.plan-card:disabled { opacity: 0.6; cursor: default; }

.plan-card__badge {
  position: absolute;
  top: -10px;
  left: 16px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--positive);
  color: white;
  padding: 3px 10px;
  border-radius: 100px;
}

.plan-card__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.plan-card__name {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.plan-card__price {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--ink);
}

.plan-card__price small {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.plan-card__track {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--brand-dark);
  margin: 2px 0 8px;
}

.plan-card__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
}

.plan-card__check::before {
  content: "✓";
  flex: 0 0 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fine-print {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
  margin: 12px 0 0;
}

/* Bottom sheet (phones) / centred dialog (wide screens) */
.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 30, 30, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 12px 22px max(26px, env(safe-area-inset-bottom));
  animation: sheet-up 0.22s ease-out;
}

.sheet .btn--full + .btn--full { margin-top: 8px; }

@media (min-width: 600px) {
  .sheet-scrim { align-items: center; }
  .sheet { border-radius: 24px; padding: 26px 28px; }
  .sheet__grab { display: none; }
}

.sheet__grab {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--hairline);
  margin: 0 auto 16px;
}

.sheet__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--brand-dark);
  margin: 0 0 8px;
}

.sheet__body {
  color: var(--ink-soft);
  margin: 0;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

/* Sign-in card: the secondary text links sit on their own line under the
   full-width button. */
#signInView .btn--full + .link-btn,
#signInView .btn--full + .error-text + .link-btn { display: block; margin-top: 12px; }

/* ---------- Add-a-parent form ---------- */

/* Pairs of fields side by side on wider screens; stacked on phones. */
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 20px;
}

@media (min-width: 700px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* 1 day / 2 days / 3 days */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}

.segmented button {
  flex: 1;
  border: none;
  background: none;
  border-radius: 9px;
  padding: 9px 6px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: 0 1px 3px rgba(30, 67, 65, .15);
}

/* Labels inside a field-row keep their normal spacing (the generic
   `.field-label:first-child { margin-top: 0 }` would otherwise collapse it). */
.field-row > div > .field-label:first-child { margin-top: 18px; }
.field-row > div > .hint { margin-bottom: 0; }

/* Your own row on "Who gets alerted": name from your profile, read-only. */
.own-alert-row__name { font-weight: 600; color: var(--ink); }

/* Two short fields that sit side by side even on phones (first/last name). */
.field-row--tight { grid-template-columns: 1fr 1fr; }
.field-row--tight .field-label:first-child { margin-top: 12px; }

/* Alert preview styled as a phone's messages thread, in iMessage colours
   for familiarity: white screen, blue bubbles, the phone's system font —
   deliberately not the app's own styling, so it reads as "this is what
   lands on your phone". */
.sms-thread {
  max-width: 380px;
  margin: 4px auto 0;
  padding: 16px 14px 18px;
  background: #FFFFFF;
  border: 1px solid #E5E5EA;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.sms-thread__sender {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid #F0F0F3;
}

.sms-thread__avatar {
  width: 46px;
  height: 46px;
  padding: 8px;
  border-radius: 50%;
  background: #F2F2F7;
  object-fit: contain;
}

.sms-thread__name { font-size: 0.85rem; font-weight: 600; color: #1C1C1E; }

.sms-thread__time {
  margin: 14px 0 6px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: #8E8E93;
}

.sms-bubble {
  max-width: 85%;
  margin: 0;
  padding: 9px 13px;
  background: linear-gradient(180deg, #2B95FF 0%, #0A7CFF 100%);
  color: #FFFFFF;
  font-size: 0.92rem;
  line-height: 1.35;
  border-radius: 18px 18px 18px 5px;
}

/* Delete on unused invite codes — quieter than Copy, red only on hover. */
.invite-row__delete { color: var(--ink-soft); }
.invite-row__delete:hover { color: var(--urgent); }

/* Account tab: "Signed in as" with Sign out on the right. */
.account-actions__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.account-actions__row .btn { margin-top: 0; }

.account-actions__label {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.account-actions__who { font-weight: 600; }

/* Destructive action (Delete my account). */
.btn--danger {
  background: var(--urgent);
  color: white;
}

.btn--danger:hover { background: #A63A2D; }

@media (max-width: 600px) {
  .account-actions__row .btn { width: auto; }
}
