/* Premium layer (D-61). Loaded after every other stylesheet, so it refines the existing system
   rather than replacing it. Apple's own sites are the reference: wide canvases, few empty gaps,
   rounded surfaces that float on soft layered shadows, large tight headlines, pill controls.
   Still inside D-16: no gradients, no blur or translucency, nothing follows the cursor, no
   opacity on buttons, nothing animates on scroll. Hover depth applies only where hover exists. */

:root {
  --radius-2xl: 28px;
  --fs-display: 2.5rem;
  --lh-display: 2.875rem;
  /* Apple-like layered shadows: a tight contact shadow plus a wide soft one. */
  --shadow-tile: 0 1px 1px rgba(0, 0, 0, 0.03), 0 2px 6px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.05);
  --shadow-tile-hover: 0 2px 4px rgba(0, 0, 0, 0.04), 0 12px 24px rgba(0, 0, 0, 0.08), 0 32px 64px rgba(0, 0, 0, 0.10);
  --shadow-press: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.06);
  --surface-hover: #FBFBFD;
  --lift: translateY(-4px);
}

@media (min-width: 1280px) {
  :root {
    --fs-display: 3rem;
    --lh-display: 3.375rem;
  }
}

body {
  letter-spacing: -0.003em;
}

/* Canvas: use the screen. The page grows with the window instead of stopping at 1200 px. */
.main {
  padding: var(--space-16) var(--space-16) calc(var(--space-80) + var(--space-48));
}

.page {
  max-width: 1680px;
  gap: var(--space-24);
}

@media (min-width: 640px) {
  .main {
    padding: var(--space-24) var(--space-24) calc(var(--space-80) + var(--space-48));
  }
}

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .main {
    padding: var(--space-24) var(--space-32) var(--space-48);
  }

  .sidebar {
    gap: var(--space-20);
    padding: var(--space-20) var(--space-12);
    background: var(--bg);
    border-right: 0;
  }
}

/* Headlines: Apple's large, tight, heavy titles. */
.page-head {
  gap: var(--space-4);
}

/* Display size only on wide screens; phones keep the Apple large title (34) and title 1 (28). */
.page-head .t-large-title,
.page-head .t-title-1 {
  font-weight: 700;
  letter-spacing: -0.025em;
}

@media (min-width: 1024px) {
  .page-head .t-large-title,
  .page-head .t-title-1 {
    font-size: var(--fs-display);
    line-height: var(--lh-display);
  }
}

.page-head .t-callout {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-2);
}

.t-title-2 { letter-spacing: -0.015em; }
.t-title-3 { letter-spacing: -0.01em; }

/* Surfaces float instead of sitting in thin boxes. */
.card,
.stat,
.user-card {
  border: 0;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-tile);
}

.card {
  padding: var(--space-20);
}

@media (min-width: 640px) {
  .card {
    padding: var(--space-24);
  }
}

.card-raised {
  box-shadow: var(--shadow-tile);
}

.card-link,
.stat.card-link {
  transition: transform var(--dur-toggle) var(--ease-enter), box-shadow var(--dur-toggle) var(--ease-enter), background-color var(--dur-toggle) linear;
}

@media (hover: hover) {
  .card-link:hover,
  .stat.card-link:hover {
    transform: var(--lift);
    box-shadow: var(--shadow-tile-hover);
  }
}

.card-link:active,
.stat.card-link:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-press);
}

/* Stat tiles: big numbers, Apple product-page style. */
.stat {
  padding: var(--space-20);
  gap: var(--space-4);
}

.stat-value {
  letter-spacing: -0.03em;
}

@media (min-width: 1024px) {
  .stat-value {
    font-size: var(--fs-display);
    line-height: var(--lh-display);
  }
}

/* Controls: pill shapes, Apple style. */
.btn {
  border-radius: var(--radius-full);
  padding-left: var(--space-20);
  padding-right: var(--space-20);
  font-weight: 600;
  transition: background-color var(--dur-press) linear, box-shadow var(--dur-toggle) var(--ease-enter), transform var(--dur-press) var(--ease-enter);
}

.btn-primary {
  box-shadow: var(--shadow-press);
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  border: 0;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

@media (hover: hover) {
  .btn-secondary:hover {
    background: var(--surface-hover);
    box-shadow: inset 0 0 0 1px var(--border-strong);
  }
}

.input,
.select,
.textarea {
  border-radius: var(--radius-m);
}

.searchbar-row .input,
.searchbar-row .select {
  border-radius: var(--radius-full);
}

.chip {
  border-radius: var(--radius-full);
  background: var(--surface);
  transition: background-color var(--dur-press) linear, box-shadow var(--dur-toggle) var(--ease-enter), transform var(--dur-press) var(--ease-enter);
}

@media (hover: hover) {
  .chip:hover {
    background: var(--surface-hover);
    box-shadow: var(--shadow-press);
  }
}

.chip:active {
  transform: scale(0.97);
}

.tag {
  border-radius: var(--radius-full);
}

/* Navigation: rounded pills on the page colour, the active page lifted on white. */
.nav-group {
  display: grid;
  gap: var(--space-4);
}

.nav a {
  min-height: var(--control-h);
  border-radius: var(--radius-m);
  font-size: var(--fs-subhead);
  transition: background-color var(--dur-press) linear, box-shadow var(--dur-toggle) var(--ease-enter);
}

@media (hover: hover) {
  .nav a:hover {
    background: var(--surface);
  }
}

.nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: var(--shadow-tile);
}

