/* ─── Theme tokens ─── */
:root, :root[data-theme="light"] {
  --accent: #1a73e8;
  --accent-soft: #4285f4;
  --accent-tint: #e8f0fe;
  --accent-banner-text: #174ea6;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f1f3f4;
  --surface-softer: #f8f9fa;
  --border: #dadce0;
  --border-soft: #eceff1;
  --bubble-in: #f1f3f4;
  --text: #1f1f1f;
  --text-dim: #5f6368;
  --text-faint: #80868b;
  --err: #d93025;
  --danger-tint: #fce8e6;
  --ok: #1e8e3e;
  --warn: #e37400;
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.08);
  --shadow-md: 0 4px 16px rgba(60, 64, 67, 0.12);
  --shadow-lg: 0 10px 40px rgba(60, 64, 67, 0.18);
  --bar-bg: rgba(255, 255, 255, 0.94);
}
:root[data-theme="dark"] {
  --accent: #8ab4f8;
  --accent-soft: #aecbfa;
  --accent-tint: #1f3b63;
  --accent-banner-text: #aecbfa;
  --bg: #0d0d0f;
  --surface: #1c1c1e;
  --surface-soft: #2c2c2e;
  --surface-softer: #141416;
  --border: #38383a;
  --border-soft: #2c2c2e;
  --bubble-in: #2c2c2e;
  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-faint: #6e6e73;
  --err: #ff6b5e;
  --danger-tint: #3a1a1a;
  --ok: #30d158;
  --warn: #f0a44a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.7);
  --bar-bg: rgba(28, 28, 30, 0.9);
}

:root {
  --radius: 12px;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --app-bar-h: 56px;
}

* { box-sizing: border-box; }
*, *::before, *::after { -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100vh;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background 0.2s, color 0.2s;
}

button { font-family: var(--font); }
.view { height: 100%; }
.hidden { display: none !important; }

/* ─── Brand ─── */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: url("/favicon.svg") center/contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(37, 99, 235, 0.25));
}
.wordmark {
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 13px;
  color: var(--text);
}
.brand-big .mark { width: 44px; height: 44px; }
.brand-big .wordmark { font-size: 15px; letter-spacing: 0.22em; }

.brand-header { min-width: 0; flex: 1; }
.brand-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.brand-stack .wordmark {
  font-size: 13px;
  letter-spacing: 0.14em;
}
.client-chip {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  margin-top: 1px;
}
.client-chip:empty { display: none; }

/* Row that holds the client identity + phone-chip side-by-side on
   desktop. Wraps to two lines on narrow viewports so the phone chip
   doesn't get cut off. */
.identity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  row-gap: 4px;
}

.phone-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-dim);
  font: 600 11.5px/1 ui-monospace, monospace;
  letter-spacing: 0.02em;
  cursor: pointer;
  max-width: 100%;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.phone-chip:hover { background: var(--accent-tint); color: var(--accent-banner-text); border-color: var(--accent-soft); }
