:root {
  --bg: #f0efe8;
  --surface: #fafaf6;
  --surface2: #eaeae4;
  --text: #1a1a1a;
  --text2: #4a4a46;
  --text3: #6a6a66;
  --border: #d0d0c8;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #fef2f2;
  --success: #16a34a;
  --success-hover: #f0fdf4;
  --hover: #e8e8e2;
  --selected: #dbeafe;
  --selected-accent: #86efac;
  --focus: #7c3aed;
  --star: #f59e0b;
  --focus-ring: rgba(37, 99, 235, 0.1);
  --shadow: rgba(0,0,0,0.06);
  --shadow-md: rgba(0,0,0,0.10);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-pill: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", monospace;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

[data-theme="dark"] {
  --bg: #131316;
  --surface: #1c1c22;
  --surface2: #25252c;
  --text: #e8e8ec;
  --text2: #a0a0ab;
  --text3: #6a6a76;
  --border: #2e2e36;
  --accent: #60a5fa;
  --accent2: #3b82f6;
  --accent-light: #1e2d5c;
  --danger: #f87171;
  --danger-hover: #2d1b1b;
  --success: #34d399;
  --success-hover: #1a2d22;
  --hover: #282830;
  --selected: #1e2d5c;
  --selected-accent: #34d399;
  --focus: #a78bfa;
  --star: #fbbf24;
  --focus-ring: rgba(96, 165, 250, 0.15);
  --shadow: rgba(0,0,0,0.25);
  --shadow-md: rgba(0,0,0,0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { min-height: 100vh; line-height: 1.5; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.skip-link { position: absolute; top: -100px; left: 1rem; background: var(--accent); color: #fff; padding: 0.5rem 1rem; border-radius: var(--radius-sm); z-index: 100; font-size: 0.875rem; }
.skip-link:focus { top: 1rem; }

.noscript-banner { background: var(--danger); color: #fff; text-align: center; padding: 0.75rem; font-size: 0.875rem; }

.pane-focus { border-top: 3px solid var(--focus); }

input, textarea, select, button { font-family: inherit; font-size: inherit; }

/* ── Login ──────────────────────────────────────────── */

.login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px var(--shadow-md);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
}

.login-card h1 {
  font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block; font-size: 0.8125rem; font-weight: 500;
  color: var(--text2); margin-bottom: 0.375rem;
}

.form-group input, .form-group textarea {
  width: 100%; padding: 0.625rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.5rem 1rem; border: none; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 0.875rem;
  cursor: pointer; transition: background 0.12s, opacity 0.12s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--accent2); }

.btn-ghost {
  background: transparent; color: var(--text2);
  padding: 0.375rem 0.625rem; border-radius: var(--radius-sm);
}

.btn-ghost:hover, .btn-icon:hover { background: var(--hover); color: var(--text); }

.btn-danger { color: var(--danger); }

.btn-danger:hover { background: var(--danger-hover); }

.btn-icon {
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; background: transparent; color: var(--text2);
  border: none; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}

#menu-btn { display: none; }

.btn-pill {
  padding: 0.375rem 0.875rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text2); font-size: 0.8125rem;
  cursor: pointer; transition: all 0.12s;
}

.btn-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.btn-pill-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.btn-pill-primary:hover { background: var(--accent2); border-color: var(--accent2); }

/* ── Error ──────────────────────────────────────────── */

.error-msg {
  background: var(--danger-hover); color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem; margin-bottom: 1rem; font-size: 0.875rem;
}

/* ── App layout ─────────────────────────────────────── */

.app-view {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

.topbar h2 {
  font-size: 1rem; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar-spacer { flex: 1; }

.main-content {
  display: flex; flex: 1; overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); overflow-y: auto; padding: 0.5rem;
}

.sidebar-overlay { display: none; }

.sidebar-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.875rem; color: var(--text);
  text-decoration: none; transition: background 0.1s;
  border-left: 3px solid transparent;
}

.sidebar-item:hover { background: var(--hover); }
.sidebar-item.active {
  background: var(--accent-light); font-weight: 600;
  border-left-color: var(--accent);
  color: var(--accent);
}

.sidebar-item .badge {
  margin-left: auto;
  background: var(--accent); color: #fff;
  font-size: 0.6875rem; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 0.375rem;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-item .icon {
  flex-shrink: 0; width: 18px; text-align: center;
  font-size: 0.9375rem;
}

/* ── Message list ────────────────────────────────────── */

.message-list {
  width: 380px; flex-shrink: 0; border-right: 1px solid var(--border);
  overflow: hidden; background: var(--surface);
  display: flex; flex-direction: column;
}

#msg-list-header { flex-shrink: 0; }
#msg-list-items { flex: 1; overflow-y: auto; }

.message-item {
  display: flex; flex-direction: column;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
  border-left: 3px solid transparent;
}

.message-item:hover { background: var(--hover); }
.message-item.selected {
  background: var(--selected);
  border-left-color: var(--selected-accent);
}
.message-item.unread {
  border-left-color: var(--accent);
}
.message-item.unread .from { font-weight: 600; color: var(--text); }

.message-item .row {
  display: flex; align-items: center; gap: 0.5rem;
}

.message-item .from {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.875rem;
}

.message-item .date {
  font-size: 0.75rem; color: var(--text3); white-space: nowrap;
}

.message-item .subject {
  font-size: 0.8125rem; color: var(--text2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.message-item .preview {
  font-size: 0.75rem; color: var(--text3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.flag-star {
  color: var(--text3); cursor: pointer; font-size: 0.875rem;
  padding: 0.125rem; border-radius: 4px; transition: color 0.12s;
}

.flag-star:hover { color: var(--star); }
.flag-star.active { color: var(--star); }

.flag-attach {
  color: var(--text3); font-size: 0.75rem; flex-shrink: 0;
}

/* ── Inline message actions ─────────────────────────── */

.msg-actions-inline {
  display: flex; gap: 0.375rem; opacity: 0;
  transition: opacity 0.12s; padding-top: 0.25rem;
}

.message-item:hover .msg-actions-inline { opacity: 1; }

.msg-actions-inline .action-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.125rem 0.5rem;
  font-size: 0.75rem; cursor: pointer; color: var(--text3);
  transition: color 0.1s, border-color 0.1s;
  display: inline-flex; align-items: center; gap: 0.125rem;
}

.msg-actions-inline .action-btn:hover {
  color: var(--text); border-color: var(--accent);
}

.msg-actions-inline .action-btn.danger:hover {
  color: var(--danger); border-color: var(--danger);
}

/* ── Search bar ─────────────────────────────────────── */

.search-bar {
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0.375rem 0.75rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1; padding: 0.375rem 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.8125rem; outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.search-bar .btn-icon {
  width: 30px; height: 30px; font-size: 0.875rem; display: none;
}

.search-bar.active .btn-icon { display: inline-flex; }

/* ── Checkbox ───────────────────────────────────────── */

.msg-checkbox {
  display: none !important; flex-shrink: 0;
  width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent);
}

.msg-checkbox.visible { display: inline-block !important; }

.select-toggle {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); color: var(--text2); font-size: 0.75rem;
  transition: all 0.1s;
}

.select-toggle:hover { border-color: var(--accent); color: var(--accent); }
.select-toggle.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── Bulk bar ───────────────────────────────────────── */

.bulk-bar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.375rem 1rem; background: var(--accent-light);
  border-bottom: 1px solid var(--border); font-size: 0.8125rem;
  flex-shrink: 0;
}

.bulk-bar .bulk-count { font-weight: 600; color: var(--accent); white-space: nowrap; }
.bulk-bar .bulk-actions { display: flex; gap: 0.25rem; }

.bulk-bar .action-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.125rem 0.5rem;
  font-size: 0.75rem; cursor: pointer; color: var(--text2);
  display: inline-flex; align-items: center; gap: 0.125rem;
  transition: all 0.1s;
}

.bulk-bar .action-btn:hover { border-color: var(--accent); color: var(--accent); }
.bulk-bar .action-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ── Add mailbox button ─────────────────────────────── */

.add-mbox-item {
  color: var(--text3) !important; font-weight: 400 !important;
  border-left-color: transparent !important;
}

.add-mbox-item:hover {
  color: var(--accent) !important; background: var(--accent-light) !important;
}

/* ── Move picker ────────────────────────────────────── */

.move-picker {
  position: absolute; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px var(--shadow); min-width: 150px;
  z-index: 30; padding: 0.25rem 0; overflow: hidden;
}

.move-picker-item {
  display: block; width: 100%; text-align: left;
  padding: 0.375rem 0.75rem; background: none; border: none;
  color: var(--text); font-size: 0.8125rem; cursor: pointer;
  transition: background 0.1s;
}

.move-picker-item:hover { background: var(--hover); }

/* ── Message view ────────────────────────────────────── */

.message-view {
  flex: 1; overflow-y: auto; padding: 1.5rem; background: var(--surface2);
}

.message-view .msg-header { margin-bottom: 1rem; }

.message-view .msg-header h3 {
  font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; line-height: 1.3;
}

.message-view .msg-meta {
  font-size: 0.8125rem; color: var(--text2);
  display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem;
}

.message-view .msg-meta .label { color: var(--text3); font-weight: 500; }

.message-view .msg-actions {
  display: flex; gap: 0.5rem; margin: 0.75rem 0 1rem;
  flex-wrap: wrap;
}

.message-view .msg-body {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.5rem;
  line-height: 1.7; font-size: 0.9375rem;
}

.message-view .msg-body.text-only {
  white-space: pre-wrap; font-family: var(--mono); font-size: 0.8125rem;
}

.message-view .msg-body iframe.msg-iframe {
  width: 100%; border: none; display: block; min-height: 200px; overflow: hidden;
}

/* ── Compose ─────────────────────────────────────────── */

.compose-view {
  max-width: 720px; margin: 0 auto; padding: 1.5rem; width: 100%;
}

.compose-view h2 { font-size: 1.25rem; margin-bottom: 1rem; }

.compose-view .form-group textarea {
  width: 100%; min-height: 250px; padding: 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  resize: vertical; outline: none;
  font-family: var(--mono); font-size: 0.875rem;
}

.compose-view .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.compose-actions { display: flex; gap: 0.75rem; margin-top: 1rem; }

/* ── Dropdown ────────────────────────────────────────── */

.dropdown { position: relative; flex-shrink: 0; }

.dropdown-menu {
  display: none; position: absolute; right: 0; top: 100%;
  margin-top: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px var(--shadow-md); min-width: 180px; z-index: 20;
  overflow: hidden;
}

.dropdown-menu.open { display: block; }

.dropdown-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; text-align: left; padding: 0.625rem 1rem;
  background: none; border: none; color: var(--text); font-size: 0.875rem;
  cursor: pointer; transition: background 0.1s;
}

.dropdown-item:hover { background: var(--hover); }

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-hover); }

.dropdown-sep {
  height: 1px; background: var(--border); margin: 0.25rem 0;
}

.user-btn {
  font-weight: 500; font-size: 0.8125rem; color: var(--text);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
  background: var(--hover); border-radius: var(--radius-sm);
  padding: 0.375rem 0.625rem; cursor: pointer;
  border: 1px solid transparent; transition: border-color 0.12s;
}

.user-btn:hover { border-color: var(--border); }

/* ── Settings ────────────────────────────────────────── */

.settings-view {
  max-width: 560px; margin: 0 auto; padding: 1.5rem; width: 100%;
}

.settings-view h3 {
  font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem;
}

.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}

