:root {
  color-scheme: light dark;
  interpolate-size: allow-keywords;
  --font-sans: "Adwaita Sans", Cantarell, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Light & dark raw tokens */
  --bg-app-light: #fafafb;
  --bg-app-dark: #222226;
  --bg-chrome-light: #f1f1f3;
  --bg-chrome-dark: #26262a;
  --bg-view-light: #ffffff;
  --bg-view-dark: #1d1d20;
  --bg-raised-light: #ffffff;
  --bg-raised-dark: #27272b;
  --bg-hover-light: rgba(0, 0, 0, 0.05);
  --bg-hover-dark: rgba(255, 255, 255, 0.06);
  --bg-input-light: #ffffff;
  --bg-input-dark: #1d1d20;
  --bg-subtle-light: rgba(0, 0, 0, 0.06);
  --bg-subtle-dark: rgba(255, 255, 255, 0.08);
  --bg-selected-light: rgba(0, 0, 6, 0.09);
  --bg-selected-dark: rgba(255, 255, 255, 0.12);
  --border-subtle-light: rgba(0, 0, 0, 0.1);
  --border-subtle-dark: rgba(255, 255, 255, 0.1);
  --border-strong-light: rgba(0, 0, 0, 0.18);
  --border-strong-dark: rgba(255, 255, 255, 0.18);
  --border-focus-light: #1c71d8;
  --border-focus-dark: #78aeed;
  --text-primary-light: #23232a;
  --text-primary-dark: #f5f5f7;
  --text-secondary-light: rgba(0, 0, 0, 0.65);
  --text-secondary-dark: rgba(255, 255, 255, 0.75);
  --text-muted-light: #66666f;
  --text-muted-dark: rgba(255, 255, 255, 0.62);
  --accent-light: #1c71d8;
  --accent-dark: #78aeed;
  --accent-subtle-light: rgba(28, 113, 216, 0.08);
  --accent-subtle-dark: rgba(120, 174, 237, 0.12);
  --green-light: #1a7f37;
  --green-dark: #2ec27e;
  --green-subtle-light: #e6f4ea;
  --green-subtle-dark: rgba(46, 194, 126, 0.16);
  --amber-light: #9a6700;
  --amber-dark: #e5a50a;
  --amber-subtle-light: #fff8c5;
  --amber-subtle-dark: rgba(229, 165, 10, 0.16);
  --red-light: #c01c28;
  --red-dark: #f58b91;
  --red-subtle-light: #ffe8e6;
  --red-subtle-dark: rgba(224, 27, 36, 0.16);
  --active-toggle-light: #ffffff;
  --active-toggle-dark: rgb(255 255 255 / 20%);
  --scrollbar-thumb-light: #6b6b76;
  --scrollbar-thumb-dark: #8a8a96;
  --scrollbar-track-light: #ebebf0;
  --scrollbar-track-dark: #252529;

  /* Default dark palette fallback for pre-light-dark browsers */
  --bg-app: var(--bg-app-dark);
  --bg-chrome: var(--bg-chrome-dark);
  --bg-view: var(--bg-view-dark);
  --bg-raised: var(--bg-raised-dark);
  --bg-hover: var(--bg-hover-dark);
  --bg-input: var(--bg-input-dark);
  --bg-subtle: var(--bg-subtle-dark);
  --bg-selected: var(--bg-selected-dark);
  --border-subtle: var(--border-subtle-dark);
  --border-strong: var(--border-strong-dark);
  --border-focus: var(--border-focus-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --text-muted: var(--text-muted-dark);
  --accent: var(--accent-dark);
  --accent-bg: #1c71d8;
  --accent-hover: #155fb8;
  --accent-subtle: var(--accent-subtle-dark);
  --accent-fg: #ffffff;
  --green: var(--green-dark);
  --green-subtle: var(--green-subtle-dark);
  --amber: var(--amber-dark);
  --amber-subtle: var(--amber-subtle-dark);
  --red: var(--red-dark);
  --danger-bg: #c01c28;
  --red-subtle: var(--red-subtle-dark);
  --active-toggle: var(--active-toggle-dark);
  --scrollbar-thumb: var(--scrollbar-thumb-dark);
  --scrollbar-track: var(--scrollbar-track-dark);
  --radius: 12px;
  --control-radius: 8px;
  --sidebar-w: 236px;
  --page-gutter: 24px;

  accent-color: var(--accent-bg);
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-app: var(--bg-app-light);
    --bg-chrome: var(--bg-chrome-light);
    --bg-view: var(--bg-view-light);
    --bg-raised: var(--bg-raised-light);
    --bg-hover: var(--bg-hover-light);
    --bg-input: var(--bg-input-light);
    --bg-subtle: var(--bg-subtle-light);
    --bg-selected: var(--bg-selected-light);
    --border-subtle: var(--border-subtle-light);
    --border-strong: var(--border-strong-light);
    --border-focus: var(--border-focus-light);
    --text-primary: var(--text-primary-light);
    --text-secondary: var(--text-secondary-light);
    --text-muted: var(--text-muted-light);
    --accent: var(--accent-light);
    --accent-subtle: var(--accent-subtle-light);
    --green: var(--green-light);
    --green-subtle: var(--green-subtle-light);
    --amber: var(--amber-light);
    --amber-subtle: var(--amber-subtle-light);
    --red: var(--red-light);
    --red-subtle: var(--red-subtle-light);
    --active-toggle: var(--active-toggle-light);
    --scrollbar-thumb: var(--scrollbar-thumb-light);
    --scrollbar-track: var(--scrollbar-track-light);
  }
}