.phone-chip.copied { background: var(--ok); color: #fff; border-color: var(--ok); }
.phone-chip.copied:hover { background: var(--ok); }
.phone-chip[hidden] { display: none; }
.phone-chip svg { flex-shrink: 0; opacity: 0.65; }
.phone-chip:hover svg { opacity: 1; }
.phone-chip.copied svg { opacity: 1; }
.phone-chip-number {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Language switcher ─── */
.lang-switcher {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 7px 26px 7px 10px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 7px center;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
  height: 34px;
  line-height: 1;
  min-width: 58px;
  text-align: left;
}
.lang-switcher:hover {
  color: var(--text);
  border-color: var(--border);
  background-color: var(--surface-soft);
}
.lang-switcher:focus {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.lang-switcher option { background: var(--surface); color: var(--text); }

.lang-row { display: flex; justify-content: center; margin-top: 18px; }

/* ─── Login ─── */
.login {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 16px 40px;
  overflow-y: auto;
  background:
    radial-gradient(1000px 500px at 50% -10%, var(--accent-tint), transparent 60%),
    var(--bg);
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.card .brand-big { justify-content: center; margin-bottom: 32px; }
h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}
.hint {
  color: var(--text-dim);
  font-size: 14px;
  margin: 6px 0 24px;
  text-align: center;
  line-height: 1.5;
}
form { display: flex; flex-direction: column; gap: 14px; }
input[type="text"] {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 22px;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 15px 16px;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-tint);
}
button[type="submit"], #loginBtn {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button[type="submit"]:hover, #loginBtn:hover { background: var(--accent-soft); }
button[type="submit"]:active { transform: scale(0.99); }
.error {
  color: var(--err);
  font-size: 13px;
  min-height: 18px;
  margin: 16px 0 0;
  text-align: center;
}

/* ─── App shell: fixed header + horizontally-split body ─── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.app-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--app-bar-h);
  background: var(--bar-bg);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  flex-shrink: 0;
  z-index: 10;
}
.bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
/* Back button lives inside thread-header.
   On desktop (two-pane): hide it — clicking another conversation is enough.
   On mobile: visible by default (thread-header is only rendered in detail mode). */
.thread-header .back-btn { display: flex; flex-shrink: 0; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-soft); color: var(--text); }
.icon-btn:active { background: var(--border-soft); }
.icon-btn.danger:hover { background: var(--danger-tint); color: var(--err); }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 7px 14px 7px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pill-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.pill-btn.danger { color: var(--text-dim); }
.pill-btn.danger:hover { background: var(--danger-tint); color: var(--err); border-color: var(--err); }
.pill-btn svg { flex-shrink: 0; }

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s, box-shadow 0.3s;
  margin-right: 4px;
}
.status-dot.connected { background: var(--ok); box-shadow: 0 0 8px rgba(30, 142, 62, 0.45); }
.status-dot.connecting { background: var(--warn); animation: pulse 1.2s infinite; }
.status-dot.disconnected { background: var(--err); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.status-banner {
  background: var(--accent-tint);
  color: var(--accent-banner-text);
  font-size: 12.5px;
  padding: 8px 16px;
  text-align: center;
  display: none;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.status-banner.visible { display: block; }

/* ─── Phone status banner (shows whether the Bulgarian phone is alive) ─── */
.phone-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 500;
  border-bottom: 1px solid var(--border-soft);
}
.phone-banner[hidden] { display: none; }
.phone-banner .phone-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.phone-banner[data-state="online"] {
  background: rgba(52, 199, 89, 0.10);
  color: #1e7a37;
}
.phone-banner[data-state="online"] .phone-dot {
  background: var(--ok);
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
}
.phone-banner[data-state="offline"] {
  background: rgba(229, 56, 59, 0.10);
  color: #b22a2c;
}
.phone-banner[data-state="offline"] .phone-dot {
  background: var(--err);
}
.phone-banner[data-state="unknown"] {
  background: var(--surface-soft);
  color: var(--text-dim);
}
.phone-banner[data-state="unknown"] .phone-dot {
  background: var(--text-faint);
}
:root[data-theme="dark"] .phone-banner[data-state="online"] { color: #5fd97a; }
:root[data-theme="dark"] .phone-banner[data-state="offline"] { color: #ff7373; }

/* ─── Login banner (for ?err= magic_expired etc.) ─── */
.login-banner {
  display: block;
  margin: 16px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: left;
  background: rgba(229, 56, 59, 0.08);
  color: var(--err);
  border: 1px solid rgba(229, 56, 59, 0.25);
}
.login-banner[hidden] { display: none; }

/* ─── Split body (two-pane on desktop, stacked on mobile) ─── */
.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}
.list-pane {
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  background: var(--surface);
  min-width: 0;
}
.thread-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-softer);
  overflow: hidden;
}

/* Single-pane behavior on small screens: show only the active pane */
@media (max-width: 899px) {
  .app-shell[data-mode="list"] .thread-pane { display: none; }
  .app-shell[data-mode="detail"] .list-pane { display: none; }
  .list-pane { border-right: none; }
}

