:root {
  --navy: #003366;
  --navy-600: #0a4a85;
  --navy-050: #e8f0fa;
  --bg: #f1f4f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --header-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #2563eb;
    --navy-600: #3b82f6;
    --navy-050: #10243f;
    --bg: #0b1220;
    --surface: #131c2e;
    --ink: #e7ecf5;
    --muted: #93a2bb;
    --line: #223049;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px; line-height: 1.5;
  overscroll-behavior: none;
}

/* ---------------------------------------------------------------- header */
.app { display: flex; flex-direction: column; height: 100dvh; }

header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--navy); color: #fff; flex: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12); z-index: 10;
}
.logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: rgba(255, 255, 255, .16); color: #fff;
  display: grid; place-items: center;
}
.title { flex: 1; min-width: 0; }
.title h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.title .sub { font-size: 12px; opacity: .8; }
.icon-btn {
  width: 38px; height: 38px; border: 0; border-radius: 12px; flex: none;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 17px;
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, background .15s;
}
.icon-btn:active { transform: scale(.92); background: rgba(255, 255, 255, .26); }

/* ------------------------------------------------------------- messages */
#messages {
  flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px 20px;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
/* Flex children shrink to fit by default, which squashed the detail and quote
   panels into thin strips once the conversation grew taller than the screen. */
#messages > * { flex: 0 0 auto; }

.row { display: flex; }
.row.me { justify-content: flex-end; }

.bubble {
  max-width: 85%; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
  white-space: pre-wrap; word-wrap: break-word;
  animation: pop .22s cubic-bezier(.22, 1, .36, 1);
}
.row.bot .bubble { border-bottom-left-radius: 6px; }
.row.me .bubble {
  background: var(--navy); color: #fff; border-bottom-right-radius: 6px;
}
.bubble b { font-weight: 700; }
.bubble a { color: inherit; }
.time { font-size: 10.5px; color: var(--muted); margin: 2px 6px 0; }
.row.me + .time { text-align: right; }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.typing { display: flex; gap: 4px; padding: 14px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite both;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------------------------------------------------------------- cards */
.cards { display: flex; flex-direction: column; gap: 8px; margin: 2px 0 4px; }
.cards .label { font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-left: 4px; }

.card {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: 16px; padding: 13px 15px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  font: inherit; color: inherit; transition: transform .12s, border-color .15s;
  animation: pop .22s cubic-bezier(.22, 1, .36, 1);
}
.card:active { transform: scale(.98); border-color: var(--navy); }
.card .emoji {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: var(--navy-050); display: grid; place-items: center; font-size: 19px;
}
.card .text { flex: 1; min-width: 0; }
.card .text strong { display: block; font-size: 15px; }
.card .text span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.card .chev { color: var(--muted); font-size: 18px; }
.card .price { font-weight: 800; color: var(--navy); white-space: nowrap; font-size: 15px; }

/* ----------------------------------------------------------- doc tracker */
.docs {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); margin: 2px 0 4px;
}
.docs h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.docs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.docs li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.docs li.todo {
  cursor: pointer; margin: 0 -8px; padding: 7px 8px; border-radius: 10px;
  transition: background .15s, transform .12s;
}
.docs li.todo:active { background: var(--navy-050); transform: scale(.99); }
.docs li .name { flex: 1; }
.docs li .add {
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  color: var(--navy); background: var(--navy-050); padding: 4px 9px; border-radius: 999px;
}
.docs .hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }
.docs .tick {
  width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 1.5px dashed var(--line); color: transparent; font-size: 12px;
}
.docs li.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.docs li.done span { color: var(--muted); text-decoration: line-through; }

/* --------------------------------------------------------------- action */
.action {
  display: block; text-align: center; text-decoration: none;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 15px;
  padding: 14px; border-radius: 14px; box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.22, 1, .36, 1);
}
.action.pay { background: linear-gradient(135deg, var(--navy), var(--navy-600)); }
.action:active { transform: scale(.98); }

