/* ============================================================
   BetterChat — application styles
   ============================================================ */

.bc-app {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-w, 246px) minmax(320px, var(--list-w, 372px)) minmax(0, 1fr);
  overflow: hidden;
  /* market accent resolves to brand accent unless tweak enables tint */
  --m-accent: var(--accent);
}
/* compact density widths cascade from html[data-density="compact"] in tokens.css */

/* when a non-inbox view is active, collapse to rail + main */
.bc-app.is-single { grid-template-columns: var(--rail-w, 246px) minmax(0, 1fr); }

/* ============================== RAIL ============================== */
.bc-rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.bc-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
}
.bc-logo {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #6b34ff));
  display: grid; place-items: center;
  box-shadow: 0 4px 12px -2px var(--accent-weak), inset 0 1px 0 rgba(255,255,255,.25);
  position: relative;
}
.bc-logo svg { color: #fff; }
.bc-wordmark { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.bc-wordmark b { color: var(--accent-text); font-weight: 700; }

/* market switcher */
.bc-market { padding: 4px 12px 14px; }
.bc-market-label {
  font-size: 10px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3); padding: 0 6px 7px;
}
.bc-market-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 4px;
}
.bc-market-btn {
  position: relative; border: 0; background: transparent; cursor: pointer;
  border-radius: var(--r-sm); padding: 8px 8px 7px; text-align: left;
  display: flex; flex-direction: column; gap: 2px; color: var(--text-2);
  transition: background .14s, color .14s;
}
.bc-market-btn:hover { background: var(--surface-hover); }
.bc-market-btn.is-active {
  background: color-mix(in srgb, var(--mb-accent) 16%, var(--surface));
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mb-accent) 38%, transparent);
}
.bc-market-top { display: flex; align-items: center; gap: 7px; }
.bc-market-flag { font-size: 14px; line-height: 1; }
.bc-market-name { font-size: 13px; font-weight: 600; letter-spacing: -.01em; }
.bc-market-dot {
  width: 7px; height: 7px; border-radius: 50%; margin-left: auto;
  background: var(--mb-accent);
}
.bc-market-btn:not(.is-active) .bc-market-dot { opacity: .5; }
.bc-market-sub { font-size: 10.5px; color: var(--text-3); }
.bc-market-unread {
  font-size: 11px; font-weight: 600; color: var(--text-2);
  font-family: var(--font-mono);
}
.bc-market-btn.is-active .bc-market-unread { color: var(--mb-accent); }

/* nav */
.bc-nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 1px; }
.bc-nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--text-2); border: 0; background: transparent; width: 100%; text-align: left;
  font-size: 13.5px; font-weight: 500; position: relative;
  transition: background .13s, color .13s;
}
.bc-nav-item:hover { background: var(--surface-hover); color: var(--text); }
.bc-nav-item.is-active { background: var(--accent-weak); color: var(--accent-text); }
.bc-nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--m-accent);
}
.bc-nav-item svg { color: currentColor; opacity: .9; }
.bc-nav-label { flex: 1; }
.bc-nav-count {
  font-size: 11px; font-weight: 600; font-family: var(--font-mono);
  color: var(--text-3); background: var(--surface-2); padding: 1px 7px; border-radius: 999px;
  min-width: 22px; text-align: center;
}
.bc-nav-item.is-active .bc-nav-count { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-text); }
.bc-nav-count.is-unread { background: var(--m-accent); color: #fff; }

.bc-nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }

.bc-rail-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.bc-user { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r-sm); }
.bc-user:hover { background: var(--surface-hover); }
.bc-user-meta { line-height: 1.25; min-width: 0; }
.bc-user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-user-role { font-size: 11px; color: var(--text-3); }