/* Two-pane desktop */
@media (min-width: 900px) {
  .app-body {
    grid-template-columns: minmax(320px, 380px) 1fr;
  }
  .thread-header .back-btn { display: none !important; }
}

/* ─── List bar (Select / Cancel / Delete bulk-actions) ─── */
.list-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  min-height: 44px;
}
.list-bar-browse,
.list-bar-select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
/* The two sub-bars are mutually exclusive — only one is shown at a time
   based on the data-mode attribute on .list-pane */
.list-pane[data-mode="browse"] .list-bar-select { display: none; }
.list-pane[data-mode="select"] .list-bar-browse { display: none; }
/* Browse mode: refresh on the left, select on the right */
.list-bar-browse { justify-content: space-between; }
.list-bar-browse #selectModeBtn { margin-left: auto; }
.list-bar-btn.icon-only {
  padding: 6px 8px;
}
.list-bar-btn .refresh-icon {
  transition: transform 0.2s;
}
.list-bar-btn.spinning .refresh-icon {
  animation: fenchell-spin 0.8s linear;
}
@keyframes fenchell-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}
.list-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.list-bar-btn:hover { background: var(--surface-soft); color: var(--text); }
.list-bar-btn.danger { color: var(--err); }
.list-bar-btn.danger:hover { background: var(--danger-tint); }
.list-bar-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.list-bar-btn:disabled:hover { background: transparent; color: var(--err); }
.list-bar-btn svg { flex-shrink: 0; }
.list-bar-count {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ─── Conversation list ─── */
.conversations { list-style: none; padding: 0; margin: 0; }
.conv {
  display: grid;
  grid-template-columns: 0 46px 1fr auto;
  column-gap: 14px;
  align-items: center;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s, grid-template-columns 0.15s;
}
/* In selection mode, slide the checkbox in by widening its column */
.list-pane[data-mode="select"] .conv {
  grid-template-columns: 28px 46px 1fr auto;
}
.conv-check {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 0;
  transition: width 0.15s;
}
.list-pane[data-mode="select"] .conv-check { width: 28px; }
.conv-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  pointer-events: none; /* the parent <li> handles the toggle */
}
.conv.checked { background: var(--accent-tint); }
.conv.checked:hover { background: var(--accent-tint); }
.conv:hover { background: var(--surface-soft); }
.conv.active {
  background: var(--accent-tint);
}
.conv.active .conv-sender { color: var(--accent-banner-text); }
.conv-content { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.conv-sender {
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time {
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.conv-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  line-height: 1.3;
  margin-top: -2px;
}
.conv-preview {
  font-size: 14px;
  color: var(--text-dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  line-height: 1.45;
  word-break: break-word;
}
.conv.fresh .conv-sender { font-weight: 700; color: var(--text); }
.conv.fresh .conv-preview { color: var(--text); font-weight: 500; }
.conv.fresh .conv-time { color: var(--accent); font-weight: 700; }
.conv-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 6px;
  flex-shrink: 0;
}
.conv:not(.fresh) .conv-unread-dot { display: none; }

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-family: var(--font);
  user-select: none;
}

/* ─── Thread header ─── */
.thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  min-height: 56px;
  flex-shrink: 0;
  position: relative;
}
/* The HTML [hidden] attribute is normally `display: none`, but our
   `display: flex` above wins via specificity. Re-assert it. */
.thread-header[hidden] { display: none !important; }
.convo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
/* On mobile, center the avatar + sender block inside the thread header
   while the back button stays pinned to the left. */