.settings-section .btn-primary { margin-top: 0.5rem; width: auto; }

.settings-section > div[id$="-msg"] {
  font-size: 0.875rem; margin-top: 0.5rem; font-weight: 500;
}

.settings-section p { margin-bottom: 0.75rem; font-size: 0.875rem; line-height: 1.5; }

.about-row {
  display: flex; gap: 0.75rem; padding: 0.375rem 0;
  font-size: 0.875rem; border-bottom: 1px solid var(--border);
}

.about-row:last-child { border-bottom: none; }

.about-label {
  flex-shrink: 0; width: 7rem; color: var(--text2); font-weight: 500;
}

.config-snippet {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem;
  font-family: var(--mono); font-size: 0.8125rem;
  line-height: 1.8;
}

.config-line { display: block; }

.config-key { color: var(--text2); display: inline-block; width: 8rem; flex-shrink: 0; }

.config-val { color: var(--text); }

/* ── Tabs ───────────────────────────────────────────── */

.tabs {
  display: flex; gap: 0; margin: 0 1rem;
}

.tab {
  padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500;
  color: var(--text2); cursor: pointer;
  border: none; border-bottom: 2px solid transparent;
  background: none; transition: color 0.12s, border-color 0.12s;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex: 1; overflow: hidden; }
