:root {
  --bg: #090B0E;
  --surface: #0E1218;
  --surface-2: #121720;
  --surface-elev: #161C27;
  --surface-hover: #1B2331;
  --surface-active: #1D283A;
  --border: rgba(255, 255, 255, 0.075);
  --border-subtle: rgba(255, 255, 255, 0.045);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --accent: #4F7DF3;
  --accent-hover: #3B68E4;
  --accent-soft: rgba(79, 125, 243, 0.13);
  --accent-border: rgba(79, 125, 243, 0.34);
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --radius: 10px;
  --radius-sm: 7px;
}

html[data-theme="light"] {
  --bg: #F3F1EC;
  --surface: #FFFFFF;
  --surface-2: #F8F7F4;
  --surface-elev: #EDEAE2;
  --surface-hover: #F1EFE9;
  --surface-active: #E8F0FE;
  --border: rgba(15, 23, 42, 0.085);
  --border-subtle: rgba(15, 23, 42, 0.05);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0F172A;
  --text-muted: #475569;
  --text-dim: #64748B;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-border: rgba(37, 99, 235, 0.28);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.hidden {
  display: none !important;
}

svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

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

button, a, .msg-row, .nav-item, .chip, .tab-btn {
  -webkit-tap-highlight-color: transparent;
}

.msg-row {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input:where(:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"])),
select {
  height: 36px;
  line-height: 1.2;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 11px;
  outline: none;
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 13px 13px;
}

textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease);
}

input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--surface-2);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-grid;
  place-content: center;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}

input[type="checkbox"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.2L6.6 11.3L12.6 4.8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-elev);
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.12s var(--ease);
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

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

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

.btn-danger {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.btn-full {
  width: 100%;
}

.btn-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text);
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}

.btn-xs:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

select.btn-xs {
  padding-right: 26px;
  background-color: var(--surface-2);
}

.btn-accent-soft {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.btn-accent-soft:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

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

.btn-danger-text:hover {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.3);
}

.icon-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

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

.link-btn {
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 4px 6px;
  border-radius: 5px;
  text-decoration: none;
  transition: color 0.14s var(--ease), background-color 0.14s var(--ease);
}

.link-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.auth-logo {
  width: 34px;
  height: 34px;
}

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.input-addon-wrap {
  height: 36px;
  display: flex;
  align-items: stretch;
}

.input-addon-wrap input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.input-addon {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 11px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.input-addon-select {
  height: 100%;
  background-color: var(--surface-elev);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 0 28px 0 10px;
}

.form-error {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
  font-size: 13px;
}

/* App Shell */
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 212px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 24px;
  height: 24px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.02em;
}