@media (max-width: 899px) {
  .thread-header .convo-head {
    justify-content: center;
    padding-right: 40px; /* balance the 40px-wide back button on the left */
  }
  .thread-header .convo-titles { align-items: center; text-align: center; }
  .thread-header .sender-line { justify-content: center; }
}
.convo-head .avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}
.convo-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.sender-line {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.sender-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sender-edit-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.sender-edit-btn svg { display: block; }
.sender-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: ui-monospace, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sender-sub:empty { display: none; }

/* ─── Thread ─── */
.thread-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 32px;
  min-height: 0;
}
.thread {
  list-style: none;
  padding: 0 14px;
  margin: 0;
  max-width: 860px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.thread-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-dim);
  padding: 60px 24px;
  gap: 4px;
}
.thread-empty .empty-title { font-size: 16px; color: var(--text); font-weight: 500; margin: 0; }
.thread-empty .empty-sub { font-size: 13px; color: var(--text-dim); margin: 0; }
.thread-empty.hidden { display: none; }

.msg-row { display: flex; flex-direction: column; max-width: 78%; }
.msg-row.incoming { align-self: flex-start; }
.msg-bubble {
  background: var(--bubble-in);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.msg-row + .msg-row.incoming .msg-bubble { border-top-left-radius: 6px; }
.msg-row.incoming:last-child .msg-bubble { border-bottom-left-radius: 18px; }
.msg-row.fresh .msg-bubble {
  background: var(--accent-tint);
  animation: freshPop 0.4s ease;
}
@keyframes freshPop {
  from { transform: scale(0.96); opacity: 0.2; }
  to { transform: scale(1); opacity: 1; }
}
.msg-time {
  font-size: 11px;
  color: var(--text-faint);
  padding: 2px 12px 0;
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
}

.date-sep {
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  padding: 18px 0 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  align-self: center;
  list-style: none;
}

/* ─── Empty list ─── */
.empty {
  text-align: center;
  padding: 100px 24px;
  color: var(--text-dim);
}
.empty.hidden { display: none; }
.empty-title { font-size: 15px; margin: 0 0 6px; color: var(--text); font-weight: 500; }
.empty-sub { font-size: 13px; color: var(--text-dim); margin: 0; }

/* ─── Dialog ─── */
.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 440px;
  width: 92vw;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.dialog .hint { margin: 10px 0 6px; text-align: left; }
.dialog .usage-note {
  background: var(--accent-tint);
  color: var(--accent-banner-text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 14px;
}
.code-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 32px;
  letter-spacing: 0.3em;
  text-align: center;
  background: var(--surface-soft);
  padding: 18px;
  border-radius: 12px;
  color: var(--accent);
  font-weight: 700;
}
.magic-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 12px;
}
.magic-box code {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.btn-mini {
  padding: 7px 12px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.btn-mini:hover { background: var(--surface-soft); }
.ttl { font-size: 12px; color: var(--text-faint); margin: 14px 0 0; text-align: left; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog-actions .primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.dialog-actions .primary:hover { background: var(--accent-soft); }
.dialog-actions .primary:disabled { opacity: 0.5; cursor: not-allowed; }
.dialog-actions .primary.danger { background: var(--err); }
.dialog-actions .primary.danger:hover { background: var(--err); filter: brightness(0.92); }
.dialog-actions .ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.dialog-actions .ghost:hover { background: var(--surface-soft); color: var(--text); }

.delete-summary {
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  word-break: break-word;
  text-align: left;
}
.delete-summary:empty { display: none; }

/* ─── Responsive tweaks ─── */
@media (max-width: 680px) {
  .pill-btn .btn-label { display: none; }
  .pill-btn { padding: 7px 10px; border-radius: 50%; width: 38px; height: 38px; justify-content: center; }
}
@media (max-width: 520px) {
  .app-bar { padding: 10px 10px; padding-top: calc(10px + env(safe-area-inset-top, 0)); gap: 6px; }
  .bar-right { gap: 2px; }
  .icon-btn { width: 38px; height: 38px; }
  .conv { padding: 12px 14px; }
  .thread { padding: 0 10px; }
  .msg-row { max-width: 85%; }
  .brand-header .wordmark { display: none; }
  .brand-header .client-chip { font-size: 14px; color: var(--text); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition: none !important; }
}
