/* ---------- card: a quiet band, not a floating SaaS card ---------- */
.card {
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: grid;
  gap: var(--s-3);
  background: var(--surface-2);
}
.card > h3 { font-size: var(--fs-lg); }
.card.tone { background: var(--tone-soft); box-shadow: inset 4px 0 0 var(--tone); }
.card.tone > h3 { color: var(--tone-ink, var(--text)); }
.card.plain { background: none; padding: 0; }

.section-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 750; letter-spacing: -.02em; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 50px; padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  font-weight: 650; font-size: var(--fs-md);
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast);
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--ink) 25%, transparent); }
.btn.ghost { background: transparent; color: var(--menstrual-ink); padding: 0 var(--s-2); min-height: 44px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 44px; padding: 0 var(--s-4); font-size: var(--fs-sm); }

/* ---------- chip: a text pill; intensity = how much ink ---------- */
.chip {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: max(44px, 2.6em); padding: 0 var(--s-4);
  border: 0; border-radius: var(--r-pill);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--ink) 18%, transparent);
  color: var(--ink);
  font-size: var(--fs-sm); font-weight: 550; line-height: 1.1; text-align: left;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast);
}
.chip:active { transform: scale(.95); }
.chip .chip-icon { display: inline-flex; }
.chip .chip-icon svg { height: 18px; width: auto; }
.chip.selected {
  --c: var(--chip-color, var(--accent));
  box-shadow: inset 0 0 0 1.5px var(--c);
  background: color-mix(in oklab, var(--c) var(--fill, 22%), var(--bg));
}
.chip.selected[data-level="2"] { --fill: 48%; }
.chip.selected[data-level="3"] { --fill: 100%; color: var(--chip-on, var(--ink)); }
.chip.selected[data-level="4"] {
  --fill: 100%; color: var(--chip-on, var(--ink));
  box-shadow: inset 0 0 0 1.5px var(--c), 0 0 0 3px color-mix(in oklab, var(--c) 35%, transparent);
}
.chip .dots { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.chip .dots i { width: 3px; border-radius: 2px; background: currentColor; opacity: .25; }
.chip .dots i:nth-child(1) { height: 5px; }
.chip .dots i:nth-child(2) { height: 8px; }
.chip .dots i:nth-child(3) { height: 11px; }
.chip .dots i:nth-child(4) { height: 12px; }
.chip .dots i.on { opacity: 1; }
.chip:not(.selected) .dots { display: none; }
.chip-grid { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- segmented ---------- */
.segmented {
  display: flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-pill);
}
.segmented button {
  flex: 1; appearance: none; border: 0; background: transparent; cursor: pointer;
  min-height: 34px; border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--fs-sm); color: var(--text-2);
  transition: background var(--t-fast), color var(--t-fast);
}
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(30, 37, 87, .12); }

/* ---------- toggle (iOS-like switch) ---------- */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); cursor: pointer; min-height: 44px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  flex: none; width: 51px; height: 31px; border-radius: var(--r-pill);
  background: var(--surface-3); position: relative;
  transition: background var(--t-fast);
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
  transition: transform var(--t-med) var(--ease);
}
.toggle input:checked + .track { background: var(--ok); }
.toggle input:checked + .track::after { transform: translateX(20px); }
.toggle input:focus-visible + .track { outline: 3px solid var(--ovulation); outline-offset: 2px; }
@supports selector(input[switch]) {
  .toggle input[switch] { position: static; opacity: 1; pointer-events: auto; accent-color: var(--ok); }
  .toggle input[switch] + .track { display: none; }
}

/* ---------- grouped list ---------- */
.list { display: grid; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); }
.list > * { padding: var(--s-3) var(--s-4); min-height: 48px; display: flex; align-items: center; gap: var(--s-3); }
.list > * + * { box-shadow: inset 0 1px 0 var(--line); }

/* ---------- tab bar: native, full width ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  padding: 6px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; justify-content: space-around; align-items: flex-start;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: 0 -1px 0 var(--line);
}
.tabbar a {
  flex: 1; display: grid; justify-items: center; gap: 1px;
  padding: 2px 0 4px;
  color: var(--text-3); text-decoration: none;
  font-size: min(.588rem, 12px); font-weight: 500; letter-spacing: .01em;   /* 10px; like iOS, tab labels barely grow */
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] svg { color: var(--accent); }
#view[data-view="onboarding"] ~ .tabbar,
#view[data-view="styleguide"] ~ .tabbar { display: none; }

/* ---------- sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: var(--backdrop);
  animation: fade-in var(--t-med) var(--ease-out);
}
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  animation: sheet-in var(--t-med) var(--ease-out);
}
@media (prefers-color-scheme: dark) { .sheet { background: var(--surface); } }
.sheet.closing { animation: sheet-out var(--t-fast) ease-in forwards; }
.sheet-backdrop.closing { animation: fade-out var(--t-fast) ease-in forwards; }
.sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--text-3); opacity: .5; margin: var(--s-2) auto 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-5) var(--s-2); }
.sheet-header h3 { font-size: var(--fs-lg); }
.sheet-header .btn.ghost { min-height: 44px; padding: 0 var(--s-3); margin-right: calc(-1 * var(--s-3)); font-weight: 650; }
.sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  grid-template-columns: minmax(0, 1fr);
  padding: var(--s-2) var(--s-5) calc(env(safe-area-inset-bottom) + var(--s-6));
  display: grid; gap: var(--s-6);
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* ---------- dialog ---------- */
.dialog {
  position: fixed; z-index: 51; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 48px));
  background: var(--bg); border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-5) var(--s-5);
  box-shadow: var(--shadow-3);
  display: grid; gap: var(--s-3);
  animation: pop-in var(--t-med) var(--ease);
}
.dialog .row { margin-top: var(--s-2); flex-wrap: nowrap; }
.dialog .row .btn { flex: 1; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 50; background: var(--backdrop); animation: fade-in var(--t-fast); }
@keyframes pop-in { from { opacity: 0; transform: translate(-50%, -48%) scale(.96); } }

/* ---------- toast ---------- */
.toast {
  pointer-events: none;
  position: fixed; z-index: 60; left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + var(--s-4));
  transform: translateX(-50%);
  max-width: calc(100vw - 48px);
  background: var(--ink); color: var(--bg);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--fs-sm);
  animation: toast-in var(--t-med) var(--ease);
}
.toast.closing { animation: fade-out var(--t-fast) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- update banner ---------- */
.update-banner {
  position: fixed; z-index: 30; left: var(--s-4); right: var(--s-4);
  top: calc(env(safe-area-inset-top) + var(--s-2));
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  background: var(--ink); color: var(--bg); border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-5);
  font-weight: 600; font-size: var(--fs-sm);
}
.update-banner .btn.primary { background: var(--accent); color: var(--menstrual-on); }

/* ---------- empty state ---------- */
.empty { display: grid; justify-items: start; gap: var(--s-3); padding: var(--s-4) 0; color: var(--text-2); }

/* ---------- styleguide (dev page) ---------- */
.sg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: var(--s-2); }
.sg-swatch { display: grid; gap: 4px; font-size: 11px; color: var(--text-2); }
.sg-swatch div { height: 40px; border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--line); }
