/* ------------------------------------------------------------------ *
 * ScanEat — design tokens
 * Warm off-white, a single turquoise accent, hairline borders. No
 * gradients, no drop shadows, no glows: depth comes from surfaces and
 * spacing, the way a printed label would do it.
 * ------------------------------------------------------------------ */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-sunk: #f2f2ec;
  --border: #e4e3db;
  --border-strong: #d3d2c7;
  --text: #1c1c1a;
  --text-muted: #6e6e66;
  --text-faint: #a09f96;
  --accent: #009b95; /* turquoise; fills, icons, borders (white semibold labels on it: AA-large) */
  --accent-ink: #007c78; /* the accent as body-size text on the page: AA */
  --accent-tint: #ddf6f4;
  --accent-border: #a6e4df;
  --on-accent: #ffffff;
  --danger: #a4462e;

  /* The only colours besides the accent: four score bands, read before
   * the number is. Always used as a fill under white text.
   * Scala del team (TEAM_HANDOFF §4): 0–24 bad, 25–49 poor, 50–74 good,
   * 75–100 excellent. */
  --score-1: #e0473c; /*  0–24  red    · Bad       */
  --score-2: #f29b30; /* 25–49  orange · Poor      */
  --score-3: #7cc242; /* 50–74  lime   · Good      */
  --score-4: #1e8e3e; /* 75–100 green  · Excellent */

  /* Over the camera picture, which is dark whatever the theme. */
  --glass: rgba(16, 17, 15, 0.52);
  --cam-accent: #62e8dd;
  --scrim: rgba(20, 21, 18, 0.36);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --gutter: 16px;
  --maxw: 440px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Liquid glass (welcome and profile): frosted, bright-edged panes over a
   * slowly moving field of the brand's turquoise and a warm sand. */
  --glass-bg: rgba(255, 255, 255, 0.46);
  --glass-bg-strong: rgba(255, 255, 255, 0.66);
  --glass-edge: rgba(255, 255, 255, 0.78);
  --glass-line: rgba(28, 40, 34, 0.07);
  --glass-hi: rgba(255, 255, 255, 0.95);
  --glass-shade: 0 1px 1px rgba(28, 40, 34, 0.04), 0 14px 34px rgba(28, 40, 34, 0.09);
  --glass-glint: rgba(255, 255, 255, 0.6);
  --blob-1: #74e6dc;
  --blob-2: #efe2cc;
  --blob-3: #2ecfc5;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614;
    --surface: #1d1f1c;
    --surface-sunk: #252724;
    --border: #2e312c;
    --border-strong: #3f423b;
    --text: #edede6;
    --text-muted: #9a9a91;
    --text-faint: #6b6b64;
    --accent: #40e0d0;
    --accent-ink: #40e0d0;
    --accent-tint: #0c3230;
    --accent-border: #185b56;
    --on-accent: #04292a;
    --danger: #e0927a;
    --scrim: rgba(0, 0, 0, 0.55);
    --glass-bg: rgba(36, 40, 36, 0.5);
    --glass-bg-strong: rgba(44, 48, 44, 0.72);
    --glass-edge: rgba(255, 255, 255, 0.14);
    --glass-line: rgba(255, 255, 255, 0.05);
    --glass-hi: rgba(255, 255, 255, 0.2);
    --glass-shade: 0 14px 34px rgba(0, 0, 0, 0.42);
    --glass-glint: rgba(255, 255, 255, 0.16);
    --blob-1: #0a6662;
    --blob-2: #3e3727;
    --blob-3: #0c8e86;
  }
}

*,
*::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-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  overscroll-behavior: none;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