.nav a[aria-current="page"] svg {
  color: var(--primary);
}

.nav-label {
  padding-top: var(--space-8);
  font-size: var(--fs-caption);
  letter-spacing: 0.01em;
}

.topbar {
  border-bottom: 0;
  box-shadow: 0 1px 0 var(--border-soft);
}

.tabbar {
  box-shadow: 0 -1px 0 var(--border-soft), 0 -8px 24px rgba(0, 0, 0, 0.04);
}

/* Result lists become tiles: two columns on wide screens, so the screen is spacious and readable. */
.list {
  gap: var(--space-12);
}

.results-card {
  container-type: inline-size;
  min-width: 0;
}

.results-card .list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-16);
  min-width: 0;
}

/* Tablet: two columns when sufficient width is available */
@media (min-width: 640px) and (max-width: 1023px) {
  .results-card .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-16);
  }
}

/* Desktop: exactly TWO cards per row */
@media (min-width: 1024px) {
  .results-card .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-16);
  }
}

@media (min-width: 1600px) {
  .results-card .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-20);
  }
}

/* Container query: adapts based on available container width */
@container (min-width: 520px) {
  .results-card .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-16);
  }
}

@container (max-width: 519px) {
  .results-card .list {
    grid-template-columns: 1fr;
    gap: var(--space-12);
  }
}

/* Compare medicine prices is intentionally full-width and uses a denser, three-up card grid.
   The data attribute is set by searchPage for this tab only; pharmacy results keep the shared
   search layout above unchanged. */
.search-layout:is([data-search-tab="medicines"], [data-search-tab="tests"]) {
  grid-template-columns: minmax(0, 1fr);
}

.results-card:is([data-search-tab="medicines"], [data-search-tab="tests"]) .list {
  grid-template-columns: 1fr;
  gap: var(--space-16);
}

.results-card:is([data-search-tab="medicines"], [data-search-tab="tests"]) .list > .list-row {
  min-height: 0;
  padding: var(--space-14, 14px) var(--space-16);
  align-items: flex-start;
}

.results-card[data-search-tab="medicines"] .list-row-main {
  align-self: center;
}

.results-card[data-search-tab="medicines"] .list-row-title {
  font-size: 15px;
  line-height: 1.35;
}

.results-card[data-search-tab="medicines"] .list-row-meta {
  font-size: 12px;
  line-height: 1.4;
}

.results-card[data-search-tab="medicines"] .obj {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-m);
}

.results-card[data-search-tab="medicines"] .list-row-trail {
  align-self: center;
  font-size: 15px;
}

@media (min-width: 640px) {
  .results-card[data-search-tab="medicines"] .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .results-card[data-search-tab="medicines"] .list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.list > .list-row {
  min-height: 72px;
  padding: var(--space-12) var(--space-16);
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  transition: transform var(--dur-toggle) var(--ease-enter), box-shadow var(--dur-toggle) var(--ease-enter), background-color var(--dur-press) linear;
}

.list > .facility-card {
  min-height: 84px;
  padding: var(--space-16);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: transform var(--dur-toggle) var(--ease-enter),
              box-shadow var(--dur-toggle) var(--ease-enter),
              border-color var(--dur-toggle) var(--ease-enter),
              background-color var(--dur-press) linear;
}

@media (hover: hover) {
  .list > a.list-row:hover,
  .list-row.lift:hover {
    transform: translateY(-2px);
    background: var(--surface);
    box-shadow: var(--shadow-tile-hover);
  }

  .list > a.facility-card:hover {
    transform: translateY(-2px);
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow-tile-hover);
  }
}

.list > a.list-row:active,
.list > a.facility-card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-press);
}

/* The domain icon becomes a small 3D object: a raised face on a darker base. */
.obj {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border-soft), 0 3px 0 var(--neutral-face-side), 0 8px 16px rgba(0, 0, 0, 0.08);
}

/* Search pages: results take the wide column, the map stays beside them. */
@media (min-width: 1024px) {
  .grid-main-side {
    grid-template-columns: minmax(0, 2.6fr) minmax(300px, 1fr);
    gap: var(--space-24);
  }

  /* On search pages the map column stays in view. Detail pages scroll normally, because their
     side column can be taller than the screen and focus must never land out of sight. */
  .results-card + * {
    position: sticky;
    top: var(--space-24);
  }
}