/* ============================== LIST COLUMN ============================== */
.bc-list { background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.bc-list-head { padding: 16px 16px 10px; display: flex; align-items: center; gap: 10px; }
.bc-list-title { font-size: 16px; font-weight: 600; letter-spacing: -.02em; }
.bc-list-title .tnum { color: var(--text-3); font-weight: 500; font-size: 13px; margin-left: 6px; font-family: var(--font-mono); }
.bc-list-actions { margin-left: auto; display: flex; gap: 2px; }

.bc-search { margin: 0 14px 10px; position: relative; display: flex; align-items: center; }
.bc-search svg { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.bc-search input {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-md); padding: 8px 10px 8px 34px; font-size: 13px; font-family: inherit;
  transition: border-color .14s, box-shadow .14s;
}
.bc-search input::placeholder { color: var(--text-3); }
.bc-search input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-weak); }

.bc-filters { padding: 0 14px 8px; display: flex; align-items: center; gap: 8px; }

/* segmented control */
.bc-seg { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; overflow: hidden; flex: 1; min-width: 0; }
.bc-seg-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  color: var(--text-2); font-size: 12px; font-weight: 500; font-family: inherit;
  padding: 5px 8px; border-radius: var(--r-xs); display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background .13s, color .13s;
}
.bc-seg-btn:hover { color: var(--text); }
.bc-seg-btn.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 0 0 1px var(--border-2); }
.bc-seg-count { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }
.bc-seg-btn.is-active .bc-seg-count { color: var(--m-accent); }

/* rows */
.bc-rows { flex: 1; overflow-y: auto; padding: 2px 8px 14px; display: flex; flex-direction: column; gap: var(--list-gap); }
.bc-row {
  position: relative; display: flex; gap: 11px; padding: var(--row-py) 12px; cursor: pointer;
  border-radius: var(--r-md); align-items: flex-start; border: 1px solid transparent;
  transition: background .12s;
}
.bc-row:hover { background: var(--surface); }
.bc-row.is-active { background: var(--surface); border-color: var(--border-2); }
.bc-row.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 999px; background: var(--accent);
}
.bc-row.needs-reply::after {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 999px;
  background: var(--stage2);
}
.bc-row.is-active.needs-reply::after { display: none; }

.bc-row-body { flex: 1; min-width: 0; }
.bc-row-top { display: flex; align-items: center; gap: 6px; }
.bc-row-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.bc-row.unread .bc-row-name { font-weight: 700; }
.bc-row-time { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; flex-shrink: 0; }
.bc-row.unread .bc-row-time { color: var(--m-accent); font-weight: 600; }
.bc-row-handle { font-size: 11.5px; color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-row-mid { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.bc-row-preview {
  font-size: 12.5px; color: var(--text-2); line-height: 1.4; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-row.unread .bc-row-preview { color: var(--text); }
[data-density="compact"] .bc-row-handle { display: none; }
[data-density="compact"] .bc-row-preview { margin-top: 1px; font-size: 12px; }
[data-density="compact"] .bc-row-mid { margin: 1px 0 0; }
/* "Hide empty" toggle: instantly drop contacts with no captured message (the server
   also filters them before pagination; this is the optimistic client-side hide). */
.bc-rows.hide-empty .bc-row.is-empty-conv { display: none; }

.bc-row-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
[data-density="compact"] .bc-row-foot { margin-top: 3px; }
.bc-badge-unread {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--m-accent); color: #fff; font-size: 10.5px; font-weight: 700; font-family: var(--font-mono);
  display: inline-flex; align-items: center; justify-content: center;
}
.bc-needs-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  color: var(--stage2); background: color-mix(in srgb, var(--stage2) 15%, transparent);
  padding: 2px 7px 2px 6px; border-radius: 999px;
}
.bc-needs-tag svg { color: var(--stage2); }

/* stage chip */
.bc-stage {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--sc) 14%, transparent);
  color: color-mix(in srgb, var(--sc) 72%, var(--text));
  font-weight: 600; white-space: nowrap;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sc) 26%, transparent);
}
.bc-stage--sm { font-size: 10.5px; padding: 2px 8px 2px 6px; }
.bc-stage--md { font-size: 12px; padding: 4px 11px 4px 8px; }
.bc-stage-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sc); flex-shrink: 0; }
.bc-stage-n { opacity: .75; font-size: .92em; }
.bc-stage--sm .bc-stage-n { display: none; }

.bc-label-chip {
  font-size: 10.5px; font-weight: 500; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}

