:root {
  --brand: #0f5c52;
  --brand-hover: #0c4a42;
  --brand-deep: #08332e;
  --on-brand: #ffffff;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --ink: #12202b;
  --muted: #5d6b76;
  --line: #dfe5ea;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --danger: #b42318;
  --human: #b54708;
  --ok-bg: #e8f7ef;
  --ok-ink: #087443;
  --warn-bg: #fff4e5;
  --warn-ink: #b54708;
  --sidebar: #ffffff;
  --sidebar-ink: #1b2a34;
  --sidebar-muted: #6b7a86;
  --sidebar-hover: #f3f6f8;
  --login-bg: #0f1720;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: color-mix(in srgb, var(--brand) 16%, #d9fdd3);
  --composer-bar: #f0f2f5;
  --unread: #25d366;
}

html[data-theme="dark"] {
  --bg: #0e141b;
  --surface: #161d26;
  --surface-2: #1d2631;
  --ink: #e8eef3;
  --muted: #93a1ae;
  --line: #2a3542;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  --sidebar: #121922;
  --sidebar-ink: #e8eef3;
  --sidebar-muted: #8b99a6;
  --sidebar-hover: #1c2530;
  --login-bg: #0b1016;
  --ok-bg: #123526;
  --ok-ink: #6ee7b7;
  --warn-bg: #3a2712;
  --warn-ink: #fbbf24;
  --chat-bg: #0b141a;
  --bubble-in: #202c33;
  --bubble-out: color-mix(in srgb, var(--brand) 28%, #005c4b);
  --composer-bar: #202c33;
  --unread: #00a884;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.011em;
}

.hidden { display: none !important; }

.kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.03em; }

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 420px at 15% -10%, color-mix(in srgb, var(--brand) 45%, transparent), transparent 60%),
    var(--login-bg);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--surface);
  padding: 36px 32px;
  display: grid;
  gap: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 28px; }
.login-card .sub { margin: 0 0 8px; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input, .search input, .composer textarea, .sim input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  border-radius: var(--radius-sm);
}
.login-card button, .composer > button[type="submit"], .sim button, .actions button, .rail-foot button, .wa-actions button {
  border: 0;
  background: var(--brand);
  color: var(--on-brand);
  font: inherit;
  font-weight: 650;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.login-card button:hover, .composer > button[type="submit"]:hover, .sim button:hover, .actions button:hover, .wa-actions button:hover {
  background: var(--brand-hover);
}
.actions button.ghost, .rail-foot button, .wa-actions button.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
}
.actions button.ghost:hover, .rail-foot button:hover, .wa-actions button.ghost:hover { background: var(--surface-2); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 340px 1fr;
}

.rail {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 18px 12px;
  gap: 12px;
}
.rail-head h2 { font-size: 18px; color: var(--sidebar-ink); }
.biz-logo { height: 36px; width: 36px; max-width: 36px; object-fit: contain; display: block; margin-bottom: 8px; }
.login-logo {
  height: auto;
  width: auto;
  max-height: 168px;
  max-width: 280px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
  background: #07090d;
  padding: 18px 22px 14px;
  border-radius: 16px;
}
.login-card.has-lockup > .kicker { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--brand);
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.plugin-nav { display: flex; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap; }
.plugin-nav button {
  background: var(--surface-2);
  color: var(--brand);
  border: 0;
  padding: 6px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  border-radius: 999px;
}
.search { padding: 0 14px 10px; }
.search input {
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
}
.filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 14px 10px;
}
.filters button {
  background: transparent;
  color: var(--sidebar-muted);
  border: 0;
  padding: 8px 0;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
}
.filters button.on {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  font-weight: 650;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}
.list li {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  grid-template-columns: 49px 1fr;
  gap: 12px;
  align-items: center;
}
.list li:hover, .list li.active { background: var(--sidebar-hover); }
.list li.active { background: var(--composer-bar); }
.list li.unread .name { font-weight: 700; }
.list li.unread .time { color: var(--unread); font-weight: 650; }
.list li.unread .preview { color: var(--ink); }
.list .body { min-width: 0; display: grid; gap: 2px; }
.list .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.list .name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .time { font-size: 12px; color: var(--sidebar-muted); flex-shrink: 0; }
.list .preview { font-size: 14px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.list .meta { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.list .chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
}
.list .chip.bot { background: var(--ok-bg); color: var(--ok-ink); }
.list .chip.human { background: var(--warn-bg); color: var(--human); }
.list li.empty-row {
  display: block;
  padding: 28px 16px;
  text-align: center;
  color: var(--sidebar-muted);
  cursor: default;
  border: 0;
  grid-template-columns: none;
}
.list li.empty-row:hover { background: transparent; }
.list .assignee { font-size: 11px; color: var(--sidebar-muted); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--unread);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}