/* Dialogs and sheets keep their float, with the larger radius. */
.dialog,
.sheet {
  border-radius: var(--radius-2xl);
}

/* Empty and error states: softer, centred object. */
.empty-art {
  border-radius: var(--radius-xl);
  box-shadow: 0 3px 0 var(--neutral-face-side), 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* 3D scene in page heads (public/js/art3d.js). Flat faces only; depth comes from shape and shadow. */
.page-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: var(--space-16);
}

.hero-art {
  display: none;
}

@media (min-width: 1024px) {
  .page-hero {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .hero-art {
    display: block;
    width: 180px;
    height: 132px;
    filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.10));
  }
}

.art-top { fill: var(--surface); }
.art-left { fill: var(--border-soft); }
.art-right { fill: var(--border); }
.art-blue-top { fill: var(--primary-face-top); }
.art-blue-left { fill: var(--primary); }
.art-blue-right { fill: var(--primary-face-side); }
.art-red-top { fill: var(--danger-face-top); }
.art-red-left { fill: var(--danger); }
.art-red-right { fill: var(--danger-face-side); }
.art-line { fill: none; stroke: var(--surface); stroke-width: 3; stroke-linecap: round; }
.art-window { fill: var(--map-water); }
.art-ground { fill: var(--border-soft); }

/* Legal and settings reading pages: Apple's legal pages keep text to a comfortable measure. */
.prose {
  display: grid;
  gap: var(--space-16);
  max-width: 760px;
}

/* Reading lines stay within 75 characters even though the card is wider. */
.prose > * {
  max-width: 680px;
}

.prose h2 {
  font-size: var(--fs-title-2);
  line-height: var(--lh-title-2);
  font-weight: 600;
  letter-spacing: -0.015em;
  padding-top: var(--space-16);
}

.prose p,
.prose li {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-1);
}

.prose ul {
  display: grid;
  gap: var(--space-8);
  padding-left: var(--space-20);
  list-style: disc;
}

.legal-meta {
  font-size: var(--fs-footnote);
  color: var(--text-2);
}

/* Settings rows: label on the left, control on the right, like iOS Settings. */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
  min-height: 56px;
  padding: var(--space-12) 0;
  border-bottom: 1px solid var(--border-soft);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row .stack-4 {
  min-width: 0;
}

.switch {
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur-toggle) var(--ease-enter);
}

/* A larger invisible hit area, so the 31 pixel track still meets the 44 pixel minimum. */
.switch::before {
  content: "";
  position: absolute;
  inset: calc(var(--space-8) * -1) calc(var(--space-4) * -1);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong), 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: transform var(--dur-toggle) var(--ease-enter);
}

.switch[aria-checked="true"] {
  background: var(--primary);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

/* Large text setting (Settings page): scales every rem-based size. */
html.text-large {
  font-size: 112.5%;
}

/* Dashboard: shortcuts into finding care, each a floating tile with its 3D object. */
.care-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
}

@media (min-width: 640px) {
  .care-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .care-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.care-tile {
  display: grid;
  align-content: start;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-20) var(--space-20);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-tile);
  color: var(--text-1);
}

.tile-art {
  width: 96px;
  height: 72px;
  margin-bottom: var(--space-8);
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.10));
}

/* Empty states take less height, so the page shows more at once. */
.empty {
  padding: var(--space-20) var(--space-16);
}

/* Public legal pages: a simple bar and one reading column, like Apple's legal pages. */
.legal-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
  padding: var(--space-12) var(--space-24);
  background: var(--bg);
  box-shadow: 0 1px 0 var(--border-soft);
}

.legal-bar nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
  padding: 0 var(--space-12);
  border-radius: var(--radius-full);
  color: var(--text-1);
  font-size: var(--fs-subhead);
}

.legal-bar nav a[aria-current="page"] {
  background: var(--surface);
  box-shadow: var(--shadow-tile);
  font-weight: 600;
}

.legal-main {
  padding: var(--space-24) var(--space-16) var(--space-64);
}

.legal-main .prose {
  margin: 0 auto;
  padding: var(--space-32) var(--space-24);
}

@media (min-width: 1024px) {
  .legal-main .prose {
    padding: var(--space-48) var(--space-64);
  }
}

.prose code {
  font-family: var(--font-mono);
  font-size: var(--fs-subhead);
}

/* Settings sections pack into columns (2026-11-04): a short section sits directly under the one
   above it, so no column is left with an empty gap. Each section stays whole. */
.settings-grid {
  column-gap: var(--space-16);
}

.settings-card {
  display: grid;
  gap: var(--space-12);
}

.settings-grid > * {
  break-inside: avoid;
  margin-bottom: var(--space-16);
}

@media (min-width: 1024px) {
  .settings-grid { column-count: 2; }
}

@media (min-width: 1600px) {
  .settings-grid { column-count: 3; }
}

.settings-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
}

.settings-loc .btn {
  justify-self: start;
}

