:root {
  --bg-dark: #1A1410;
  --card-bg: rgba(60, 40, 25, 0.55);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);
  --button-primary-bg: #FFFFFF;
  --button-primary-text: #1A1410;
  --button-secondary-bg: rgba(255, 255, 255, 0.12);
  --button-secondary-border: rgba(255, 255, 255, 0.2);
  --button-selected-bg: rgba(255, 255, 255, 0.25);
  --button-selected-border: rgba(255, 255, 255, 0.5);
  --progress-active: #FFFFFF;
  --progress-inactive: rgba(255, 255, 255, 0.2);
  --accent: #C9A96E;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fallback color while the hero image loads — sits behind the ::before layer. */
html { background: var(--bg-dark); }

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: transparent;
}

/* Blurred homepage hero behind the onboarding shell. Pseudo-elements are
   over-extended (negative inset) so the blur radius doesn't leave visible
   bands at the viewport edges. */
body::before {
  content: "";
  position: fixed;
  inset: -80px;
  z-index: -2;
  background: url('/hero-garden.jpg') center/cover no-repeat #2a2520;
  filter: blur(24px) brightness(0.85) saturate(1.2);
  -webkit-filter: blur(24px) brightness(0.85) saturate(1.2);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 0%, rgba(0, 0, 0, 0.25) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, select { font: inherit; color: inherit; }

/* ─── layout ────────────────────────────────────────────────── */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  padding: 28px;
  animation: card-in 420ms cubic-bezier(.2,.7,.2,1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── wordmark ──────────────────────────────────────────────── */

.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.wordmark img { height: 28px; width: auto; filter: invert(1) brightness(1.4); }
.wordmark-text {
  font-size: 17px;
  font-weight: 600;
}

/* ─── typography ────────────────────────────────────────────── */

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

h1.heading {
  font-size: 26px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}
@media (min-width: 480px) {
  h1.heading { font-size: 28px; }
}

.subtext {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ─── progress + back ───────────────────────────────────────── */

.progress-bar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.back-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
  transition: background 150ms ease, opacity 150ms ease;
  flex-shrink: 0;
}
.back-button:hover { background: rgba(255,255,255,0.14); }
.back-button:disabled,
.back-button[hidden] { visibility: hidden; }
.back-button svg { width: 16px; height: 16px; }

.progress-track {
  flex: 1;
  height: 3px;
  background: var(--progress-inactive);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--progress-active);
  border-radius: 999px;
  width: 0%;
  transition: width 320ms cubic-bezier(.2,.7,.2,1);
}

/* ─── buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 500;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease, transform 150ms ease;
  will-change: transform;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--button-primary-bg);
  color: var(--button-primary-text);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #f0ebe1; }

.btn-secondary {
  background: var(--button-secondary-bg);
  border: 1px solid var(--button-secondary-border);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.18); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); }

/* Coming-soon auth button — visible but not clickable, muted */
.btn.is-soon {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.is-soon:disabled { opacity: 0.55; }
.btn-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 999px;
  background: rgba(201, 169, 110, 0.16);
  color: var(--accent);
  border: 1px solid rgba(201, 169, 110, 0.32);
  font-weight: 600;
  line-height: 1.2;
}

.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.text-link {
  display: inline-block;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding-bottom: 1px;
  transition: color 150ms ease, border-color 150ms ease;
}
.text-link:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.5); }

.center { text-align: center; }

/* ─── inputs ────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.input,
.select {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-primary);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--text-muted); }
.input:focus,
.select:focus {
  border-color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}

.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1L6 6L11 1' stroke='white' stroke-opacity='0.5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}
.select option { background: #2a1f18; color: var(--text-primary); }

.field-row { display: grid; gap: 10px; }
.field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.phone-input {
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.phone-input:focus-within {
  border-color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.08);
}
.phone-prefix {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--text-secondary);
  border-right: 1px solid rgba(255,255,255,0.14);
  font-size: 16px;
  white-space: nowrap;
}
.phone-input .input {
  border: none;
  background: transparent;
  border-radius: 0;
}
.phone-input .input:focus { box-shadow: none; background: transparent; }

.error-text {
  color: #f3b48a;
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ─── option buttons (toggles, goals, sex) ──────────────────── */

.option-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid var(--button-secondary-border);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease;
}
.option:hover { background: rgba(255,255,255,0.08); }
.option[aria-pressed="true"],
.option.is-selected {
  background: var(--button-selected-bg);
  border-color: var(--button-selected-border);
}
.option .check {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  transition: background 150ms ease, border-color 150ms ease;
}
.option[aria-pressed="true"] .check,
.option.is-selected .check {
  background: #fff;
  border-color: #fff;
}
.option[aria-pressed="true"] .check::after,
.option.is-selected .check::after {
  content: "";
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bg-dark);
}

/* ─── device grid ───────────────────────────────────────────── */