@supports (color: light-dark(white, black)) {
  :root {
    --bg-app: light-dark(var(--bg-app-light), var(--bg-app-dark));
    --bg-chrome: light-dark(var(--bg-chrome-light), var(--bg-chrome-dark));
    --bg-view: light-dark(var(--bg-view-light), var(--bg-view-dark));
    --bg-raised: light-dark(var(--bg-raised-light), var(--bg-raised-dark));
    --bg-hover: light-dark(var(--bg-hover-light), var(--bg-hover-dark));
    --bg-input: light-dark(var(--bg-input-light), var(--bg-input-dark));
    --bg-subtle: light-dark(var(--bg-subtle-light), var(--bg-subtle-dark));
    --bg-selected: light-dark(var(--bg-selected-light), var(--bg-selected-dark));
    --border-subtle: light-dark(var(--border-subtle-light), var(--border-subtle-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --border-focus: light-dark(var(--border-focus-light), var(--border-focus-dark));
    --text-primary: light-dark(var(--text-primary-light), var(--text-primary-dark));
    --text-secondary: light-dark(var(--text-secondary-light), var(--text-secondary-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --accent: light-dark(var(--accent-light), var(--accent-dark));
    --accent-subtle: light-dark(var(--accent-subtle-light), var(--accent-subtle-dark));
    --green: light-dark(var(--green-light), var(--green-dark));
    --green-subtle: light-dark(var(--green-subtle-light), var(--green-subtle-dark));
    --amber: light-dark(var(--amber-light), var(--amber-dark));
    --amber-subtle: light-dark(var(--amber-subtle-light), var(--amber-subtle-dark));
    --red: light-dark(var(--red-light), var(--red-dark));
    --red-subtle: light-dark(var(--red-subtle-light), var(--red-subtle-dark));
    --active-toggle: light-dark(var(--active-toggle-light), var(--active-toggle-dark));
    --scrollbar-thumb: light-dark(var(--scrollbar-thumb-light), var(--scrollbar-thumb-dark));
    --scrollbar-track: light-dark(var(--scrollbar-track-light), var(--scrollbar-track-dark));
  }
}

[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
  --bg-app: var(--bg-app-light);
  --bg-chrome: var(--bg-chrome-light);
  --bg-view: var(--bg-view-light);
  --bg-raised: var(--bg-raised-light);
  --bg-hover: var(--bg-hover-light);
  --bg-input: var(--bg-input-light);
  --bg-subtle: var(--bg-subtle-light);
  --bg-selected: var(--bg-selected-light);
  --border-subtle: var(--border-subtle-light);
  --border-strong: var(--border-strong-light);
  --border-focus: var(--border-focus-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --text-muted: var(--text-muted-light);
  --accent: var(--accent-light);
  --accent-subtle: var(--accent-subtle-light);
  --green: var(--green-light);
  --green-subtle: var(--green-subtle-light);
  --amber: var(--amber-light);
  --amber-subtle: var(--amber-subtle-light);
  --red: var(--red-light);
  --red-subtle: var(--red-subtle-light);
  --active-toggle: var(--active-toggle-light);
  --scrollbar-thumb: var(--scrollbar-thumb-light);
  --scrollbar-track: var(--scrollbar-track-light);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
th { text-wrap: balance; }
p { margin: 0; }
.view-toolbar p, .note, .preflight-box, .settings-card-header p, .empty {
  text-wrap: pretty;
}
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
}
#view-title:focus:not(:focus-visible) {
  outline: none;
}
[hidden] { display: none !important; }

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.content-viewport,
.mail-list-items,
.list,
.table-wrap,
.modal-body,
.settings-pane,
.recipient-picks,
.check-list,
.history-list {
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  scrollbar-width: thin;
}

@supports not (scrollbar-color: auto) {
  .content-viewport::-webkit-scrollbar,
  .mail-list-items::-webkit-scrollbar,
  .list::-webkit-scrollbar,
  .table-wrap::-webkit-scrollbar,
  .modal-body::-webkit-scrollbar,
  .settings-pane::-webkit-scrollbar,
  .recipient-picks::-webkit-scrollbar,
  .check-list::-webkit-scrollbar,
  .history-list::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  .content-viewport::-webkit-scrollbar-thumb,
  .mail-list-items::-webkit-scrollbar-thumb,
  .list::-webkit-scrollbar-thumb,
  .table-wrap::-webkit-scrollbar-thumb,
  .modal-body::-webkit-scrollbar-thumb,
  .settings-pane::-webkit-scrollbar-thumb,
  .recipient-picks::-webkit-scrollbar-thumb,
  .check-list::-webkit-scrollbar-thumb,
  .history-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
  }
  .content-viewport::-webkit-scrollbar-track,
  .mail-list-items::-webkit-scrollbar-track,
  .list::-webkit-scrollbar-track,
  .table-wrap::-webkit-scrollbar-track,
  .modal-body::-webkit-scrollbar-track,
  .settings-pane::-webkit-scrollbar-track,
  .recipient-picks::-webkit-scrollbar-track,
  .check-list::-webkit-scrollbar-track,
  .history-list::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
}

/* View Transitions */
#view-title { view-transition-name: view-title; width: fit-content; }
#view-title:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

.app-workspace {
  height: 100vh;
  height: 100dvh;
  display: flex;
  background: var(--bg-chrome);
}
.app-main-layout { flex: 1; min-width: 0; display: flex; overflow: hidden; }
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-chrome);
  padding: 8px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.sidebar-brand {
  width: 100%;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.sidebar-brand:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  box-shadow: 0 2px 6px rgb(21 83 158 / 28%);
}
.brand-info {
  flex: 1;
  min-inline-size: 0;
  display: grid;
  gap: 5px;
  align-content: center;
}
.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-inline-size: 0;
}
.brand-name {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-primary);
  text-box: trim-both cap alphabetic;
}
.brand-tagline {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-box: trim-both cap alphabetic;
}
.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}
.sidebar-menu { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  width: 100%;
  min-inline-size: 0;
}
.menu-item:hover { background: color-mix(in srgb, currentColor 6%, transparent); }
.menu-item.active { background: var(--bg-selected); font-weight: 600; }
.sidebar-menu .menu-item:focus-visible { outline-offset: -2px; }
.menu-icon { width: 16px; height: 16px; flex-shrink: 0; }
.menu-label { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.user-menu { position: relative; }
.user-capsule {
  anchor-name: --user-menu-trigger;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  color: inherit;
  cursor: pointer;
  min-inline-size: 0;
}
.user-capsule:hover,
.user-capsule[aria-expanded="true"] { background: var(--bg-hover); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.user-details { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.user-details strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Popover User Menu with Anchor Positioning & Top-Layer Transitions */
.menu-popover {
  min-width: 240px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 64px);
  overflow: auto;
  padding: 6px;
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgb(0 0 0 / 28%);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.16s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
@media (prefers-reduced-motion: no-preference) {
  .menu-popover {
    transform: translateY(4px) scale(0.98);
  }
}
@media (prefers-reduced-motion: reduce) {
  .menu-popover {
    transition-duration: 0.08s;
  }
}
#user-menu-popover:is(:popover-open, .\:popover-open) {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#user-menu-popover:is(:popover-open, .\:popover-open):where(:not([data-closing])) {
  opacity: 1;
  @starting-style {
    opacity: 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0) scale(1);
    @starting-style {
      transform: translateY(4px) scale(0.98);
    }
  }
}
@supports (position-area: block-start) {
  #user-menu-popover {
    position-anchor: --user-menu-trigger;
    inset: auto;
    margin: 0 0 6px 0;
    position-area: block-start span-inline-end;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
  }
}
@supports not (position-area: block-start) {
  #user-menu-popover {
    position: fixed;
    inset: auto auto 64px 12px;
    margin: 0;
  }
}
.menu-user-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 6px; min-width: 0; }
.menu-user-head strong, .menu-user-head span { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.menu-item-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.menu-item-btn:hover { background: var(--bg-hover); }
.menu-item-btn.danger { color: var(--red); }
.menu-item-btn.danger:hover { background: var(--red-subtle); }
.menu-separator { height: 1px; margin: 4px 2px; background: var(--border-subtle); }
.menu-shortcut { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.menu-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 6px 10px;
  font-size: 13px;
}
.menu-theme-label { color: var(--text-secondary); }
.menu-theme-switch {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 7%, transparent);
}
.menu-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  height: auto;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
}
.menu-theme-btn svg { width: 14px; height: 14px; }
.menu-theme-btn:hover { color: var(--text-primary); }
.menu-theme-btn.active {
  background: var(--bg-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgb(0 0 0 / 18%);
}
[data-theme="light"] .menu-theme-btn.active { box-shadow: 0 1px 2px rgb(0 0 6 / 16%); }

.app-content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-view);
  overflow: hidden;
  min-height: 0;
}
.view-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 18px var(--page-gutter) 14px;
  flex-shrink: 0;
  background: var(--bg-view);
  border-bottom: 1px solid var(--border-subtle);
}
.view-title { min-width: 0; }
.view-toolbar h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.view-toolbar p { margin-top: 3px; color: var(--text-secondary); font-size: 13px; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.toolbar-search-group { display: flex; align-items: center; gap: 6px; }
.toolbar-search-group input { width: 200px; }
.content-viewport { flex: 1; min-height: 0; overflow: auto; padding: 16px var(--page-gutter) 32px; }

.btn {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--control-radius);
  min-height: 32px;
  min-inline-size: 24px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn.primary { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; color: var(--red); border-color: transparent; }
.btn.danger:hover { background: var(--red-subtle); }
.btn:disabled { opacity: 0.55; cursor: default; pointer-events: none; }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 12px; }

