/* ==========================================================================
   Voice Shopping Assistant — SaaS dashboard skin.
   Mobile-first · zero external assets · system fonts only · light + dark.
   Every colour, radius and shadow is a token declared once in :root.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* ---- surfaces ---- */
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eef2f7;
  --border: #eef2f7;
  --border-strong: #e4e9f0;
  --divider: #eef2f7;

  /* ---- ink ---- */
  --text: #0f172a;
  --muted: #667085;

  /* ---- accent ---- */
  --accent: #2f80ed;
  --accent-strong: #2563eb;
  --accent-soft: #eaf2ff;
  --accent-ink: #ffffff;
  --grad-accent: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  --grad-btn: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  --grad-mic: linear-gradient(160deg, #3b82f6 0%, #1d4ed8 100%);
  --grad-mic-live: linear-gradient(160deg, #f97066 0%, #b42318 100%);

  /* ---- semantic ---- */
  --success: #067647;
  --success-soft: #e7f7ee;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --warning: #b54708;
  --warning-soft: #fdf3e6;
  --violet: #6941c6;
  --violet-soft: #f4f0ff;
  --teal: #0e7490;
  --teal-soft: #e6f6fa;

  /* ---- geometry ---- */
  --radius-card: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, 0.10), 0 2px 6px rgba(16, 24, 40, 0.06);
  --shadow-btn: 0 1px 2px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(37, 99, 235, 0.18);
  --focus-ring: 0 0 0 3px rgba(47, 128, 237, 0.15);
  --tap: 44px;
  --page: 1200px;
  --pad: 16px;
  --gap: 20px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', 'Noto Sans Devanagari', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0b1220;
    --surface: #111a2e;
    --surface-2: #17223a;
    --surface-3: #1e293b;
    --border: #1e293b;
    --border-strong: #26334b;
    --divider: #1e293b;

    --text: #e8eef9;
    --muted: #94a3b8;

    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: #16294a;
    --accent-ink: #06122b;

    --success: #6ee7b7;
    --success-soft: #0b3226;
    --danger: #fca5a5;
    --danger-soft: #3a1618;
    --warning: #fbbf6e;
    --warning-soft: #3a2a12;
    --violet: #c4b5fd;
    --violet-soft: #272150;
    --teal: #67e8f9;
    --teal-soft: #0d3340;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.36), 0 1px 3px rgba(0, 0, 0, 0.30);
    --shadow-pop: 0 10px 28px rgba(0, 0, 0, 0.50);
    --shadow-btn: 0 1px 3px rgba(0, 0, 0, 0.45);
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.28);
  }
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 calc(2.5rem + env(safe-area-inset-bottom));
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-offline { background: var(--canvas); }

h1, h2, h3, h4, p, ul, figure { margin: 0; }
ul { list-style: none; padding: 0; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 40;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--grad-btn);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-pop);
  transition: top 130ms ease;
}
.skip-link:focus { top: calc(12px + env(safe-area-inset-top)); }

/* Shared page gutter for the three top-level landmarks. */
.topbar,
.offline-banner,
.main {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: max(var(--pad), env(safe-area-inset-left));
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-bottom: 14px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  font-size: 18px;
  line-height: 1;
}
.brand-name { white-space: nowrap; }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-field { display: inline-flex; align-items: center; }

.lang-select {
  min-height: var(--tap);
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.lang-select:focus-visible { box-shadow: var(--focus-ring); }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
}
.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background 150ms ease;
  flex: none;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
  transition: transform 160ms ease;
}
.switch-label { white-space: nowrap; }
.switch[aria-pressed='true'] { color: var(--text); border-color: var(--accent); }
.switch[aria-pressed='true'] .switch-track { background: var(--grad-btn); }
.switch[aria-pressed='true'] .switch-thumb { transform: translateX(14px); }

