/* FunNow Inbox — the merchant messaging UI (dev build).
   One stylesheet, design tokens first. Light and dark from the OS setting. */

:root {
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --fb: #1877f2;
  --wa: #25d366;
  --wa-strong: #008069; /* white text on it passes AA; --wa does not */

  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-hover: #f3f4f6;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --info: #1d4ed8;
  --info-soft: #dbeafe;

  --bubble-in: #ffffff;
  --bubble-out: var(--brand);
  --bubble-out-text: #ffffff;
  --note: #fffbeb;
  --note-line: #fcd34d;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow: 0 4px 16px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 20px 48px rgba(17, 24, 39, 0.18);

  --topbar: 56px;
  --sidebar: 224px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #818cf8;
    --brand-strong: #a5b4fc;
    --brand-soft: #1e1b4b;
    --bg: #0b0f19;
    --surface: #111827;
    --surface-2: #0f1523;
    --surface-hover: #1a2233;
    --line: #1f2937;
    --line-strong: #374151;
    --text: #f3f4f6;
    --text-2: #c2c8d3;
    --text-3: #8b94a5;
    --ok: #4ade80;
    --ok-soft: #052e16;
    --warn: #fbbf24;
    --warn-soft: #3a2a05;
    --bad: #f87171;
    --bad-soft: #3b0d0d;
    --info: #93c5fd;
    --info-soft: #0c1f3f;
    --bubble-in: #1f2937;
    --bubble-out: #4f46e5;
    --note: #2a2207;
    --note-line: #a16207;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
/* Icons are inline SVG: give every one a size, or a bare <svg> renders at its
   300×150 default and covers its neighbours. Specific classes override it. */
svg { width: 18px; height: 18px; flex: none; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
code { background: var(--surface-hover); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--brand); color: #fff;
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--brand-strong); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-hover); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger { background: var(--bad); }
.btn.fb { background: var(--fb); }
.btn.fb:hover { background: #166fe5; }
.btn.wa { background: var(--wa-strong); }
.btn.wa:hover { background: #006e5a; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 36px; padding: 0; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }
.btn svg { width: 16px; height: 16px; }
.btn.lg svg { width: 18px; height: 18px; }
.btn.icon-only svg { width: 18px; height: 18px; }

/* ---- form controls -------------------------------------------------------- */

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--text-3); font-size: 12px; }
.input, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input { height: 38px; }
.textarea { resize: vertical; min-height: 72px; }
.input:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---- chips, badges, avatars ------------------------------------------------- */

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-hover); color: var(--text-2); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip svg { width: 12px; height: 12px; }

.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; background: #64748b;
  position: relative; overflow: visible;
}
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .channel-dot {
  position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--surface); display: flex; align-items: center; justify-content: center; color: #fff;
}
.avatar .channel-dot svg { width: 10px; height: 10px; }