.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.device-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 110px;
  padding: 16px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--button-secondary-border);
  color: var(--text-primary);
  transition: background 150ms ease, border-color 150ms ease;
}
.device-card:hover { background: rgba(255,255,255,0.1); }
.device-card .device-logo {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.92);
  border-radius: 10px;
  overflow: hidden;
}
.device-card .device-logo img,
.device-card .device-logo svg {
  width: 26px; height: 26px; object-fit: contain;
}
.device-card .device-name { font-size: 13.5px; font-weight: 500; }
.device-card[data-connected="true"] {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.45);
}
.device-card[data-connected="true"] .device-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #8B9A7B; /* only used as semantic "connected" green, intentionally NOT sage accent */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.device-card .device-check { display: none; }
.device-card[data-connected="true"] .device-check { display: inline-flex; }
.device-card .device-check svg { width: 12px; height: 12px; color: #fff; }

/* disconnect affordance in settings */
.device-card .device-disconnect {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.device-card[data-connected="true"]:hover .device-disconnect {
  display: inline-flex;
}
.device-card[data-connected="true"]:hover .device-check { display: none; }

/* Coming-soon device card (Apple Watch until the iOS app ships) */
.device-card[data-soon="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.device-card[data-soon="true"]:hover { background: rgba(255,255,255,0.05); }
.device-card .device-soon-badge {
  position: absolute;
  top: 6px; right: 6px;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(201, 169, 110, 0.18);
  color: var(--accent);
  border: 1px solid rgba(201, 169, 110, 0.35);
  font-weight: 600;
}

/* "+ More devices" expander below the primary device grid */
.more-devices {
  margin-bottom: 18px;
}
.more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
  margin-top: -4px;
  margin-bottom: 10px;
}
.more-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.24);
}
.more-grid {
  margin-top: 6px;
  animation: slide-in 260ms cubic-bezier(.2,.7,.2,1);
}

/* ─── step transitions ──────────────────────────────────────── */

.steps { position: relative; }
.step { display: none; }
.step.is-active { display: block; animation: slide-in 320ms cubic-bezier(.2,.7,.2,1); }
.step.is-active.is-back { animation: slide-in-back 320ms cubic-bezier(.2,.7,.2,1); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slide-in-back {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── timeline (welcome page) ───────────────────────────────── */

.timeline { display: flex; flex-direction: column; gap: 14px; margin: 22px 0 24px; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
}
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(201, 169, 110, 0.15);
}
.timeline-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.timeline-body { font-size: 14.5px; color: var(--text-primary); }

/* ─── settings screen ───────────────────────────────────────── */

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 24px;
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 14px;
  color: #fff;
}
.name-line { font-size: 18px; font-weight: 600; }
.badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(201, 169, 110, 0.12);
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: 999px;
}

.menu { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 20px; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  text-align: left;
  transition: background 150ms ease;
}
.menu-row:hover { background: rgba(255,255,255,0.1); }
.menu-row .label { font-size: 15.5px; font-weight: 500; }
.menu-row .meta { font-size: 13px; color: var(--text-muted); }
.menu-row .chev svg { width: 14px; height: 14px; color: var(--text-muted); }

.panel { display: none; }
.panel.is-open { display: block; animation: slide-in 260ms cubic-bezier(.2,.7,.2,1); }

.vault-list { display: flex; flex-direction: column; gap: 10px; }
.vault-item {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
}
.vault-item .vault-desc { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.vault-item .vault-meta { font-size: 12.5px; color: var(--text-muted); }
.vault-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vault-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 24px 8px 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.danger { color: #f3b48a; }

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--text-muted);
}
.footer-links a { transition: color 150ms ease; }
.footer-links a:hover { color: var(--text-primary); }

/* ─── misc ──────────────────────────────────────────────────── */

.hidden { display: none !important; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  background: rgba(30, 20, 15, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  font-size: 14px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 50;
}
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── QR code ───────────────────────────────────────────────── */

.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 4px 0 22px;
}
.qr-tile {
  width: 168px;
  height: 168px;
  padding: 12px;
  background: #F4F1EB;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-canvas {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1A1410;
}
.qr-canvas svg { width: 100%; height: 100%; display: block; }
.qr-number {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-top: 12px;
}
.qr-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ─── welcome actions (device-aware) ────────────────────────── */

.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
  margin: 4px 0 22px;
}
.welcome-actions .welcome-text-btn { order: 1; width: 100%; }
.welcome-actions .qr-block {
  order: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.welcome-actions .qr-eyebrow { display: none; }
.welcome-actions .qr-tile {
  width: 132px;
  height: 132px;
  padding: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}
.welcome-actions .qr-number { font-size: 14px; margin-top: 8px; }
.welcome-actions .qr-hint { font-size: 12px; color: var(--text-muted); }

/* Desktop (mouse + hover capable) — QR becomes the primary affordance */
@media (hover: hover) and (pointer: fine) {
  .welcome-actions .qr-block { order: 1; padding-top: 0; }
  .welcome-actions .welcome-text-btn { order: 2; }
  .welcome-actions .qr-eyebrow {
    display: block;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .welcome-actions .qr-tile {
    width: 192px;
    height: 192px;
    padding: 14px;
  }
  .welcome-actions .qr-number { font-size: 16.5px; }
  .welcome-actions .qr-hint { font-size: 13px; }
}

/* ─── modal ─────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 5, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-backdrop.is-open {
  display: flex;
  animation: fade-in 180ms ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  animation: card-in 260ms cubic-bezier(.2,.7,.2,1);
}
.modal .qr-tile { margin: 0 auto; }
.modal .qr-number { text-align: center; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.18); }