.tab-content.active.block { display: block; overflow-y: auto; }

/* ── Sidebar groups ─────────────────────────────────── */

.sidebar-sep {
  height: 1px; background: var(--border); margin: 0.25rem 0.75rem;
}

.sidebar-group-header {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.75rem; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text3); transition: color 0.1s;
}

.sidebar-group-header:hover { color: var(--text2); }

.sidebar-group-header .chevron {
  font-size: 0.625rem; transition: transform 0.15s;
}

.sidebar-group-header.open .chevron {
  transform: rotate(90deg);
}

.sidebar-group-items {
  display: none;
}

.sidebar-group-items.open {
  display: block;
}

/* ── Alias view ─────────────────────────────────────── */

.alias-view {
  max-width: 560px; margin: 0 auto; padding: 1.5rem; width: 100%;
}

.alias-view h3 {
  font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem;
}

.alias-create {
  display: flex; gap: 0.5rem; margin-bottom: 1rem;
}

.alias-create input {
  flex: 1; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
  font-size: 0.875rem;
}

.alias-create input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.alias-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}

.alias-item {
  display: flex; align-items: center; padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--border); font-size: 0.875rem;
}

.alias-item:last-child { border-bottom: none; }

.alias-item .alias-name { flex: 1; }

/* ── Dialog ──────────────────────────────────────────── */