.topbar-search {
  flex: 1;
  max-width: 540px;
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search .search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 70px 0 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.topbar-search input:focus {
  background: var(--surface-elev);
  border-color: var(--accent);
}

.search-kbd {
  position: absolute;
  right: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 36px;
  font-size: 18px;
  color: var(--text-dim);
  padding: 0 5px;
}

.search-filter-btn {
  position: absolute;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.search-filter-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.search-filter-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}

.user-pill[role="button"] {
  cursor: pointer;
}

.user-pill[role="button"]:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.user-email {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-only {
  display: none;
}

/* Workspace */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-top {
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-compose {
  width: 100%;
  justify-content: center;
  height: 38px;
  padding: 0 14px;
  font-weight: 600;
  border-radius: 8px;
}

.mailbox-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mailbox-switcher select {
  flex: 1;
  min-width: 0;
  height: 34px;
  font-size: 12.5px;
  padding: 0 28px 0 10px;
  background-color: var(--surface-2);
}

.mailbox-switcher .mini-plus {
  width: 30px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mailbox-switcher .mini-plus:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 16px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mini-plus {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
}

.mini-plus:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-muted);
  text-align: left;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.78;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item:hover svg {
  opacity: 1;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item.active svg {
  color: var(--accent);
  opacity: 1;
}

.nav-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav-label > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #FFFFFF;
}

.nav-empty {
  padding: 4px 10px 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 6px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.quota-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.quota-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-elev);
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s var(--ease);
}

.quota-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Pane */
.main-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.mail-workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.mail-list-col {
  width: 400px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.list-toolbar {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.list-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pane-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pane-count:empty {
  display: none;
}

.list-toolbar-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.icon-btn-sm svg {
  width: 15px;
  height: 15px;
}

.filter-chips {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.chip {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--text-muted);
  background: transparent;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  background: var(--surface-elev);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.list-toolbar-row .checkbox-wrap,
.msg-checkbox {
  display: none !important;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-elev);
  border: 1px solid var(--accent-border);
}

.bulk-bar-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bulk-clear-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
}

.bulk-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.message-list {
  flex: 1;
  overflow-y: auto;
}

.empty-list-state {
  padding: 56px 20px;
}

.msg-row {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 0.14s var(--ease), opacity 0.12s var(--ease), transform 0.12s var(--ease);
}

.msg-row.msg-row-leaving {
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
}

.msg-row:hover {
  background: var(--surface-hover);
}

.msg-row.unread {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.msg-row.selected {
  background: var(--surface-active);
}

.msg-row.checked {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.msg-row.unread .msg-sender,
.msg-row.unread .msg-subject {
  font-weight: 600;
  color: var(--text);
}

.msg-row-checks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding-top: 2px;
}

.star-btn {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  transition: color 0.12s var(--ease), transform 0.12s var(--ease);
}

.star-btn:hover {
  color: var(--warning);
}

.star-btn.starred {
  color: var(--warning);
}

.msg-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
  margin-top: 1px;
  overflow: hidden;
  transition: transform 0.14s var(--ease), background-color 0.14s var(--ease);
}

.msg-row.checked .msg-avatar::after {
  content: "✓";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
}

.msg-row-main {
  flex: 1;
  min-width: 0;
}

.msg-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.msg-sender {
  font-size: 13.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-row-top-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  min-height: 22px;
}

.msg-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.msg-row-quick-actions {
  display: none;
  align-items: center;
  gap: 3px;
}

.msg-row:hover .msg-date,
.msg-row:focus-within .msg-date {
  display: none;
}

.msg-row:hover .msg-row-quick-actions,
.msg-row:focus-within .msg-row-quick-actions {
  display: inline-flex;
}

@media (hover: none) {
  .msg-row:hover .msg-date,
  .msg-row:focus-within .msg-date {
    display: inline;
  }
  .msg-row:hover .msg-row-quick-actions,
  .msg-row:focus-within .msg-row-quick-actions {
    display: none;
  }
}

.row-action-btn {
  width: 24px;
  height: 22px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--surface-elev);
  border: 1px solid var(--border);
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease), border-color 0.12s var(--ease);
}

.row-action-btn:hover {
  background: var(--surface-active);
  border-color: var(--border-strong);
  color: var(--text);
}

.row-action-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
  background: var(--danger-soft);
}

