/* ── Fonts: Atkinson Hyperlegible (self-hosted; OFL) ──────────────────────── */
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/static/fonts/atkinson-400-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('/static/fonts/atkinson-400-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: italic; font-weight: 700; font-display: swap;
  src: url('/static/fonts/atkinson-700-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: italic; font-weight: 700; font-display: swap;
  src: url('/static/fonts/atkinson-700-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/atkinson-400-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/static/fonts/atkinson-400-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/atkinson-700-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/static/fonts/atkinson-700-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f3f4f6;
  --surface: #fcfcfb;        /* soft off-white instead of harsh pure #fff */
  --border: #e7e9ee;
  --text: #20242c;           /* near-black, not pure black */
  --text-muted: #6b7280;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #3b82f6;
  --gray: #9ca3af;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body { font-family: 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 1.5rem; height: 56px; position: sticky; top: 0; z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.1rem; }
.nav-logo { font-size: 1.3rem; }
.nav-links { display: flex; gap: 0.25rem; margin-left: 1rem; }
.nav-link { padding: 0.4rem 0.75rem; border-radius: var(--radius); color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: #eff6ff; color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

/* "[ ] to cycle" onboarding hint — removed permanently after 5 uses (keyboard.js) */
.nav-cycle-hint { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; align-self: center; }
.nav-cycle-hint kbd { font-size: 0.7rem; padding: 0.05rem 0.3rem; }

/* Narrow screens: let the nav wrap and the links scroll horizontally so every
   destination stays reachable on a phone (the bar was a fixed no-wrap row). */
@media (max-width: 860px) {
  .nav { flex-wrap: wrap; height: auto; min-height: 56px; gap: 0.5rem; padding: 0.4rem 0.75rem; }
  .nav-brand .nav-title { display: none; }
  .nav-actions { gap: 0.4rem; }
  .nav-links {
    order: 3; width: 100%; margin-left: 0;
    overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }
  .nav-link { white-space: nowrap; }
  .nav-cycle-hint { display: none; } /* no [ ] keys on phones */
}

/* Inbox search box (lives in the inbox bar next to the filter tabs) */
.inbox-search { max-width: 220px; margin-left: 0.5rem; }
@media (max-width: 860px) { .inbox-search { max-width: 140px; } }

/* Task → source-email link */
.task-source-link { text-decoration: none; font-size: 0.85rem; opacity: 0.65; margin-left: 0.15rem; }
.task-source-link:hover { opacity: 1; }

/* Activity log */
.activity-list { display: flex; flex-direction: column; gap: 0.4rem; }
.activity-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.activity-action { flex-shrink: 0; }
.activity-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-subject { font-weight: 500; }
.activity-sender, .activity-detail { color: var(--text-muted); }
.activity-when { flex-shrink: 0; color: var(--text-muted); font-size: 0.85rem; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main { width: 100%; padding: 2rem 2.5rem; box-sizing: border-box; }
.page-header { margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card-sent { border-left: 3px solid var(--green); opacity: 0.75; }
.card-rejected { border-left: 3px solid var(--gray); opacity: 0.6; }
.card-error { border-left: 3px solid var(--red); }

.card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.card-time { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }

.email-subject { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; }
.email-meta { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.draft-preview {
  background: #f8faff; border: 1px solid #dbeafe; border-radius: 6px;
  padding: 0.75rem; font-size: 0.875rem; line-height: 1.5;
  color: #374151; margin-bottom: 0.75rem;
}
.draft-label { font-weight: 600; color: var(--primary); display: block; margin-bottom: 0.25rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

.card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.error-msg { font-size: 0.85rem; color: var(--red); flex: 1; }
.skip-reason { font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

/* ── Confidence bar ──────────────────────────────────────────────────────── */
.confidence-bar-wrap { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.confidence-label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.confidence-bar { flex: 1; height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.confidence-fill { height: 100%; border-radius: 99px; transition: width 0.3s ease; }
.confidence-fill.confidence-high { background: var(--green); }
.confidence-fill.confidence-medium { background: var(--orange); }
.confidence-fill.confidence-low { background: var(--red); }
.confidence-pct { font-size: 0.75rem; font-weight: 600; min-width: 2.5rem; text-align: right; }
.confidence-reason { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 0.1rem; }
.confidence-text.confidence-high { color: var(--green); font-weight: 600; }
.confidence-text.confidence-medium { color: var(--orange); font-weight: 600; }
.confidence-text.confidence-low { color: var(--red); font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-orange { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-blue   { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-green  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-gray   { background: #f9fafb; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-red    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, opacity 0.15s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost    { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ── Empty & loading states ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--text-muted); }
.empty-icon  { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.empty-body  { font-size: 0.9rem; }

.loading-state { text-align: center; padding: 3rem; color: var(--text-muted); display: flex; align-items: center; justify-content: center; gap: 0.5rem; }

.queue-count { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner-inline { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }

.loading-overlay {
  position: fixed; top: 1rem; right: 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow); z-index: 200;
  align-items: center; gap: 0.4rem; font-size: 0.85rem;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--text); color: #fff; padding: 0.75rem 1.25rem; border-radius: var(--radius); font-size: 0.875rem; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.2s ease; }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── History table ───────────────────────────────────────────────────────── */
.history-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.history-table th { text-align: left; padding: 0.6rem 0.75rem; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border); }
.history-row { cursor: pointer; }
.history-row:hover td { background: var(--bg); }
.history-row td { padding: 0.75rem; border-bottom: 1px solid var(--border); }
.history-subject { font-weight: 500; }
.history-date { color: var(--text-muted); white-space: nowrap; }
.history-detail { display: none; }
.history-detail.expanded { display: table-row; }
.history-detail td { padding: 0.75rem; background: #f8faff; }
.history-body-text { font-size: 0.82rem; white-space: pre-wrap; word-break: break-word; color: #374151; margin-top: 0.5rem; }

.filter-bar { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.filter-btn { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.35rem 0.75rem; font-size: 0.8rem; cursor: pointer; }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-card { max-width: 560px; }
.settings-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-label { font-weight: 500; font-size: 0.9rem; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); }
.form-input, .form-select, .form-textarea {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.9rem; background: var(--surface); color: var(--text);
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px;
}
.form-textarea { resize: vertical; min-height: 80px; }
.toggle-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.form-actions { display: flex; align-items: center; gap: 1rem; padding-top: 0.5rem; }
.divider { border: none; border-top: 1px solid var(--border); }
input[type=range] { width: 100%; accent-color: var(--primary); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
dialog.modal { border: none; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0,0,0,0.2); padding: 0; max-width: 620px; width: 90vw; }
dialog.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal-content { display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1.1rem; font-weight: 700; flex: 1; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 0.25rem; }
.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

.original-context {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem; font-size: 0.85rem;
}
.context-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.25rem; }
.context-subject { font-weight: 600; }
.context-meta { color: var(--text-muted); font-size: 0.8rem; }
.context-preview { margin-top: 0.5rem; color: #374151; line-height: 1.5; }
.draft-textarea { font-family: inherit; line-height: 1.6; }

/* ── Inbox split-pane layout ─────────────────────────────────────────────── */
/* Superhuman-style single pane: the message list fills the screen; opening a
   message (click / Enter) swaps it for a full-screen reader; Escape / Back
   returns to the list. The .detail-open class on the list pane is the toggle. */
.inbox-layout {
  display: block;
  height: calc(100vh - 56px);
  overflow: hidden;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.inbox-list-pane {
  height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.inbox-list-pane.detail-open { display: none; }

/* Single compact header bar: tabs left, Compose right */
.inbox-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border); background: var(--surface);
  flex-shrink: 0;
}

.inbox-filter-bar { display: flex; gap: 0.25rem; }
.inbox-filter-btn {
  background: none; border: 1px solid transparent; border-radius: 6px;
  padding: 0.2rem 0.65rem; font-size: 0.8rem; cursor: pointer;
  color: var(--text-muted); transition: all 0.1s;
}
.inbox-filter-btn:hover { background: var(--bg); color: var(--text); }
.inbox-filter-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

#inbox-message-list {
  flex: 1; overflow-y: auto;
}

#inbox-tab-all,
#inbox-tab-needs-reply,
#inbox-tab-awaiting {
  flex: 1; overflow-y: auto; height: 100%;
}

.inbox-detail-pane {
  display: none;            /* hidden until a message is open (full-screen swap) */
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
}
.inbox-list-pane.detail-open + .inbox-detail-pane { display: block; }

/* ── Message rows (dense single line: sender · subject—preview · time) ─────── */
.message-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 1rem;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  white-space: nowrap;
  font-size: 0.85rem;
  line-height: 1.35;
}
/* No per-row divider lines — rows separate by spacing + hover (Superhuman-style). */

/* Day separators — airy, no heavy rule */
.date-group {
  position: sticky; top: 0; z-index: 2;
  padding: 0.6rem 1rem 0.25rem;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface);
}
.message-row:hover { background: #f0f4ff; }
.message-row.keyboard-focused { background: #e8f0fe; outline: 2px solid var(--primary); outline-offset: -2px; }
.home-email-row.keyboard-focused { background: #e8f0fe; outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 6px; }

/* State color coding — left border + subtle background tint */
.message-row.state-needs_reply { border-left: 3px solid #e6a817; background: #fffbf0; }
.message-row.state-needs_reply:hover { background: #fff4d6; }
.message-row.state-watched { border-left: 3px solid #2196f3; background: #f0f7ff; }
.message-row.state-watched:hover { background: #dceffe; }
.message-row.state-awaiting { border-left: 3px solid #26a69a; background: #f0faf9; }
.message-row.state-awaiting:hover { background: #d8f3f1; }
.message-row.unread .msg-sender,
.message-row.unread .msg-subject { font-weight: 700; }
.message-row.unread .acct-dot { box-shadow: 0 0 0 2px var(--surface); }

.acct-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
.msg-sender {
  flex: 0 0 180px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.msg-body {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-subject { color: var(--text); }
.msg-preview { color: var(--text-muted); }
.msg-attach { flex: 0 0 auto; font-size: 0.75rem; }
.msg-time { flex: 0 0 auto; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; min-width: 3.5rem; text-align: right; }

.row-action-btn {
  flex: 0 0 auto;
  background: none; border: none; cursor: pointer; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.1s; padding: 0 0.1rem;
}
.message-row:hover .row-action-btn { opacity: 0.5; }
.message-row:hover .row-action-btn:hover { opacity: 1; }
.home-email-row .row-action-btn { opacity: 0.5; }
.home-email-row .row-action-btn:hover { opacity: 1; }

.load-more-wrap { padding: 1rem; text-align: center; }
.awaiting-badge { color: var(--primary); font-size: 0.75rem; font-style: italic; }

/* ── Message detail ──────────────────────────────────────────────────────── */
.detail-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; padding: 3rem;
  color: var(--text-muted); text-align: center;
}
.detail-empty kbd {
  display: inline-block; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.1rem 0.4rem; font-size: 0.8rem; font-family: monospace;
}

/* Thread count badge on message rows */
.thread-count-badge { display: inline-block; background: var(--primary); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 0.05rem 0.35rem; border-radius: 999px; margin-left: 0.3rem; vertical-align: middle; }

/* Thread messages in detail pane */
.thread-message { border-bottom: 1px solid var(--border); }
.thread-message:last-child { border-bottom: none; }
.thread-message-collapsed { padding: 0.5rem 1.25rem; }
.thread-message-collapsed summary { cursor: pointer; display: flex; align-items: baseline; gap: 0.5rem; list-style: none; font-size: 0.85rem; }
.thread-message-collapsed summary::-webkit-details-marker { display: none; }
.thread-msg-sender { font-weight: 600; color: var(--text); }
.thread-msg-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.thread-msg-preview { color: var(--text-muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.thread-message-latest { padding: 0 0 1rem; }
.thread-message-body { padding: 0 1.25rem; }

/* Watched button active state */
.btn-watch-active { color: #2196f3 !important; border: 1px solid #2196f3 !important; }

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
  gap: 0.75rem;
}
.detail-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.detail-feedback { display: flex; align-items: center; gap: 0.35rem; margin-left: 0.5rem; padding-left: 0.75rem; border-left: 1px solid var(--border); }
.detail-feedback-label { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.detail-feedback-yes      { color: var(--success, #28a745) !important; }
.detail-feedback-no       { color: var(--text-muted) !important; }
.detail-feedback-resolved { color: var(--accent, #6c757d) !important; }
.detail-back { display: inline-flex; }  /* always available: returns to the full-screen list */

/* Full-width reader: the opened email uses the whole screen (the list is hidden via
   .detail-open). No narrow centered column. */
.detail-body { padding: 1.5rem 2rem; max-width: none; margin: 0; }
.detail-subject { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.75rem; }
.detail-meta { font-size: 0.85rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 0.2rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.detail-meta strong { color: var(--text); }
.detail-content { line-height: 1.6; }
.detail-iframe { width: 100%; border: none; min-height: 300px; }
.detail-text { white-space: pre-wrap; word-break: break-word; font-size: 0.9rem; font-family: inherit; }

/* detail kbd badges */
.detail-actions kbd {
  display: inline-block; background: rgba(255,255,255,0.15);
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 3px; padding: 0 0.3rem; font-size: 0.7rem;
  font-family: monospace; vertical-align: middle; margin-left: 0.2rem;
}

/* ── Compose form ─────────────────────────────────────────────────────────── */
.compose-modal { max-width: 680px; width: 95vw; }
.compose-form { display: flex; flex-direction: column; gap: 0.75rem; }
.compose-field { display: flex; align-items: baseline; gap: 0.75rem; }
.compose-field-body { flex-direction: column; }
.compose-label { min-width: 3.5rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-align: right; }
.compose-input { flex: 1; }
.compose-textarea { width: 100%; font-family: inherit; line-height: 1.6; resize: vertical; }

/* ── Keyboard shortcuts overlay ───────────────────────────────────────────── */
.shortcuts-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 500; display: flex; align-items: center; justify-content: center;
}
.shortcuts-panel {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  padding: 1.5rem; max-width: 640px; width: 95vw;
}
.shortcuts-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 1rem; font-weight: 700; margin-bottom: 1.25rem;
}
.shortcuts-header button {
  background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-muted);
}
.shortcuts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.25rem;
}
.shortcuts-group-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.5rem; }
.shortcut-row { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; margin-bottom: 0.35rem; }
.shortcut-row span { color: var(--text-muted); }
kbd {
  display: inline-block; background: var(--bg); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px;
  padding: 0.1rem 0.45rem; font-size: 0.75rem; font-family: monospace;
  color: var(--text);
}

/* ── Toast types ─────────────────────────────────────────────────────────── */
.toast-success { background: #166534; }
.toast-error   { background: #b91c1c; }
.toast-info    { background: var(--text); }

.main.main-inbox { max-width: 100%; padding: 0; height: calc(100vh - 56px); overflow: hidden; }

/* ── Home dashboard grid ─────────────────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
@media (max-width: 1100px) { .home-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px)  { .home-grid { grid-template-columns: 1fr; } }

.home-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow);
}
.home-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.85rem;
}
.home-section-title { font-weight: 700; font-size: 0.95rem; }
.home-section-link { font-size: 0.8rem; color: var(--primary); }

.home-email-list { display: flex; flex-direction: column; gap: 0.5rem; }
.home-email-row {
  display: flex; flex-direction: column; padding: 0.5rem 0.6rem;
  border-radius: 6px; border: 1px solid var(--border);
  transition: background 0.1s; color: var(--text);
}
.home-email-row:hover { background: var(--bg); }
.home-email-main { display: flex; align-items: flex-start; gap: 0.5rem; }
.home-email-link { flex: 1; min-width: 0; color: inherit; text-decoration: none; display: block; }
.home-email-subject { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-email-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.home-email-reasoning { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; font-style: italic; }
.thread-activity-badge { font-size: 0.72rem; color: var(--accent, #6c757d); margin-top: 0.2rem; }
.home-email-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; margin-top: 0.15rem; }

.conf-badge {
  font-size: 0.68rem; font-weight: 600; padding: 0.1rem 0.35rem;
  border-radius: 3px; cursor: default;
}
.conf-high { background: #d4edda; color: #155724; }
.conf-medium { background: #fff3cd; color: #856404; }
.conf-low { background: #f8d7da; color: #721c24; }

.needs-reply-confirm-btn   { color: var(--success, #28a745); }
.needs-reply-skip-btn      { color: var(--text-muted); }
.needs-reply-resolved-btn  { color: var(--accent, #6c757d); font-size: 0.7rem; }

.skip-form { margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }

.watched-thread-row.watched-overdue { border-left: 3px solid var(--warning, #f0ad4e); padding-left: 0.5rem; }
.overdue-badge { background: var(--warning, #f0ad4e); color: #fff; font-size: 0.65rem; font-weight: 600; padding: 0.1rem 0.35rem; border-radius: 3px; margin-left: 0.35rem; vertical-align: middle; }
.opened-badge { background: rgba(46, 160, 67, 0.15); color: var(--success, #2ea043); font-size: 0.65rem; font-weight: 600; padding: 0.1rem 0.35rem; border-radius: 3px; margin-left: 0.35rem; vertical-align: middle; white-space: nowrap; }
.watch-reply-label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.watch-reply-checkbox { cursor: pointer; }
.skip-form form { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.skip-reason-input {
  flex: 1; min-width: 150px; font-size: 0.8rem;
  padding: 0.2rem 0.4rem; border: 1px solid var(--border);
  border-radius: 4px; background: var(--bg-secondary); color: var(--text);
}

.home-task-list { display: flex; flex-direction: column; gap: 0.4rem; }
.home-task-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.home-task-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-task-badge { font-size: 0.68rem !important; }

.home-empty { font-size: 0.85rem; color: var(--text-muted); padding: 0.5rem 0; }

.queue-count-big { font-size: 2.5rem; font-weight: 800; color: var(--primary); display: block; }
.queue-count-label { font-size: 0.85rem; color: var(--text-muted); }
.home-queue-badge { text-align: center; padding: 0.5rem 0; }

/* ── Priority dots ───────────────────────────────────────────────────────── */
.priority-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.priority-dot.priority-high { background: var(--red); }
.priority-dot.priority-medium { background: var(--orange); }
.priority-dot.priority-low { background: var(--green); }

/* ── Task cards ──────────────────────────────────────────────────────────── */
.task-create-card { margin-bottom: 1rem; }
.task-create-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.task-title-input { flex: 1; min-width: 160px; }
.task-priority-select { width: 100px; }
.task-due-input { width: 140px; }

.task-section-header {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 1.25rem 0 0.5rem;
}
.done-section { border: none; }
.done-summary { cursor: pointer; list-style: none; }
.done-summary::-webkit-details-marker { display: none; }

.task-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.65rem 1rem;
  margin-bottom: 0.5rem; gap: 0.75rem;
}
.task-card.task-done { opacity: 0.55; }
.task-card-main { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; }
.task-card-title { font-size: 0.9rem; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-due { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.task-card-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.task-status-select { font-size: 0.8rem; padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.task-delete-btn { color: var(--text-muted); padding: 0.2rem 0.4rem; }
.task-delete-btn:hover { color: var(--red); }

/* ── Chat panel ──────────────────────────────────────────────────────────── */
.chat-panel {
  position: fixed; top: 56px; right: 0; bottom: 0; width: 380px;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.25s ease;
  z-index: 150; box-shadow: -4px 0 24px rgba(0,0,0,0.08);
}
.chat-panel.chat-open { transform: translateX(0); }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-title { font-weight: 700; font-size: 0.95rem; }
.chat-close-btn { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); padding: 0.2rem; }
.chat-close-btn:hover { color: var(--text); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; }

.chat-msg-content {
  max-width: 85%; padding: 0.6rem 0.9rem;
  border-radius: 12px; font-size: 0.875rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg-user .chat-msg-content {
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 3px;
}
.chat-msg-assistant .chat-msg-content {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 3px;
}

.chat-input-form {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
  flex-shrink: 0; background: var(--surface);
}
.chat-input {
  flex: 1; padding: 0.45rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.875rem; font-family: inherit;
  background: var(--bg);
}
.chat-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

@media (max-width: 500px) {
  .chat-panel { width: 100%; }
}

/* ── Ignore rules ────────────────────────────────────────────────────────── */
.rules-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.rules-meta { font-size: 0.8rem; color: var(--text-muted); }
.rules-body { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; margin: 0; color: var(--text); }
.rules-empty { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

.ignore-rule-add-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.ignore-rules-table { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.ignore-rule-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.ignore-rule-type { flex-shrink: 0; }
.ignore-rule-pattern { flex: 1; font-size: 0.875rem; font-family: monospace; word-break: break-all; }
.ignore-rule-delete { color: var(--text-muted); padding: 0.1rem 0.4rem; }
.ignore-rule-delete:hover { color: var(--red); }

/* ── Nav logo image ──────────────────────────────────────────────────────── */
.nav-logo-img { width: 28px; height: 28px; flex-shrink: 0; }

/* ── Dark mode ───────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1b2433;
  --border: #2c3a4f;
  --text: #d6deea;           /* softened from near-pure-white to reduce glare */
  --text-muted: #8a97ab;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Message row hover/focus */
[data-theme="dark"] .message-row:hover { background: #1e3a5f; }
[data-theme="dark"] .message-row.keyboard-focused { background: #1a3355; outline-color: var(--primary); }
[data-theme="dark"] .home-email-row.keyboard-focused { background: #1a3355; outline-color: var(--primary); }

/* State color coding */
[data-theme="dark"] .message-row.state-needs_reply { background: #2a1f0d; }
[data-theme="dark"] .message-row.state-needs_reply:hover { background: #372a10; }
[data-theme="dark"] .message-row.state-watched { background: #0f2340; }
[data-theme="dark"] .message-row.state-watched:hover { background: #1a3355; }
[data-theme="dark"] .message-row.state-awaiting { background: #0a2420; }
[data-theme="dark"] .message-row.state-awaiting:hover { background: #143028; }

/* Draft preview */
[data-theme="dark"] .draft-preview { background: #0f172a; border-color: #1e3a5f; color: #cbd5e1; }

/* History */
[data-theme="dark"] .history-detail td { background: #162032; }
[data-theme="dark"] .history-body-text { color: #cbd5e1; }

/* Context preview in modals */
[data-theme="dark"] .context-preview { color: #cbd5e1; }

/* Nav active link */
[data-theme="dark"] .nav-link.active { background: #1e3a5f; color: var(--primary); }

/* Badges */
[data-theme="dark"] .badge-orange { background: #431407; color: #fdba74; border-color: #c2410c; }
[data-theme="dark"] .badge-blue   { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }
[data-theme="dark"] .badge-green  { background: #14532d; color: #86efac; border-color: #166534; }
[data-theme="dark"] .badge-gray   { background: #1f2937; color: #9ca3af; border-color: #374151; }
[data-theme="dark"] .badge-red    { background: #450a0a; color: #fca5a5; border-color: #b91c1c; }

/* Confidence badges */
[data-theme="dark"] .conf-high   { background: #14532d; color: #86efac; }
[data-theme="dark"] .conf-medium { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .conf-low    { background: #450a0a; color: #fca5a5; }

/* Modal */
[data-theme="dark"] dialog.modal { box-shadow: 0 20px 60px rgba(0,0,0,0.7); }
[data-theme="dark"] dialog.modal::backdrop { background: rgba(0,0,0,0.7); }

/* Email body — iframe content has its own white background/black text */
[data-theme="dark"] .detail-iframe { filter: invert(1) hue-rotate(180deg); }
/* Plain-text emails */
[data-theme="dark"] .detail-text { color: var(--text); }


/* === Multi-inbox account switcher === */
.account-switcher {
  position: relative;
  display: inline-block;
}
.account-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: var(--card, #fff);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  gap: 0.45rem;
  color: var(--text, #111827);
  list-style: none;
  user-select: none;
}
.account-switcher-toggle::-webkit-details-marker { display: none; }
.account-switcher-toggle:hover { background: var(--hover, #f9fafb); }
.account-switcher-toggle .account-dot { width: 10px; height: 10px; }
.account-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
}
.account-label {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chevron { font-size: 0.7rem; opacity: 0.6; }
.account-switcher-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 260px;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  padding: 0.25rem 0;
  z-index: 100;
}
.account-switcher-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text, #111827);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.account-switcher-item:hover { background: var(--hover, #f3f4f6); }
.account-switcher-item-active { background: var(--hover-strong, #eff6ff); }
.account-item-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  gap: 1px;
}
.account-item-name {
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-item-email {
  font-size: 0.75rem; opacity: 0.65;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-item-check { color: #22c55e; font-weight: 700; }
.account-glyph {
  font-size: 0.9rem; width: 1.2rem; text-align: center;
  opacity: 0.85; flex-shrink: 0;
}
.account-hotkey {
  font-size: 0.65rem;
  padding: 1px 5px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  opacity: 0.6;
  flex-shrink: 0;
  font-family: inherit;
}
.account-switcher-link { font-size: 0.8rem; opacity: 0.8; }
.account-switcher-item-form { margin: 0; }
.account-switcher-item-form button { width: 100%; }
.account-switcher-divider {
  border-top: 1px solid var(--border, #e5e7eb);
  margin: 0.25rem 0;
}

/* === Inbox identity bar (which mailbox am I viewing) === */
.inbox-identity-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  border-left: 3px solid var(--account-color, transparent);
  background: var(--card, #fff);
}
.inbox-identity-bar.identity-unified {
  border-left-color: var(--primary, #3b82f6);
  background: linear-gradient(90deg, rgba(59,130,246,0.08), transparent);
}
.identity-name { font-weight: 700; }
.identity-sub {
  opacity: 0.6; font-size: 0.8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.identity-glyph { margin-left: auto; opacity: 0.7; }

/* === Per-account chips (shown in unified lists) === */
.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 1px 7px 1px 5px;
  border-radius: 999px;
  background: var(--hover, #f3f4f6);
  color: var(--text, #374151);
  vertical-align: middle;
}
.account-chip .account-dot { width: 7px; height: 7px; }
.account-chip-row { float: right; margin-left: 0.4rem; }
.account-chip-inline { margin-left: 0.4rem; }
.account-chip-glyph { opacity: 0.7; }
.detail-account-chip { margin-bottom: 0.5rem; }

/* === /accounts page === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.accounts-list { display: flex; flex-direction: column; gap: 0.75rem; }
.account-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: var(--card, #fff);
}
.account-card-inactive { opacity: 0.6; }
.account-card-main { flex: 1; min-width: 0; }
.account-card-name-form { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.account-card-name-input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  font-size: 0.95rem;
  background: var(--bg, #fff);
  color: var(--text, #111);
}
.account-card-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.account-card-email { opacity: 0.75; }
.account-card-actions { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.empty-state { padding: 2rem; text-align: center; color: var(--text-muted, #6b7280); }

[data-theme="dark"] .account-switcher-toggle,
[data-theme="dark"] .account-switcher-menu,
[data-theme="dark"] .account-card,
[data-theme="dark"] .account-card-name-input {
  background: #1f2937;
  border-color: #374151;
}
[data-theme="dark"] .account-switcher-item:hover { background: #374151; }
[data-theme="dark"] .account-switcher-item-active { background: #1e3a5f; }
[data-theme="dark"] .btn-danger { background: #7f1d1d; color: #fecaca; border-color: #991b1b; }
[data-theme="dark"] .inbox-identity-bar { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .inbox-identity-bar.identity-unified {
  background: linear-gradient(90deg, rgba(59,130,246,0.18), transparent);
}
[data-theme="dark"] .account-chip { background: #374151; color: #e5e7eb; }
[data-theme="dark"] .account-hotkey { border-color: #4b5563; }


/* === Add-account provider chooser === */
.provider-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  max-width: 720px;
}
.provider-card {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: var(--card, #fff);
  text-decoration: none;
  color: var(--text, #111);
  transition: border-color 0.15s, transform 0.1s;
}
.provider-card:hover {
  border-color: var(--accent, #3b82f6);
  transform: translateY(-1px);
}
.provider-card-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.provider-card-disabled:hover { transform: none; border-color: var(--border, #e5e7eb); }
.provider-logo { font-size: 2.25rem; margin-bottom: 0.5rem; }
.provider-name { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.35rem; }
.provider-blurb { font-size: 0.85rem; opacity: 0.75; }
.provider-blurb code { background: var(--hover, #f3f4f6); padding: 0 0.25rem; border-radius: 3px; }

[data-theme="dark"] .provider-card { background: #1f2937; border-color: #374151; }
[data-theme="dark"] .provider-blurb code { background: #374151; }


/* === HITLOutreach lead badge in message detail === */
.hitlo-lead-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0 1rem 0.75rem 1rem;
  background: var(--hover, #eff6ff);
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text, #1e293b);
}
.hitlo-lead-icon { font-size: 1rem; }
.hitlo-lead-text { line-height: 1.4; }
.hitlo-lead-status {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  background: #e0e7ff;
  color: #3730a3;
}
.hitlo-status-replied { background: #dcfce7; color: #166534; }
.hitlo-status-sent    { background: #dbeafe; color: #1e40af; }
.hitlo-status-drafted { background: #fef3c7; color: #92400e; }
.hitlo-status-skipped { background: #f3f4f6; color: #6b7280; }
[data-theme="dark"] .hitlo-lead-badge { background: #1e293b; border-color: #1e40af; color: #e2e8f0; }

/* === Cleanup page === */
.cleanup-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.cleanup-toolbar-spacer { flex: 1; }
.cleanup-group { margin-bottom: 1.25rem; }
.cleanup-group-title {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.cleanup-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.cleanup-row:hover { background: var(--hover, #f8fafc); }
.cleanup-row input[type="checkbox"] { margin-top: 0.25rem; }
.cleanup-row-main { flex: 1; min-width: 0; }
.cleanup-row-subject { font-weight: 600; font-size: 0.9rem; }
.cleanup-row-sender { font-size: 0.8rem; color: var(--text-muted); }
.cleanup-row-preview { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.cleanup-row-reason { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-top: 0.2rem; }
.cleanup-unsub-link { font-size: 0.78rem; }

/* === Labels (settings) === */
.labels-table { display: flex; flex-direction: column; gap: 0.25rem; }
.label-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.label-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.label-name { font-weight: 500; font-size: 0.9rem; }
.label-desc { flex: 1; }
.label-delete { margin-left: auto; }
[data-theme="dark"] .cleanup-row:hover { background: #1e293b; }

/* === Insights === */
.insights-toolbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.insights-toolbar-spacer { flex: 1; }
.insights-range { display: flex; flex-direction: column; line-height: 1.25; }
.insights-range-dates { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.insights-range-sub { font-size: 0.78rem; color: var(--text-muted); }
.insights-window {
  display: flex; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.window-btn {
  padding: 0.4rem 0.85rem; font-size: 0.82rem; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.window-btn + .window-btn { border-left: 1px solid var(--border); }
.window-btn:not(.active):hover { background: var(--bg); color: var(--text); }
.window-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.insights-note {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  border-radius: var(--radius); padding: 0.6rem 0.85rem; font-size: 0.85rem; margin-bottom: 1rem;
}

.stat-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat-card { padding: 1rem 1.25rem; }
.stat-card-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.stat-card-label { font-size: 0.95rem; font-weight: 600; margin-top: 0.15rem; }
.stat-card-sub { font-weight: 400; color: var(--text-muted); font-size: 0.8rem; }
.stat-card-foot { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.35rem; }

.insights-chart-card { padding: 1rem 1.25rem; margin-bottom: 1rem; position: relative; }
.insights-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.insights-chart-title { font-size: 0.95rem; font-weight: 600; }
.insights-chart-range { font-size: 0.78rem; font-weight: 400; color: var(--text-muted); margin-left: 0.4rem; }
.chart-legend { display: flex; gap: 0.85rem; font-size: 0.78rem; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.swatch-received { background: var(--primary); }
.swatch-sent { background: var(--green); }

.bar-chart { display: block; }
.bar-chart .bar-received { fill: var(--primary); }
.bar-chart .bar-sent { fill: var(--green); }
.bar-chart .chart-axis { stroke: var(--border); stroke-width: 1; }
.bar-chart .chart-x-label { fill: var(--text-muted); font-size: 10px; text-anchor: middle; }
.bar-chart .chart-max-label { fill: var(--text-muted); font-size: 10px; }
.bar-chart .chart-hover-col { fill: transparent; }
.bar-chart .chart-hover-col:hover { fill: rgba(100, 116, 139, 0.10); }

.chart-tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; gap: 0.1rem;
  background: #1e293b; color: #f1f5f9;
  padding: 0.4rem 0.6rem; border-radius: 6px;
  font-size: 0.78rem; line-height: 1.35; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.chart-tooltip strong { font-size: 0.8rem; }
.chart-tooltip .tip-row::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; margin-right: 0.35rem;
}
.chart-tooltip .tip-received::before { background: var(--primary); }
.chart-tooltip .tip-sent::before { background: var(--green); }

.insights-people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.people-card { padding: 1rem 1.25rem; }
.people-card .insights-chart-title { margin-bottom: 0.75rem; }
.people-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.people-name { width: 34%; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people-bar-track { flex: 1; height: 14px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.people-bar { display: block; height: 100%; border-radius: 99px; min-width: 2px; }
.people-bar.fill-received { background: var(--primary); }
.people-bar.fill-sent { background: var(--green); }
.people-count { width: 2.5rem; text-align: right; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }

@media (max-width: 640px) {
  .stat-cards, .insights-people { grid-template-columns: 1fr; }
}

[data-theme="dark"] .insights-note { background: #2a1f0d; border-color: #7c2d12; color: #fdba74; }
[data-theme="dark"] .bar-chart .chart-hover-col:hover { fill: rgba(148, 163, 184, 0.12); }
[data-theme="dark"] .chart-tooltip { background: #0f172a; border: 1px solid #334155; }

/* === Insights: AI cost card === */
.insights-cost-card { padding: 1rem 1.25rem; margin-bottom: 1rem; }
.cost-total { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.cost-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.cost-breakdown { display: flex; flex-direction: column; gap: 0.4rem; }
.people-bar.fill-cost { background: var(--orange); }
.cost-row-amount { width: 6rem; text-align: right; font-size: 0.82rem; font-weight: 600; }
.cost-row-calls { color: var(--text-muted); font-weight: 400; }

/* === Cleanup: sender batches + topic labels === */
.cleanup-sender-group { margin-bottom: 0.35rem; }
.cleanup-sender-batch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  overflow: hidden;
}
.cleanup-sender-batch .cleanup-row { padding-left: 1.4rem; }
.cleanup-sender-batch .cleanup-row:last-child { border-bottom: none; }
.cleanup-sender-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
}
.cleanup-sender-name { font-weight: 700; }
.label-chip {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  vertical-align: middle;
  white-space: nowrap;
}
[data-theme="dark"] .cleanup-sender-header { background: #1e293b; }
[data-theme="dark"] .label-chip { background: #312e81; color: #c7d2fe; border-color: #4338ca; }

/* === Command palette (Ctrl/Cmd+K) === */
.cmdk-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 600; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.cmdk-panel {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  width: 560px; max-width: 95vw;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cmdk-input {
  border: none; outline: none; background: transparent;
  padding: 0.9rem 1.1rem;
  font-size: 1rem; color: var(--text);
  border-bottom: 1px solid var(--border);
  font-family: inherit;
}
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 0.35rem 0; }
.cmdk-section {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); padding: 0.5rem 1.1rem 0.2rem;
}
.cmdk-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.45rem 1.1rem; cursor: pointer; font-size: 0.9rem;
}
.cmdk-item:hover { background: var(--bg); }
.cmdk-selected, .cmdk-selected:hover { background: var(--primary); color: #fff; }
.cmdk-selected .cmdk-item-keys kbd { background: rgba(255,255,255,0.2); color: #fff; border-color: transparent; }
.cmdk-item-keys { display: flex; gap: 0.25rem; flex-shrink: 0; }
.cmdk-item-keys kbd {
  font-size: 0.72rem; padding: 1px 6px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-muted);
  font-family: inherit;
}
.cmdk-empty { padding: 1.25rem 1.1rem; color: var(--text-muted); font-size: 0.9rem; }
.cmdk-footer {
  display: flex; gap: 1.1rem; padding: 0.5rem 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem; color: var(--text-muted);
}
.cmdk-footer kbd {
  font-size: 0.7rem; padding: 0 5px; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border);
  font-family: inherit;
}
[data-theme="dark"] .cmdk-overlay { background: rgba(0,0,0,0.65); }