p,
h1,
h2,
h3 {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* Arabic letters join up: tracking and capitals are Latin habits. */
html[lang='ar'] * {
  letter-spacing: 0 !important;
  text-transform: none !important;
}
html[lang='ar'] body {
  line-height: 1.6;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view {
  display: none;
}

/* min-height: 0 lets a flex child shrink instead of growing past the
 * screen: a flex item defaults to min-height: auto. */
.view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ------------------------------------------------------------------ *
 * Shared pieces
 * ------------------------------------------------------------------ */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
}

.brand__name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.icon-btn:active {
  background: var(--surface-sunk);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition:
    opacity 0.15s ease,
    transform 0.15s var(--ease);
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn:not(:disabled):active {
  transform: scale(0.98);
  opacity: 0.9;
}
.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--light {
  background: #ffffff;
  color: #1c1c1a;
  min-height: 44px;
  font-size: 15px;
}
.btn--block {
  width: 100%;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Product image, or a quiet pack glyph when there is none. */
.thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-faint);
  overflow: hidden;
  flex-shrink: 0;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.thumb--photo img {
  object-fit: cover;
}
.thumb--lg {
  width: 76px;
  height: 76px;
  border-radius: 16px;
}
.thumb--empty {
  background: var(--surface-sunk);
}

/* A score: the band colour as a fill, the number in white. */
.score-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  background: var(--surface-sunk);
  flex-shrink: 0;
}

.score-chip--1 {
  background: var(--score-1);
}
.score-chip--2 {
  background: var(--score-2);
}
.score-chip--3 {
  background: var(--score-3);
}
.score-chip--4 {
  background: var(--score-4);
}

.score-chip--pending {
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.score-chip--lg {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

/* Choices: a grouped list in Settings. */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: start;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.choice:active {
  background: var(--surface-sunk);
}

.choice[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.choice__text {
  flex: 1;
  min-width: 0;
}

.choice__label {
  display: block;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 2px;
}

.choice__desc {
  display: block;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-muted);
}

.choice__radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease;
}

.choice__radio::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.2s var(--ease);
}

.choice[aria-pressed='true'] .choice__radio {
  border-color: var(--accent);
}
.choice[aria-pressed='true'] .choice__radio::after {
  transform: scale(1);
}

.choices--list {
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.choices--list .choice {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 14px 16px;
}

.choices--list .choice + .choice {
  border-top: 1px solid var(--border);
}
.choices--list .choice[aria-pressed='true'] {
  background: transparent;
}
.choices--list .choice__label {
  font-size: 16px;
}
.choices--list .choice__desc {
  font-size: 13px;
}

/* ------------------------------------------------------------------ *
 * Main — top bar
 * ------------------------------------------------------------------ */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 10px 6px var(--gutter);
}

/* ------------------------------------------------------------------ *
 * Stage — the voice, top half
 * ------------------------------------------------------------------ */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Voice mode: the orb, centred. */
.voice {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 40px 12px;
  text-align: center;
}

.main.is-chat .voice,
.main.is-chat .result {
  display: none !important;
}
.main.is-voice .chat,
.main.is-voice .composer {
  display: none;
}

.voice__back {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.voice__back:active {
  background: var(--surface-sunk);
}

.stage__status {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  min-height: 22px;
}

.stage.is-error .stage__status {
  color: var(--danger);
}

.stage__said {
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-muted);
  max-width: 28ch;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stage__said:empty {
  display: none;
}

.stage__caption {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--text);
  max-width: 28ch;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stage__caption:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  font-size: 15px;
}

/* Session clock: Live bills by the second, so this is not decoration. */
.live-pill {
  position: absolute;
  top: 6px;
  inset-inline-start: var(--gutter);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.live-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* The orb. A plain circle whose ripple and bars follow the audio — your
 * voice while you talk, Savio's while he does. --level is set per frame. */
.orb {
  --level: 0;
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.orb__ring,
.orb__ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  pointer-events: none;
}

.orb__ripple {
  border-color: var(--accent-border);
  opacity: 0;
  transform: scale(1);
  transition:
    transform 90ms linear,
    opacity 120ms linear;
}

.orb__core {
  position: relative;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  transform: scale(calc(1 + var(--level) * 0.08));
  transition:
    transform 90ms linear,
    background 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease;
}

.orb:active .orb__core {
  background: var(--surface-sunk);
}

.orb__bars {
  display: none;
  align-items: center;
  gap: 4px;
  height: 30px;
}

.orb__bars i {
  --b: 0.16;
  width: 4px;
  height: 30px;
  border-radius: 2px;
  background: currentColor;
  transform: scaleY(var(--b));
  transition: transform 80ms linear;
}

/* live */
.stage.is-listening .orb__core,
.stage.is-thinking .orb__core {
  background: var(--accent-tint);
  border-color: var(--accent);
}

.stage.is-speaking .orb__core {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.stage.is-listening .orb__ripple,
.stage.is-speaking .orb__ripple {
  opacity: calc(0.35 + var(--level) * 1.4);
  transform: scale(calc(1 + var(--level) * 0.3));
}

.stage.is-listening .orb__mic,
.stage.is-speaking .orb__mic,
.stage.is-thinking .orb__mic {
  display: none;
}

.stage.is-listening .orb__bars,
.stage.is-speaking .orb__bars,
.stage.is-thinking .orb__bars {
  display: flex;
}

/* thinking: the bars wave on their own */
.stage.is-thinking .orb__bars i {
  animation: wave 1s ease-in-out infinite;
}
.stage.is-thinking .orb__bars i:nth-child(2) {
  animation-delay: 0.12s;
}
.stage.is-thinking .orb__bars i:nth-child(3) {
  animation-delay: 0.24s;
}
.stage.is-thinking .orb__bars i:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes wave {
  0%,
  100% {
    transform: scaleY(0.2);
  }
  50% {
    transform: scaleY(0.75);
  }
}

/* connecting */
.stage.is-connecting .orb__core {
  animation: breathe 1.4s ease-in-out infinite;
}
.stage.is-connecting .orb__mic {
  opacity: 0.4;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

/* Scores — one per scanned product, in the top bar, newest nearest the
 * settings button; the oldest slide out of view when there is no room. */
.scores {
  flex: 1;
  min-width: 0;
  margin: 0 6px;
  padding: 4px; /* room for the highlight outline */
  list-style: none;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  gap: 5px;
  overflow: hidden;
}

.scores li {
  flex-shrink: 0;
}

.scores .score-chip {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 14px;
  animation: pop 0.35s var(--ease);
}

.scores .score-chip.is-flash {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ------------------------------------------------------------------ *
 * Chat — the default way to talk to Savio
 * ------------------------------------------------------------------ */

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px var(--gutter) 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

/* Few messages sit at the bottom, like any chat. */
.chat > :first-child {
  margin-top: auto;
}

.msg {
  display: flex;
  max-width: 86%;
  margin: 0;
}
.msg--me {
  align-self: flex-end;
}
.msg--savio {
  align-self: flex-start;
}

.bubble {
  margin: 0;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--savio .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-end-start-radius: 6px;
}

.msg--me .bubble {
  background: var(--accent);
  color: var(--on-accent);
  border-end-end-radius: 6px;
}

.bubble--error {
  color: var(--danger);
}

.bubble--typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 38px;
}

.bubble--typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: typing 1.2s ease-in-out infinite;
}

.bubble--typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.bubble--typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.msg--note {
  align-self: center;
  max-width: 90%;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* A scan, as Savio's message. */
.msg--scan {
  align-self: flex-start;
  width: 86%;
  gap: 11px;
  align-items: flex-start;
  padding: 10px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-end-start-radius: 6px;
  animation: rise 0.3s var(--ease);
}

.msg--scan:active {
  background: var(--surface-sunk);
}
.msg--scan .thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}
.msg--scan.is-missing .thumb {
  color: var(--accent);
  background: var(--accent-tint);
  border-color: var(--accent-border);
}

.scan__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.scan__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scan__name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan__score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.scan__score .score-chip {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 13px;
}

.scan__band {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.scan__text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}
.scan__text:empty {
  display: none;
}

/* The composer. 16px text: smaller makes iOS zoom in on focus. */
.composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px var(--gutter) 10px;
}

.composer__field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding-block: 4px;
  padding-inline: 14px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: border-color 0.15s ease;
}

.composer__field:focus-within {
  border-color: var(--accent);
}

.composer__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  font-size: 16px;
  line-height: 1.4;
  padding: 7px 0;
  max-height: 112px;
}