/* -------------------------------------------------------------- composer */
.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; max-height: 110px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px;
  font: inherit; background: var(--bg); color: var(--ink); outline: none;
}
.composer textarea:focus { border-color: var(--navy); }
.round {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px; cursor: pointer;
  background: var(--bg); color: var(--ink); transition: transform .12s;
}
.round.send { background: var(--navy); color: #fff; }
.round:active { transform: scale(.9); }
.round:disabled { opacity: .45; }

.sheet {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .45);
  display: none; align-items: flex-end; z-index: 30;
}
.sheet.open { display: flex; }
.sheet .panel {
  width: 100%; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 14px);
  animation: up .22s cubic-bezier(.22, 1, .36, 1);
}
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet button {
  width: 100%; display: flex; align-items: center; gap: 12px; font: inherit; color: inherit;
  background: none; border: 0; padding: 14px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.sheet button:last-child { border: 0; }
.sheet .emoji { width: 38px; height: 38px; border-radius: 12px; background: var(--navy-050); display: grid; place-items: center; font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px;
  font-size: 13px; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: .95; }

/* a photo the customer sent, shown as a thumbnail rather than a filename */
.bubble.photo { padding: 4px; max-width: 62%; }
.bubble.photo img {
  display: block; width: 100%; max-height: 240px; object-fit: cover;
  border-radius: 14px;
}

/* ------------------------------------------------------------ voice mode */
.round.mic { background: var(--navy-050); color: var(--navy); }
.round.mic.on { background: #dc2626; color: #fff; transform: scale(1.06); }
.icon-btn.off { opacity: .45; }

.recording {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  display: none; align-items: center; gap: 9px;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 40; box-shadow: var(--shadow);
}
.recording.on { display: flex; }
.recording .pulse {
  width: 9px; height: 9px; border-radius: 50%; background: #ef4444;
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }

.bubble.speaking { box-shadow: 0 0 0 2px var(--navy), var(--shadow); }
.heard { font-style: italic; opacity: .9; }

/* --------------------------------------------------------- opening screen */
.choose {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
}
.choose.hidden { display: none; }

.hero {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-600) 100%);
  color: #fff; text-align: center; flex: none;
  padding: calc(env(safe-area-inset-top) + 42px) 24px 40px;
  border-radius: 0 0 28px 28px; box-shadow: 0 10px 30px rgba(0, 51, 102, .22);
}
.hero .mark {
  width: 70px; height: 70px; margin: 0 auto 16px; border-radius: 22px;
  background: rgba(255, 255, 255, .16); display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.hero h2 { margin: 0; font-size: 23px; letter-spacing: -.2px; }
.hero .tag { margin: 8px 0 0; font-size: 14.5px; opacity: .88; }

.points { list-style: none; margin: 22px 20px 4px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.points li { display: flex; align-items: center; gap: 13px; }
.points li > span {
  width: 40px; height: 40px; flex: none; border-radius: 13px; font-size: 18px;
  background: var(--navy-050); display: grid; place-items: center;
}
.points li div { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.points li strong { display: block; font-size: 14.5px; color: var(--ink); margin-bottom: 1px; }

.choices { display: flex; flex-direction: column; gap: 11px; margin: 22px 20px 0; }
.choice {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 15px; box-shadow: var(--shadow); transition: transform .12s, border-color .15s;
}
.choice:active { transform: scale(.98); border-color: var(--navy); }
.choice .emoji {
  width: 44px; height: 44px; flex: none; border-radius: 14px; font-size: 21px;
  background: var(--navy-050); display: grid; place-items: center;
}
.choice .text { flex: 1; }
.choice .text strong { display: block; font-size: 16px; }
.choice .text span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.choice .chev { color: var(--muted); font-size: 20px; }
.choice.primary {
  background: linear-gradient(135deg, var(--navy), var(--navy-600));
  color: #fff; border-color: transparent;
}
.choice.primary .emoji { background: rgba(255, 255, 255, .18); }
.choice.primary .text span, .choice.primary .chev { color: rgba(255, 255, 255, .8); }

.products {
  margin: 20px 20px 0; text-align: center; font-size: 11.5px; color: var(--muted);
  letter-spacing: .4px; text-transform: uppercase;
}

/* ------------------------------------------------------------- call mode */
body.voice .composer textarea { display: none; }
body.voice .round.send { display: none; }
body.voice .round.mic {
  flex: 1; width: auto; border-radius: 26px; height: 52px; font-size: 16px;
  background: var(--navy); color: #fff; gap: 10px;
}
body.voice .round.mic.on { background: #dc2626; }
body.voice .round.mic::after { content: "Hold to speak"; font-weight: 600; }
body.voice .round.mic.on::after { content: "Listening..."; }
body.voice .round { height: 52px; }

/* ------------------------------------------------- call mode: the assistant */
/* Omar is heard, not read. The strip shows that he is talking; the list below
   holds only what is worth looking at - your words, your photos, the numbers. */
.strip { display: none; }
body.voice .strip {
  display: flex; align-items: center; gap: 9px; flex: none;
  padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); letter-spacing: .2px;
}

.orb { position: relative; width: 22px; height: 22px; flex: none; display: block; }
.orb i {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #7cd4ff 0%, #2563eb 55%, #0b3d7a 100%);
}
.orb i:nth-child(2) {
  inset: -6px; background: none; border: 2px solid var(--navy); opacity: 0;
}
.orb.speaking i:nth-child(1) { animation: bloom 1.3s ease-in-out infinite; }
@keyframes bloom {
  50% { transform: scale(1.22); filter: brightness(1.25) saturate(1.3); }
}
.orb.listening i:nth-child(2) { animation: ripple 1.4s ease-out infinite; }
@keyframes ripple { 0% { opacity: .55; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.5); } }

/* Cards that live in the conversation on a call */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; animation: pop .22s cubic-bezier(.22, 1, .36, 1);
}
.panel h5 {
  margin: 0; padding: 11px 15px 7px; font-size: 11px; letter-spacing: .7px;
  text-transform: uppercase; color: var(--muted);
}
.panel .row-item {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 15px; font-size: 13.5px;
}
.panel .row-item span:first-child { color: var(--muted); }
.panel .row-item span:last-child { font-weight: 600; text-align: right; }
.panel .row-item.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; font-size: 15px; }
.panel .foot { padding: 9px 15px 13px; font-size: 11.5px; color: var(--muted); }