/* Inside Settings the location bar sits in a card already, so it drops its own frame. */
.settings-loc .loc-bar {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.setting-glyph {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-m);
  background: var(--primary-tint);
  color: var(--primary);
}

.setting-glyph-danger {
  background: var(--danger-tint);
  color: var(--danger);
}

.setting-grow {
  flex: 1;
  min-width: 0;
}

.setting-sos .t-headline {
  color: var(--danger);
}

.setting-row-wrap {
  flex-wrap: wrap;
}

.setting-link {
  color: var(--text-1);
  text-decoration: none;
}

.setting-link > svg {
  color: var(--text-2);
}

@media (hover: hover) {
  .setting-link:hover {
    text-decoration: none;
  }

  .setting-link:hover .t-headline {
    color: var(--primary);
  }
}

.legal-links {
  display: flex;
  gap: var(--space-16);
  padding: 0 var(--space-12);
  font-size: var(--fs-footnote);
}

.legal-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
  color: var(--text-2);
}

@media (max-width: 639px) {
  .legal-bar {
    position: static;
    padding: var(--space-8) var(--space-16);
  }

  /* Settings rows put their controls on their own line on phones, except a switch, which stays
     on the right of its label as in iOS Settings. */
  .setting-row {
    flex-wrap: wrap;
  }

  .setting-row:has(> .switch) {
    flex-wrap: nowrap;
  }

  .setting-row:has(> .switch) > .stack-4 {
    flex: 1;
  }
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin-top: calc(var(--space-8) * -1);
}

/* Explore: the map shares the first screen with two charts instead of filling it alone. */
.explore-top {
  display: grid;
  gap: var(--space-16);
}

@media (min-width: 1024px) {
  .explore-top {
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    align-items: start;
  }
}

.explore-grid {
  gap: var(--space-16);
}

@media (min-width: 1600px) {
  .explore-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Phone top bar: brand on the left, compact actions on one line. */
.topbar > .row-8 {
  flex-wrap: nowrap;
}

@media (max-width: 639px) {
  .topbar {
    padding: var(--space-8) var(--space-12);
  }

  .topbar .brand-name {
    font-size: var(--fs-headline);
  }

  /* The wordmark is 190px wide on the sidebar; on a phone it shares one line with three actions. */
  .topbar .brand-mark {
    width: min(132px, 34vw);
  }

  .topbar .btn-sm {
    padding-left: var(--space-12);
    padding-right: var(--space-12);
  }

  /* Dashboard: the two header actions share one line. */
  .dash-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .dash-actions .btn {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
    font-size: var(--fs-subhead);
  }

  .greeting .t-large-title {
    font-size: var(--fs-title-1);
    line-height: var(--lh-title-1);
  }
}

@media (max-width: 639px) {
  .care-tile {
    padding: var(--space-12) var(--space-16) var(--space-16);
  }

  .tile-art {
    width: 72px;
    height: 54px;
    margin-bottom: var(--space-4);
  }
}

/* Phones: filters are one row you swipe sideways, so results start on the first screen. */
@media (max-width: 639px) {
  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 calc(var(--space-20) * -1);
    padding: var(--space-4) var(--space-20);
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .filter-row::-webkit-scrollbar {
    display: none;
  }

  .filter-row > * {
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  .filter-row .select {
    min-width: 0 !important;
    width: auto !important;
  }

  .page-head .t-callout {
    font-size: var(--fs-subhead);
    line-height: var(--lh-subhead);
  }
}

/* Dashboard refinement: keep the premium system, but give the information-dense home screen
   a calmer scale. These rules are intentionally scoped so search and detail pages retain their
   existing proportions. */
.dashboard-view .sidebar {
  gap: var(--space-16);
}

.dashboard-view .nav-group {
  gap: var(--space-4);
}

.dashboard-view .nav a {
  min-height: 40px;
  padding-inline: var(--space-8);
  gap: var(--space-8);
}

.dashboard-view .sidebar-foot {
  gap: var(--space-8);
}

.dashboard-view .sos-key-compact {
  min-height: 48px;
  font-size: var(--fs-subhead);
  line-height: var(--lh-subhead);
}

.dashboard-page {
  gap: var(--space-20);
}

.dashboard-page .greeting {
  gap: var(--space-12);
}

.dashboard-page .avatar-l {
  width: 64px;
  height: 64px;
  font-size: var(--fs-title-3);
}

.dashboard-page .t-large-title {
  font-size: 28px;
  line-height: 34px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dashboard-page .t-title-2 {
  font-size: 20px;
  line-height: 26px;
}

.dashboard-page .t-title-3 {
  font-size: 17px;
  line-height: 22px;
}

.dashboard-page .t-headline {
  font-size: 15px;
  line-height: 20px;
}

.dashboard-page .t-callout,
.dashboard-page .t-subhead {
  font-size: 14px;
  line-height: 19px;
}

.dashboard-page .t-footnote {
  font-size: 12px;
  line-height: 17px;
}

.dashboard-page .dash-actions .btn {
  min-height: 40px;
  padding-inline: var(--space-16);
  font-size: 14px;
  line-height: 19px;
}

.dashboard-page .card,
.dashboard-page .stat,
.dashboard-page .care-tile {
  border-radius: var(--radius-l);
  border: 1px solid var(--border-soft);
}

.dashboard-page .card {
  padding: var(--space-20);
}

.dashboard-page .card.stack-16 {
  gap: var(--space-12);
}

.dashboard-page .card.stack-12 {
  gap: var(--space-8);
}

.dashboard-page .card-raised {
  box-shadow: var(--shadow-tile);
}

.dashboard-page .care-tiles {
  gap: var(--space-12);
}

.dashboard-page .care-tile {
  grid-template-rows: 54px auto minmax(17px, auto);
  min-height: 140px;
  padding: var(--space-12) var(--space-16) var(--space-16);
  gap: var(--space-4);
  box-shadow: var(--shadow-tile);
}

.dashboard-page .care-tile .tile-art {
  width: 72px;
  height: 54px;
  margin-bottom: 0;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.08));
}

.dashboard-page .care-tile .t-headline {
  font-size: 15px;
  line-height: 19px;
  font-weight: 600;
}

.dashboard-page .care-tile .num {
  font-size: 12px;
  line-height: 17px;
}

@media (hover: hover) {
  .dashboard-page .care-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08);
  }
}