.channel-icon {
  flex: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.channel-icon svg { width: 18px; height: 18px; }
.ch-facebook { background: var(--fb); }
.ch-whatsapp { background: var(--wa); }
.ch-instagram { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); }
.ch-line { background: #06c755; }
.ch-telegram { background: #229ed9; }
.ch-email { background: #64748b; }
.ch-web { background: #0ea5e9; }
.ch-api { background: #475569; }
.ch-sms { background: #7c3aed; }

/* ---- spinner, skeleton ------------------------------------------------------ */

.spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; opacity: 0.8;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-hover) 25%, var(--line) 37%, var(--surface-hover) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton { animation: none; } }

/* ---- sign-in ---------------------------------------------------------------- */

.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px; }
.signin-card h1 { margin: 20px 0 4px; font-size: 22px; }
.signin-card .sub { color: var(--text-2); margin: 0 0 22px; }
.signin-foot { margin-top: 18px; color: var(--text-3); font-size: 12px; text-align: center; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), #9333ea); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.brand-mark svg { width: 17px; height: 17px; }
.dev-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); padding: 2px 6px; border-radius: 4px; }

/* ---- app shell -------------------------------------------------------------- */

/* minmax(0, 1fr), not 1fr: a 1fr track grows to its content's min width, so
   one long topbar or message would widen the whole page past a phone's screen. */
.shell { height: 100%; height: 100dvh; display: grid; grid-template-rows: var(--topbar) minmax(0, 1fr); grid-template-columns: var(--sidebar) minmax(0, 1fr); grid-template-areas: "top top" "side main"; }
.topbar { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 16px; min-width: 0; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .brand { min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.merchant { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-2); font-size: 13px; }
.merchant .avatar { width: 26px; height: 26px; font-size: 11px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.live.on { color: var(--ok); } .live.on .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.live.wait { color: var(--warn); } .live.wait .dot { background: var(--warn); }
.live.off { color: var(--bad); } .live.off .dot { background: var(--bad); }

.sidebar { grid-area: side; background: var(--surface); border-right: 1px solid var(--line); padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .count { margin-left: auto; }
.nav-section { margin: 14px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.sidebar .grow { flex: 1; }
.main { grid-area: main; min-width: 0; min-height: 0; overflow: hidden; }

/* ---- inbox (three panes) ---------------------------------------------------- */

.inbox { height: 100%; display: grid; grid-template-columns: 340px minmax(0, 1fr); min-height: 0; }
.conv-pane { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.pane-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0 0 10px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 4px; background: var(--surface-hover); padding: 3px; border-radius: 8px; }
.tab { flex: 1; height: 28px; border: 0; background: transparent; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab:disabled { opacity: 0.5; cursor: not-allowed; }

.conv-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; border-left: 3px solid transparent; }
.conv-item:hover { background: var(--surface-hover); }
.conv-item.active { background: var(--brand-soft); border-left-color: var(--brand); }
.conv-item .body { min-width: 0; flex: 1; }
.conv-item .row1 { display: flex; align-items: baseline; gap: 8px; }
.conv-item .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-item .time { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.conv-item .row2 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.conv-item .preview { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-size: 13px; }
.conv-item.unread .name, .conv-item.unread .preview { color: var(--text); font-weight: 700; }
.list-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: center; }

.thread-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-head .who { min-width: 0; flex: 1; }
.thread-head .who .name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-head .who .meta { display: flex; gap: 6px; align-items: center; color: var(--text-3); font-size: 12px; margin-top: 2px; flex-wrap: wrap; }
.back-btn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.day-sep { align-self: center; margin: 12px 0 6px; font-size: 11px; font-weight: 700; color: var(--text-3); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.msg { display: flex; flex-direction: column; max-width: min(72%, 560px); }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.note { align-self: flex-end; align-items: flex-end; }
.msg.activity { align-self: center; max-width: 80%; }
.bubble { padding: 9px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.msg.in .bubble { background: var(--bubble-in); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 4px; }
.msg.note .bubble { background: var(--note); border: 1px dashed var(--note-line); border-radius: var(--radius); box-shadow: none; }
.msg.activity .bubble { background: none; box-shadow: none; color: var(--text-3); font-size: 12px; text-align: center; padding: 2px 0; }
.msg .meta { display: flex; gap: 6px; align-items: center; color: var(--text-3); font-size: 11.5px; margin: 3px 4px 0; }
.msg .meta svg { width: 12px; height: 12px; }
.msg.pending .bubble { opacity: 0.65; }
.msg.failed .bubble { box-shadow: 0 0 0 2px var(--bad); }
.note-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; color: var(--warn); margin-bottom: 4px; }
.note-label svg { width: 12px; height: 12px; }
.attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.attach img { max-width: 240px; max-height: 200px; border-radius: 10px; display: block; }
.older { align-self: center; margin-bottom: 8px; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--info-soft); color: var(--info); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner .text { color: var(--text); }
.thread-banner { margin: 10px 18px 0; }

.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 18px 14px; }
.composer .modes { display: flex; gap: 2px; margin-bottom: 8px; }
.mode { border: 0; background: none; padding: 6px 10px; border-radius: 6px; font-weight: 700; font-size: 13px; color: var(--text-3); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.mode svg { width: 14px; height: 14px; }
.mode.active { color: var(--brand); background: var(--brand-soft); }
.mode.active.note-mode { color: var(--warn); background: var(--warn-soft); }
.mode:disabled { opacity: 0.45; cursor: not-allowed; }
.composer .box { display: flex; gap: 10px; align-items: flex-end; }
.composer .textarea { min-height: 44px; max-height: 180px; }
.composer.note-on .textarea { background: var(--note); border-color: var(--note-line); }
.composer .hint { color: var(--text-3); font-size: 11.5px; margin-top: 6px; }

/* ---- empty states ----------------------------------------------------------- */

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 40px 24px; color: var(--text-2); height: 100%; }
.empty .art { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.empty .art svg { width: 30px; height: 30px; }
.empty h3 { margin: 4px 0 0; color: var(--text); font-size: 16px; }
.empty p { margin: 0; max-width: 360px; }

/* ---- pages (channels) ------------------------------------------------------- */

.page { height: 100%; overflow-y: auto; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .spacer { flex: 1; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 28px 0 10px; }

.meter { min-width: 220px; }
.meter .label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.meter .bar { height: 8px; background: var(--surface-hover); border-radius: 999px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width 0.3s; }
.meter.full .fill { background: var(--bad); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.card .top { display: flex; gap: 12px; align-items: center; }
.card .title { font-weight: 700; }
.card .subtitle { color: var(--text-3); font-size: 12.5px; }
.card .desc { color: var(--text-2); font-size: 13px; flex: 1; }
.card .actions { display: flex; gap: 8px; align-items: center; }
.card.muted { opacity: 0.7; }

/* ---- modal, stepper --------------------------------------------------------- */

.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise 0.18s ease; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.stepper { display: flex; gap: 8px; margin-bottom: 20px; }
.step { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.step .n { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong); display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.step.active { color: var(--text); } .step.active .n { border-color: var(--brand); color: var(--brand); }
.step.done { color: var(--ok); } .step.done .n { border-color: var(--ok); background: var(--ok); color: #fff; }
.step .n svg { width: 12px; height: 12px; }

.choice-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.choice:hover { border-color: var(--line-strong); background: var(--surface-2); }
.choice.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.choice.disabled { opacity: 0.55; cursor: not-allowed; }
.choice input { accent-color: var(--brand); }
.choice .grow { flex: 1; min-width: 0; }
.choice .title { font-weight: 700; }
.choice .subtitle { color: var(--text-3); font-size: 12px; }

.result { text-align: center; padding: 8px 4px 4px; }
.result .art { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; }
.result .art svg { width: 28px; height: 28px; }
.result.ok .art { background: var(--ok-soft); color: var(--ok); }
.result.bad .art { background: var(--bad-soft); color: var(--bad); }
.result.warn .art { background: var(--warn-soft); color: var(--warn); }
.result h3 { margin: 0 0 6px; font-size: 18px; }
.result p { margin: 0 auto; color: var(--text-2); max-width: 420px; }
.result .detail { margin-top: 14px; text-align: left; }

details.advanced { margin-top: 14px; color: var(--text-2); }
details.advanced summary { cursor: pointer; font-size: 13px; font-weight: 600; }

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

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow); animation: rise 0.18s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.toast.ok svg { color: var(--ok); } .toast.bad svg { color: var(--bad); } .toast.warn svg { color: var(--warn); } .toast svg { color: var(--info); }
.toast .text { flex: 1; overflow-wrap: anywhere; }
.toast .close { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 0; }

/* ---- developer drawer ------------------------------------------------------- */

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 55; display: flex; flex-direction: column; animation: slide 0.18s ease; }
@keyframes slide { from { transform: translateX(16px); opacity: 0; } }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.reqlog { list-style: none; padding: 0; margin: 0; font-family: var(--mono); font-size: 12px; }
.reqlog li { display: grid; grid-template-columns: 58px 1fr auto; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.reqlog .st { font-weight: 700; } .reqlog .bad { color: var(--bad); } .reqlog .ok { color: var(--ok); }
.reqlog .rid { color: var(--text-3); font-size: 11px; grid-column: 2 / 4; }

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

@media (max-width: 1100px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  /* Phone: a bottom tab bar instead of the sidebar, one pane at a time, and
     no tab bar inside a conversation, so the composer sits at the bottom. */
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--topbar) minmax(0, 1fr) auto; grid-template-areas: "top" "main" "side"; }
  .shell:has(.inbox.has-thread) { grid-template-rows: var(--topbar) minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .shell:has(.inbox.has-thread) .sidebar { display: none; }
  .sidebar { flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 4px; }
  .sidebar .nav-section, .sidebar .grow { display: none; }
  .nav-item { position: relative; flex: 1; flex-direction: column; justify-content: center; height: 50px; padding: 4px; gap: 3px; font-size: 11px; }
  .nav-item .count { position: absolute; top: 2px; left: calc(50% + 4px); margin: 0; }
  .topbar { gap: 8px; padding: 0 12px; }
  .btn-label, .live .label, .merchant .text { display: none; }
  .merchant { padding: 0; border: 0; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox.has-thread .conv-pane { display: none; }
  .inbox:not(.has-thread) .thread-pane { display: none; }
  .back-btn { display: inline-flex; }
  .thread-head { padding: 10px 12px; }
  .messages { padding: 12px; }
  .composer { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .page { padding: 20px 16px 40px; }
  .page-head .meter { width: 100%; }
  .msg { max-width: 86%; }
  /* iOS Safari zooms into any field under 16px when it is focused. */
  .input, .textarea { font-size: 16px; }
}
