:root {
  color-scheme: light dark;

  --ink: #17150f;
  --ink-soft: #5d5648;
  --ink-faint: #8d8577;
  --ground: #f7f4ee;
  --panel: #fffdf9;
  --line: #e4ded1;
  --accent: #7b4b2a;
  --accent-ink: #fffdf9;
  --good: #2f6b46;
  --bad: #9a3b2f;
  --radius: 14px;
  --tap: 3rem; /* minimum comfortable thumb target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2ede3;
    --ink-soft: #b6ad9d;
    --ink-faint: #8a8172;
    --ground: #16150f;
    --panel: #201e17;
    --line: #333026;
    --accent: #d99a68;
    --accent-ink: #16150f;
    --good: #7fc79b;
    --bad: #e0897a;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- header --------------------------------------------------------------- */

.masthead-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lang-chip {
  flex: 0 0 auto;
  width: auto;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  min-height: 2rem;
}
.lang-chip::after { content: " ▾"; color: var(--ink-faint); }

.business {
  margin: 0.3rem 0 0.9rem;
  font-size: 1.45rem;
  line-height: 1.2;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.steps {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.68rem;
  color: var(--ink-faint);
}

.steps li {
  flex: 1;
  padding-top: 0.45rem;
  border-top: 2px solid var(--line);
  transition: color 0.2s, border-color 0.2s;
}
.steps li.is-done { border-color: var(--accent); color: var(--ink-soft); }
.steps li.is-current { border-color: var(--accent); color: var(--ink); font-weight: 600; }

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  flex: 1;
}

.card h2 { margin: 0 0 0.3rem; font-size: 1.2rem; font-weight: 620; letter-spacing: -0.01em; }
.card .sub { margin: 0 0 1.1rem; color: var(--ink-soft); font-size: 0.92rem; }

.stack { display: grid; gap: 0.55rem; }
.field { display: grid; gap: 0.55rem; margin-bottom: 1.4rem; }
.field .q { font-weight: 560; font-size: 0.95rem; }

/* --- buttons -------------------------------------------------------------- */

button, .btn {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.8rem 0.9rem;
  min-height: var(--tap);
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: block;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}

button:active, .btn:active { transform: scale(0.99); }
button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-weight: 560;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 640;
  text-align: center;
  min-height: 3.25rem;
  font-size: 1.02rem;
}

button.link {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  text-align: center;
  min-height: 2.5rem;
  padding: 0.4rem;
  font-size: 0.9rem;
}