.dashboard-page .stat-row {
  gap: var(--space-12);
}

.dashboard-page .stat {
  padding: var(--space-16);
  border-radius: var(--radius-l);
}

.dashboard-page .stat-value {
  font-size: 38px;
  line-height: 42px;
  font-weight: 600;
}

.dashboard-page .dash-grid {
  gap: var(--space-20);
}

.dashboard-page .dash-grid > .stack-24 {
  gap: var(--space-20);
}

.dashboard-page .dose-wrap {
  gap: var(--space-20);
}

.dashboard-page .dose-ring {
  width: 96px;
  height: 96px;
  box-shadow: 0 4px 0 var(--border-soft), 0 10px 20px rgba(16, 24, 40, 0.10);
}

.dashboard-page .dose-ring .t-title-2 {
  font-size: 18px;
  line-height: 23px;
}

.dashboard-page .dose {
  padding: var(--space-8);
}

.dashboard-page .list > .list-row {
  min-height: 60px;
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-m);
}

.dashboard-page .list-row-title {
  font-size: 15px;
  line-height: 20px;
}

.dashboard-page .list-row-meta {
  font-size: 13px;
  line-height: 18px;
}

.dashboard-page .facts {
  gap: var(--space-12);
}

.dashboard-page .sos-key {
  min-height: 72px;
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-l);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 4px 0 var(--danger-face-side),
    0 12px 24px rgba(215, 0, 21, 0.20);
}

.dashboard-page .sos-key-title {
  font-size: 20px;
  line-height: 25px;
}

.dashboard-page .sos-key-sub {
  font-size: 13px;
  line-height: 18px;
}

@media (max-width: 639px) {
  .dashboard-page .card {
    padding: var(--space-16);
  }

  .dashboard-page .avatar-l {
    width: 56px;
    height: 56px;
  }

  .dashboard-page .t-large-title {
    font-size: 26px;
    line-height: 31px;
  }

  .dashboard-page .care-tile {
    min-height: 132px;
    padding: 12px var(--space-12) var(--space-12);
  }

  .dashboard-page .care-tile .tile-art {
    width: 64px;
    height: 48px;
  }

  .dashboard-page .stat-value {
    font-size: 34px;
    line-height: 38px;
  }
}

/* Explore map: a real tile-backed map is the primary visual, while the existing analytics cards
   remain compact supporting context. */
.explore-page {
  gap: var(--space-20);
}

.explore-page .page-head .t-large-title {
  font-size: 26px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.explore-page .stat-row {
  gap: var(--space-12);
}

.explore-page .stat {
  min-height: 96px;
  padding: var(--space-16);
  border-radius: var(--radius-l);
}

.explore-page .stat-value {
  font-size: 36px;
  line-height: 40px;
  font-weight: 600;
}

.explore-page .card {
  padding: var(--space-20);
  border-radius: var(--radius-l);
}

.explore-page .explore-top > .card:first-child {
  min-width: 0;
}

.explore-page .explore-top > .stack-16 {
  gap: var(--space-16);
}

.explore-page .hbars-row {
  min-height: 40px;
  padding: var(--space-4) var(--space-8);
}

.explore-page .hbars-track {
  height: 8px;
  border-radius: var(--radius-full);
}

.explore-page .hbars-bar {
  border-radius: var(--radius-full);
}

.geo-map {
  position: relative;
  display: grid;
  gap: var(--space-12);
  min-width: 0;
}

.geo-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
}