.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.dialog-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 1.5rem; max-width: 380px; width: 90%;
  box-shadow: 0 8px 32px var(--shadow-md);
}

.dialog-box p { margin-bottom: 1rem; font-size: 0.9375rem; line-height: 1.5; }

.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── Context menu ────────────────────────────────────── */

.context-menu {
  position: fixed; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px var(--shadow-md);
  min-width: 170px; z-index: 50; padding: 0.25rem 0;
  overflow: hidden;
}

.context-menu-item {
  display: block; width: 100%; text-align: left;
  padding: 0.5rem 1rem; background: none; border: none;
  color: var(--text); font-size: 0.875rem; cursor: pointer;
  transition: background 0.1s;
}

.context-menu-item:hover { background: var(--hover); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger:hover { background: var(--danger-hover); }

/* ── Loading ─────────────────────────────────────────── */

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 3rem; color: var(--text2);
}

.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────── */

.empty-state {
  text-align: center; padding: 3rem; color: var(--text2); font-size: 0.875rem;
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
  #menu-btn { display: inline-flex; }
  .sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 10; box-shadow: 2px 0 12px var(--shadow); }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 9; }
  .message-list { width: 100%; }
  .message-view { display: none; }
  .message-view.open { display: block; position: fixed; inset: 0; z-index: 5; background: var(--bg); overflow-y: auto; padding: 1rem; }
  .compose-view { padding: 1rem; }
  .msg-actions-inline { opacity: 1; }
  .tab { font-size: 0; padding: 0.5rem 0.75rem; }
  .tab::before { font-size: 0.9375rem; display: inline-block; }
  .tab[data-tab="mail"]::before { content: "📥"; }
  .tab[data-tab="aliases"]::before { content: "📋"; }
  .tab[data-tab="settings"]::before { content: "⚙"; }
  .tab[data-tab="about"]::before { content: "ℹ️"; }
  .tab[data-tab="help"]::before { content: "❓"; }
  .input-clear-btn { min-width: 44px; min-height: 44px; }
  .autocomplete-dropdown { max-width: calc(100vw - 1rem); }
}