.tagline {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

/* --------------------------------------------------------------- offline */

.offline-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.offline-banner[hidden] { display: none; }
.offline-dot {
  margin-top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  flex: none;
}
.offline-text {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: var(--text);
}
.offline-text strong { font-size: 13px; font-weight: 700; }

/* ------------------------------------------------------------ card shell */

.main {
  display: grid;
  gap: var(--gap);
  align-items: start;
  padding-top: 4px;
}

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-header-actions { display: flex; align-items: center; gap: 6px; }

.panel-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* Small header control (count / status), spec B. */
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill:empty { display: none; }

/* ------------------------------------------------------------- stat tiles */

.stat-row {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.stat-row:empty { display: none; }

.stat-tile {
  display: grid;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-chip {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.stat-glyph { width: 18px; height: 18px; fill: currentColor; }
.stat-chip-blue { background: var(--accent-soft); color: var(--accent-strong); }
.stat-chip-green { background: var(--success-soft); color: var(--success); }
.stat-chip-violet { background: var(--violet-soft); color: var(--violet); }
.stat-chip-teal { background: var(--teal-soft); color: var(--teal); }

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.stat-pill-good { background: var(--success-soft); color: var(--success); }
.stat-pill-action { background: var(--danger-soft); color: var(--danger); }
.stat-pill-neutral { background: var(--surface-2); color: var(--muted); }

.stat-desc { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------------- voice */

.voice-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 20px 24px;
  background:
    radial-gradient(120% 130% at 50% -20%, var(--accent-soft) 0%, var(--surface) 62%);
}

.mic {
  position: relative;
  width: 96px;
  height: 96px;
  border: none;
  border-radius: 50%;
  background: var(--grad-mic);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28), 0 2px 4px rgba(16, 24, 40, 0.12);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 130ms ease, filter 130ms ease, box-shadow 130ms ease;
}
.mic:hover { filter: brightness(1.07); }
.mic:active { transform: scale(0.96); }
.mic:disabled { opacity: 0.55; cursor: not-allowed; }
.mic:focus-visible { outline-offset: 6px; }
.mic-glyph { width: 42px; height: 42px; fill: currentColor; position: relative; z-index: 1; }

.mic-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
}
.mic.is-listening .mic-ring { animation: pulse 1.8s ease-out infinite; }
.mic.is-listening .mic-ring-2 { animation-delay: 0.9s; }
.mic.is-listening {
  background: var(--grad-mic-live);
  box-shadow: 0 10px 24px rgba(180, 35, 24, 0.28);
}
.mic.is-listening .mic-ring { border-color: #f97066; }
.mic.is-processing { filter: saturate(0.55); }
.mic.is-processing .mic-glyph { animation: breathe 1.1s ease-in-out infinite; }
.mic.is-unavailable {
  background: var(--surface-3);
  color: var(--muted);
  box-shadow: none;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.75); opacity: 0; }
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.mic-state {
  min-height: 1.5em;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.note {
  display: grid;
  gap: 10px;
  justify-items: start;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.note[hidden] { display: none; }
.note-text { font-size: 14px; color: var(--text); }

/* ------------------------------------------------- transcript + understood */

.transcript-card[hidden],
.understanding-card[hidden],
.search-card[hidden] { display: none; }

.transcript-card { border-left: 3px solid var(--accent); }
.transcript-text {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.transcript-text.is-interim { color: var(--muted); font-weight: 500; }
.transcript-text.is-interim::after {
  content: '▌';
  margin-left: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.understanding-card { border-left: 3px solid var(--violet); }
.understanding-body { display: grid; gap: 14px; margin-top: 14px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

/* Data chip: label above value (spec D) — reads as designed data, not debug output. */
.chip {
  display: inline-grid;
  gap: 1px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  max-width: 100%;
}
.chip-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.chip-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}
.chip-intent {
  background: var(--grad-btn);
  border-color: transparent;
}
.chip-intent .chip-label { color: rgba(255, 255, 255, 0.82); }
.chip-intent .chip-value { color: #ffffff; }
.chip-product { background: var(--accent-soft); border-color: var(--accent-soft); }
.chip-product .chip-value { color: var(--accent-strong); }
.chip-price { background: var(--warning-soft); border-color: var(--warning-soft); }
.chip-price .chip-value { color: var(--warning); }
.chip-rule { background: var(--surface); }
.chip-rule .chip-value { font-family: var(--mono); font-size: 12px; }
.chip-index {
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.confidence {
  display: grid;
  gap: 7px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.confidence-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.confidence-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.confidence-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.confidence-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.confidence-fill {
  display: block;
  height: 100%;
  width: calc(var(--confidence, 0) * 100%);
  border-radius: var(--radius-pill);
  transition: width 340ms ease;
}
.confidence-fill.is-high { background: var(--grad-accent); }
.confidence-fill.is-medium { background: var(--warning); }
.confidence-fill.is-low { background: var(--danger); }

.understanding-hint { font-size: 14px; color: var(--muted); }

/* --------------------------------------------------------- status + errors */

.status-line {
  min-height: 1.3em;
  margin: -8px 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.error-region:empty { display: none; }

.error-banner {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-card);
  background: var(--danger-soft);
  box-shadow: var(--shadow-card);
}
.error-body { display: grid; gap: 3px; }
.error-title { font-size: 14px; font-weight: 700; color: var(--danger); }
.error-message { font-size: 14px; color: var(--text); }
.error-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ inputs */

.input-card { display: grid; gap: 12px; }

.input-row { display: flex; gap: 10px; }
.input-row-secondary { margin-top: 0; }

.text-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--tap);
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
.text-input::placeholder { color: var(--muted); }
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.text-input:focus-visible { outline: none; }

.input-hint { margin-top: -4px; font-size: 12px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  /* Deliberately NOT nowrap: the localized labels (hi/es/fr) are much longer than the
     English ones and must wrap inside the button rather than overflow a 360px screen. */
  transition: filter 130ms ease, transform 130ms ease, background 130ms ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-text { display: inline-block; }

.btn-primary {
  background: var(--grad-btn);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover { filter: brightness(1.07); }

.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: transparent;
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--muted);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 13px; }
.btn.is-armed { box-shadow: var(--shadow-btn), 0 0 0 3px var(--accent-soft); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- examples */

.examples {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}
.examples-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.examples-summary::marker { color: var(--muted); }
.examples-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.example-item { display: flex; max-width: 100%; }
.example-btn {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
}
.example-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}

/* -------------------------------------------------------------------- list */

.list-body { display: grid; gap: 20px; }

.group { display: grid; gap: 10px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-icon { font-size: 15px; line-height: 1; }
.group-name { overflow-wrap: anywhere; }
.group-count {
  margin-left: auto;
  min-width: 22px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  letter-spacing: 0;
}

.items { display: grid; gap: 8px; }

.item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'check main del'
    'check stepper price';
  align-items: center;
  gap: 6px 12px;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 130ms ease, background 130ms ease;
}
.item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.item.is-checked { background: var(--surface-2); opacity: 0.7; }
.item.is-checked .item-name { text-decoration: line-through; }

.item-check {
  grid-area: check;
  width: 20px;
  height: 20px;
  margin: 0 6px 0 2px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}
.item-main {
  grid-area: main;
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 4px 0;
  cursor: pointer;
}
.item-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: 12px; color: var(--muted); }

.stepper {
  grid-area: stepper;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
.stepper-btn {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 130ms ease;
}
.stepper-btn:hover { background: var(--surface-2); }
.stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; background: transparent; }
.stepper-value {
  min-width: 3ch;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.item-price {
  grid-area: price;
  justify-self: end;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.item-delete { grid-area: del; justify-self: end; background: transparent; }
.item-delete:hover { background: var(--danger-soft); color: var(--danger); }

.list-footer {
  display: grid;
  gap: 14px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}
.total-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.total-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.total-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.footer-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.footer-actions .btn { flex: 1 1 auto; }

/* ------------------------------------------------------------- suggestions */

.suggestions-body { display: grid; gap: 22px; }

.suggestion-group { display: grid; gap: 10px; }
.suggestion-group-title {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--divider);
}
.suggestion-group-title::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--muted);
  flex: none;
}
.group-history .suggestion-group-title::before { background: var(--accent); }
.group-seasonal .suggestion-group-title::before { background: var(--success); }
.group-substitutes .suggestion-group-title::before { background: var(--violet); }

.suggestion-list { display: grid; gap: 10px; }

.suggestion,
.result {
  position: relative;
  padding: 14px 66px 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
.suggestion:hover,
.result:hover { border-color: var(--border-strong); box-shadow: var(--shadow-card); }

.suggestion-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.suggestion-icon { font-size: 15px; }
.suggestion-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.suggestion-price {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* The recommender's explanation is the most important text on the page. */
.suggestion-reason {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.suggestion-add,
.result-add {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: var(--tap);
  min-width: var(--tap);
  height: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.suggestion-add:active,
.result-add:active { transform: translateY(-50%) scale(0.94); }

/* ------------------------------------------------------------------ search */

.search-results { display: grid; }
.result-list { display: grid; gap: 10px; }
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.result-title { display: grid; gap: 2px; min-width: 0; }
.result-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.result-brand { font-size: 12px; color: var(--muted); }
.result-prices { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.result-was {
  color: var(--muted);
  font-size: 13px;
  text-decoration: line-through;
}
.result-price {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sale-badge {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.reasons { margin-top: 10px; }
.reason-list { display: grid; gap: 4px; }
.reason {
  position: relative;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.reason::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--success);
  font-weight: 700;
}

/* --------------------------------------------------------- empty + loading */

.empty-state {
  display: grid;
  gap: 6px;
  padding: 32px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  text-align: center;
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-hint { font-size: 13px; color: var(--muted); }

.skeleton-wrap { display: grid; gap: 10px; }
.skeleton-row {
  height: 58px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ------------------------------------------------------------------ toasts */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(94vw, 440px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 13px 16px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  animation: rise 200ms ease;
}
.toast-info { border-left-color: var(--accent); }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------- responsive tiers */

/* Compact 2x2 KPI block so the mic stays above the fold one-handed. */
@media (max-width: 640px) {
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .stat-tile { padding: 14px; gap: 8px; }
  .stat-value { font-size: 24px; }
  .stat-chip { width: 32px; height: 32px; border-radius: 9px; }
  .stat-glyph { width: 16px; height: 16px; }
  .stat-desc { font-size: 11px; }
  .main { gap: 16px; }
  .card { padding: 16px; }
  .voice-card { padding: 24px 16px 20px; }
  .input-row { flex-wrap: wrap; }
  .input-row .btn { flex: 1 1 100%; }
  .footer-actions .btn { flex: 1 1 100%; }
  .item { padding: 10px 8px 10px 10px; gap: 6px 8px; }
  .transcript-text { font-size: 18px; }
}

@media (min-width: 641px) {
  :root { --pad: 24px; }
  .card { padding: 24px; }
  .mic { width: 112px; height: 112px; }
  .mic-glyph { width: 48px; height: 48px; }
  .footer-actions .btn { flex: 0 1 auto; }
  .input-row .btn { min-width: 116px; }
}

/* Wide: cards use their width instead of stretching one row per item. */
@media (min-width: 900px) {
  .items { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .suggestion-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .result-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .input-row { flex-wrap: nowrap; }
}

/* The list and the suggestions are the only always-present siblings, so they are
   the only pair it is safe to put side by side with plain auto-placement. */
@media (min-width: 1080px) {
  .main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main > * { grid-column: 1 / -1; }
  .list-card { grid-column: 1; }
  .suggestions-card { grid-column: 2; }
  .items,
  .suggestion-list,
  .result-list { grid-template-columns: minmax(0, 1fr); }
  .result-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .voice-card { padding: 36px 24px 28px; }
}

/* -------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .mic.is-listening { outline: 3px solid var(--danger); outline-offset: 5px; }
  .skeleton-row { background: var(--surface-2); }
}

/* ----------------------------------------------------------- high contrast */

@media (forced-colors: active) {
  .card,
  .stat-tile,
  .item,
  .suggestion,
  .result { border: 1px solid CanvasText; }
}