.geo-map-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 0;
}

.geo-map-search-wrap > svg {
  position: absolute;
  left: var(--space-12);
  z-index: 1;
  color: var(--text-2);
  pointer-events: none;
}

.geo-map-search {
  min-height: 40px;
  padding-left: var(--space-40);
  border-radius: var(--radius-full);
  font-size: var(--fs-subhead);
}

.geo-map-styles {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-full);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.geo-map-style {
  min-height: 34px;
  padding: 0 var(--space-12);
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-footnote);
  font-weight: 600;
  cursor: pointer;
}

.geo-map-style[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: var(--shadow-card);
}

.geo-map-viewport {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--radius-l);
  background: #e9eef0;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.geo-map-viewport.is-dragging {
  cursor: grabbing;
}

.geo-map-tiles,
.geo-map-markers,
.geo-map-popups {
  position: absolute;
  inset: 0;
}

.geo-map-tiles {
  z-index: 0;
  overflow: hidden;
  background: #e9eef0;
}

.geo-map-tile {
  position: absolute;
  display: block;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

.geo-map-tile-transportation,
.geo-map-tile-places {
  z-index: 1;
}

.geo-map-tile.is-error {
  visibility: hidden;
}

.geo-map-markers {
  z-index: 4;
  pointer-events: none;
}

.geo-marker,
.geo-cluster {
  position: absolute;
  display: grid;
  place-items: center;
  transform: translate(-50%, -100%);
  border: 2px solid var(--surface);
  color: var(--surface);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.28);
  transition: transform var(--dur-press) var(--ease-enter), box-shadow var(--dur-toggle) var(--ease-enter);
}

.geo-marker {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -75%) rotate(-45deg);
}

.geo-marker svg {
  transform: rotate(45deg);
}

.geo-marker.is-selected,
.geo-cluster.is-selected {
  z-index: 2;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 0 4px 12px rgba(16, 24, 40, 0.34);
}

.geo-marker:hover,
.geo-cluster:hover {
  transform: translate(-50%, -78%) rotate(-45deg) scale(1.06);
}

.geo-cluster {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--primary);
}

.geo-cluster:hover {
  transform: translate(-50%, -50%) scale(1.06);
}

.geo-cluster-mixed {
  background: #425466;
}

.geo-cluster-count {
  font-size: var(--fs-footnote);
  line-height: 1;
  font-weight: 700;
}

.geo-origin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  color: var(--surface);
  box-shadow: 0 0 0 7px rgba(0, 102, 204, 0.20), 0 2px 8px rgba(16, 24, 40, 0.30);
  pointer-events: none;
}