.row-action-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.msg-subject-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.msg-subject {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.msg-thread-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.msg-snippet {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.mini-pill {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.mini-pill.failed {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.35);
}

.mini-pill.scheduled {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
}

/* Reading Pane */
.mail-read-col {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}

.empty-read-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
}

.empty-read-state svg {
  width: 38px;
  height: 38px;
  opacity: 0.42;
}

@keyframes paneFadeIn {
  from {
    opacity: 0.65;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-detail-pane {
  padding: 24px 30px 42px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-detail-pane.pane-enter {
  animation: paneFadeIn 140ms var(--ease) both;
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-subject-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.detail-nav-pos {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
  margin-right: 4px;
  white-space: nowrap;
}

.detail-nav-btn {
  width: 28px;
  padding: 0;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.detail-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.detail-subject {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-more-wrap {
  margin-left: auto;
}

.action-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}

.read-receipt-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  font-size: 13px;
}

.thread-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.thread-item-head {
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.sender-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
  overflow: hidden;
}

.sender-meta {
  min-width: 0;
}

.sender-name-line {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sender-addr {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.rcpt-line {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.thread-attachments {
  padding: 10px 18px;
  background: var(--surface-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.att-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
}

.att-pill:hover {
  border-color: var(--border-strong);
}

.att-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.email-iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 64px;
  background: #FFFFFF;
}

.quick-reply-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.quick-reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quick-reply-to {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-reply-card textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
}

.quick-reply-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* Module Views */
.module-view {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px 44px;
}

.module-container {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.module-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-head .card-title {
  margin: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.nowrap {
  white-space: nowrap;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 15px 17px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.toolbar-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-ok {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.32);
  color: var(--success);
}

.badge-warn {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.32);
  color: var(--warning);
}

.badge-accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.badge-err {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--danger);
}

.list-row-item {
  border-top: 1px solid var(--border);
  padding: 11px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.module-section-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-quota-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-quota-row .quota-bar {
  flex: 1;
  margin-bottom: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: var(--surface-hover);
}

.empty-cell {
  text-align: center;
  color: var(--text-dim);
  padding: 26px 12px !important;
}

.contact-cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
  overflow: hidden;
}

.profile-avatar-editor {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.profile-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: #FFFFFF;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--border-strong);
}

.profile-avatar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.external-sync-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.external-sync-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.external-sync-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.external-sync-url-row input {
  flex: 1;
  min-width: 0;
}

.avatar-cropper-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.avatar-cropper-canvas {
  width: 256px;
  height: 256px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  cursor: grab;
  touch-action: none;
}

.avatar-cropper-canvas:active {
  cursor: grabbing;
}

.avatar-cropper-controls {
  width: 100%;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-cropper-controls input[type="range"] {
  flex: 1;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.kbd-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
}

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.status-ok {
  color: var(--success);
  font-weight: 500;
}

.status-err {
  color: var(--danger);
  font-weight: 500;
}

.status-warn {
  color: var(--warning);
  font-weight: 500;
}

/* Composer Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.composer-card {
  width: 100%;
  max-width: 840px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.generic-modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.generic-modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.composer-header {
  padding: 13px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
}

.composer-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--border);
}

.composer-row label {
  width: 64px;
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.composer-row input,
.composer-row select {
  flex: 1;
  height: 32px;
  background-color: transparent;
  border: none;
  padding: 0 4px;
}

.composer-row select {
  padding-right: 28px;
}

.chip-input-wrap {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  position: relative;
}

.chip-input-wrap input {
  min-width: 160px;
  flex: 1;
}

.addr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
}

.addr-chip button {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

.autocomplete-item {
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

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

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--surface-elev);
  border-bottom: 1px solid var(--border);
}

.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.toolbar-group-right {
  margin-left: auto;
  gap: 6px;
}

.editor-toolbar button {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.editor-toolbar button svg {
  width: 16px;
  height: 16px;
}

.editor-toolbar button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.editor-toolbar select {
  height: 28px;
  font-size: 12px;
  padding: 0 26px 0 8px;
  background-color: var(--surface);
}

.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
}

.compose-editor {
  min-height: 240px;
  max-height: 360px;
  overflow-y: auto;
  padding: 15px 18px;
  outline: none;
  font-size: 14px;
  line-height: 1.6;
}

.compose-editor blockquote {
  border-left: 2px solid var(--border-strong);
  margin: 8px 0;
  padding-left: 12px;
  color: var(--text-muted);
}

.compose-attachments-zone {
  padding: 9px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compose-attachments-zone.drag-over {
  background: var(--accent-soft);
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.composer-footer {
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-elev);
}

.composer-options {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#attachFileBtn svg {
  width: 14px;
  height: 14px;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.toggle-inline input[type="datetime-local"] {
  padding: 4px 8px;
  font-size: 12px;
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--text);
}

.toast-action-btn {
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  white-space: nowrap;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}

.toast-action-btn:hover {
  background: var(--accent);
  color: #FFFFFF;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.45);
}

.tabs-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
}

.tab-btn {
  height: 32px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.tab-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface-elev);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

.nav-custom-row {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-custom-row .nav-item {
  flex: 1;
  min-width: 0;
}

.nav-row-actions {
  display: none;
  align-items: center;
  gap: 2px;
  position: absolute;
  right: 6px;
  background: var(--surface-hover);
  border-radius: 4px;
  padding: 1px 2px;
}

.nav-custom-row:hover .nav-row-actions {
  display: inline-flex;
}

.nav-badge-muted {
  background: var(--surface-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.copyable-addr {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.copyable-addr:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.quick-contact-btn {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

.detail-labels-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rule-action-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.modal-backdrop.composer-minimized {
  inset: auto;
  right: 20px;
  bottom: 0;
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 0;
  background: transparent;
  pointer-events: auto;
}

.modal-backdrop.composer-minimized .composer-card {
  width: 100%;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

.modal-backdrop.composer-minimized .composer-header {
  cursor: pointer;
}

.modal-backdrop.composer-minimized .composer-body {
  display: none;
}

.pin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  opacity: 0.45;
  transition: color 0.12s var(--ease), opacity 0.12s var(--ease), transform 0.12s var(--ease);
}

.msg-row:hover .pin-btn,
.pin-btn.pinned {
  opacity: 1;
}

.pin-btn:hover,
.pin-btn.pinned {
  color: var(--accent);
}

.msg-row.pinned {
  background: var(--accent-soft);
}

.snooze-pill {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.unsubscribe-btn {
  border-color: var(--accent-border);
  color: var(--accent);
}

.sidebar-backdrop,
.mobile-bottom-nav,
.mobile-compose-fab {
  display: none;
}

@media (hover: none) {
  .nav-custom-row .nav-row-actions {
    display: inline-flex;
    position: static;
    background: transparent;
  }
  .pin-btn {
    opacity: 0.8;
  }
}

@media (max-width: 1024px) {
  .mail-list-col {
    width: 330px;
  }
}

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }

  /* Prevent iOS Safari zoom on input focus */
  input:where(:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"])),
  select,
  textarea {
    font-size: 16px;
  }

  .topbar {
    gap: 8px;
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(56px + env(safe-area-inset-top, 0px));
  }
  .topbar-left {
    min-width: auto;
    gap: 6px;
  }
  .topbar-search {
    min-width: 0;
  }
  .topbar-search input {
    height: 36px;
    font-size: 15px;
    padding: 0 30px 0 32px;
  }
  .topbar-search .search-icon {
    left: 10px;
  }
  .search-kbd,
  .topbar-sep {
    display: none;
  }
  .topbar-right {
    gap: 4px;
  }
  .user-pill {
    padding: 3px;
    height: 32px;
  }
  .user-email {
    display: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: calc(56px + env(safe-area-inset-top, 0px));
    background: rgba(5, 7, 11, 0.62);
    backdrop-filter: blur(2px);
    z-index: 39;
  }
  .sidebar {
    position: fixed;
    top: calc(56px + env(safe-area-inset-top, 0px));
    left: 0;
    bottom: 0;
    width: min(280px, 84vw);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .mail-list-col {
    width: 100%;
    border-right: none;
  }
  .mail-read-col {
    display: none;
  }
  .mail-workspace.reading-mobile .mail-list-col {
    display: none;
  }
  .mail-workspace.reading-mobile .mail-read-col {
    display: flex;
  }

  .list-toolbar {
    padding: 12px 12px 10px;
    gap: 8px;
  }
  .filter-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-chips::-webkit-scrollbar {
    display: none;
  }
  .chip {
    flex: 0 0 auto;
    padding: 0 12px;
  }
  .bulk-bar {
    gap: 6px;
  }
  .bulk-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .message-list {
    padding-bottom: 76px;
    -webkit-overflow-scrolling: touch;
  }
  .msg-row {
    padding: 12px;
    gap: 10px;
  }
  .msg-row-checks {
    gap: 10px;
  }
  .star-btn {
    padding: 4px;
    margin: -4px;
    font-size: 16px;
  }

  .message-detail-pane {
    padding: 14px 12px 28px;
    gap: 14px;
  }
  .detail-subject-row {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .detail-subject {
    font-size: 18px;
    flex: 1;
    min-width: 180px;
  }
  #mobileBackBtn {
    order: -1;
    height: 32px;
    padding: 0 12px;
    font-weight: 600;
  }
  .detail-actions {
    gap: 6px;
    flex-wrap: wrap;
    overflow: visible;
  }
  .detail-action-group {
    flex-wrap: wrap;
  }
  .action-sep {
    display: none;
  }
  .read-receipt-banner {
    flex-wrap: wrap;
    gap: 8px;
  }
  .thread-item-head {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .thread-attachments {
    padding: 10px 14px;
  }

  .module-view {
    padding: 16px 12px 28px;
    -webkit-overflow-scrolling: touch;
  }
  .card {
    padding: 16px 14px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .tabs-bar {
    display: flex;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs-bar::-webkit-scrollbar {
    display: none;
  }
  .tab-btn {
    flex-shrink: 0;
  }

  /* Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 35;
    flex-shrink: 0;
  }
  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 2px;
    min-width: 0;
  }
  .mobile-nav-btn svg {
    width: 20px;
    height: 20px;
  }
  .mobile-nav-btn.active {
    color: var(--accent);
    font-weight: 600;
  }
  .mobile-nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-nav-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: #FFFFFF;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Mobile Floating Compose Button */
  .mobile-compose-fab {
    position: fixed;
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    z-index: 34;
    height: 46px;
    padding: 0 18px;
    border-radius: 999px;
    background: var(--accent);
    color: #FFFFFF;
    font-weight: 600;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  }
  .mobile-compose-fab svg {
    width: 18px;
    height: 18px;
  }
  .app-shell.mobile-reading .mobile-compose-fab,
  .app-shell:not([data-active-view="mail"]) .mobile-compose-fab {
    display: none;
  }

  /* Full-screen Mobile Composer */
  #composerModal.modal-backdrop:not(.composer-minimized) {
    padding: 0;
    align-items: stretch;
  }
  #composerModal.modal-backdrop:not(.composer-minimized) .composer-card {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    padding-top: env(safe-area-inset-top, 0px);
  }
  #composerModal.modal-backdrop.composer-minimized {
    right: 12px;
    left: 12px;
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
  }
  .composer-row {
    padding: 7px 12px;
    gap: 8px;
  }
  .composer-row label {
    width: 52px;
  }
  .editor-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px;
    scrollbar-width: none;
  }
  .toolbar-group-right {
    margin-left: 0;
  }
  .editor-toolbar::-webkit-scrollbar {
    display: none;
  }
  .editor-toolbar button,
  .editor-toolbar select {
    flex-shrink: 0;
  }
  .compose-editor {
    flex: 1;
    min-height: 160px;
    max-height: none;
    padding: 12px;
    font-size: 16px;
  }
  .compose-attachments-zone {
    padding: 9px 12px;
  }
  .composer-footer {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .composer-submit {
    margin-left: auto;
  }

  /* Bottom-sheet Generic Modal */
  #genericModal.modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  #genericModal .generic-modal-card {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .generic-modal-body {
    padding: 16px 16px 20px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 540px) {
  .auth-card {
    padding: 24px 18px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi-card {
    padding: 12px;
  }
  .kpi-value {
    font-size: 18px;
  }
  .module-header {
    gap: 10px;
  }
  .module-actions,
  .toolbar-inline {
    width: 100%;
  }
  .module-actions > input,
  .module-actions > select,
  .toolbar-inline > input,
  .toolbar-inline > select {
    width: 100% !important;
    flex: 1 1 100%;
  }
  .thread-date {
    width: 100%;
    padding-left: 50px;
    font-size: 11px;
  }
  .list-row-item {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .brand-name {
    display: none;
  }
}

/* Active Topbar Controls & Popovers */
.icon-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.adv-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 340px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}

@media (max-width: 720px) {
  .adv-search-panel {
    position: fixed;
    top: 62px;
    left: 12px;
    right: 12px;
    min-width: 0;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
}

/* Mail Layout Modes (Desktop) */
@media (min-width: 821px) {
  .mail-workspace[data-mail-layout="bottom"] {
    flex-direction: column;
  }
  .mail-workspace[data-mail-layout="bottom"] .mail-list-col {
    width: 100%;
    height: 44%;
    min-height: 210px;
    max-height: 55%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .mail-workspace[data-mail-layout="bottom"] .mail-read-col {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .mail-workspace[data-mail-layout="list"] .mail-list-col {
    width: 100%;
    flex: 1;
    border-right: none;
  }
  .mail-workspace[data-mail-layout="list"] .mail-read-col {
    display: none;
  }
  .mail-workspace[data-mail-layout="list"].reading-list-open .mail-list-col {
    display: none;
  }
  .mail-workspace[data-mail-layout="list"].reading-list-open .mail-read-col {
    display: flex;
    width: 100%;
    flex: 1;
  }
}

.list-mode-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* Compact Density Mode */
.mail-workspace[data-mail-density="compact"] .msg-row {
  padding: 7px 14px;
  gap: 9px;
}

.mail-workspace[data-mail-density="compact"] .msg-avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.mail-workspace[data-mail-density="compact"] .msg-sender,
.mail-workspace[data-mail-density="compact"] .msg-subject {
  font-size: 12.5px;
}

.mail-workspace[data-mail-density="compact"] .msg-snippet {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Priority & Authenticity Pills */
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.security-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
  white-space: nowrap;
}

/* Drag & Drop Targets */
.nav-item.drop-target {
  background: var(--accent-soft);
  color: var(--text);
  outline: 1px dashed var(--accent);
}

.msg-list.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: var(--accent-soft);
}

.msg-row.dragging {
  opacity: 0.45;
}

/* Message Context Menu */
.context-menu {
  position: fixed;
  z-index: 120;
  min-width: 210px;
  max-width: 260px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.context-menu-item {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  transition: background-color 0.12s var(--ease);
}

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

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

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

.context-menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--border);
}

/* Maximized Composer & Toolbar Color Picker */
#composerModal.modal-backdrop.composer-maximized {
  padding: 16px;
}

#composerModal.modal-backdrop.composer-maximized .composer-card {
  max-width: none;
  width: 100%;
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
}

.toolbar-color {
  width: 28px;
  height: 26px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  cursor: pointer;
}

/* Action Popovers & Sidebar Folder Toggle */
.popover-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.action-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 95;
  min-width: 215px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-popover-right {
  left: auto;
  right: 0;
}

.popover-item {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
  background: transparent;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.popover-item svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

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

.popover-item.active,
.popover-item.btn-accent-soft {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border: none;
}

.popover-item.active svg {
  color: var(--accent);
}

.popover-item.danger {
  color: var(--danger);
}

.popover-item.danger:hover {
  background: var(--danger-soft);
}

.popover-field {
  padding: 3px 4px;
}

.popover-select {
  width: 100%;
  height: 30px;
  font-size: 12.5px;
  padding: 0 26px 0 8px;
  border-radius: 6px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
}

.nav-more-toggle {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: left;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}

.nav-more-toggle svg {
  width: 15px;
  height: 15px;
  transition: transform 0.18s var(--ease);
}

.nav-more-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.nav-more-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-muted);
}

.nav-more-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 2px;
}