/* avatar */
.bc-avatar {
  border-radius: 50%; flex-shrink: 0; position: relative;
  display: grid; place-items: center; color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.bc-avatar span { letter-spacing: -.02em; }
.bc-avatar-fav {
  position: absolute; bottom: -2px; right: -2px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--stage2); display: grid; place-items: center; color: #2a1d00;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ============================== ICON BUTTON ============================== */
.bc-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; min-width: 32px; padding: 0 7px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
}
.bc-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.bc-iconbtn.is-active { background: var(--accent-weak); color: var(--accent-text); }
.bc-iconbtn.is-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ============================== CONVERSATION PANE ============================== */
.bc-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.bc-pane-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); background: var(--surface); min-height: 64px;
}
.bc-pane-creator { display: flex; align-items: center; gap: 11px; min-width: 0; cursor: pointer; }
.bc-pane-creator:hover .bc-pane-name { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.bc-pane-name { font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-pane-sub { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-3); margin-top: 1px; min-width: 0; overflow: hidden; }
/* Meta items never wrap internally ("active 5m ago" was stacking into 3 lines and
   pushing the ID under the stage pill); when space runs out the ID, least critical
   since its full value sits in the tooltip, is the one item allowed to ellipsize. */
.bc-pane-sub > span, .bc-pane-sub > a { white-space: nowrap; flex: none; }
.bc-pane-sub .bc-pane-id { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bc-pane-handle { font-family: var(--font-mono); }
.bc-channel {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 8px 2px 6px; border-radius: 999px;
}
.bc-channel svg { color: var(--text); }
.bc-pane-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

/* stage dropdown trigger */
.bc-stage-trigger {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px 0 11px;
  border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--sc) 30%, var(--border));
  background: color-mix(in srgb, var(--sc) 11%, transparent); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  transition: background .12s;
}
.bc-stage-trigger:hover { background: color-mix(in srgb, var(--sc) 18%, transparent); }
.bc-stage-trigger .bc-stage-dot { width: 7px; height: 7px; }
.bc-stage-trigger .bc-st-label { color: var(--text-2); font-weight: 500; font-size: 11px; margin-right: -2px; }
.bc-stage-trigger svg { color: var(--text-3); }

/* thread */
.bc-thread { flex: 1; overflow-y: auto; padding: 22px 0 16px; display: flex; flex-direction: column; gap: 3px; }
.bc-thread-inner { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 34px; }
.bc-daysep { display: flex; align-items: center; gap: 12px; margin: 14px 0 18px; }
.bc-daysep::before, .bc-daysep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.bc-daysep span { font-size: 10.5px; font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; }
.bc-daysep-move { margin: 20px 0 22px; }
.bc-daysep-move::before, .bc-daysep-move::after { background: var(--accent-line); }
.bc-daysep-move span { color: var(--accent-text); }

.bc-msg { display: flex; flex-direction: column; margin-bottom: 12px; max-width: 100%; }
.bc-msg.from-them { align-items: flex-start; }
.bc-msg.from-us { align-items: flex-end; }
.bc-bubble {
  max-width: 74%; padding: 10px 14px 11px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.55;
  position: relative; word-break: break-word; white-space: pre-wrap;
}
.bc-msg.from-them .bc-bubble { background: var(--bubble-them); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.bc-msg.from-us .bc-bubble { background: var(--bubble-us); border: 1px solid var(--bubble-us-border); border-bottom-right-radius: 5px; }
.bc-msg.is-ai .bc-bubble { background: var(--bubble-ai); border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--border)); }
.bc-bubble[dir="rtl"] { text-align: right; }

.bc-msg-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding: 0 4px; font-size: 10.5px; color: var(--text-3); }
.bc-msg.from-us .bc-msg-meta { flex-direction: row-reverse; }
.bc-msg-time { font-family: var(--font-mono); }
.bc-ai-tag {
  display: inline-flex; align-items: center; gap: 3px; font-weight: 600;
  color: var(--accent-text); background: var(--accent-weak); padding: 1px 6px 1px 4px; border-radius: 999px;
}
.bc-ai-tag svg { color: var(--accent-text); }
.bc-human-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.bc-human-tag .bc-h-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }

/* composer */
.bc-composer { padding: 14px 26px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.bc-composer-inner { max-width: 1180px; margin: 0 auto; }
.bc-composer-box {
  border: 1px solid var(--border-2); border-radius: var(--r-lg); background: var(--bg);
  transition: border-color .14s, box-shadow .14s; overflow: hidden;
}
.bc-composer-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-weak); }
.bc-composer textarea {
  width: 100%; border: 0; background: transparent; resize: none; color: var(--text);
  font-family: inherit; font-size: 13.5px; line-height: 1.5; padding: 12px 14px 4px; min-height: 24px; max-height: 160px;
}
.bc-composer textarea:focus { outline: none; }
.bc-composer textarea::placeholder { color: var(--text-3); }
.bc-composer-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px 8px; }
.bc-composer-bar .spacer { flex: 1; }
.bc-ai-suggest {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; margin-right: 6px;
  border-radius: var(--r-sm); border: 1px solid var(--accent-line); background: var(--accent-weak);
  color: var(--accent-text); font-size: 11.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.bc-send {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: var(--r-md); border: 0; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg);
  box-shadow: 0 2px 8px -2px var(--accent-weak);
  transition: filter .12s, transform .05s;
}
.bc-send:hover { filter: brightness(1.08); }
.bc-send:active { transform: translateY(1px); }
.bc-send svg { color: currentColor; }

/* ============================== POPOVER / MENUS ============================== */
.bc-pop {
  position: absolute; z-index: 50; background: var(--raised); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 5px; min-width: 200px;
  animation: bc-pop-in .12s ease;
}
@keyframes bc-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.99); } to { opacity: 1; transform: none; } }
.bc-pop-head { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 6px 9px 5px; }
.bc-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 9px; border-radius: var(--r-sm); border: 0; background: transparent; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 13px;
}
.bc-menu-item:hover { background: var(--surface-2); }
.bc-menu-item.is-active { background: var(--accent-weak); }
.bc-menu-item .bc-mi-check { margin-left: auto; color: var(--accent-text); opacity: 0; }
.bc-menu-item.is-active .bc-mi-check { opacity: 1; }
.bc-menu-stage { display: flex; align-items: center; gap: 9px; }