.composer__input::placeholder {
  color: var(--text-faint);
}

.composer__send {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  flex-shrink: 0;
  transition:
    opacity 0.15s ease,
    transform 0.15s var(--ease);
}

.composer__send:disabled {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

.composer__voice {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  flex-shrink: 0;
}

.composer__voice:active {
  transform: scale(0.95);
}

/* ------------------------------------------------------------------ *
 * Latest scan
 * ------------------------------------------------------------------ */

.result {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 var(--gutter) 10px;
  padding-block: 9px;
  padding-inline: 9px 10px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: rise 0.35s var(--ease);
  transition: background 0.15s ease;
}

.result:active {
  background: var(--surface-sunk);
}

.result__body {
  flex: 1;
  min-width: 0;
}

.result__name,
.result__sub {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result__name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.result__sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}

.result__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 56px;
}

.result__score:empty {
  display: none;
}

.result__band {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.result.is-missing .thumb {
  color: var(--accent);
  background: var(--accent-tint);
  border-color: var(--accent-border);
}

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

/* ------------------------------------------------------------------ *
 * Camera — bottom half, always ready
 * ------------------------------------------------------------------ */

.cam {
  position: relative;
  flex: 0 0 auto;
  height: clamp(250px, 44dvh, 440px);
  margin: 0 var(--gutter) calc(env(safe-area-inset-bottom) + 12px);
  border-radius: 22px;
  overflow: hidden;
  background: #0e0f0d;
  isolation: isolate;
  color: #ffffff;
}

.cam__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The target. Its outline is the scrim that dims everything outside —
 * an outline follows the border radius and spreads without a shadow. */
.cam__frame {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 30%;
  bottom: 32%;
  border-radius: 14px;
  outline: 200vmax solid rgba(8, 9, 8, 0.32);
  pointer-events: none;
  transition:
    top 0.3s var(--ease),
    bottom 0.3s var(--ease),
    left 0.3s var(--ease),
    right 0.3s var(--ease);
}

.cam__corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid #ffffff;
  transition:
    border-color 0.2s ease,
    transform 0.25s var(--ease);
}

