:root {
  --ink: #0a0a0b;
  --ink-soft: #6b7280;
  --ink-faint: #9ca3af;
  --paper: #ffffff;
  --card: #ffffff;
  --line: #e5e7eb;
  --good-a: #cfefe0;
  --good-b: #7fd9b0;
  --bad-a: #ffd9a0;
  --bad-b: #f0813a;
  /* Cyan-to-green teal, sampled from the SharedSky logo — sky and health
     in one hue. #0D9488 holds ~4.6:1 contrast on white; dark mode gets a
     brighter variant below since this value would be too dim on near-black. */
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --danger: #d2352c;
  --danger-bg: #fdedec;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Reserved top strip — doubles as the "if Google's banner ever shows
   anyway" landing spot, but styled as our own language switcher so the
   whole thing reads as one native control, not a bolted-on 3rd party bar. */
.lang-indicator-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 16px;
  background: var(--paper);
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lang-indicator-bar svg {
  width: 15px;
  height: 15px;
  flex: none;
}
.lang-indicator-bar .lang-indicator-chevron {
  width: 13px;
  height: 13px;
  opacity: 0.6;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  gap: 12px;
}

.topbar-city {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.topbar-link {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14px;
  padding: 8px;
  min-height: 44px;
  cursor: pointer;
}

.emergency-link {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
}

.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 20px 8px;
  text-align: center;
}

.brand-logo {
  height: 100px;
  width: auto;
}

.brand-name {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand-tagline {
  margin: 2px 0 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.brand-subtext {
  margin: 0;
  max-width: 320px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
}

.app {
  padding-bottom: calc(76px + var(--safe-area-bottom));
}

.screen {
  display: none;
}
.screen.active {
  display: block;
}

.home {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 220px);
  padding: 0 20px;
  gap: 28px;
}

.hero {
  border-radius: 24px;
  padding: 32px 24px;
  background: linear-gradient(160deg, var(--good-a), var(--good-b));
  transition: background 400ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .hero {
    transition: none;
  }
}

.hero-eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

.hero-headline {
  margin: 0 0 10px;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-detail {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  opacity: 0.8;
}

.log {
  margin-top: auto;
  padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.log-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.symptom-button {
  min-height: 60px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 17px;
  font-weight: 700;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background 120ms ease;
}
.symptom-button:active {
  background: #f7f8fa;
}

.symptom-button:focus-visible,
.fine-button:focus-visible,
.nav-item:focus-visible,
.chip:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.fine-button {
  min-height: 58px;
  border-radius: 16px;
  border: none;
  background: var(--ink);
  color: var(--card);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.section-title {
  font-size: 24px;
  padding: 4px 20px 0;
}

.section-lead {
  font-size: 15px;
  color: var(--ink-soft);
  padding: 6px 20px 20px;
  margin: 0;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  padding: 18px 16px 0;
  cursor: pointer;
}

.profile-row-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 58px;
  background: var(--card);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  text-align: left;
}

.consent-banner {
  margin: 8px 20px 20px;
  border: 1.5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
  border-radius: 16px;
  padding: 16px 18px;
}

.consent-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.consent-checkbox-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  flex: none;
  margin-top: 1px;
  accent-color: var(--accent);
}
.consent-checkbox-row span {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

.health-context-fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.health-context-fieldset:disabled {
  opacity: 0.45;
}
.health-context-fieldset .profile-block {
  padding: 0 20px;
  margin-bottom: 18px;
}

.hc-group-title {
  font-size: 18px;
  padding: 0 20px;
  margin: 28px 0 4px;
}
.hc-group-title:first-of-type {
  margin-top: 4px;
}

/* Stats */
.stats-screen {
  padding: 8px 0 24px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 20px 4px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.chip.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}

.stats-card {
  margin: 20px 20px 0;
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px 20px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
  margin-top: 12px;
}
.stats-table col.label {
  width: 40%;
}
.stats-table th {
  text-align: right;
  font-weight: 700;
  color: var(--ink-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0 10px;
  border-bottom: 1.5px solid var(--line);
}
.stats-table th:first-child {
  text-align: left;
}
.stats-table td {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.stats-table tr:last-child td {
  border-bottom: none;
}
.stats-table td.value {
  text-align: right;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.stats-table td.value.suppressed {
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 15px;
}
.stats-scope-label {
  font-weight: 700;
  color: var(--ink);
}

.stats-footnote {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 16px 20px 0;
  line-height: 1.5;
}

.stats-empty {
  margin: 20px;
  padding: 24px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 15px;
}

/* Profile */
.profile-screen {
  padding: 8px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.profile-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 58px;
}
.profile-row-value {
  font-weight: 700;
  font-size: 17px;
}
.profile-row-action {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 8px;
}

.select-field {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  padding: 0 16px;
}

.chip-row.wrap {
  flex-wrap: wrap;
  overflow-x: visible;
  padding: 0;
}

.legal-links {
  display: flex;
  gap: 20px;
  justify-content: center;
  padding-top: 8px;
}
.legal-links a {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
}

.history-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.history-entry-label {
  font-weight: 700;
  font-size: 16px;
}
.history-entry-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.history-entry-date {
  font-size: 13px;
  color: var(--ink-faint);
  white-space: nowrap;
}
.history-entry.clickable {
  cursor: pointer;
}
.history-entry.clickable:active {
  background: #f7f8fa;
}
.history-entry.clickable:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.history-summary {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 20px 16px;
  -webkit-overflow-scrolling: touch;
}
.history-summary::-webkit-scrollbar {
  display: none;
}
.history-summary-item {
  flex: none;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  min-width: 84px;
}
.history-summary-count {
  font-size: 20px;
  font-weight: 800;
}
.history-summary-label {
  font-size: 12px;
  color: var(--ink-soft);
}

.notifications-hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 8px 0 0;
  line-height: 1.5;
}

.lang-row {
  display: flex;
  gap: 10px;
}
.lang-button {
  flex: 1;
  min-height: 52px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.lang-button.selected {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}

.danger-button {
  min-height: 56px;
  border-radius: 16px;
  border: 1.5px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  border-top: 1.5px solid var(--line);
  padding-bottom: var(--safe-area-bottom);
  z-index: 15;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-faint);
}
.nav-item svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}
.nav-item span {
  font-size: 12px;
  font-weight: 700;
}
.nav-item.active {
  color: var(--ink);
}

/* Desktop only: frame the phone-shaped app in a centered card over a sky
   background, so a wide window still reads as "the app" rather than a
   website. Scoped to body:has(.app) so it never touches about/legal/admin,
   which don't have this element. Mobile is untouched below the breakpoint
   — .app keeps its normal full-width, page-scrolls-normally behaviour;
   .bottom-nav stays position:fixed to the real viewport either way, just
   width-clamped to match the card at desktop so it still looks attached. */
@media (min-width: 640px) {
  body:has(.app) {
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    background-image: url("background.jpeg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
  }

  .app {
    position: relative;
    width: 100%;
    max-width: 460px;
    min-height: calc(100vh - 80px);
    background: var(--paper);
    border-radius: 28px;
    box-shadow: 0 30px 80px rgba(10, 10, 11, 0.35);
    overflow: hidden;
  }

  .bottom-nav {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 460px;
    transform: translateX(-50%);
    border-radius: 0 0 28px 28px;
  }
}

/* Google Translate: our own dropdown drives it (app.js), so its own gadget
   stays visually hidden — it's an unstylable cross-origin iframe, showing
   it would look inconsistent no matter what CSS we throw at it. */
.gt-hidden-widget {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
/* Google's banner iframe class is an obfuscated build hash that changes
   between deployments (e.g. VIpgJd-ZVi9od-ORHb-OEVmcd) — .goog-te-banner-frame
   is the old/documented name and no longer matches current markup. .skiptranslate
   is the one stable class Google keeps on all its own injected UI (banner +
   gadget), and it's never applied to our own content, so it's safe to hide broadly. */
iframe.skiptranslate {
  display: none !important;
}
body {
  top: 0px !important;
  position: static !important;
}
.goog-tooltip,
.goog-tooltip:hover {
  display: none !important;
}
.goog-text-highlight {
  background: none !important;
  box-shadow: none !important;
}

/* Defensive fallback only — if Google's banner frame ever renders anyway
   (SIMPLE layout / autoDisplay:false is expected to prevent it), push our
   fixed topbar down rather than let it sit underneath. */
html.gt-banner-visible .app {
  margin-top: 40px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(76px + 16px + var(--safe-area-bottom));
  background: var(--ink);
  color: var(--card);
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  z-index: 40;
  max-width: 480px;
  margin: 0 auto;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 11, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 30;
}
.sheet-backdrop[hidden] {
  display: none;
}

.sheet {
  background: var(--card);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 26px 20px calc(24px + var(--safe-area-bottom));
  max-height: 80vh;
  overflow-y: auto;
}

.sheet h2 {
  margin: 0 0 14px;
  font-size: 22px;
}

.city-search {
  width: 100%;
  min-height: 52px;
  font-size: 18px;
  padding: 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  margin-bottom: 12px;
}

.city-results {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.city-results li {
  border-bottom: 1px solid var(--line);
}

.city-result-button {
  width: 100%;
  min-height: 56px;
  background: none;
  border: none;
  text-align: left;
  font-size: 17px;
  font-weight: 600;
  padding: 12px 4px;
  cursor: pointer;
}

.sheet-close,
.consent-agree {
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.sheet-close {
  background: var(--paper);
  border: 1.5px solid var(--line);
}

.consent-agree {
  background: var(--ink);
  color: var(--card);
  border: none;
}

.consent-copy,
.emergency-copy,
.confirm-copy {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.emergency-copy {
  color: var(--ink);
}
.emergency-note {
  font-weight: 800;
}

.attribution {
  padding: 20px;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}

/* System theme (no explicit choice stored) follows the OS, unless the
   user picked "light" explicitly — then system-dark must not win. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f5f6f7;
    --ink-soft: #a0a6ad;
    --ink-faint: #6b7280;
    --paper: #0a0a0b;
    --card: #17181b;
    --line: #2a2c30;
    --danger-bg: #2e1917;
    /* Brighter teal for near-black backgrounds — #0D9488 reads muddy there. */
    --accent: #2dd4bf;
    --accent-ink: #0a0a0b;
  }
}

/* Explicit "dark" choice wins regardless of OS setting. */
:root[data-theme="dark"] {
  --ink: #f5f6f7;
  --ink-soft: #a0a6ad;
  --ink-faint: #6b7280;
  --paper: #0a0a0b;
  --card: #17181b;
  --line: #2a2c30;
  --danger-bg: #2e1917;
  --accent: #2dd4bf;
  --accent-ink: #0a0a0b;
}