.marker-blue,
.geo-filter-blue .geo-filter-dot { background: #1467b8; }
.marker-orange,
.geo-filter-orange .geo-filter-dot { background: #c36a12; }
.marker-green,
.geo-filter-green .geo-filter-dot { background: #16845d; }
.marker-text-blue { color: #1467b8; }
.marker-text-orange { color: #c36a12; }
.marker-text-green { color: #16845d; }

.geo-map-controls {
  position: absolute;
  top: var(--space-12);
  right: var(--space-12);
  z-index: 6;
  display: grid;
  gap: var(--space-4);
}

.geo-map-controls .icon-btn,
.geo-map-control-text {
  min-width: 36px;
  min-height: 36px;
  padding: 0 var(--space-8);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-1);
  box-shadow: var(--shadow-card);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
}

.geo-map-controls .icon-btn {
  display: grid;
  place-items: center;
  padding: 0;
}

.geo-map-controls button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.geo-map-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  padding: var(--space-8) var(--space-12);
  transform: translate(-50%, -50%);
  border-radius: var(--radius-s);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-2);
  font-size: var(--fs-footnote);
  box-shadow: var(--shadow-card);
}

.geo-map-data-notice {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: var(--space-12);
  width: min(360px, calc(100% - 32px));
  padding: var(--space-16);
  transform: translate(-50%, -50%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  background: rgba(255, 255, 255, 0.96);
  text-align: center;
  box-shadow: var(--shadow-float);
}

.geo-map-data-message {
  color: var(--text-2);
  font-size: var(--fs-footnote);
  line-height: 17px;
}

.geo-map-attribution {
  position: absolute;
  left: var(--space-8);
  bottom: var(--space-8);
  z-index: 6;
  padding: 2px var(--space-4);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-2);
  font-size: 10px;
  line-height: 14px;
}

.geo-map-popups {
  z-index: 8;
  pointer-events: none;
}

.geo-popup {
  position: absolute;
  display: grid;
  gap: var(--space-12);
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: var(--space-16);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  pointer-events: auto;
}

.geo-popup-details {
  max-height: 300px;
  overflow-y: auto;
  padding-right: var(--space-4);
}

.geo-popup-description {
  color: var(--text-2);
  font-size: var(--fs-footnote);
  line-height: 18px;
}

.geo-popup-list {
  display: grid;
  gap: var(--space-4);
  color: var(--text-1);
  font-size: var(--fs-caption);
}

.geo-popup-positive {
  color: var(--success, #16845d);
}

.geo-popup-loading {
  font-size: var(--fs-caption);
  line-height: 16px;
}

.geo-popup-close {
  position: absolute;
  top: var(--space-8);
  right: var(--space-8);
  width: 32px;
  height: 32px;
  min-height: 32px;
  border: 0;
  box-shadow: none;
}

.geo-popup-category {
  padding-right: var(--space-24);
  font-size: var(--fs-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.geo-popup-title {
  padding-right: var(--space-24);
  font-size: 16px;
  line-height: 21px;
  font-weight: 600;
}

.geo-popup-line {
  font-size: var(--fs-footnote);
  line-height: 17px;
}

.geo-popup-link {
  color: var(--primary);
  text-decoration: none;
}

.geo-popup-actions {
  padding-top: var(--space-4);
  flex-wrap: wrap;
}

.geo-popup-unavailable {
  align-self: center;
  color: var(--text-2);
  font-size: var(--fs-caption);
}

.geo-map-legend {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.geo-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: 32px;
  padding: 0 var(--space-8);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--fs-caption);
  cursor: pointer;
}

.geo-filter[aria-pressed="false"] {
  background: var(--surface-sunken);
  color: var(--text-2);
  text-decoration: line-through;
}

.geo-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.geo-map-count {
  margin-left: auto;
  color: var(--text-2);
  font-size: var(--fs-caption);
}

.geo-map-search-results {
  position: absolute;
  top: calc(100% + var(--space-8));
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.geo-search-result {
  display: grid;
  gap: 2px;
  padding: var(--space-8) var(--space-12);
  border: 0;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.geo-search-result:hover {
  background: var(--surface-sunken);
}

.geo-search-result strong {
  font-size: var(--fs-footnote);
  font-weight: 600;
}

.geo-search-result span,
.geo-search-empty {
  color: var(--text-2);
  font-size: var(--fs-caption);
}

.geo-search-empty {
  padding: var(--space-12);
}

.geo-map:fullscreen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100vh;
  padding: var(--space-20);
  background: var(--bg);
}

.geo-map:fullscreen .geo-map-viewport {
  min-height: 0;
}

.geo-map.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: var(--space-20);
  background: var(--bg);
}

.geo-map.is-fullscreen .geo-map-viewport {
  min-height: 0;
}

@media (max-width: 1023px) {
  .geo-map-viewport {
    min-height: 440px;
  }
}

@media (max-width: 639px) {
  .explore-page .page-head .t-large-title {
    font-size: 24px;
    line-height: 30px;
  }

  .explore-page .card {
    padding: var(--space-16);
  }

  .explore-page .stat {
    min-height: 84px;
    padding: var(--space-12);
  }

  .explore-page .stat-value {
    font-size: 32px;
    line-height: 36px;
  }

  .geo-map-toolbar {
    align-items: stretch;
  }

  .geo-map-search-wrap,
  .geo-map-styles {
    flex-basis: 100%;
  }

  .geo-map-styles {
    justify-content: space-between;
  }

  .geo-map-style {
    flex: 1;
  }

  .geo-map-viewport {
    min-height: 360px;
  }

  .geo-map-count {
    width: 100%;
    margin-left: 0;
  }

  .geo-popup {
    right: 8px !important;
    bottom: calc(var(--space-8) + var(--space-80) + env(safe-area-inset-bottom)) !important;
    left: 8px !important;
    top: auto !important;
    width: auto !important;
    max-height: min(72%, calc(100% - var(--space-80) - var(--space-24)));
  }

  .geo-map-popups {
    z-index: 40;
  }

  .geo-map.has-popup {
    z-index: 31;
  }

  .geo-popup-details {
    max-height: 220px;
  }

  .geo-popup-actions {
    flex-wrap: wrap;
  }
}

/* Medical ID: keep the sharing copy independent from the compact global switch control. */
.medical-id-page .medical-id-sharing-row {
  padding: var(--space-16);
  background: var(--surface-sunken);
  box-shadow: none;
}

.medical-id-page .medical-id-sharing-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-24);
  width: 100%;
  min-width: 0;
  cursor: pointer;
}

.medical-id-page .medical-id-sharing-copy {
  display: grid;
  flex: 1 1 auto;
  gap: var(--space-4);
  min-width: 0;
}

.medical-id-page .medical-id-sharing-copy .t-headline,
.medical-id-page .medical-id-sharing-copy .t-subhead {
  overflow-wrap: anywhere;
}

.medical-id-page .medical-id-sharing-toggle > input {
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 51px;
  height: 31px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  cursor: pointer;
  transition: background-color var(--dur-toggle) var(--ease-enter);
}

.medical-id-page .medical-id-sharing-toggle > input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong), 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: transform var(--dur-toggle) var(--ease-enter);
}

.medical-id-page .medical-id-sharing-toggle > input:checked {
  background: var(--primary);
}

.medical-id-page .medical-id-sharing-toggle > input:checked::after {
  transform: translateX(20px);
}

.medical-id-page form {
  padding-bottom: calc(var(--space-80) + var(--space-24));
}

.medical-id-page .sticky-save {
  margin-bottom: calc(var(--space-80) + var(--space-16));
}

@media (max-width: 639px) {
  .medical-id-page .medical-id-sharing-toggle {
    align-items: flex-start;
    gap: var(--space-16);
  }

  .medical-id-page .medical-id-sharing-row {
    padding: var(--space-12);
  }

  .medical-id-page form {
    padding-bottom: calc(var(--space-64) + var(--space-24));
  }

  .medical-id-page .sticky-save {
    margin-bottom: calc(var(--space-64) + var(--space-16));
  }
}

/* Search pages (2026-11-04): a wider map column whose map fills the height of the screen while it
   stays in view, instead of a short map with empty space under it. */
@media (min-width: 1024px) {
  .search-layout {
    grid-template-columns: minmax(0, 1.8fr) minmax(340px, 1fr);
  }

  .search-side .rmap-view {
    height: calc(100vh - 140px);
    min-height: 380px;
    max-height: 820px;
  }
}

/* Side columns (2026-11-04): a long button label, such as a full phone number, wraps instead of
   pushing the column past the edge of the screen. */
.grid-main-side > * {
  min-width: 0;
}

.grid-main-side > :last-child .btn {
  max-width: 100%;
  white-space: normal;
  text-align: center;
}

/* Medical ID: the emergency contacts card stays in view beside the long form. */
@media (min-width: 1024px) {
  .medical-id-page #contacts {
    position: sticky;
    top: var(--space-24);
  }
}