.cam__corner--tl {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 14px;
}
.cam__corner--tr {
  top: -1px;
  right: -1px;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 14px;
}
.cam__corner--bl {
  bottom: -1px;
  left: -1px;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 14px;
}
.cam__corner--br {
  bottom: -1px;
  right: -1px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 14px;
}

/* A code was just read. */
.cam.is-hit .cam__corner {
  border-color: var(--cam-accent);
}
.cam.is-hit .cam__corner--tl {
  transform: translate(4px, 4px);
}
.cam.is-hit .cam__corner--tr {
  transform: translate(-4px, 4px);
}
.cam.is-hit .cam__corner--bl {
  transform: translate(4px, -4px);
}
.cam.is-hit .cam__corner--br {
  transform: translate(-4px, -4px);
}

.cam__top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cam__mode,
.cam__hint,
.cam__tool {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.cam__mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cam__mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cam-accent);
  animation: pulse 1.6s ease-in-out infinite;
}

.cam__tools {
  display: flex;
  gap: 8px;
}

.cam__tool {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #ffffff;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.cam__tool[aria-pressed='true'] {
  background: #ffffff;
  color: #1c1c1a;
}

.cam__hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  white-space: nowrap;
  transition: bottom 0.3s var(--ease);
}

#cam-hint-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam__hint .spinner {
  display: none;
  width: 13px;
  height: 13px;
}
.cam__hint.is-busy .spinner {
  display: inline-block;
}

/* Label mode: frame an ingredient list and take the picture. */
.cam__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  display: none;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
}

.cam__text-btn {
  justify-self: start;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 4px;
  color: #ffffff;
}

.shutter {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  display: grid;
  place-items: center;
  transition: transform 0.15s var(--ease);
}

.shutter:active {
  transform: scale(0.93);
}

.shutter__inner {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffffff;
  color: #1c1c1a;
}

.shutter .spinner {
  display: none;
  width: 20px;
  height: 20px;
}

.cam.is-label .cam__frame {
  top: 17%;
  bottom: 30%;
  left: 8%;
  right: 8%;
}
.cam.is-label .cam__controls {
  display: grid;
}
.cam.is-label .cam__hint {
  bottom: 98px;
}
.cam.is-busy .shutter .spinner {
  display: inline-block;
}
.cam.is-busy .cam__controls {
  pointer-events: none;
}
.cam.is-busy .cam__text-btn {
  opacity: 0.4;
}

/* No camera: permission denied, or none available. */
.cam__off {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  color: rgba(255, 255, 255, 0.55);
}

.cam__off-title {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}
.cam__off-text {
  font-size: 14px;
  max-width: 28ch;
  margin-bottom: 14px;
}

.cam.is-off .cam__off {
  display: flex;
}
.cam.is-off .cam__frame,
.cam.is-off .cam__top,
.cam.is-off .cam__hint,
.cam.is-off .cam__controls {
  display: none;
}

/* ------------------------------------------------------------------ *
 * Sheets — rise from the bottom over a scrim
 * ------------------------------------------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.sheet.is-open {
  display: block;
}

.sheet__scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: fade-in 0.25s ease;
}

.sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: var(--maxw);
  max-height: calc(100dvh - env(safe-area-inset-top) - 28px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  animation: sheet-up 0.38s var(--ease);
}

.sheet.is-closing .sheet__scrim {
  animation: fade-out 0.22s ease forwards;
}
.sheet.is-closing .sheet__panel {
  animation: sheet-down 0.22s ease-in forwards;
}
/* Swiped away: the drag's own transition finishes the job. */
.sheet.is-closing.is-dragged .sheet__panel {
  animation: none;
}

.sheet__grab,
.sheet__head {
  touch-action: none;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

/* A 5px pill, with a taller invisible strip around it to catch the thumb. */
.sheet__grab {
  width: 100%;
  height: 21px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.sheet__grab::before {
  content: '';
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 4px 20px;
  flex-shrink: 0;
}

.sheet__head--bare {
  justify-content: flex-end;
  margin-bottom: -18px;
}

.sheet__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.sheet__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 28px);
}

/* ---- Settings ---------------------------------------------------- */

.group + .group {
  margin-top: 26px;
}

.group__title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-block: 0 10px;
  margin-inline: 4px 0;
}

.group__note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  margin: 10px 4px 0;
}

.memory-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  margin-top: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.memory-toggle input {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  accent-color: #f58300;
}
.memory-toggle:focus-within {
  outline: 2px solid #f58300;
  outline-offset: 2px;
}

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list__row {
  display: block;
  width: 100%;
  padding: 15px 16px;
  font-size: 16px;
  text-align: start;
  transition: background 0.15s ease;
}