.adw-toggle { display: inline-flex; align-items: center; padding: 2px; border-radius: 9px; background: color-mix(in srgb, currentColor 8%, transparent); gap: 2px; }
.adw-toggle .btn { background: transparent; min-height: 26px; border: none; box-shadow: none; font-size: 12px; font-weight: 500; }
.adw-toggle .btn.active { background: var(--active-toggle); font-weight: 600; }
[data-theme="light"] .adw-toggle .btn.active { background: #fff; box-shadow: 0 1px 2px rgb(0 0 6 / 16%); }

input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
textarea {
  height: auto;
  field-sizing: content;
  min-block-size: 5lh;
  max-block-size: 14lh;
  resize: vertical;
  line-height: 1.5;
  font-family: inherit;
}
#body {
  min-block-size: 9lh;
  max-block-size: 24lh;
}
#bulk-paste-text {
  min-block-size: 8lh;
  max-block-size: 18lh;
}

/* Deferred validation states */
:is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--red);
  background-color: var(--red-subtle);
}
.field:has(:is(input, select, textarea):is(:user-invalid, .user-invalid-fallback)) {
  color: var(--red);
}
.error-msg {
  display: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}
:is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) + .error-msg,
.password-wrap:has(:is(:user-invalid, .user-invalid-fallback)) + .error-msg {
  display: block;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.align-center { align-items: center; }
.row > input, .row > select { width: auto; flex: 1 1 140px; }
.row-actions { display: flex; align-items: center; gap: 8px; }
label.field, .compose-steps .field {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 0;
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.char-counter {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.char-counter.warn {
  color: var(--amber);
  font-weight: 600;
}
.field-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-top: 4px; }
.muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-semibold { font-weight: 600; }
.ml-auto { margin-left: auto; }
.flex-grow { flex: 1; }

.split {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: min(700px, calc(100vh - 160px));
}
.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.editor, .pad { padding: 18px; display: grid; gap: 14px; }
.editor {
  container-type: inline-size;
  align-content: start;
}
.editor-workspace {
  display: grid;
  gap: 16px;
  align-items: start;
}
.editor-main, .editor-side {
  display: grid;
  gap: 14px;
  min-width: 0;
}
@container (min-width: 920px) {
  .editor-workspace {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 20px;
  }
  .editor-side {
    position: sticky;
    top: 0;
  }
  .editor-side .sample-wrapper {
    border-top: 0;
    padding-top: 0;
  }
}

.list { overflow: auto; }
.panel-header-search { padding: 10px; border-bottom: 1px solid var(--border-subtle); }
.mail-list-items { overflow-y: auto; flex: 1; min-height: 0; }
.mail-list-items,
.list-choices {
  container-type: scroll-state;
}
.mail-list-items::before,
.mail-list-items::after,
.list-choices::before,
.list-choices::after {
  content: "";
  display: block;
  position: sticky;
  block-size: 0.75rem;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.mail-list-items::before,
.list-choices::before {
  inset-block-start: 0;
  margin-block-end: -0.75rem;
  background: radial-gradient(farthest-side at 50% 0, rgb(0 0 0 / 0.22), transparent);
}
.mail-list-items::after,
.list-choices::after {
  inset-block-end: 0;
  margin-block-start: -0.75rem;
  background: radial-gradient(farthest-side at 50% 100%, rgb(0 0 0 / 0.22), transparent);
}
@container scroll-state(scrollable: block-start) {
  .mail-list-items::before,
  .list-choices::before { opacity: 1; }
}
@container scroll-state(scrollable: block-end) {
  .mail-list-items::after,
  .list-choices::after { opacity: 1; }
}
@supports not (container-type: scroll-state) {
  .mail-list-items::before,
  .mail-list-items::after,
  .list-choices::before,
  .list-choices::after {
    animation: show-scroll-shadow linear both;
    animation-timeline: scroll();
  }
  .mail-list-items::before,
  .list-choices::before {
    animation-range: 0 2rem;
  }
  .mail-list-items::after,
  .list-choices::after {
    animation-direction: reverse;
    animation-range: calc(100% - 2rem) 100%;
  }
}
@keyframes show-scroll-shadow {
  to { opacity: 1; }
}

button.item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  padding: 12px 14px;
  border-radius: 0;
  color: var(--text-primary);
  display: grid;
  gap: 4px;
  justify-items: start;
  min-inline-size: 0;
}
button.item:focus-visible { outline-offset: -2px; }
button.item:last-of-type { border-bottom: 0; }
button.item strong {
  display: block;
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.item small { color: var(--text-muted); font-size: 12px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; max-width: 100%; }
button.item.active, tr.selected { background: var(--bg-selected); }
button.item:hover { background: var(--bg-hover); }
.marks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }

.editor-top-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.editor-buttons-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tokens-section { display: grid; gap: 8px; }
.tokens-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tokens { display: flex; gap: 6px; flex-wrap: wrap; }
.token {
  border-radius: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: monospace;
  min-block-size: 26px;
}
.token:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

/* Accordion / Details Disclosure */
details.tokens-disclosure {
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
  padding: 6px 10px;
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}
details.tokens-disclosure summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
details.tokens-disclosure summary::-webkit-details-marker { display: none; }
details.tokens-disclosure summary::before {
  content: "";
  inline-size: 0.85em;
  block-size: 0.85em;
  flex-shrink: 0;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}
details.tokens-disclosure[open] > summary::before {
  rotate: 0deg;
}
@media (prefers-reduced-motion: no-preference) {
  details.tokens-disclosure summary::before {
    transition: rotate 0.2s ease;
  }
}
details.tokens-disclosure::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}
details.tokens-disclosure:not([open])::details-content {
  block-size: 0;
}
@media (prefers-reduced-motion: no-preference) {
  details.tokens-disclosure::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: 0.22s;
    transition-timing-function: ease-in-out;
    transition-behavior: allow-discrete;
  }
}
details.tokens-disclosure .tokens {
  padding-top: 8px;
}