.doc-card {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer; border: 1px dashed var(--navy);
  background: var(--navy-050); border-radius: 16px; padding: 14px 15px;
  animation: pop .22s cubic-bezier(.22, 1, .36, 1);
}
.doc-card:active { transform: scale(.98); }
.doc-card .emoji { font-size: 21px; }
.doc-card strong { display: block; font-size: 15px; color: var(--navy); }
.doc-card span.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

body.voice .round.keyb { display: grid; }
body.voice .composer textarea, body.voice .round.send { display: none; }
body.voice.typing .round.mic { display: none; }
body.voice.typing .composer textarea { display: block; }
body.voice.typing .round.send { display: grid; }
.round.keyb { display: none; background: var(--bg); color: var(--muted); }
body.voice .round.mic {
  flex: 1; width: auto; border-radius: 22px; height: 44px; font-size: 14px;
  background: var(--navy); color: #fff; gap: 8px;
}
body.voice .round.mic.on { background: #dc2626; }
body.voice .round.mic::after { content: "Hold to speak"; font-weight: 600; }
body.voice .round.mic.on::after { content: "Listening..."; }

/* Chat is a typed conversation: no speaker, no microphone. Both of those
   belong to a call and appear only in voice mode. */
#voice-toggle { display: none; }
body.voice #voice-toggle { display: grid; }
body:not(.voice) .round.mic { display: none; }