.list__row:active {
  background: var(--surface-sunk);
}
.list__row + .list__row {
  border-top: 1px solid var(--border);
}
.list__row--danger {
  color: var(--danger);
}

.build {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---- Product detail ---------------------------------------------- */

.detail__hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-inline-end: 36px; /* clear of the close button */
}

.detail__heading {
  min-width: 0;
}

.detail__name {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.detail__brand {
  margin-top: 3px;
  font-size: 14px;
  color: var(--text-muted);
}

.detail__score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
}

.detail__band {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.detail__of {
  font-size: 14px;
  color: var(--text-muted);
}

/* A scale runs from bad to excellent left to right in every language. */
.scale {
  margin-top: 18px;
  direction: ltr;
}

.scale__bar {
  position: relative;
  display: grid;
  grid-template-columns: 40fr 20fr 20fr 20fr;
  gap: 3px;
  height: 6px;
}

.scale__seg {
  border-radius: 3px;
}
.scale__seg--1 {
  background: var(--score-1);
}
.scale__seg--2 {
  background: var(--score-2);
}
.scale__seg--3 {
  background: var(--score-3);
}
.scale__seg--4 {
  background: var(--score-4);
}

.scale__marker {
  --pos: 50;
  position: absolute;
  top: -6px;
  left: calc(var(--pos) * 1%);
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--text);
  outline: 2px solid var(--bg);
}