.sample-wrapper { border-top: 1px solid var(--border-subtle); padding-top: 12px; display: grid; gap: 8px; }
.sample-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sample {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg-input);
  transition: max-width 0.25s ease;
}
.sample-subject { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border-subtle); font-size: 14px; }
.sample-content { font-size: 13px; line-height: 1.5; color: var(--text-secondary); }

/* Responsive Device Preview Frames */
.preview-device-desktop { width: 100%; }
.preview-device-mobile {
  max-width: 375px;
  margin: 12px auto;
  border: 3px solid var(--border-strong);
  border-radius: 28px;
  padding: 16px 12px;
  background: var(--bg-view);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.preview-device-mobile iframe { min-height: 480px; width: 100%; }
.preview-device-mobile .send-body { max-height: 480px; overflow-y: auto; padding: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
  text-box: trim-both cap alphabetic;
}
.badge.warn { color: var(--amber); background: var(--amber-subtle); }
.badge.ok, .badge.sent, .badge.completed, .badge.active { color: var(--green); background: var(--green-subtle); }
.badge.bad, .badge.failed, .badge.unknown, .badge.interrupted, .badge.completed_with_errors, .badge.unsubscribed { color: var(--red); background: var(--red-subtle); }
.list-pills { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.list-pill,
.list-pills .badge {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tables, Sticky Context & Sortable Headers */
.table-wrap { overflow: auto; container-type: inline-size; max-inline-size: 100%; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); }

th:has(> .sort-btn) { padding: 0; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.sort-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.sort-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.sort-icon {
  width: 12px;
  height: 12px;
  flex: none;
  opacity: 0.35;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
th[aria-sort] .sort-btn { color: var(--text-primary); }
th[aria-sort] .sort-icon { opacity: 1; color: var(--accent); }
th[aria-sort="descending"] .sort-icon { transform: rotate(180deg); }

.list-viewport, .contacts-viewport { padding-bottom: 16px; }
.list-split {
  height: 100%;
  min-height: min(320px, 65dvh);
  grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.list-panel-left {
  align-self: start;
  max-height: 100%;
  overflow: hidden;
}
.list-choices { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.list-choices .item { flex-shrink: 0; overflow-wrap: anywhere; }
.list-picker { display: none; }
.list-actions { flex-wrap: wrap; }
#list-members-title { overflow-wrap: anywhere; }
.list-split .pad, .contacts-panel .pagination-bar { flex-shrink: 0; }
.list-members, .contacts-table { flex: 1; min-height: 0; }
.list-members { border-radius: 0 0 var(--radius) var(--radius); }
.list-members:focus-visible, .contacts-table:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.list-members table { width: max-content; min-width: 100%; }
.list-members th, .list-members td { padding: 8px 12px; white-space: nowrap; }
.list-members thead th, .contacts-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--bg-raised);
  box-shadow: inset 0 -1px var(--border-subtle);
}
.contacts-table th:first-child,
.contacts-table td:first-child,
.list-members th:first-child,
.list-members td:first-child {
  position: sticky;
  inset-inline-start: 0;
  background: var(--bg-raised);
  box-shadow: inset -1px 0 var(--border-subtle), inset 0 -1px var(--border-subtle);
}
.contacts-table thead th:first-child,
.list-members thead th:first-child {
  z-index: 3;
}
.contacts-table tbody th[scope="row"],
.contacts-table tbody td:first-child,
.list-members tbody th[scope="row"],
.list-members tbody td:first-child {
  z-index: 1;
  font-weight: 600;
}
tr[data-action]:hover th[scope="row"],
tr[data-action]:hover td:first-child {
  background: color-mix(in srgb, var(--bg-raised) 94%, var(--text-primary));
}
tr.selected th[scope="row"],
tr.selected td:first-child {
  background: color-mix(in srgb, var(--bg-raised) 88%, var(--text-primary));
}
.list-members th:last-child,
.list-members td:last-child {
  position: sticky;
  inset-inline-end: 0;
  background: var(--bg-raised);
  box-shadow: inset 1px 0 var(--border-subtle), inset 0 -1px var(--border-subtle);
}
.list-members thead th:last-child {
  z-index: 3;
}
.list-members tbody td:last-child {
  z-index: 1;
  text-align: right;
}

/* Responsive stacked cards for narrow containers */
@container (width < 560px) {
  .contacts-table table,
  .contacts-table thead,
  .contacts-table tbody,
  .contacts-table tr,
  .contacts-table th,
  .contacts-table td {
    display: block;
  }
  .contacts-table thead {
    display: none;
  }
  .contacts-table tr {
    margin: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--control-radius);
    overflow: hidden;
    background: var(--bg-view);
  }
  .contacts-table tbody th[scope="row"] {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--bg-subtle);
    box-shadow: inset 0 -1px var(--border-subtle);
  }
  .contacts-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
  }
  .contacts-table td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .contacts-table td.empty::before {
    content: none;
  }
}

.member-field, .member-email { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-field { max-width: 16rem; }
.member-email {
  max-width: 20rem;
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 600;
  text-align: left;
  color: inherit;
}
.member-email:hover { text-decoration: underline; }
iframe { width: 100%; min-height: 320px; border: 1px solid var(--border-subtle); border-radius: var(--radius); background: white; }

.mini-progress-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.mini-progress { width: 50px; height: 6px; background: var(--bg-subtle); border-radius: 4px; overflow: hidden; }
.mini-progress-fill { height: 100%; background: var(--green); }

.campaign-summary-bar {
  padding: 12px 14px;
  background: var(--bg-subtle);
  border-radius: var(--control-radius);
  display: grid;
  gap: 8px;
}
.progress-container { display: grid; gap: 4px; margin-top: 4px; }
.progress-bar-wrap { width: 100%; height: 8px; background: var(--bg-raised); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent-bg); transition: width 0.3s ease; }
.progress-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }

.bulk-actions-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-radius: var(--control-radius);
}

.recipient-filter-row, .member-search-row { margin-bottom: 4px; }
.list-toolbar-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.list-toolbar-search input,
.list-member-search {
  flex: 1 1 160px;
  width: auto;
  min-inline-size: 160px;
  max-inline-size: 240px;
}
.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.subject-over {
  color: var(--amber);
  font-weight: 600;
}
.review-table-wrap { max-height: 240px; overflow-y: auto; border: 1px solid var(--border-subtle); border-radius: var(--control-radius); }

.password-wrap { position: relative; display: flex; align-items: center; }
.password-toggle { position: absolute; right: 4px; }

.dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; background: var(--amber); margin-right: 6px; }
.dot.on { background: var(--green); }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }
.empty-inline { display: grid; gap: 8px; justify-items: center; }
.justify-center { justify-content: center; }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.note { margin-bottom: 12px; padding: 10px 12px; border-radius: var(--control-radius); background: var(--amber-subtle); color: var(--amber); }

/* Persistent Top-Layer Toast Notification */
.toast {
  position: fixed;
  inset: auto 0 22px 0;
  margin: 0 auto;
  width: fit-content;
  max-width: min(460px, calc(100vw - 32px));
  background: var(--text-primary);
  color: var(--bg-view);
  border: 1px solid var(--border-subtle);
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgb(0 0 0 / 28%);
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.2s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
.toast:is(:popover-open, .\:popover-open) {
  display: flex;
}
.toast:is(:popover-open, .\:popover-open):where(:not([data-closing])) {
  opacity: 1;
  @starting-style {
    opacity: 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    transform: translateY(0);
    @starting-style {
      transform: translateY(10px);
    }
  }
}
@media (prefers-reduced-motion: no-preference) {
  .toast {
    transform: translateY(10px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition-duration: 0.08s;
  }
}
.toast.error { background: var(--danger-bg); color: #fff; border-color: transparent; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.78;
  min-inline-size: 24px;
  min-block-size: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
}
.toast-close:hover {
  opacity: 1;
  background: rgb(127 127 127 / 20%);
}

/* Native <dialog> Modals & Top-Layer Transitions */
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgb(0 0 0 / 0);
  backdrop-filter: blur(2px);
  transition-property: background-color, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog.modal,
dialog.settings-shell {
  padding: 0;
  margin: auto;
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
dialog.modal {
  width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(85dvh, 780px);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}
dialog.modal.wide {
  width: min(860px, calc(100vw - 32px));
}
dialog.settings-shell {
  width: min(980px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: min(760px, calc(100dvh - 32px));
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgb(0 0 0 / 35%);
}
[data-theme="light"] dialog.settings-shell { background: #fff; }
dialog.modal[open],
dialog.settings-shell[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  dialog.modal,
  dialog.settings-shell {
    transform: scale(0.96);
  }
}
:is(dialog.modal[open], dialog.settings-shell[open]):where(:not([data-closing])) {
  opacity: 1;
  @starting-style {
    opacity: 0;
  }
  @media (prefers-reduced-motion: no-preference) {
    transform: scale(1);
    @starting-style {
      transform: scale(0.96);
    }
  }
  &::backdrop {
    background-color: rgb(0 0 0 / 54%);
    @starting-style {
      background-color: rgb(0 0 0 / 0);
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  dialog.modal,
  dialog.settings-shell,
  dialog::backdrop {
    transition-duration: 0.08s;
  }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.modal-close-btn { border: none; background: transparent; font-size: 14px; min-inline-size: 28px; min-block-size: 28px; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 14px; flex: 1; min-height: 0; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-subtle); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
.modal-footer:empty { display: none; }

.modal-form, .compose-steps { display: grid; gap: 14px; }
.compose-steps .step {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.recipient-picks {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}
.send-preview { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.send-body { white-space: pre-wrap; color: var(--text-secondary); }
.recipient-subject { font-size: 13px; color: var(--text-primary); }
.check { display: flex; gap: 8px; align-items: center; min-height: 30px; cursor: pointer; }
.check input { width: auto; margin: 0; }
tr[data-action] { cursor: pointer; }
tr[data-action]:hover { background: var(--bg-hover); }

@media (max-width: 900px) {
  .app-main-layout { flex-direction: column; }
  .app-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .sidebar-brand .brand-info { display: none; }
  .sidebar-brand { width: auto; padding: 4px; margin-bottom: 0; }
  .nav-section-label { display: none; }
  .sidebar-menu { flex-direction: row; }
  .menu-label { display: none; }
  .menu-item { width: auto; flex: none; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border-top: none; }
  .user-capsule { padding: 4px; }
  .user-details { display: none; }
  @supports (position-area: block-start) {
    #user-menu-popover {
      margin: 6px 0 0 0;
      position-area: block-end span-inline-start;
    }
  }
  @supports not (position-area: block-start) {
    #user-menu-popover {
      inset: 58px 12px auto auto;
    }
  }
  .split { grid-template-columns: 1fr; min-height: 0; }
  .list-split { display: flex; flex-direction: column; min-height: 320px; gap: 10px; }
  .list-panel-left { display: none; }
  .list-picker { display: block; flex-shrink: 0; width: 100%; max-inline-size: 100%; }
  .list-split > .panel { flex: 1; }
  .view-toolbar { padding: 14px 14px 10px; }
  .toolbar-actions { min-width: 0; flex-shrink: 1; }
  .content-viewport { padding: 12px 14px 16px; }
  .contacts-viewport .adw-toggle { flex-wrap: wrap; }
  dialog.modal { max-height: 95dvh; }
}

/* Dashboard & Stats */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  text-align: left;
  align-content: start;
  transition: border-color 0.15s, background-color 0.15s;
}
button.kpi-card.kpi-action:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--bg-raised) 96%, var(--text-primary));
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-secondary); }
.kpi-value.ok { color: var(--green); }
.kpi-value.bad { color: var(--red); }
.kpi-value.accent { color: var(--accent); }

.section-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.section-card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-card-head h2 { font-size: 15px; }

/* Mail editor enhancements */
.html-snippets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.media-panel {
  display: grid;
  gap: 8px;
}
.media-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.media-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--control-radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.media-item img {
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-input);
}
.media-url {
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

/* Copy Button Feedback Bubble */
.copy {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.copy .tip {
  position: absolute;
  inset-block-end: calc(100% + 6px);
  inset-inline-end: 0;
  background: var(--text-primary);
  color: var(--bg-view);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.copy:is([data-copied], [data-failed]) .tip {
  opacity: 1;
}
.copy[data-failed] .tip {
  background: var(--danger-bg);
  color: #fff;
}

.attachments-panel {
  display: grid;
  gap: 8px;
}
.attachment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.attachment-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--control-radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.attachment-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-muted, inherit);
}
.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.send-attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.send-attachments .menu-icon,
.attachments-panel .btn .menu-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}
@media (max-width: 640px) {
  .attachment-item {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .attachment-item .media-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.preflight-box {
  padding: 10px 12px;
  border-radius: var(--control-radius);
  background: var(--amber-subtle);
  color: var(--amber);
  font-size: 12px;
  display: grid;
  gap: 4px;
}
.preflight-box.ok {
  background: var(--green-subtle);
  color: var(--green);
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.template-card {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--control-radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: grid;
  gap: 4px;
}
.template-card:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.template-card small { color: var(--text-muted); font-weight: 400; }

/* Contacts filter & pagination */
.contacts-viewport { display: flex; flex-direction: column; }
.contacts-panel { flex: 1; min-height: min(240px, 45dvh); }
.contacts-table { border-radius: var(--radius) var(--radius) 0 0; }
.filter-bar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.filter-bar select,
#send-jitter {
  width: auto;
  field-sizing: content;
  min-inline-size: 14ch;
  max-inline-size: 38ch;
}
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Campaign review metrics & actions */
.review-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
  gap: 8px;
}
.metric-pill {
  background: var(--bg-view);
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}
.metric-pill span { font-size: 11px; color: var(--text-muted); }
.metric-pill strong { font-size: 16px; }
.metric-pill.ok strong { color: var(--green); }
.metric-pill.bad strong { color: var(--red); }
.metric-pill.warn strong { color: var(--amber); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
}
.check-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--control-radius);
  padding: 6px 10px;
  display: grid;
  gap: 2px;
}
.status-counts-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.inline-check input { width: auto; margin: 0; }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.signin-card { width: min(100%, 380px); padding: 32px; }
.signin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.signin-brand .brand-mark { width: 40px; height: 40px; }
.signin-brand-text { display: grid; gap: 5px; min-inline-size: 0; }
.signin-card h1 { margin: 0; font-size: 20px; line-height: 1.15; text-box: trim-both cap alphabetic; }
.signin-card .btn { width: 100%; justify-content: center; }
.sidebar-auth { display: grid; gap: 8px; padding: 12px 16px; }
.sidebar-auth span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.contact-modal .modal-body { align-content: start; overscroll-behavior: contain; }
.contact-group { border-top: 1px solid var(--border-subtle); }
.contact-group summary { padding: 8px 0; font-weight: 600; cursor: pointer; }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-items: start; gap: 12px; }
.contact-grid textarea { min-block-size: 3lh; max-block-size: 10lh; }
.share-list { list-style: none; padding: 0; }
.share-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0; overflow-wrap: anywhere; }

