/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1.0625rem; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid rgba(124, 92, 255, .45); outline-offset: 2px; border-radius: 12px; }

@media (min-width: 560px) {
  body { background: var(--page); }
  #app { box-shadow: 0 0 0 1px #E8EBF2, 0 30px 80px -40px rgba(15, 23, 42, .35); }
}

#app {
  position: relative; max-width: var(--app-max); min-height: 100dvh; margin: 0 auto; background: var(--bg);
  overflow-x: clip; isolation: isolate;
}

/* soft violet-cyan glow at the top of light screens */
.glow::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 340px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 55% at 50% 0%, rgba(124, 92, 255, .08), transparent 70%),
    radial-gradient(45% 50% at 95% 10%, rgba(34, 211, 238, .04), transparent 70%),
    radial-gradient(40% 40% at 5% 15%, rgba(59, 130, 246, .03), transparent 70%);
}

.screen {
  position: relative; min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) calc(env(safe-area-inset-bottom) + 24px);
  animation: screen-in .28s cubic-bezier(.2, .8, .2, 1);
}
.screen.with-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 120px); }
.screen.with-bar { padding-bottom: calc(env(safe-area-inset-bottom) + 104px); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .fade-up { animation: none !important; } }

/* ---------- type ---------- */
.h-display { font-size: 2.125rem; line-height: 1.12; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.h1 { font-size: 1.875rem; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.h2 { font-size: 1.625rem; line-height: 1.22; font-weight: 800; letter-spacing: -.015em; margin: 0; }
.h3 { font-size: 1.25rem; line-height: 1.3; font-weight: 800; margin: 0; }
.lead { font-size: 1.0625rem; color: var(--text-body); margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 0.875rem; line-height: 1.4; }
.caption { font-size: 0.875rem; color: var(--text-3); line-height: 1.4; }
.section-label { font-size: 0.9375rem; font-weight: 700; color: var(--text-2); margin: 26px 0 10px; }
.accent-text { background: var(--headline-accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-word { color: var(--accent-text); font-weight: 800; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 56px; margin: 0 -10px 8px; }
.topbar .title { font-size: 1.25rem; font-weight: 800; flex: 1; margin: 0; }
.topbar .center { flex: 1; display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; }
.icon-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  color: var(--text); transition: background .15s;
}
.icon-btn:active { background: var(--field); }
.icon-btn svg { width: 24px; height: 24px; }
.text-btn { min-height: var(--tap); padding: 0 10px; font-weight: 700; color: var(--text-2); font-size: 1.0625rem; }

/* ---------- buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px;
  border-radius: var(--r-pill); font-weight: 800; font-size: 1.125rem; padding: 0 24px; transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { color: #fff; background: var(--accent-gradient); box-shadow: var(--shadow-accent); }
.btn-secondary { background: var(--field); color: var(--text); }
.btn-ghost { color: var(--text-body); font-weight: 700; font-size: 1.0625rem; min-height: 48px; }
.btn-danger { background: var(--danger-bg); color: var(--danger-strong); }
.btn svg { width: 22px; height: 22px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips.center { justify-content: center; }
.chip {
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-pill); background: var(--chip);
  border: 1.5px solid var(--chip-border); font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap; transition: background .15s, border-color .15s;
}
button.chip:active { background: var(--field); }
.chip.selected { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.static { pointer-events: none; }
.chip svg { width: 18px; height: 18px; }
.chip.toggle.selected { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-from); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.segmented .chip { justify-content: center; white-space: normal; text-align: center; line-height: 1.15; padding: 6px 12px; min-height: 52px; }

/* ---------- tags ---------- */
.tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px; font-weight: 700; font-size: 0.9375rem; white-space: nowrap; }
.tag-danger { background: var(--danger-bg); color: var(--danger-strong); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-neutral { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-demo { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 8px; background: var(--neutral-bg); color: var(--text-2); font-size: 0.75rem; font-weight: 800; letter-spacing: .02em; vertical-align: 2px; }

/* ---------- cards ---------- */
.card { border: 1.5px solid var(--line); border-radius: var(--r-card); background: var(--surface); padding: 18px; }
.card-soft { background: var(--chip); border-radius: var(--r-card); padding: 16px 18px; }
.gradient-card {
  position: relative; border-radius: var(--r-card); padding: 18px; background: var(--surface); border: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--glow-gradient) border-box;
}
.thumb { width: 56px; height: 56px; border-radius: var(--r-thumb); background: var(--thumb); flex: none; overflow: hidden; display: grid; place-items: center; color: var(--text-3); font-weight: 800; font-size: 1.25rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
/* The person's own pack photo fills the tile, also where database packshots are fitted whole */
.thumb > img.own-photo.own-photo { object-fit: cover; }
.thumb.lg { width: 64px; height: 64px; border-radius: 16px; }
.thumb.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 0.9375rem; }

.product-row { display: flex; align-items: center; gap: 16px; }
.product-row .name { font-size: 1.1875rem; font-weight: 800; line-height: 1.25; }
.product-row .meta { color: var(--text-3); font-size: 1rem; margin-top: 2px; }

.alt-card { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; }
.alt-card .kicker { color: var(--accent-text); font-weight: 800; font-size: 0.875rem; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.alt-card .kicker svg { width: 16px; height: 16px; }
.alt-card .name { font-size: 1.25rem; font-weight: 800; line-height: 1.25; margin: 2px 0; overflow-wrap: break-word; hyphens: auto; }
.alt-card .why { color: var(--text-body); font-size: 1rem; line-height: 1.35; }
.alt-card .metric { font-weight: 800; font-size: 1.25rem; color: var(--ok-text); white-space: nowrap; }
.alt-card .chev { color: var(--text-3); width: 24px; height: 24px; flex: none; }
.alt-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.alt-list .card { padding: 18px; }

/* ---------- banners ---------- */
.banner { display: flex; align-items: center; gap: 14px; border-radius: var(--r-card-sm); padding: 16px 18px; font-weight: 700; font-size: 1.0625rem; line-height: 1.35; }
.banner .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-weight: 900; }
.banner-danger { background: var(--danger-bg); color: var(--danger-text); }
.banner-danger .ico { background: var(--danger-icon); }
.banner-warn { background: var(--warn-bg); color: var(--warn-strong); }
.banner-warn .ico { background: #F59E0B; }
.banner-info { background: var(--info-bg); color: var(--text-body); font-weight: 500; }
.banner .ico svg { width: 18px; height: 18px; }
.banner .ai-badge { width: 44px; height: 44px; }

/* ---------- AI ---------- */
.ai-badge { width: 40px; height: 40px; border-radius: 50%; background: var(--ai-badge); display: grid; place-items: center; flex: none; color: #fff; }
.ai-badge svg { width: 55%; height: 55%; }
.bubble-ai { background: var(--field); border-radius: 24px; padding: 16px 20px; font-size: 1.0625rem; color: var(--text-body); }
.ai-line { display: flex; gap: 14px; align-items: flex-start; }

/* ---------- inputs ---------- */
.field { width: 100%; min-height: 56px; border-radius: var(--r-pill); background: var(--field); border: 0; padding: 0 22px; font-size: 1.0625rem; outline: none; }
.field::placeholder { color: var(--text-2); }
textarea.field { border-radius: 20px; padding: 16px 20px; min-height: 110px; resize: vertical; line-height: 1.4; }
.search { position: relative; }
.search svg { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--text-2); }
.search .field { padding-left: 54px; }
.ask-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: min(100%, var(--app-max)); padding: 0 var(--gutter); display: flex; gap: 12px; align-items: center; z-index: 20;
}
.ask-bar::before { content: ''; position: absolute; inset: -18px 0 -30px; background: linear-gradient(transparent, var(--bg) 35%); z-index: -1; pointer-events: none; }
.ask-input { flex: 1; min-width: 0; display: flex; align-items: center; min-height: 56px; border-radius: var(--r-pill); background: var(--field); padding: 0 8px 0 22px; gap: 6px; }
.ask-input input { flex: 1; border: 0; background: none; outline: none; font-size: 1.0625rem; min-width: 0; height: 56px; }
.ask-input input::placeholder { color: var(--text-body); }
.ask-input .icon-btn { color: var(--text-2); }
.ask-input button.ask-fake { flex: 1; text-align: left; color: var(--text-body); font-size: 1.0625rem; height: 56px; }
.round-gradient { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-gradient-diag); color: #fff; display: grid; place-items: center; flex: none; box-shadow: var(--shadow-accent); }
.round-gradient svg { width: 26px; height: 26px; }
.round-gradient.sm { width: 44px; height: 44px; box-shadow: none; }
.round-gradient.sm svg { width: 22px; height: 22px; }

/* ---------- options (onboarding) ---------- */
.options { display: grid; gap: 14px; }
.option {
  width: 100%; min-height: 60px; border-radius: var(--r-card-sm); border: 2px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; padding: 12px 18px 12px 22px; font-size: 1.125rem; font-weight: 800; text-align: left; gap: 14px;
}
.option .sub { display: block; font-size: 0.875rem; font-weight: 500; color: var(--text-2); margin-top: 2px; }
.option .radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #CBD5E1; flex: none; position: relative; }
.option .check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid #CBD5E1; flex: none; display: grid; place-items: center; color: #fff; }
.option[aria-checked='true'], .option[aria-pressed='true'] { border-color: var(--accent-from); background: var(--accent-soft); }
.option[aria-checked='true'] .radio { border: 0; background: var(--accent-gradient-diag); }
.option[aria-checked='true'] .radio::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.option[aria-pressed='true'] .check { background: var(--accent-gradient-diag); border: 0; }
.option .check svg { width: 16px; height: 16px; }
.options-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.options-chips .option { width: auto; min-height: 48px; padding: 10px 16px; border-radius: 999px; font-size: 1rem; font-weight: 700; }
.options-chips .option .radio { display: none; }

.progress { flex: 1; height: 8px; border-radius: 4px; background: var(--field); overflow: hidden; margin: 0 8px; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--accent-gradient); transition: width .3s; }

/* ---------- lists ---------- */
.list { border: 1.5px solid var(--line); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 14px 20px; text-align: left; border-top: 1.5px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .k { font-size: 0.9375rem; color: var(--text-2); }
.list-row .v { font-size: 1.1875rem; font-weight: 800; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row > svg { width: 22px; height: 22px; color: var(--text-3); flex: none; }
.list-row.danger .v, .list-row.danger { color: var(--danger-strong); }

.history-row { display: flex; align-items: center; gap: 16px; width: 100%; padding: 10px 0; text-align: left; }
.history-row .grow { flex: 1; min-width: 0; }
.history-row .name { font-size: 1.125rem; font-weight: 800; line-height: 1.25; }
.history-row .time { color: var(--text-3); font-size: 0.9375rem; margin-top: 2px; }
.day-label { font-size: 0.9375rem; font-weight: 700; color: var(--text-2); margin: 22px 0 6px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 16px); z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 40px; background: var(--nav-bg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-float);
}
.nav-item { text-decoration: none; min-width: 92px; height: 60px; border-radius: 30px; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--text-2); font-size: 0.8125rem; font-weight: 800; }
.nav-item svg { width: 24px; height: 24px; }
.nav-item[aria-current='page'] { background: var(--field); color: var(--text); }
.nav-scan { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-gradient-diag); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-accent); }
.nav-scan svg { width: 28px; height: 28px; }

