:root {
  --ink: #0b0d12;
  --soft: #5b6170;
  --faint: #8a90a0;
  --line: #e6e8ee;
  --bubble: #eef0f4;
  --accent: #0b3b8c;
  --ok: #0f7a4a;
  --ok-bg: #e7f5ee;
  --warn: #9a5b00;
  --warn-bg: #fff3df;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #fff; color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

header {
  flex: none; display: flex; align-items: center; gap: 10px; height: 64px;
  padding: max(env(safe-area-inset-top), 12px) 20px 0;
}
.mark { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.mark::after { content: ""; width: 11px; height: 11px; border-radius: 50%; background: #fff; }
header h1 { font-size: 23px; font-weight: 650; letter-spacing: -0.02em; flex: 1; }
.key { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.key svg { width: 15px; height: 15px; }

main { flex: 1; min-height: 0; overflow-y: auto; position: relative; padding: 8px 20px 24px; scroll-behavior: smooth; }
.empty { position: absolute; left: 20px; right: 20px; top: 30%; font-size: clamp(34px, 10vw, 44px); font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }
.thread:not(:empty) ~ .empty { display: none; }
.enroll { position: absolute; left: 20px; right: 20px; top: 26%; }
.enroll h2 { font-size: 34px; letter-spacing: -0.03em; margin-bottom: 12px; }
.enroll p { font-size: 18px; line-height: 1.45; color: var(--soft); }
.thread { display: flex; flex-direction: column; gap: 22px; padding-top: 12px; }

/* Chef's messages */
.chef { align-self: flex-end; max-width: 88%; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; animation: rise .3s var(--ease) both; }
.said { background: var(--bubble); border-radius: 22px 22px 8px 22px; padding: 14px 18px; font-size: 21px; line-height: 1.34; letter-spacing: -0.01em; }
.said .w { transition: background .25s, color .25s; padding: 2px 0; }
.said .w.lit { background: #d6e2f7; color: var(--accent); }
.said.pending { color: var(--faint); }
.meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--soft); }
.meta .play { width: 28px; height: 28px; border-radius: 50%; background: var(--bubble); display: grid; place-items: center; }
.meta .play svg { width: 13px; height: 13px; fill: var(--ink); stroke: none; }
.meta .sig { display: flex; align-items: center; gap: 5px; }
.meta .sig svg { width: 13px; height: 13px; }

/* Aimo's replies */
.aimo { display: flex; gap: 12px; align-items: flex-start; animation: rise .3s var(--ease) both; }
.aimo .mark { margin-top: 3px; }
.aimo p { font-size: 20px; font-weight: 600; line-height: 1.32; letter-spacing: -0.015em; }
.working { display: flex; gap: 12px; align-items: center; animation: rise .25s var(--ease) both; }
.working .dots { display: flex; gap: 6px; }
.working .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--soft); animation: dot 1s infinite ease-in-out; }
.working .dots i:nth-child(2) { animation-delay: .15s; }
.working .dots i:nth-child(3) { animation-delay: .3s; }
.working span { font-size: 16px; color: var(--soft); }

/* Order card: everything in it comes from Valio Aimo's server, never from the assistant's text */
.order { border-radius: 20px; background: #fff; box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(11, 13, 18, .07); overflow: hidden; animation: rise .35s var(--ease) both; }
.order .top { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 20px 6px; gap: 12px; }
.status { font-size: 14px; font-weight: 650; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.status.held { color: var(--warn); background: var(--warn-bg); }
.status.placed { color: var(--ok); background: var(--ok-bg); }
.status.rejected, .status.declined, .status.returned { color: var(--bad); background: var(--bad-bg); }
.status.verifying { color: var(--soft); background: var(--bubble); }
.when { font-size: 15px; color: var(--soft); white-space: nowrap; }
.lines { list-style: none; padding: 4px 0; }
.line { padding: 14px 20px; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line.removed { opacity: .4; }
.line.removed .name { text-decoration: line-through; }
.line .name { font-size: 17px; font-weight: 600; line-height: 1.3; }
.line .price { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.line .qty { font-size: 15px; color: var(--soft); font-variant-numeric: tabular-nums; }
.line .why { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 6px 11px; border-radius: 999px; background: var(--bubble); color: var(--ink); }
.chip svg { width: 13px; height: 13px; }
.chip.hear svg { fill: currentColor; stroke: none; }
.chip.hear { color: var(--accent); background: #e9effa; font-weight: 600; }
.chip.flag { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.chip.flag.unusual, .chip.flag.unclear, .chip.flag.unsigned { background: var(--warn-bg); color: var(--warn); }
.chip.note { color: var(--soft); }
.chip.remove { background: var(--ink); color: #fff; font-weight: 600; }
.reasons { list-style: none; padding: 4px 20px 0; display: flex; flex-direction: column; gap: 6px; }
.reasons li { font-size: 15px; line-height: 1.4; color: var(--warn); padding-left: 18px; position: relative; }
.reasons li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.total { display: flex; justify-content: space-between; padding: 14px 20px; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); margin-top: 10px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 20px 16px; font-size: 13px; color: var(--soft); }
.checks span { display: inline-flex; align-items: center; gap: 4px; }
.checks svg { width: 13px; height: 13px; stroke-width: 2.4; }
.checks .ok svg { color: var(--ok); }
.checks .no svg { color: var(--bad); }
.checks .ms { margin-left: auto; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 10px; padding: 0 16px 16px; }
.approve { flex: 1; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; font-size: 18px; font-weight: 650; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 8px 20px rgba(11, 59, 140, .25); transition: transform .15s var(--ease); }
.approve:active { transform: scale(.98); }
.approve svg { width: 24px; height: 24px; }
.decline { height: 56px; padding: 0 18px; border-radius: 16px; background: var(--bubble); font-size: 17px; font-weight: 600; }
.done { padding: 0 20px 18px; font-size: 15px; color: var(--ok); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.done svg { width: 18px; height: 18px; stroke-width: 2.4; flex: none; }
.done { line-height: 1.35; }

footer { flex: none; padding: 10px 20px max(env(safe-area-inset-bottom), 20px); }
.controls { display: flex; align-items: center; justify-content: center; gap: 22px; }
.kbd, .kbd-spacer { width: 48px; height: 48px; flex: none; }
.kbd { border-radius: 50%; background: var(--bubble); display: grid; place-items: center; color: var(--soft); }
.kbd svg { width: 24px; height: 24px; }
.typed { display: flex; gap: 8px; margin-bottom: 12px; }
.typed input { flex: 1; min-width: 0; height: 52px; border-radius: 26px; border: 0; background: var(--bubble); padding: 0 20px; font: inherit; font-size: 18px; outline: none; }
.typed input:focus { box-shadow: 0 0 0 2px var(--accent); }
.typed button { height: 52px; padding: 0 20px; border-radius: 26px; background: var(--accent); color: #fff; font-weight: 650; font-size: 17px; }

.mic {
  position: relative; width: 80px; height: 80px; border-radius: 40px; flex: none;
  background: var(--accent); color: #fff; overflow: hidden; box-shadow: 0 10px 30px rgba(11, 59, 140, .28);
  transition: width .45s var(--ease), transform .15s var(--ease);
}
.mic:active { transform: scale(.96); }
body.listening .mic { width: min(300px, 70vw); }
body.listening .kbd, body.listening .kbd-spacer { display: none; }
.mic > * { position: absolute; transition: opacity .25s, transform .35s var(--ease); }
.icon { inset: 0; display: grid; place-items: center; }
.icon svg { width: 32px; height: 32px; }
.rec { inset: 0; display: flex; align-items: center; gap: 14px; padding: 0 14px 0 24px; opacity: 0; transform: scale(.9); pointer-events: none; }
.time { flex: none; width: 44px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wave { flex: 1; height: 38px; display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.wave i { width: 4px; height: 100%; border-radius: 2px; background: #fff; transform: scaleY(.1); transition: transform .08s linear; }
.stop { flex: none; width: 50px; height: 50px; border-radius: 25px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; }
.stop::after { content: ""; width: 17px; height: 17px; border-radius: 5px; background: #fff; }
.spin { inset: 23px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; opacity: 0; animation: spin .8s linear infinite; }
body.listening .icon, body.sending .icon { opacity: 0; transform: scale(.6); }
body.listening .rec { opacity: 1; transform: none; transition-delay: .12s; }
body.sending .spin { opacity: 1; }

.toast { position: fixed; left: 50%; bottom: 130px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px; max-width: 86vw; animation: rise .3s var(--ease) both; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
