:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #fff;
  --surface-2: #f7f8fa;
  --surface-3: #e9edf3;
  --text: #172033;
  --muted: #526071;
  --line: #d8dee8;
  --accent: #2457d6;
  --accent-soft: #e8efff;
  --danger: #bd2c38;
  --success: #147a4c;
  --sidebar-w: 232px;
  --threads-w: 360px;
  --top-h: 54px;
  font: 14px/1.4 Inter, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible, [contenteditable]:focus-visible, a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.skip-link { position: fixed; z-index: 100; left: 8px; top: -50px; padding: 8px 12px; background: var(--surface); color: var(--accent); }
.skip-link:focus { top: 8px; }
.app { width: 100%; height: 100%; }
.topbar { height: var(--top-h); display: flex; align-items: center; gap: 18px; padding: 0 14px; background: #18243a; color: #fff; border-bottom: 1px solid #0d1728; }
.brand { display: flex; align-items: center; gap: 9px; min-width: calc(var(--sidebar-w) - 14px); color: inherit; text-decoration: none; font-weight: 650; }
.brand-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 7px; background: #365cc7; font-size: 11px; font-weight: 700; }
.brand b { color: #a9bdfc; font-size: 10px; }
.top-search { width: min(620px, 46vw); height: 34px; margin-inline: auto; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid #455269; border-radius: 6px; background: #26344b; }
.top-search input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: #fff; }
.top-search input::placeholder { color: #b5bdca; }
kbd { padding: 1px 5px; border: 1px solid currentColor; border-radius: 4px; font: 11px ui-monospace, monospace; opacity: .7; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.connection { display: flex; align-items: center; gap: 6px; color: #ccd3df; font-size: 12px; white-space: nowrap; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: #f1b642; }
.connection.online i { background: #3fd18a; }
.connection.offline i { background: #ff6975; }
.connection.connecting i { background: #f1b642; animation: pulse-dot 1.2s ease-in-out infinite; }
.simulation-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; background: #5c4a12; color: #ffe08a; font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.engagement-chip.simulated { background: #fff7e6; color: #9a6700; border: 1px solid #f1d48a; }
@keyframes pulse-dot { 50% { opacity: .45; } }
/* minmax(0,1fr) row: without it the auto row grows with content and the panes cannot scroll. */
.workspace { height: calc(100% - var(--top-h)); display: grid; grid-template-columns: var(--sidebar-w) 5px 1fr; grid-template-rows: minmax(0, 1fr); min-width: 0; }
.pane { background: var(--surface); min-width: 0; }
.sidebar { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line); }
.app-nav { padding: 9px; }
.nav-item, .folder-item { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; border-radius: 5px; background: none; text-align: left; }
.nav-item { min-height: 36px; padding: 6px 10px; }
.nav-item:hover, .folder-item:hover { background: var(--surface-2); }
.nav-item.active, .folder-item.active { background: var(--accent-soft); color: #1648bd; font-weight: 650; }
.nav-item em { margin-left: auto; padding: 0 6px; border-radius: 10px; background: var(--accent); color: white; font-style: normal; font-size: 11px; }
.nav-item em.muted { background: #94a3b8; font-weight: 600; }
.sidebar-separator { border-top: 1px solid var(--line); }
.folder-section { min-height: 0; flex: 1; padding: 9px; overflow-y: auto; }
.section-label { display: flex; justify-content: space-between; align-items: center; padding: 7px 9px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.nav-group-label { padding-top: 2px; padding-bottom: 2px; }
.nav-group-label:first-child { padding-top: 0; }
.nav-group-sep { margin: 4px 9px; }
.replies-subtitle { margin: -6px 0 14px; max-width: 52rem; line-height: 1.45; }
.lead-chip { align-self: start; font-size: 11px; }
.tiny-btn { border: 0; background: none; color: inherit; font-size: 17px; }
.folder-item { min-height: 34px; padding: 5px 10px; }
.folder-item .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.folder-icon { width: 18px; text-align: center; }
.labels-title { margin: 14px 9px 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.label-dot { width: 8px; height: 8px; border-radius: 50%; }
.sidebar-footer { padding: 10px 12px; border-top: 1px solid var(--line); color: var(--muted); }
.language-label { display: flex; align-items: center; justify-content: space-between; }
.language-label select { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.account-address { display: block; margin-top: 7px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.resizer { position: relative; z-index: 5; background: var(--line); cursor: col-resize; touch-action: none; }
.resizer:hover, .resizer.dragging, .resizer:focus-visible { background: var(--accent); }
.mail-stage { display: none; grid-template-columns: var(--threads-w) 5px minmax(320px, 1fr); grid-template-rows: minmax(0, 1fr); min-width: 0; min-height: 0; }
.mail-stage.active { display: grid; }
.section:not(.active) { display: none !important; }
.section[hidden] { display: none !important; }
.thread-pane, .reader-pane { min-height: 0; overflow: hidden; }
.thread-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.pane-toolbar { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.pane-toolbar h1 { margin: 0; font-size: 15px; }
.pane-toolbar > div:first-child { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.muted { color: var(--muted); font-size: 12px; }
.toolbar-buttons { display: flex; gap: 4px; }
.icon-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.icon-btn svg { flex: none; }
.icon-btn:hover { border-color: var(--line); background: var(--surface-2); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent); }
.icon-btn.accent:hover { border-color: var(--accent); }
.btn { min-height: 33px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.danger, .icon-btn.danger { color: var(--danger); }
.bulk-bar { display: flex; align-items: center; gap: 2px; min-height: 36px; padding: 3px 9px; border-bottom: 1px solid #b9c9f8; background: var(--accent-soft); }
.bulk-bar[hidden] { display: none; }
.bulk-bar span { margin-right: auto; font-weight: 650; font-size: 12px; }
.bulk-bar button { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; border: 0; border-radius: 4px; background: transparent; color: var(--accent); }
.bulk-bar button:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.thread-list { min-height: 0; flex: 1; overflow: auto; }
.load-more { margin: 8px; min-height: 34px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--accent); font-weight: 650; }
.thread { position: relative; display: grid; grid-template-columns: 25px minmax(0,1fr) auto; gap: 7px; min-height: 64px; padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface); outline: 0; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.thread.selected { background: #edf3ff; }
.thread.unread .thread-sender, .thread.unread .thread-subject { font-weight: 750; color: #0e1930; }
.thread.unread .thread-sender::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--accent); vertical-align: 1px; flex-shrink: 0; }
.thread.unread .thread-subject { letter-spacing: -.01em; }
.thread.unread .thread-snippet { color: #3d4a5c; font-weight: 550; }
.thread-badges .badge.label { background: var(--surface-3); }
.badge.unread { min-width: 1.1rem; text-align: center; }
.badge.meta { font-variant-numeric: tabular-nums; }
.thread-check { margin-top: 3px; }
.thread-open { width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.thread-open:focus-visible { border-radius: 4px; }
.thread-main { min-width: 0; }
.thread-top { display: flex; align-items: center; gap: 5px; }
.thread-sender, .thread-subject, .thread-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-sender { flex: 1; }
.thread-subject { margin-top: 2px; }
.thread-snippet { margin-top: 2px; color: var(--muted); font-size: 12px; }
.thread-badges { display: flex; gap: 4px; margin-top: 3px; }
.badge { padding: 1px 5px; border-radius: 3px; background: var(--surface-3); color: var(--muted); font-size: 10px; }
.badge.warn { background: #fff0d7; color: #8a5500; }
.badge.error { background: #fff0f0; color: var(--danger); font-weight: 600; }
.inbound-error-banner { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 14px; border-bottom: 1px solid #e5a4aa; background: #fff5f5; color: var(--danger); font-size: 12px; }
.thread-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; color: var(--muted); font-size: 11px; }
.star-btn { padding: 0; border: 0; background: none; color: #a5adba; }
.star-btn.on { color: #d78a00; }
.reader-pane { display: flex; }
.reader { width: 100%; min-width: 0; overflow: auto; background: var(--surface); }
.state { min-height: 100%; display: grid; place-content: center; padding: 30px; text-align: center; color: var(--muted); }
.state .state-icon { font-size: 42px; opacity: .6; }
.state h2 { margin: 12px 0 3px; color: var(--text); font-size: 18px; }
.reader-header { position: sticky; z-index: 2; top: 0; padding: 12px 18px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); }
.reader-title-row { display: flex; align-items: start; gap: 10px; }
.reader-title-row h2 { flex: 1; margin: 0; font-size: 20px; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.sender-block { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; margin-top: 10px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: #dce6ff; color: #214ba8; font-weight: 750; }
.sender-detail small { display: block; color: var(--muted); }
.message-card { margin: 12px 18px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.message-meta { padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.message-engagement { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 14px 0; }
.engagement-chip { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border-radius: 11px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 600; }
.engagement-chip.delivered { background: #e7f6ed; color: #237a45; }
.engagement-chip.opened { background: #e8f2ff; color: #175b9c; }
.engagement-chip.clicked { background: #eee9ff; color: #6240a8; }
.engagement-chip.problem { background: #fff0f0; color: var(--danger); }
.engagement-count { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.engagement-count.opened { color: #175b9c; }
.engagement-count.clicked { color: #6240a8; }
.remote-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; border-bottom: 1px solid #efcf94; background: #fff7e6; color: #765000; font-size: 12px; }
.email-frame { display: block; width: 100%; height: 440px; border: 0; background: #fff; opacity: 0; transition: opacity .2s ease; }
.email-frame.is-ready { opacity: 1; }
.email-frame-wrap { position: relative; min-height: 440px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.email-frame-loading, .email-frame-empty { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; padding: 24px; color: var(--muted); text-align: center; }
.email-frame-wrap .email-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.loading-spinner { width: 22px; height: 22px; border: 2px solid color-mix(in srgb, var(--accent) 20%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.state .loading-spinner { margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.plain-message { padding: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 14px; border-top: 1px solid var(--line); }
.message-attachments a { color: var(--accent); }
.menu-wrap { position: relative; }
.menu { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 180px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: 0 12px 35px #0d1b3030; }
.menu.align-right { right: 0; left: auto; }
.menu button { width: 100%; padding: 7px 9px; border: 0; border-radius: 4px; background: none; text-align: left; }
.menu button:hover, .menu button:focus { background: var(--accent-soft); }
.context-menu { position: fixed; }
.content-stage { padding: 20px; overflow: auto; background: var(--bg); }
.content-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.content-head h1 { margin: 0; font-size: 22px; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; }
.filters input, .filters select, .form-control { min-height: 34px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.card { padding: 16px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 11px; text-transform: uppercase; }
tbody tr:hover { background: var(--surface-2); }
.status-pill { display: inline-block; padding: 2px 7px; border-radius: 10px; background: var(--surface-3); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(140px,1fr)); gap: 12px; }
.kpi strong { display: block; margin-top: 7px; font-size: 28px; }
.kpi span { color: var(--muted); }
.dashboard-hero { margin: 10px 0 16px; }
.dashboard-grid--hero { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.dashboard-grid--hero .kpi-hero { padding: 16px 18px; }
.dashboard-grid--hero .kpi-hero strong { margin-top: 6px; font-size: 30px; line-height: 1.12; }
.dashboard-section--secondary { margin: 12px 0; }
.dashboard-section--secondary h2 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.dashboard-grid--secondary { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 8px; }
.dashboard-grid--secondary .kpi { padding: 10px 12px; }
.dashboard-grid--secondary .kpi strong { margin-top: 4px; font-size: 20px; }
.dashboard-grid--secondary .kpi span { font-size: 11px; line-height: 1.3; }
.dashboard-funnel { margin: 14px 0 16px; }
.wide { grid-column: 1 / -1; }
.reply-grid, .setup-grid { display: grid; grid-template-columns: repeat(2, minmax(280px,1fr)); gap: 12px; }
.reply-card h3, .setup-card h3 { margin-top: 0; }
.reply-preview { max-height: 200px; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); white-space: pre-wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.setup-card label { display: grid; gap: 5px; margin: 10px 0; }
.setup-card textarea { min-height: 100px; resize: vertical; }
.esp-choices { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 10px; }
.esp-choice { display: grid !important; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px !important; min-height: 74px; margin: 0 !important; padding: 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.esp-choice:hover { background: var(--surface-2); }
.esp-choice.selected { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 18%, transparent); background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.esp-choice.unavailable { opacity: .62; cursor: not-allowed; }
.esp-choice input { margin: 0; }
.esp-logo { width: 36px; height: 36px; display: inline-grid; place-items: center; }
.esp-logo svg { width: 36px; height: 36px; display: block; }
.esp-copy { display: grid; gap: 4px; }
.esp-copy small { display: flex; align-items: center; gap: 5px; }
.esp-copy small.ok { color: #237a45; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.setup-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.setup-hint.ok { color: #237a45; }
.setup-hint .status-dot { display: inline-block; margin-right: 3px; }
.setup-mode-banner { margin: 0 0 12px; padding: 10px 12px; border-radius: 6px; border-left: 3px solid var(--line); background: var(--surface-2); font-size: 13px; line-height: 1.45; }
.setup-mode-banner.ok { border-left-color: #237a45; background: #edf8f1; color: #1b5c34; }
.setup-mode-banner.warn { border-left-color: #c98200; background: #fff6df; color: #704900; }
.setup-mode-banner.danger { border-left-color: var(--danger); background: #fff5f5; color: var(--danger); }
.setup-mode-banner.muted { border-left-color: var(--muted); color: var(--text); }
.hot-mode-switch { font-weight: 700; letter-spacing: 0.02em; color: var(--danger); }
.hot-mode-switch input { accent-color: var(--danger); }
.maintenance-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.maintenance-head h3 { margin-bottom: 0; }
.maintenance-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 12px; margin: 15px 0; }
.maintenance-grid > div { padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.maintenance-grid p { margin: 7px 0 0; }
.event-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.webhook-events { display: grid; gap: 1px; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.webhook-events > div { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(180px, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); }
.webhook-events time { color: var(--muted); font-size: 11px; }
.webhook-events > p { padding: 10px; margin: 0; }
.switch { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.error-state { padding: 24px; border: 1px dashed #e5a4aa; border-radius: 7px; background: #fff5f5; color: var(--danger); text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.empty-state { padding: 22px; border: 1px dashed var(--line); border-radius: 7px; color: var(--muted); text-align: center; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-head h2, .panel-head h3, .dashboard-section h2 { margin: 0 0 4px; }
.automation-panel { margin-bottom: 18px; }
.campaign-controls, .research-basics { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) auto; align-items: end; gap: 10px; }
.campaign-controls label, .research-basics label, .inline-form label, .candidate-fields label, .reply-card > label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 650; }
.inline-form { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)) auto; align-items: end; gap: 10px; margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.research-form { margin-top: 18px; }
.research-form-simple { display: grid; gap: 14px; }
.research-panel-head { align-items: center; }
.research-panel-head h2, .candidate-section h3 { display: flex; align-items: center; gap: 8px; }
.title-icon, .status-icon { flex-shrink: 0; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: #1648bd; font-size: 12px; font-weight: 650; white-space: nowrap; }
.research-steps { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; padding: 0; }
.research-steps li { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 650; }
.research-steps .step-num { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-size: 11px; }
.research-steps li.is-active { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); color: #1648bd; }
.research-steps li.is-active .step-num { background: var(--accent); color: #fff; }
.research-steps li.is-done { border-color: #b7e4c7; background: #edf8f1; color: #1b5c34; }
.research-steps li.is-done .step-num { background: var(--success); color: #fff; }
.purpose-label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.purpose-label-row { display: flex; align-items: center; gap: 8px; }
.purpose-label-row .char-count { margin-left: auto; font-weight: 600; color: var(--muted); }
.purpose-subhint { font-weight: 500; }
.purpose-input { min-height: 220px; resize: vertical; }
.purpose-warn {
  margin: 0.55rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #92400e;
  font-size: 0.88rem;
  line-height: 1.45;
}
.purpose-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.purpose-actions .count-label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 650; min-width: 100px; }
.purpose-actions .btn.primary { margin-left: auto; }
.btn-with-icon, .btn.is-busy { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-spinner, .research-spinner { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; border-radius: 50%; animation: ea-spin .7s linear infinite; flex-shrink: 0; }
.quote-card { display: grid; gap: 12px; padding: 14px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: 10px; background: linear-gradient(180deg, #f7f9ff, var(--surface)); }
.quote-card-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.quote-card-head strong { display: inline-flex; align-items: center; gap: 8px; }
.quote-amounts { display: flex; gap: 10px; align-items: baseline; font-weight: 750; font-size: 18px; }
.quote-amounts small { display: block; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.quote-max { color: #1648bd; }
.research-statusbar { position: sticky; top: 0; z-index: 4; display: grid; gap: 10px; margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(23, 32, 51, .06); }
.research-statusbar[data-tone="done"] { border-color: #b7e4c7; background: #f3fbf6; }
.research-statusbar[data-tone="failed"] { border-color: #e5a4aa; background: #fff5f5; }
.research-statusbar-top { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.research-statusbar-title { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.research-statusbar-title strong { display: block; }
.research-statusbar-title p { margin: 2px 0 0; }
.research-statusbar-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }
.meta-chip b { font-variant-numeric: tabular-nums; }
.research-progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.research-progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #3b6ef5, #2457d6); transition: width .4s ease; }
.research-statusbar[data-tone="done"] .research-progress-bar { background: var(--success); }
.research-statusbar[data-tone="failed"] .research-progress-bar { background: var(--danger); }
.candidate-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.candidate-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.candidate-card.is-incomplete { border-color: #f0c4a8; background: #fffaf5; }
.evidence-warn-badge {
  display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
}
.cost-without-result-banner {
  display: block;
  margin: 12px 0 14px;
  border: 2px solid color-mix(in srgb, var(--danger) 55%, #e5a4aa);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff5f5, #fffafa);
  box-shadow: 0 4px 18px rgba(180, 35, 24, .12);
}
.cost-without-result-banner[hidden] { display: none; }
.cost-without-result-banner > summary {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px 16px; cursor: pointer; list-style: none;
}
.cost-without-result-banner > summary::-webkit-details-marker { display: none; }
.cost-warning-summary .cost-warning-title { font-size: 15px; font-weight: 800; color: var(--danger); }
.cost-warning-amount-compact { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; color: #8a1f1a; }
.cost-warning-expanded { padding: 0 16px 14px; }
.cost-without-result-banner:not([open]) .cost-warning-expanded { display: none; }
.cost-warning-icon { color: var(--danger); flex-shrink: 0; }
.cost-warning-body { flex: 1; min-width: 200px; }
.cost-warning-title { display: block; font-size: 18px; font-weight: 800; color: var(--danger); }
.cost-warning-amount { margin: 6px 0 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: #8a1f1a; }
.cost-warning-detail { margin: 4px 0 0; font-size: 13px; }
.cost-warning-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.candidate-fields .field-caption { display: inline-flex; align-items: center; gap: 6px; }
.candidate-meta { display: flex; flex-wrap: wrap; gap: 10px 14px; margin: 10px 0; color: var(--muted); font-size: 12px; }
.candidate-meta span, .candidate-meta strong { display: inline-flex; align-items: center; gap: 5px; }
.ok-text { color: var(--success); }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; }
@keyframes ea-spin { to { transform: rotate(360deg); } }
.research-debug { margin: 14px 0; border: 1px solid #c9d4e8; border-radius: 10px; padding: 10px 12px; background: #f5f8ff; }
.research-debug > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; list-style: none; }
.research-debug > summary::-webkit-details-marker { display: none; }
.research-debug[open] > summary { margin-bottom: 8px; }
.research-debug .debug-count { margin-left: auto; min-width: 1.6rem; padding: 2px 7px; border-radius: 999px; background: #2457d6; color: #fff; font-size: 11px; text-align: center; }
.research-debug-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.research-debug-pre { max-height: 280px; overflow: auto; margin: 0; padding: 12px; border-radius: 8px; border: 1px solid var(--line); background: #0f172a; color: #e2e8f0; font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.research-advanced { margin-top: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.research-advanced summary { cursor: pointer; font-weight: 650; color: var(--muted); display: flex; align-items: center; gap: 8px; list-style: none; }
.research-advanced .advanced-research-hint { margin: 0 0 8px; }
.research-advanced summary::-webkit-details-marker { display: none; }
.research-advanced[open] summary { margin-bottom: 10px; }
.research-advanced .btn { margin: 6px 0; }
@media (max-width: 900px) {
  .research-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purpose-actions .btn.primary { margin-left: 0; width: 100%; }
}
.research-basics .query-label { grid-column: span 2; }
.lead-list-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lead-table .col-check { width: 36px; }
.lead-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.lead-table .lead-status-select { min-width: 8.5rem; font-size: 12px; padding: 4px 8px; border-radius: 999px; }
.lead-table tr.lead-row-new { outline: 2px solid var(--accent, #2457d6); outline-offset: -2px; background: #eff4ff; transition: background 2s ease; }
.link-btn { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; text-align: left; font: inherit; }
.link-btn:hover strong { color: var(--accent, #2457d6); text-decoration: underline; }
.icon-btn.danger { color: #b42318; }
.icon-btn.danger:hover { background: #fef3f2; }
.status-new { background: #eef2ff; }
.status-contacted { background: #eff8ff; }
.status-replied { background: #ecfdf3; }
.status-interested { background: #ecfdf3; border-color: #abefc6; }
.status-question { background: #fffaeb; }
.status-rejected, .status-blacklisted, .status-unsubscribed { background: #fef3f2; color: #b42318; }
.status-manual { background: #f2f4f7; }
.research-fields { margin: 14px 0; border: 1px solid var(--line); border-radius: 7px; }
.research-fields > summary { padding: 12px; cursor: pointer; font-weight: 700; }
#researchFieldList, .research-field-list { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 10px; padding: 0 12px 12px; }
.research-field { display: grid; grid-template-columns: minmax(120px, .7fr) minmax(160px, 1fr); gap: 8px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 6px; }
.research-field legend { padding: 0 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.research-field label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 650; }
.research-field .field-instructions { grid-column: 1 / -1; }
.research-field textarea { resize: vertical; }
.research-options { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 12px; }
.research-option { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
.research-option h3 { margin-top: 0; }
.research-option > label { display: grid; gap: 5px; margin-top: 10px; font-weight: 650; }
.research-copy { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.operation-state { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.operation-state[hidden] { display: none; }
.detail-list { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 12px; width: 100%; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 650; }
.detail-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.warning-note { padding: 9px; border-left: 3px solid #c98200; background: #fff6df; color: #704900; }
.confirm-row, .select-row { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 8px !important; color: var(--text) !important; }
.confirm-row input, .select-row input { margin-top: 3px; flex: 0 0 auto; }
.candidate-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.candidate-list, .approval-grid, .campaign-rows { display: grid; gap: 10px; }
.candidate-card, .approval-card { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.candidate-card .select-row { align-items: center; }
.candidate-card .select-row .status-pill { margin-left: auto; }
.candidate-fields { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 8px; margin: 12px 0; }
.candidate-fields .missing { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 5%, var(--surface)); }
.candidate-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; color: var(--muted); font-size: 12px; }
.danger-text { color: var(--danger); }
.evidence-list { max-height: 180px; margin: 8px 0; overflow: auto; overflow-wrap: anywhere; }
.evidence-list a { color: var(--accent); }
.approval-grid { grid-template-columns: repeat(2, minmax(280px, 1fr)); }
.message-preview { max-height: 240px; overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); overflow-wrap: anywhere; }
.lead-list-section { margin-top: 20px; }
.lead-list-section .content-head > div { min-width: 0; }
.lead-list-section h2 { margin: 0 0 9px; }
.reply-bulk { padding: 10px 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); margin-bottom: 8px; }
.reply-bulk--primary { position: sticky; top: 0; z-index: 3; box-shadow: 0 2px 10px rgba(15, 23, 42, .08); }
.reply-bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.reply-workflow-hint { margin: 2px 0 0; font-size: 12px; }
.reply-card { padding: 12px 14px; }
.reply-card .reply-editor { min-height: 5.5rem; }
.reply-single-actions { margin-top: 8px; }
.reply-single-actions > summary { cursor: pointer; font-size: 12px; color: var(--muted); font-weight: 650; }
.leads-wizard { display: grid; gap: 12px; }
.leads-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.leads-tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 650; color: var(--muted); cursor: pointer; }
.leads-tab.active, .leads-tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--line); }
.leads-panel[hidden] { display: none !important; }
.candidate-next-step { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 0 0 12px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 10px; background: var(--accent-soft); }
.candidate-next-step[hidden] { display: none !important; }
.candidate-next-step-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-goal-toggle { margin-left: auto; }
.app[data-section="mail"] #projectGoal { display: none !important; }
.app[data-section="mail"] #projectGoal.is-mail-shown { display: -webkit-box !important; overflow: hidden; margin-top: 7px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.35; }
.app[data-section="mail"] #projectGoal.is-mail-shown.is-expanded { -webkit-line-clamp: unset; display: block !important; overflow: visible; white-space: pre-wrap; }
.reply-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.reply-filters .sort-chip { margin-left: auto; }
.reply-card { display: grid; align-content: start; gap: 7px; padding: 12px 14px; }
.reply-card h3 { margin: 0; }
.reply-card > label { gap: 4px; margin: 0; }
.reply-card .card-actions { margin-top: 6px; }
.reply-editor { width: 100%; min-height: 132px; resize: vertical; }
.thread-context { border-block: 1px solid var(--line); padding: 8px 0; }
.thread-context summary { cursor: pointer; font-weight: 650; }
.dashboard-section { margin: 20px 0; }
.funnel { display: grid; gap: 10px; margin-top: 14px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 48px; align-items: center; gap: 10px; }
.funnel-row > div { height: 11px; overflow: hidden; border-radius: 7px; background: var(--surface-3); }
.funnel-row i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.funnel-row strong { text-align: right; }
.campaign-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.campaign-row > div { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.campaign-row dl { display: grid; grid-template-columns: repeat(5, minmax(70px, 1fr)); gap: 14px; flex: 1; margin: 0; }
.campaign-row dl > div { text-align: right; }
.campaign-row dt { color: var(--muted); font-size: 11px; }
.campaign-row dd { margin: 3px 0 0; font-weight: 700; }
.skeleton { background: linear-gradient(90deg,#edf0f4 25%,#f7f8fa 45%,#edf0f4 65%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
.thread.skeleton { height: 86px; }
.reader-skeleton .skeleton-line { display: block; height: 12px; margin: 8px 0; border-radius: 4px; background: linear-gradient(90deg,#edf0f4 25%,#f7f8fa 45%,#edf0f4 65%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
.reader-skeleton .skeleton-line.w30 { width: 30%; }
.reader-skeleton .skeleton-line.w40 { width: 40%; }
.reader-skeleton .skeleton-line.w55 { width: 55%; }
.reader-skeleton .skeleton-line.w60 { width: 60%; }
.reader-skeleton .skeleton-line.w75 { width: 75%; }
.reader-skeleton .skeleton-line.w90 { width: 90%; }
.reader-skeleton .skeleton-line.w100 { width: 100%; }
.reader-skeleton .skeleton-btn { display: inline-block; width: 32px; height: 32px; border-radius: 6px; background: linear-gradient(90deg,#edf0f4 25%,#f7f8fa 45%,#edf0f4 65%); background-size: 300% 100%; animation: shimmer 1.3s infinite; }
.reader-skeleton .skeleton-avatar { background: linear-gradient(90deg,#edf0f4 25%,#f7f8fa 45%,#edf0f4 65%); background-size: 300% 100%; animation: shimmer 1.3s infinite; color: transparent; }
.reader-skeleton-body .skeleton-plain { color: var(--muted); margin-bottom: 10px; }
.reader-loading-hint { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; color: var(--muted); font-size: 13px; }
@keyframes shimmer { to { background-position: -100% 0; } }
.composer { position: fixed; z-index: 50; right: 18px; bottom: 0; width: min(640px, calc(100vw - 36px)); height: min(660px, calc(100vh - 70px)); display: flex; flex-direction: column; border: 1px solid #aeb7c6; border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface); box-shadow: 0 15px 60px #0e172a4d; }
.composer[hidden] { display: none; }
.composer.minimized { width: 320px; height: 48px; }
.composer.minimized > :not(.composer-head) { display: none; }
.composer-head { min-height: 43px; display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 13px; border-radius: 7px 7px 0 0; background: #24334d; color: #fff; }
.composer-head strong { flex: 1; }
.composer-sim-chip { flex: 0 0 auto; background: rgba(255, 224, 138, 0.18); color: #ffe08a; border: 1px solid rgba(255, 224, 138, 0.35); }
.draft-state { color: #c9d3e3; font-size: 11px; white-space: nowrap; }
.draft-state--saving { color: #f1d48a; }
.draft-state--saved { color: #9fd9b3; }
.draft-state--error { color: #ffb4b4; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.composer-fields { border-bottom: 1px solid var(--line); }
.address-row { min-height: 39px; display: grid; grid-template-columns: 60px 1fr auto; align-items: center; padding: 0 10px; border-bottom: 1px solid var(--line); }
.address-row:last-child { border: 0; }
.address-row label { color: var(--muted); }
.address-row input { min-width: 0; border: 0; outline: 0; background: transparent; }
.address-row button { border: 0; background: none; color: var(--accent); }
.compose-toolbar { display: flex; align-items: center; gap: 3px; padding: 5px 9px; border-bottom: 1px solid var(--line); }
.compose-toolbar button, .attach-btn { min-height: 29px; padding: 4px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; }
.compose-toolbar button:hover, .attach-btn:hover { border-color: var(--line); background: var(--surface-2); }
.compose-body { min-height: 0; flex: 1; width: 100%; padding: 14px; border: 0; outline: 0; resize: none; overflow: auto; background: var(--surface); }
.html-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.attachment-chip { padding: 4px 7px; border-radius: 4px; background: var(--surface-3); font-size: 11px; }
.attachment-chip button { border: 0; background: none; color: var(--danger); }
.composer-actions { display: flex; gap: 7px; padding: 9px; border-top: 1px solid var(--line); }
.composer-actions .danger { margin-left: auto; }
dialog { width: min(500px, calc(100vw - 30px)); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 20px 80px #10182855; }
dialog::backdrop { background: #10182866; }
dialog header { display: flex; justify-content: space-between; align-items: center; }
.shortcuts { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.shortcuts dt, .shortcuts dd { margin: 0; }
.toast-region { position: fixed; z-index: 90; right: 16px; top: 66px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 10px 13px; border-radius: 5px; background: #172033; color: #fff; box-shadow: 0 8px 30px #10182840; }
.toast button { margin-left: 12px; border: 1px solid #ffffff88; border-radius: 4px; background: transparent; color: #fff; font-weight: 700; }
.snooze-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.snooze-options + label, #organizeDialog form > label { display: grid; gap: 6px; margin: 12px 0; }
.organize-labels { display: grid; gap: 7px; margin-top: 8px; }
.organize-labels label { display: flex; gap: 8px; }
.organize-empty { display: grid; gap: 10px; padding: 8px 0; text-align: center; }
.dialog-hint { margin: 4px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.lead-status-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.status-chip:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--text); }
.status-chip.active { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); color: #1648bd; }
.dialog-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.mobile-only { display: none; }

@media (max-width: 800px) {
  :root { --top-h: 50px; }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { gap: 7px; padding: 0 8px; }
  .brand { min-width: 0; flex: 1; }
  .brand span:not(.brand-mark), .brand b, .connection, .top-actions .primary, .top-search kbd { display: none; }
  .top-search { order: 2; width: auto; flex: 2; margin: 0; }
  .workspace { display: block; height: calc(100% - var(--top-h)); position: relative; overflow: hidden; }
  .resizer { display: none; }
  .sidebar, .mail-stage, .thread-pane, .reader-pane, .content-stage { width: 100%; height: 100%; }
  .mail-stage, .sidebar, .thread-pane, .reader-pane, .content-stage { display: none !important; }
  .app:not([data-section="mail"]) .mail-stage { display: none !important; }
  .app[data-section="mail"] .content-stage { display: none !important; }
  .app[data-section="mail"][data-mobile-view="list"] .mail-stage.active,
  .app[data-section="mail"][data-mobile-view="reader"] .mail-stage.active { display: block !important; }
  .app[data-section="mail"][data-mobile-view="folders"] .sidebar { display: flex !important; }
  .app[data-section="mail"][data-mobile-view="list"] .thread-pane { display: flex !important; }
  .app[data-section="mail"][data-mobile-view="reader"] .reader-pane { display: flex !important; }
  .app:not([data-section="mail"])[data-mobile-view="content"] .content-stage.active { display: block !important; }
  .app[data-mobile-view="composer"] .composer { display: flex; }
  .sidebar-footer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .thread { min-height: 82px; }
  .reader-header { padding: 13px 14px 10px; }
  .reader-actions .btn span { display: none; }
  .toast-region { left: 12px; right: 12px; top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .message-card { margin: 10px; }
  .email-frame { height: 500px; }
  .content-stage { padding: 12px; }
  .dashboard-grid, .reply-grid, .setup-grid { grid-template-columns: 1fr; }
  .esp-choices { grid-template-columns: 1fr; }
  .maintenance-grid { grid-template-columns: 1fr; }
  .campaign-controls, .research-basics, .inline-form, .research-options, #researchFieldList, .research-field-list, .candidate-fields, .approval-grid, .purpose-actions { grid-template-columns: 1fr; }
  .purpose-actions .btn.primary { margin-left: 0; width: 100%; }
  .research-basics .query-label, .research-field .field-instructions { grid-column: auto; }
  .research-field { grid-template-columns: 1fr; }
  .panel-head, .campaign-row { align-items: stretch; flex-direction: column; }
  .panel-head .btn { align-self: flex-start; }
  .campaign-row dl { grid-template-columns: repeat(2, minmax(90px, 1fr)); }
  .campaign-row dl > div { text-align: left; }
  .webhook-events > div { grid-template-columns: 1fr; gap: 4px; }
  .table-wrap table { min-width: 720px; }
  .composer { inset: var(--top-h) 0 0 0; width: 100%; height: calc(100% - var(--top-h)); border: 0; border-radius: 0; }
  .composer.minimized { width: 100%; height: 46px; top: auto; }
}

.project-switcher{padding:12px;border-bottom:1px solid var(--border);background:linear-gradient(145deg,#f7f9ff,#fff)}
.project-switcher>label{display:block;margin-bottom:6px;color:var(--muted);font-size:10px;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
.project-switch-row{display:flex;gap:6px}
.project-switch-row select{min-width:0;flex:1;border:1px solid var(--border);border-radius:8px;background:#fff;padding:8px;color:var(--text);font-weight:700}
.project-switcher small.project-goal{display:-webkit-box;overflow:hidden;margin-top:7px;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-height:1.35;cursor:pointer;border-radius:4px;padding:2px 4px;margin-left:-4px}
.project-switcher small.project-goal:hover,.project-switcher small.project-goal:focus-visible{background:var(--accent-soft)}
.project-switcher small.project-goal.is-expanded{-webkit-line-clamp:unset;display:block;overflow:visible;white-space:pre-wrap}
.project-dialog{width:min(820px,calc(100vw - 24px));max-height:calc(100vh - 24px)}
.project-dialog form>header{display:flex;align-items:flex-start;justify-content:space-between;gap:20px}
.project-dialog form>header h2,.project-dialog form>header p{margin:0 0 5px}
.project-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:18px 0}
.project-form-grid label{display:grid;gap:6px;font-size:12px;font-weight:700}
.project-form-grid label.wide{grid-column:1/-1}
.project-form-grid textarea{resize:vertical}
.project-form-grid small{color:var(--muted);font-weight:400}
@media(max-width:640px){.project-form-grid{grid-template-columns:1fr}.project-form-grid label.wide{grid-column:auto}}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg:#111725; --surface:#192131; --surface-2:#202a3b; --surface-3:#2b3547; --text:#e8edf5; --muted:#aab4c5; --line:#344055; --accent:#6f96ff; --accent-soft:#263b69; }
  .topbar { background:#111827; }
  .thread.unread .thread-sender, .thread.unread .thread-subject { color:#fff; }
  .email-frame { background:#fff; }
  .remote-notice { background:#463a1f; color:#ffd987; border-color:#6d5726; }
  .warning-note { background:#41361f; color:#ffdc8b; }
  .cost-without-result-banner { border-color:#7a3a42; background:linear-gradient(180deg,#3b2025,#2a181c); box-shadow:0 4px 18px rgba(0,0,0,.35); }
  .cost-warning-title, .cost-warning-amount { color:#f0a8ae; }
  .setup-mode-banner.warn { background:#41361f; color:#ffdc8b; }
  .setup-mode-banner.ok { background:#1a3324; color:#9fd9b3; }
  .setup-mode-banner.danger { background:#3b2025; color:#f0a8ae; }
  .error-state { background:#3b2025; }
  .inbound-error-banner { background:#3b2025; border-color:#7a3a42; color:#f0a8ae; }
  .badge.error { background:#4a2a30; color:#f0a8ae; }
  .skeleton { background:linear-gradient(90deg,#222c3d 25%,#2b3649 45%,#222c3d 65%); background-size:300% 100%; }
  .reader-skeleton .skeleton-line, .reader-skeleton .skeleton-btn, .reader-skeleton .skeleton-avatar { background:linear-gradient(90deg,#222c3d 25%,#2b3649 45%,#222c3d 65%); background-size:300% 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