/* ── Utility ─────────────────────────────────────────── */

.hidden { display: none !important; }
.text-sm { font-size: 0.8125rem; }
.text-muted { color: var(--text2); }

/* ── Attachments in message detail ──────────────────── */

.msg-attachments {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; margin-top: 0.75rem;
}

.msg-attachments h4 {
  font-size: 0.8125rem; font-weight: 600; margin-bottom: 0.5rem;
  color: var(--text2);
}

.attach-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0; font-size: 0.875rem;
}

.attach-item a {
  color: var(--accent); text-decoration: none; font-weight: 500;
}

.attach-item a:hover { text-decoration: underline; }

.attach-item .text-muted {
  font-size: 0.75rem; color: var(--text3); margin-left: auto;
}

/* ── File list in compose ───────────────────────────── */

.file-list {
  margin-top: 0.5rem; font-size: 0.8125rem;
}

.file-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0; color: var(--text2);
}

/* ── Autocomplete dropdown ──────────────────────────── */

.autocomplete-dropdown {
  position: fixed; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px var(--shadow); min-width: 200px;
  z-index: 50; overflow: hidden;
}

.autocomplete-item {
  padding: 0.5rem 0.75rem; font-size: 0.8125rem;
  cursor: pointer; color: var(--text);
  transition: background 0.08s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--accent-light); color: var(--accent);
}

.autocomplete-separator {
  height: 1px; background: var(--border); margin: 0.25rem 0.5rem;
}

.autocomplete-item.current {
  font-weight: 600; color: var(--accent);
}

/* ── Input with clear button ─────────────────────────── */

.input-with-clear {
  position: relative;
}
.input-with-clear input {
  padding-right: 2rem;
}
.input-clear-btn {
  position: absolute; right: 0.375rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; line-height: 1;   color: var(--text2);
  padding: 0.125rem 0.25rem; border-radius: 2px;
}
.input-clear-btn:hover {
  color: var(--text);
}

/* ── Source view & diagnostics ─────────────────────── */

.source-view {
  max-height: 50vh; overflow: auto; white-space: pre-wrap; word-break: break-all;
  font-family: var(--mono); font-size: 0.75rem; line-height: 1.5;
  background: var(--bg); padding: 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 0.75rem;
}

.source-diag {
  background: var(--accent-light); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin-bottom: 0.75rem;
}

.diag-row {
  display: flex; gap: 0.5rem; font-size: 0.8125rem; padding: 0.25rem 0;
}

.diag-label {
  color: var(--text2); font-weight: 500; min-width: 7rem; flex-shrink: 0;
}

.diag-pass { color: var(--success); font-weight: 600; }
.diag-fail { color: var(--danger); font-weight: 600; }

.received-detail pre {
  font-family: var(--mono); font-size: 0.75rem;
  background: var(--bg); padding: 0.5rem; border-radius: var(--radius-sm);
  margin: 0.25rem 0 0.25rem 7.5rem; white-space: pre-wrap; word-break: break-all;
  line-height: 1.6;
}
.received-toggle {
  cursor: pointer; color: var(--accent); user-select: none;
}