/* ---------- sheet / toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: min(100%, var(--app-max)); background: var(--surface); border-radius: 28px 28px 0 0; padding: 12px var(--gutter) calc(env(safe-area-inset-bottom) + 20px); animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); max-height: 90dvh; overflow: auto; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: #E2E8F0; margin: 0 auto 16px; }
.sheet .actions { display: grid; gap: 10px; margin-top: 20px; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-size: 0.9375rem; font-weight: 600; max-width: calc(min(100vw, var(--app-max)) - 32px); box-shadow: var(--shadow-float); animation: fade .2s; }

/* ---------- misc ---------- */
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.center-text { text-align: center; }
.skeleton { background: linear-gradient(90deg, var(--field) 0%, var(--chip) 50%, var(--field) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.fade-up { animation: screen-in .35s cubic-bezier(.2, .8, .2, 1) both; }
.empty { text-align: center; padding: 40px 12px; color: var(--text-2); }
.empty .ai-badge { margin: 0 auto 16px; width: 56px; height: 56px; }
.divider { height: 1.5px; background: var(--line); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 1fr auto auto; gap: 10px 16px; font-size: 1rem; align-items: baseline; }
.kv .h { font-size: 0.875rem; color: var(--text-3); font-weight: 700; }
.kv .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.source-line { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); font-size: 0.875rem; line-height: 1.4; }
.source-line svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(15, 23, 42, .12); border-top-color: var(--accent-from); }
@keyframes spin { to { transform: rotate(360deg); } }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .2); }
.status-dot.off { background: #94A3B8; box-shadow: none; }
.link { color: var(--accent-text); font-weight: 700; text-decoration: none; }
/* 320 px phones: the input, mic and send button must fit inside the bar */
@media (max-width: 340px) { .ask-input { padding-left: 14px; gap: 2px; } .ask-input input { font-size: 1rem; } }

/* Native modality supplies focus containment and makes the background inert. */
dialog.sheet-backdrop { border:0; padding:0; margin:0; width:100%; height:100dvh; max-width:none; max-height:none; color:var(--text); }
dialog.sheet-backdrop:not([open]) { display:none; }
dialog.sheet-backdrop::backdrop { background:transparent; }
.sheet button:focus-visible { outline:2px solid var(--text); outline-offset:3px; }

/* Enlarged text can wrap instead of disappearing at the screen edge. */
.btn { padding-block:10px; overflow-wrap:anywhere; text-align:center; }
.tag { white-space:normal; max-width:100%; overflow-wrap:anywhere; }
.alt-card .kicker { white-space:normal; }
.chip { white-space:normal; max-width:100%; overflow-wrap:anywhere; padding-block:8px; }
.ask-input button.ask-fake { height:auto; min-height:56px; min-width:0; padding-block:10px; overflow-wrap:anywhere; }
.badge-demo { height:auto; min-height:22px; }
.screen.with-bar { padding-bottom:calc(env(safe-area-inset-bottom) + max(156px, 9rem)); }

/* Offline: one calm line at the top, above the content, never covering the bottom bar */
.net-banner { position: fixed; top: env(safe-area-inset-top); left: 50%; transform: translateX(-50%); z-index: 40;
  width: min(100% - 24px, var(--app-max)); margin-top: 8px; padding: 10px 14px; border-radius: 14px;
  background: var(--warn-bg); color: var(--warn-text); font-size: 14px; line-height: 1.35; box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.net-banner[hidden] { display: none; }
.toast-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0 16px; width: calc(min(100vw, var(--app-max)) - 32px); padding-bottom: 2px; }
.toast-actions > span { flex: 1 0 100%; padding-top: 2px; }
.toast-action { min-height: 44px; padding: 0 4px; background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; display: inline-flex; align-items: center; }