/* big first-screen choices */
.big-choice { display: flex; align-items: center; gap: 0.9rem; padding: 0.9rem; min-height: 4.25rem; }
.big-emoji { font-size: 1.9rem; line-height: 1; }
.big-choice strong { display: block; font-weight: 580; }
.big-choice small { display: block; color: var(--ink-faint); font-size: 0.82rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chips button {
  width: auto;
  flex: 0 0 auto;
  padding: 0.6rem 0.9rem;
  min-height: 2.75rem;
  border-radius: 999px;
  font-size: 0.92rem;
  text-align: center;
}

/* five-tap scale, in place of a slider */
.scale-buttons { display: flex; gap: 0.35rem; }
.scale-btn {
  flex: 1;
  width: auto;
  padding: 0.55rem 0.2rem;
  min-height: 3.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}
.scale-dot { font-size: 0.5rem; letter-spacing: 0.06em; color: var(--accent); line-height: 1; }
.scale-btn small { font-size: 0.66rem; color: var(--ink-faint); line-height: 1.15; }

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

input[type="text"], textarea {
  font: inherit;
  font-size: 16px; /* anything smaller makes iOS Safari zoom on focus */
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  width: 100%;
  min-height: var(--tap);
  resize: none;
}

input:focus-visible, textarea:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.draft { line-height: 1.6; background: var(--ground); overflow: hidden; }

/* --- draft screen --------------------------------------------------------- */

.paste-hint {
  font-size: 0.86rem;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin: 0.9rem 0 0.85rem;
}
.paste-hint strong { color: var(--ink); }

.dest { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.dest strong { display: block; font-weight: 580; }
.dest small { display: block; color: var(--ink-faint); font-weight: 400; font-size: 0.8rem; margin-top: 0.1rem; }
.chev { color: var(--ink-faint); flex: 0 0 auto; }

.dest-btn { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.quiet-card { background: transparent; border-style: dashed; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.35rem 0 0.9rem;
  color: var(--ink-faint);
  font-size: 0.78rem;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* --- anonymous or named --------------------------------------------------- */

.segmented { display: flex; gap: 0.45rem; }
.segmented button {
  flex: 1;
  width: auto;
  text-align: center;
  padding: 0.7rem 0.5rem;
  min-height: 4rem;
}
.segmented strong { display: block; font-weight: 580; font-size: 0.92rem; }
.segmented small { display: block; color: var(--ink-faint); font-size: 0.74rem; margin-top: 0.15rem; line-height: 1.25; }

.identity-fields { display: grid; gap: 0.55rem; margin-bottom: 1.4rem; }
.identity-fields[hidden] { display: none; }
.notice { margin: 0; color: var(--ink-faint); font-size: 0.8rem; line-height: 1.45; }
.notice a, .powered a { color: inherit; }

.status { margin: 0.5rem 0 0; min-height: 1.25rem; }

.done {
  font-size: 2rem;
  color: var(--good);
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* --- sticky action bar ---------------------------------------------------- */

.sticky {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem 0 calc(0.4rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--ground) 72%, transparent);
}
.sticky[hidden] { display: none; }

/* --- language sheet ------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet-backdrop[hidden] { display: none; }

.sheet-panel {
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 32rem;
  max-height: 78dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.sheet-close { width: auto; min-height: 2.25rem; padding: 0.25rem 0.6rem; border: none; background: transparent; color: var(--ink-faint); }

.sheet-body { overflow-y: auto; padding: 0.6rem; display: grid; gap: 0.35rem; }
.sheet-item { border: none; background: transparent; }
.sheet-item.is-on { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--ground);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.86rem;
  z-index: 30;
  max-width: 90vw;
  text-align: center;
}
.toast[hidden] { display: none; }

/* --- misc ----------------------------------------------------------------- */

.footer { color: var(--ink-faint); font-size: 0.76rem; text-align: center; }
.footer p { margin: 0; }

.loading { color: var(--ink-faint); }
.error { color: var(--bad); }

.thinking { display: flex; align-items: center; gap: 0.6rem; color: var(--ink-soft); padding: 1.5rem 0; }
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .dot { animation: none; }
  * { transition: none !important; }
}

[dir="rtl"] .chev { transform: scaleX(-1); }

/* --- speak it ------------------------------------------------------------- */

.mic {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 9.5rem;
  border-radius: 18px;
  border: 2px dashed var(--line);
  background: var(--ground);
  text-align: center;
}

.mic-icon { font-size: 2.4rem; line-height: 1; }
.mic-label { font-weight: 580; color: var(--ink-soft); }

.mic.is-live {
  border-style: solid;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.mic.is-live .mic-icon { animation: listen 1.1s ease-in-out infinite; }
.mic.is-live .mic-label { color: var(--ink); }

@keyframes listen {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.14); opacity: 1; }
}

.transcript-label { margin-top: 1.1rem; }

.transcript {
  margin-top: 0.5rem;
  min-height: 3rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
}
.transcript:empty { display: none; }
.transcript .interim { color: var(--ink-faint); }

.lang-chip.is-busy { opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  .mic.is-live .mic-icon { animation: none; }
}

/* The customer's page belongs to the business, so our mark sits quietly in the
   footer rather than competing with their name at the top. */
.powered {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.45rem 0 0;
  opacity: 0.75;
  font-size: 0.72rem;
}
.powered img { display: block; }

/* Two secondary actions sharing one row under the primary button. Back stays
   compact so the longer label beside it does not get squeezed into three
   lines on a narrow phone. */
.sticky-row { display: flex; gap: 0.5rem; align-items: center; }
/* width:auto matters: the base button rule is width:100%, which becomes the
   flex base size and lets one button claim the whole row. */
.sticky-row button { flex: 1 1 auto; width: auto; }
.sticky-row button.back { flex: 0 0 auto; padding-inline: 0.75rem; }

/* A disabled primary button must not look like a tappable one. */
button:disabled { cursor: default; }
button.primary:disabled {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-faint);
  font-weight: 500;
}

/* The close of the flow: big enough to read as an ending. */
.done-big {
  font-size: 3rem;
  line-height: 1;
  color: var(--good);
  margin-bottom: 0.75rem;
}