.scale__labels {
  display: grid;
  grid-template-columns: 40fr 20fr 20fr 20fr;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail__verdict {
  margin-top: 26px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.015em;
}

.detail__points {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.detail__points li {
  position: relative;
  padding-block: 12px;
  padding-inline: 18px 0;
  font-size: 15px;
  line-height: 1.55;
  border-top: 1px solid var(--border);
}

.detail__points li::before {
  content: '';
  position: absolute;
  inset-inline-start: 2px;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}

.detail__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.detail__tags:empty {
  display: none;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.detail__source {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------------ *
 * Database Safi (TEAM_HANDOFF §3b/§5.2c): badge della fonte dei valori,
 * tag con prefissi, avvisi del profilo, "aggiungi prodotto".
 * ------------------------------------------------------------------ */

.score-chip--none {
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-muted);
}

.detail__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.detail__badges:empty,
.detail__badges[hidden] {
  display: none;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-tint);
  color: var(--text);
}

.badge--warn {
  border-color: #f29b30;
  background: #fdf3e3;
  color: #8a5a00;
}

.tag--no {
  border-color: #e0473c;
  background: #fcebe9;
  color: #a62b22;
}

.tag--maybe {
  border-color: #f29b30;
  background: #fdf3e3;
  color: #8a5a00;
}

.tag--ok {
  border-color: #1e8e3e;
  background: #e9f6ec;
  color: #14682c;
}

.tag--halal,
.tag--neutral {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.tag--info {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.detail__profile {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.detail__profile:empty {
  display: none;
}

.warn {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.warn--high {
  border-color: #e0473c;
  background: #fcebe9;
  color: #a62b22;
}

.warn--medium {
  border-color: #f29b30;
  background: #fdf3e3;
  color: #8a5a00;
}

.warn--note {
  color: var(--text-muted);
  font-size: 12px;
}

.warn--ok {
  border-color: #1e8e3e;
  background: #e9f6ec;
  color: #14682c;
}

/* "Aggiungi prodotto": tre foto, invio a submit-product. */

.add__row {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.add__row[hidden] {
  display: none;
}

.add__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.add__input {
  font-size: 13px;
  color: var(--text-muted);
}

.add__status {
  min-height: 18px;
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.add__submit {
  width: 100%;
}

/* ------------------------------------------------------------------ *
 * Short screens: give the camera its room, shrink the voice.
 * ------------------------------------------------------------------ */

@media (max-height: 760px) {
  .orb {
    width: 108px;
    height: 108px;
  }
  .orb__core {
    width: 74px;
    height: 74px;
  }
  .stage__status {
    margin-top: 10px;
  }
  .stage__caption {
    -webkit-line-clamp: 2;
  }
}

@media (max-height: 660px) {
  .orb {
    width: 88px;
    height: 88px;
  }
  .orb__core {
    width: 62px;
    height: 62px;
  }
  .orb__bars {
    transform: scale(0.8);
  }
  .stage__said {
    display: none;
  }
  .cam {
    height: clamp(220px, 42dvh, 440px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ *
 * Liquid glass — the welcome and profile flow
 * ------------------------------------------------------------------ */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    inset 0 -1px 0 var(--glass-line),
    var(--glass-shade);
}

/* Press: it gives under your finger with a little spring on release, and
 * a light blooms from exactly where you touched (--px/--py, set in JS). */
.press {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.5s var(--spring),
    background 0.25s ease,
    border-color 0.25s ease,
    color 0.25s ease;
}

.press::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    150px circle at var(--px, 50%) var(--py, 50%),
    var(--glass-glint),
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.6s ease;
}

.press.is-pressed {
  transform: scale(0.965);
  transition-duration: 0.14s;
}
.press.is-pressed::after {
  opacity: 1;
  transition-duration: 0.06s;
}

.ob {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

/* The colour field behind the glass. It drifts on its own and swings to a
 * new arrangement on every page (--scene). */
.ob__bg {
  position: absolute;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  transform: translate3d(calc(var(--scene, 0) * -5%), calc(var(--scene, 0) * 3%), 0)
    rotate(calc(var(--scene, 0) * 9deg));
  transition: transform 1.6s var(--ease);
}

.ob__bg i {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.6;
  will-change: transform;
  animation: drift 22s ease-in-out infinite alternate;
}

.ob__bg i:nth-child(1) {
  background: var(--blob-1);
  top: 0;
  left: 0;
}
.ob__bg i:nth-child(2) {
  background: var(--blob-2);
  bottom: 0;
  right: 0;
  animation-duration: 27s;
  animation-delay: -7s;
}
.ob__bg i:nth-child(3) {
  background: var(--blob-3);
  top: 38%;
  left: 34%;
  width: 44vmax;
  height: 44vmax;
  opacity: 0.4;
  animation-duration: 31s;
  animation-delay: -13s;
}

@keyframes drift {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(7%, 9%) scale(1.1);
  }
  100% {
    transform: translate(-5%, 4%) scale(0.95);
  }
}

.ob__top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 6px;
}

/* Hidden but still holding their place, so the progress bar doesn't jump. */
.ob__back[hidden],
.ob__skip[hidden] {
  display: grid !important;
  visibility: hidden;
}

.ob__back {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--text);
  flex-shrink: 0;
}

[dir='rtl'] .ob__back svg {
  transform: scaleX(-1);
}

.ob__progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  padding: 0;
}

.ob__progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.6s var(--ease);
}

.ob__skip {
  min-width: 52px;
  height: 42px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

.ob__stage {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
}

/* Pages glide and un-blur in, the old one blurs away the other side. */
.ob-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 24px 16px;
  transition:
    transform 0.6s var(--ease),
    opacity 0.45s ease,
    filter 0.5s ease;
}

.ob-page.from-fwd {
  transform: translateX(56px) scale(0.98);
  opacity: 0;
  filter: blur(14px);
}
.ob-page.from-back {
  transform: translateX(-56px) scale(0.98);
  opacity: 0;
  filter: blur(14px);
}
.ob-page.to-fwd {
  transform: translateX(-56px) scale(0.98);
  opacity: 0;
  filter: blur(14px);
  pointer-events: none;
}
.ob-page.to-back {
  transform: translateX(56px) scale(0.98);
  opacity: 0;
  filter: blur(14px);
  pointer-events: none;
}
[dir='rtl'] .ob-page.from-fwd,
[dir='rtl'] .ob-page.to-back {
  transform: translateX(-56px) scale(0.98);
}
[dir='rtl'] .ob-page.from-back,
[dir='rtl'] .ob-page.to-fwd {
  transform: translateX(56px) scale(0.98);
}

.ob-form--scroll {
  justify-content: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 18px;
  padding-bottom: 28px;
  -webkit-overflow-scrolling: touch;
}

.ob-head {
  margin-bottom: 26px;
}

.ob-title {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.ob-sub {
  margin-top: 9px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ---- welcome ------------------------------------------------------ */

.ob-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ob-logo {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 30px;
  margin-bottom: 22px;
}

.ob-logo__bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
}

.ob-logo__bars i {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  background: var(--accent);
  animation: bars 2.4s ease-in-out infinite;
}

.ob-logo__bars i:nth-child(2) {
  animation-delay: -0.3s;
}
.ob-logo__bars i:nth-child(3) {
  animation-delay: -0.6s;
}
.ob-logo__bars i:nth-child(4) {
  animation-delay: -0.9s;
}
.ob-logo__bars i:nth-child(5) {
  animation-delay: -1.2s;
}
.ob-logo__bars i:nth-child(6) {
  animation-delay: -1.5s;
}

@keyframes bars {
  0%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.45);
  }
}

.ob-wordmark {
  font-size: 52px;
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
}

.ob-tagline {
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 24ch;
}

.ob-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 36px;
}

.ob-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 600;
  text-align: start;
  opacity: 0;
  animation: rise 0.7s var(--ease) forwards;
  animation-delay: calc(0.25s + var(--i) * 0.1s);
}

.ob-feature__e {
  font-size: 20px;
}

/* ---- name --------------------------------------------------------- */

.ob-field {
  display: block;
  padding: 2px 20px;
  border-radius: 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}

.ob-field:focus-within {
  border-color: var(--accent);
}

.ob-input {
  width: 100%;
  height: 60px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.ob-input::placeholder {
  color: var(--text-faint);
  font-weight: 400;
}

.ob-hello {
  min-height: 28px;
  margin-top: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-ink);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.4s ease,
    transform 0.5s var(--spring);
}

.ob-hello.is-on {
  opacity: 1;
  transform: none;
}

/* ---- cards (one choice) -------------------------------------------- */

.ob-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ob-card {
  display: flex;
  align-items: center;
  gap: 15px;
  width: 100%;
  padding: 18px 18px;
  border-radius: 24px;
  text-align: start;
}

.ob-cards--compact .ob-card {
  padding: 14px 16px;
  border-radius: 20px;
}

.ob-card[aria-pressed='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--glass-bg));
}

.ob-card__glyph {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-edge);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.ob-card__meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
  width: 30px;
  flex-shrink: 0;
}

.ob-card__meter i {
  width: 4px;
  border-radius: 2px;
  background: var(--border-strong);
}
.ob-card__meter i:nth-child(1) {
  height: 30%;
}
.ob-card__meter i:nth-child(2) {
  height: 45%;
}
.ob-card__meter i:nth-child(3) {
  height: 62%;
}
.ob-card__meter i:nth-child(4) {
  height: 80%;
}
.ob-card__meter i:nth-child(5) {
  height: 100%;
}
.ob-card__meter i.on {
  background: var(--accent);
}

.ob-card__text {
  flex: 1;
  min-width: 0;
}
.ob-card__label {
  display: block;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.ob-card__desc {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
}
.ob-cards--compact .ob-card__label {
  font-size: 16px;
}
.ob-cards--compact .ob-card__desc {
  font-size: 13px;
}

.ob-card__tick {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  color: var(--on-accent);
  flex-shrink: 0;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.ob-card__tick svg {
  transform: scale(0);
  transition: transform 0.45s var(--spring);
}
.ob-card[aria-pressed='true'] .ob-card__tick {
  background: var(--accent);
  border-color: var(--accent);
}
.ob-card[aria-pressed='true'] .ob-card__tick svg {
  transform: scale(1);
}

/* ---- chips (many choices) ------------------------------------------ */

.ob-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* No backdrop blur per chip: dozens of them would be heavy to draw. */
.ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 15px;
  border-radius: 999px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 var(--glass-hi),
    0 2px 10px rgba(28, 40, 34, 0.05);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.ob-chip__e {
  font-size: 17px;
}

.ob-chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent);
}

.ob-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.ob-search__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

.ob-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.ob-group__title {
  margin: 22px 4px 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ob-none {
  margin-top: 24px;
  text-align: center;
  color: var(--text-muted);
}

/* ---- the "why we ask" page ------------------------------------------ */

.ob-why__card {
  padding: 28px 24px;
  border-radius: 28px;
}

.ob-why__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  margin-bottom: 18px;
  background: var(--accent-tint);
  color: var(--accent);
}

.ob-why__q {
  margin-top: 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.ob-why__card .ob-sub {
  margin-top: 4px;
}

.ob-why__private {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-line);
  font-size: 13px;
  color: var(--text-muted);
}

/* ---- ruler ---------------------------------------------------------- */

.ruler {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.ruler__value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  direction: ltr;
}

.ruler__num {
  width: 3.6ch;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: center;
  font-size: 68px;
  font-weight: 600;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding: 0;
}

.ruler__num:focus {
  color: var(--accent);
}
.ruler__unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
}