/* ============================== EMPTY STATES ============================== */
.bc-empty { flex: 1; display: grid; place-items: center; padding: 40px; text-align: center; }
.bc-empty-inner { max-width: 340px; }
.bc-empty-icon {
  width: 60px; height: 60px; border-radius: var(--r-xl); margin: 0 auto 18px;
  background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3);
}
.bc-empty h3 { margin: 0 0 7px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.bc-empty p { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.55; }
.bc-empty-list { padding: 60px 24px; text-align: center; color: var(--text-3); }
.bc-empty-list .bc-empty-icon { width: 48px; height: 48px; margin-bottom: 14px; }
.bc-empty-list h4 { margin: 0 0 5px; font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.bc-empty-list p { margin: 0; font-size: 12px; }

/* ============================== CONTACTS VIEW ============================== */
.bc-contacts { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.bc-contacts-head { padding: 18px 24px 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.bc-contacts-head .bc-list-title { font-size: 18px; }
.bc-contacts-scroll { flex: 1; overflow-y: auto; }
.bc-table { width: 100%; border-collapse: collapse; }
.bc-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.bc-table tbody tr { cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; }
.bc-table tbody tr:hover { background: var(--surface); }
.bc-table td { padding: 11px 16px; font-size: 13px; vertical-align: middle; }
[data-density="compact"] .bc-table td { padding: 7px 16px; }
.bc-cell-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.bc-cell-name-text { min-width: 0; }
.bc-cell-name-text .nm { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-cell-name-text .hd { font-size: 11.5px; color: var(--text-3); font-family: var(--font-mono); }
.bc-cell-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.bc-cell-muted { color: var(--text-3); }
.bc-id-missing { font-size: 10.5px; color: var(--text-faint); font-style: italic; }

/* ============================== CONTACT DRAWER ============================== */
.bc-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 90; animation: bc-fade .16s ease; backdrop-filter: blur(1px); }
@keyframes bc-fade { from { opacity: 0; } to { opacity: 1; } }
.bc-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; z-index: 100;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column; animation: bc-slide .22s cubic-bezier(.22,.61,.36,1);
}
@keyframes bc-slide { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.bc-drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.bc-drawer-head h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.bc-drawer-scroll { flex: 1; overflow-y: auto; }

.bc-profile { padding: 22px 20px 18px; text-align: center; border-bottom: 1px solid var(--border); position: relative; }
.bc-profile .bc-avatar { margin: 0 auto 12px; }
.bc-profile-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.bc-profile-handle { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.bc-profile-meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.bc-fields { padding: 8px 8px 16px; }
.bc-field {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-md); position: relative;
  transition: background .1s;
}
.bc-field:hover { background: var(--surface-2); }
.bc-field-icon { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.bc-field:hover .bc-field-icon { background: var(--surface-3); }
.bc-field-body { flex: 1; min-width: 0; }
.bc-field-label { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.bc-field-value { font-size: 13px; color: var(--text); margin-top: 2px; word-break: break-word; }
.bc-field-value.mono { font-family: var(--font-mono); font-size: 12.5px; }
.bc-field-value.empty { color: var(--text-faint); font-style: italic; }
.bc-field-edit { opacity: 0; color: var(--text-3); transition: opacity .1s; }
.bc-field:hover .bc-field-edit { opacity: 1; }
.bc-field-input {
  width: 100%; background: var(--bg); border: 1px solid var(--accent-line); color: var(--text);
  border-radius: var(--r-sm); padding: 5px 8px; font-size: 13px; font-family: inherit; margin-top: 2px;
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.bc-field-input:focus { outline: none; }
.bc-field-input.mono { font-family: var(--font-mono); }

.bc-section-title { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); padding: 14px 20px 6px; display: flex; align-items: center; gap: 8px; }
.bc-section-title .ln { flex: 1; height: 1px; background: var(--border); }

.bc-notes { padding: 4px 20px 20px; }
.bc-notes-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 13px; font-size: 13px; line-height: 1.55; color: var(--text); min-height: 70px; cursor: text;
}
.bc-notes-box.empty { color: var(--text-faint); font-style: italic; }
.bc-notes-box:hover { border-color: var(--border-2); }
.bc-notes textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--accent-line); color: var(--text);
  border-radius: var(--r-md); padding: 12px 13px; font-size: 13px; line-height: 1.55; font-family: inherit;
  resize: vertical; min-height: 90px; box-shadow: 0 0 0 3px var(--accent-weak);
}
.bc-notes textarea:focus { outline: none; }

.bc-drawer-stage { padding: 12px 20px 18px; }
.bc-stage-steps { display: flex; gap: 6px; margin-top: 8px; }
.bc-stage-step {
  flex: 1; border: 1px solid var(--border-2); background: transparent; cursor: pointer; border-radius: var(--r-sm);
  padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--text-3);
  font-family: inherit; transition: all .12s;
}
.bc-stage-step:hover { border-color: var(--ss); color: var(--text-2); }
.bc-stage-step.is-active { background: color-mix(in srgb, var(--ss) 14%, transparent); border-color: color-mix(in srgb, var(--ss) 42%, transparent); color: color-mix(in srgb, var(--ss) 72%, var(--text)); }
.bc-stage-step .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.bc-stage-step .lbl { font-size: 11px; font-weight: 600; }
.bc-stage-step .num { font-size: 9.5px; font-family: var(--font-mono); opacity: .7; }

/* ============================== TOPBAR (generic views) ============================== */
.bc-view { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }

/* density toggle pill in list head */
.bc-density-pill { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px; }
.bc-density-pill button { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 5px; color: var(--text-3); display: grid; place-items: center; }
.bc-density-pill button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

/* toast */
.bc-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--raised); border: 1px solid var(--border-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 10px 14px; display: flex; align-items: center; gap: 9px;
  font-size: 12.5px; color: var(--text); animation: bc-toast-in .2s ease;
}
@keyframes bc-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.bc-toast .bc-toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