.rail-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--sidebar-muted);
}
.rail-foot a { color: var(--brand); text-decoration: none; font-weight: 650; }

.head-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}
.head-pills .pill { white-space: nowrap; }
.wa-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wa-pill svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}
.pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.pill.on { background: var(--ok-bg); color: var(--ok-ink); }
.pill.off { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bot { background: var(--ok-bg); color: var(--ok-ink); }
.pill.human { background: var(--warn-bg); color: var(--human); }

.stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.empty {
  margin: auto;
  max-width: 460px;
  padding: 32px 24px;
  text-align: center;
}
.empty-mark {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.empty-mark svg { width: 42px; height: 42px; }
.empty h1 { font-size: 32px; margin: 8px 0 10px; font-weight: 300; letter-spacing: -0.02em; }
.empty p { color: var(--muted); line-height: 1.5; }
.sim { display: grid; gap: 8px; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }

.thread-wrap { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.thread-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--composer-bar);
  align-items: center;
}
.thread-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.thread-id { min-width: 0; }
.thread-back { display: none; flex-shrink: 0; width: 36px; height: 36px; }
.thread-head h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-head p { margin: 1px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions .icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.actions .icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }

.thread-find {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.thread-find input {
  flex: 1;
  border: 0;
  background: var(--surface-2);
  padding: 8px 12px;
  font: inherit;
  color: var(--ink);
  border-radius: 8px;
}
.muted { color: var(--muted); font-size: 12px; }

.thread-scroll {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.thread-loading {
  align-self: center;
  margin: auto 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.thread {
  flex: 1;
  overflow: auto;
  padding: 12px 7% 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 18% 22%, color-mix(in srgb, var(--ink) 5%, transparent) 1.2px, transparent 1.4px),
    radial-gradient(circle at 72% 64%, color-mix(in srgb, var(--ink) 4%, transparent) 1px, transparent 1.2px);
  background-size: 28px 28px, 18px 18px;
}

.day-chip {
  align-self: center;
  margin: 10px 0 8px;
  padding: 5px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(11, 20, 26, 0.08);
}

.bubble {
  max-width: 65%;
  padding: 6px 8px 4px 9px;
  background: var(--bubble-in);
  border: 0;
  display: block;
  border-radius: 7.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  position: relative;
}
.bubble.in { align-self: flex-start; border-top-left-radius: 0; }
.bubble.out {
  align-self: flex-end;
  background: var(--bubble-out);
  border-top-right-radius: 0;
}
.bubble.system {
  align-self: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.08);
  max-width: 80%;
  padding: 6px 12px;
  border-radius: 8px;
}
.bubble .who { display: block; font-size: 12.8px; font-weight: 700; color: var(--brand); margin-bottom: 2px; }
.bubble.out .who { color: var(--human); }
.bubble .txt { white-space: pre-wrap; word-break: break-word; font-size: 14.2px; line-height: 1.35; }
.bubble .when {
  float: right;
  margin: 4px 0 -2px 12px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.bubble .ticks { width: 16px; height: 11px; display: inline-block; opacity: 0.7; }
.bubble.hit { outline: 2px solid var(--brand); outline-offset: 2px; }

.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  background: var(--composer-bar);
  border-top: 0;
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.macro-select {
  max-width: 92px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 0;
  cursor: pointer;
}
.composer textarea {
  resize: none;
  min-height: 42px;
  max-height: 140px;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--surface);
  line-height: 1.35;
  flex: 1;
  min-width: 0;
  width: auto;
}
.composer .error { margin: 0; }
.composer-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}
.composer-preview.hidden { display: none; }
.composer-preview button {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
}
.composer-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.send-btn {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.send-btn svg { width: 20px; height: 20px; margin-left: 2px; }
.send-btn:hover { background: var(--brand-hover); }
.icon-btn.ghost-icon {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
}
.icon-btn.ghost-icon:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.icon-btn.rec {
  background: #c0392b;
  color: #fff;
}
.bubble .media-img {
  max-width: min(280px, 62vw);
  border-radius: 6px;
  display: block;
  margin: 2px 0 4px;
  cursor: zoom-in;
}
.bubble audio {
  width: min(240px, 70vw);
  margin: 6px 0;
  display: block;
}
.bubble .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  font-size: 13px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); }
.qc-wrap { position: relative; }
.qc-btn { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.qc-btn:hover { background: var(--brand-hover); }
.qc-btn.is-open { background: var(--brand-deep); }
.qc-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 55;
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.qc-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.qc-item:hover { background: var(--surface-2); }
.qc-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--brand); }
.wa-lines { list-style: none; padding: 0; margin: 10px 0 14px; display: grid; gap: 6px; }
.wa-line {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  font: inherit;
  border-radius: 8px;
  cursor: pointer;
}
.wa-line.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--surface)); }
.wa-line .muted { margin-left: auto; font-size: 12px; }