.ruler__track {
  position: relative;
  width: 100%;
  height: 92px;
  border-radius: 24px;
  overflow: hidden;
  direction: ltr;
}

.ruler__scroll {
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent);
}

.ruler__scroll::-webkit-scrollbar {
  display: none;
}

.ruler__ticks {
  display: flex;
  height: 100%;
  width: max-content;
  padding-inline: calc(50% - 6px);
}

.ruler__tick {
  position: relative;
  flex: 0 0 12px;
  height: 100%;
  scroll-snap-align: center;
}

.ruler__tick::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 5px;
  width: 2px;
  height: 16px;
  border-radius: 1px;
  background: var(--border-strong);
}

.ruler__tick.is-mid::before {
  height: 24px;
}
.ruler__tick.is-major::before {
  height: 34px;
  background: var(--text-muted);
}

.ruler__tick.is-major::after {
  content: attr(data-label);
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ruler__needle {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 4px;
  height: 46px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}

.ruler__steppers {
  display: flex;
  gap: 16px;
}

.ruler__step {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

/* ---- summary -------------------------------------------------------- */

.ob-kcal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 22px 22px;
  border-radius: 28px;
  text-align: center;
}

.ob-kcal__ring {
  width: 190px;
  height: 190px;
  transform: rotate(-90deg);
}
.ob-kcal__ring circle {
  fill: none;
  stroke-width: 10;
}
.ob-kcal__ring .track {
  stroke: var(--glass-line);
  stroke: color-mix(in srgb, var(--text) 8%, transparent);
}
.ob-kcal__ring .fill {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s var(--ease);
}

.ob-kcal__center {
  position: absolute;
  top: 26px;
  left: 50%;
  width: 190px;
  height: 190px;
  margin-left: -95px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ob-kcal__icon {
  color: var(--accent);
}

.ob-kcal__num {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.ob-kcal__unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.ob-kcal__facts {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}
.ob-kcal__facts p + p {
  margin-top: 3px;
}
.ob-kcal__note {
  margin-top: 10px !important;
  font-size: 12px;
  color: var(--text-faint);
}
.ob-kcal.is-empty {
  padding: 22px;
}

.ob-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.ob-tag {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-edge);
  font-size: 13px;
  font-weight: 600;
}

/* ---- footer --------------------------------------------------------- */

.ob__foot {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 24px calc(env(safe-area-inset-bottom) + 18px);
}

.ob__cta {
  height: 58px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--on-accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 60%), var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 12px 26px color-mix(in srgb, var(--accent) 34%, transparent);
}

.ob__cta:disabled {
  color: var(--text-faint);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  border: 1px solid var(--glass-edge);
  cursor: default;
}

.ob__later {
  height: 40px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

@media (max-height: 700px) {
  .ob-title {
    font-size: 28px;
  }
  .ob-head {
    margin-bottom: 18px;
  }
  .ob-features {
    margin-top: 24px;
  }
  .ob-card {
    padding: 14px 16px;
  }
  .ruler__num {
    font-size: 56px;
  }
}

/* ---- the account page ------------------------------------------------ */

.ob-account > * {
  flex-shrink: 0;
}

.ob-account__tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 20px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
}

.ob-account__tab {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 15px;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
}

.ob-account__tab[aria-pressed='true'] {
  background: var(--accent);
  color: var(--on-accent);
}

.ob-account__tab:focus-visible,
.ob-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.ob-account__field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 12px 18px;
}