/* Find care: the fifth tile fills the last row instead of leaving an empty half or third. */
@media (max-width: 639px) {
  .care-tiles > .care-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (min-width: 640px) and (max-width: 1279px) {
  .care-tiles > .care-tile:last-child:nth-child(3n + 2) { grid-column: span 2; }
}

/* Emergency (2026-11-04): calling and the list on the left, the same hospitals on a map on the
   right, which stays in view. */
@media (min-width: 1024px) {
  .sos-layout {
    grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr);
  }

  .sos-side {
    position: sticky;
    top: var(--space-24);
  }
}

/* Account and privacy (2026-11-04): who is signed in across the top, then privacy, data and
   security cards packed into columns. */
.account-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-16) var(--space-20);
  margin-bottom: var(--space-16);
}

.account-hero .avatar img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.account-ready {
  display: grid;
  grid-column: 1 / -1;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-l);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  color: var(--text-1);
  text-decoration: none;
}

.account-ready .strong {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--primary);
}

@media (min-width: 768px) {
  .account-hero {
    grid-template-columns: auto minmax(0, 1fr) minmax(220px, 280px);
  }

  .account-ready {
    grid-column: auto;
  }
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-8);
}

/* An odd last tile takes the whole row, so the grid has no hole. */
.account-stats > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.account-who {
  min-width: 0;
}

.account-who .t-subhead {
  overflow-wrap: anywhere;
}

/* Pack account sections into two balanced columns without stretching short cards. */
@media (min-width: 1024px) {
  .account-settings-grid {
    column-count: 2;
    column-gap: var(--space-12);
  }

  .account-settings-grid > * {
    display: inline-block;
    width: 100%;
    break-inside: avoid;
    min-width: 0;
    margin: 0 0 var(--space-12);
  }

  .account-settings-grid > .card {
    padding: var(--space-16);
  }

  .account-settings-grid .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .account-hero .avatar-xl {
    width: 64px;
    height: 64px;
    font-size: var(--fs-title-3);
  }
}

.account-stat {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
  padding: var(--space-12);
  border-radius: var(--radius-l);
  background: var(--surface-sunken);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  color: var(--text-1);
  text-decoration: none;
  transition: transform var(--dur-toggle) var(--ease-enter), box-shadow var(--dur-toggle) var(--ease-enter);
}

.account-stat:hover,
.account-stat:focus-visible {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--primary-tint), var(--shadow-card);
}

.pw-meter {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.pw-meter[hidden] { display: none; }

.pw-meter-track {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--border-soft);
}

.pw-meter-bar {
  display: block;
  width: 10%;
  height: 100%;
  border-radius: inherit;
  background: var(--danger);
  transition: width var(--dur-toggle) var(--ease-enter);
}

.pw-meter[data-score="1"] .pw-meter-bar { width: 40%; background: var(--warning); }
.pw-meter[data-score="2"] .pw-meter-bar { width: 70%; background: var(--primary); }
.pw-meter[data-score="3"] .pw-meter-bar { width: 100%; background: var(--success); }

@media (prefers-reduced-motion: reduce) {
  .account-stat { transition: none; }
}