#wa-modal:empty { display: none; }
.wa-back {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 22, 0.48);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 18px;
}
.wa-card {
  width: min(420px, 100%);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.wa-card h2 { font-size: 20px; margin-bottom: 6px; }
.wa-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.wa-card img.qr {
  width: 240px;
  height: 240px;
  display: block;
  margin: 12px auto;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}
.wa-card .pair {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.18em;
  text-align: center;
  font-weight: 700;
  margin: 8px 0 14px;
}
.wa-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.wa-actions button { flex: 1; min-width: 120px; }
.wa-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--warn-ink);
}
.wa-dot.on { background: var(--ok-ink); }

.wa-avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  user-select: none;
}
.wa-avatar.lg { width: 40px; height: 40px; font-size: 15px; }
.wa-avatar.has-photo {
  background: #d9d9d9;
  overflow: hidden;
  padding: 0;
}
.wa-avatar.has-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  border-radius: 8px;
  max-height: 180px;
  overflow: auto;
}
.emoji-panel button {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1.3;
  cursor: pointer;
  border-radius: 6px;
  padding: 4px;
}
.emoji-panel button:hover { background: var(--surface-2); }

.jump-bottom {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}
.jump-bottom svg { width: 20px; height: 20px; }
.jump-bottom:hover { color: var(--ink); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(11, 20, 26, 0.88);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: min(920px, 94vw);
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.list li.pinned .name::before {
  content: "📌 ";
  font-size: 11px;
}
.pin-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.pin-chip {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}
.reply-bar.hidden { display: none; }
.reply-bar p { margin: 0; }
.reply-bar #reply-bar-text {
  color: var(--muted);
  max-width: 70vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote {
  display: block;
  margin: 0 0 6px;
  padding: 5px 8px;
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble.deleted .txt { font-style: italic; color: var(--muted); }
.bubble.pinned { box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 35%, transparent); }
.edited-mark { font-size: 11px; color: var(--muted); margin-right: 4px; }
.ctx-menu {
  position: fixed;
  z-index: 80;
  min-width: 200px;
  padding: 6px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger { color: var(--danger); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .stage { display: none; }
  .app[data-thread="1"] .rail { display: none; }
  .app[data-thread="1"] .stage { display: flex; min-height: 0; }
  .thread-back { display: grid; }
  .thread { padding: 8px 10px 16px; }
  .bubble { max-width: 88%; }
  .macro-select { max-width: 72px; }
}