.ob-account__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.ob-account__field .ob-input {
  padding: 6px 0;
  font-size: 18px;
  height: 36px;
  min-height: 30px;
}

.ob-account__hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 2px 0 12px;
}

.ob-account__sent {
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-muted);
}

.ob-input--code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

.ob-account__links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ob-link {
  padding: 6px 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
}

.ob-link:disabled {
  opacity: 0.5;
}

.ob-account__status {
  min-height: 20px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
}

.ob-account__status.is-error {
  color: var(--danger);
}

.ob-account__done {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-ink);
}

/* ---- consent switch on the "why we ask" page ------------------------- */

.ob-consent {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 18px 20px;
  border-radius: 22px;
  cursor: pointer;
}

.ob-consent__text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.ob-consent__label {
  font-size: 16px;
  font-weight: 600;
}

.ob-consent__body {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Same clearly visible switch on every browser, with a 44px tap target.
 * The enclosing label also makes the whole consent card tappable. */
.ob-consent__switch {
  flex: none;
  direction: ltr;
  appearance: none;
  -webkit-appearance: none;
  width: 64px;
  height: 44px;
  margin: 0;
  padding: 5px;
  border: 2px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.ob-consent__switch::after {
  content: '';
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.ob-consent__switch:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.ob-consent__switch:checked::after {
  transform: translateX(20px);
  background: #fff;
}

.ob-consent__switch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

/* Tester code in Settings: an input and its button on one line. */
.tester {
  display: flex;
  gap: 8px;
}

.tester__input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: 16px;
}

.tester__input:focus {
  outline: none;
  border-color: var(--accent);
}

.tester__save {
  padding: 0 18px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

/* Premium in Settings: "See plans" or "Manage subscription". */
.premium__action {
  width: 100%;
  height: 46px;
}

.tester__remove {
  margin: 6px 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

.group__note.is-error {
  color: var(--danger);
}

.group__note--top {
  margin: 0 4px 10px;
}

/* "Continue with Google" on the account page, and the "or" under it. */
.ob-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 56px;
  margin-top: 14px;
  border-radius: 20px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.ob-google:disabled {
  opacity: 0.6;
}

.ob-or {
  margin: 14px 0 4px;
  font-size: 13px;
  text-align: center;
  color: var(--text-muted);
}

/* Under the strictness and personality pages: nothing here is final. */
.ob-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}