.signin-card form { display: grid; gap: 10px; }
.signin-card form + a { margin-top: 12px; }

button.note-action {
  display: block;
  width: 100%;
  border: none;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.settings-shell-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-shell-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.settings-shell-body { flex: 1; min-height: 0; display: flex; }
.settings-nav {
  flex: none;
  width: 228px;
  padding: 12px 10px 16px;
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-nav-group {
  margin: 14px 10px 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.settings-nav-group:first-child { margin-top: 4px; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.settings-nav-item svg { width: 16px; height: 16px; flex: none; }
.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-nav-item.active { background: var(--bg-selected); color: var(--text-primary); font-weight: 500; }
.settings-pane {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 8px 28px 32px;
}
.settings-card { background: transparent; border: none; padding: 16px 0 0; max-width: 720px; }
.settings-card-header h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.settings-card-header p { margin: 0 0 12px; font-size: 13px; color: var(--text-secondary); }
.settings-list { display: flex; flex-direction: column; }
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--border-subtle);
}
.settings-item:first-child { border-top: none; }
.settings-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-item-title { font-size: 14px; font-weight: 500; }
.settings-item-desc { font-size: 12.5px; color: var(--text-muted); }
.settings-item-ctrl { display: flex; align-items: center; gap: 10px; flex: none; }
.account-profile { display: flex; align-items: center; gap: 14px; padding: 6px 0 16px; border-bottom: 1px solid var(--border-subtle); }
.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 700;
  flex: none;
}
.account-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.account-who strong { font-size: 15px; }
.account-who span, .account-value { font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.segmented-control {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}
.segmented-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 12px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.segmented-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.segmented-btn.active {
  background: var(--bg-raised);
  color: var(--text-primary);
  font-weight: 600;
  border-color: var(--border-subtle);
}

@media (max-width: 720px) {
  dialog.settings-shell { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none; }
  .settings-shell-body { flex-direction: column; }
  .settings-nav {
    width: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .settings-nav-group { display: none; }
  .settings-nav-item { width: auto; flex: none; white-space: nowrap; }
  .settings-pane { padding: 4px 16px 24px; }
  .settings-item { flex-wrap: wrap; }
  .menu-shortcut { display: none; }
}
