/* Cloudmail. Colors are tokens on :root, redefined for dark mode. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e7eaef;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1c2330;
  --text-2: #4b5565;
  --text-3: #7a8494;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning-soft: #fff7e0;
  --flag: #f59e0b;
  --unread-bg: #ffffff;
  --read-bg: #f8f9fb;
  --row-active: #e3ebff;
  --row-checked: #eef3ff;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 8%);
  --shadow-lg: 0 8px 32px rgb(16 24 40 / 18%);
  --radius: 10px;
  --radius-sm: 6px;
  --font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 56px;
  --sidebar-w: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1e232d;
    --surface-3: #282e3a;
    --border: #2a303c;
    --border-strong: #3a4250;
    --text: #e6e9ef;
    --text-2: #b4bbc8;
    --text-3: #8a93a3;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1e2a47;
    --accent-text: #0b1020;
    --danger: #f87171;
    --danger-soft: #3a1d1f;
    --warning-soft: #3a3016;
    --unread-bg: #1b2029;
    --read-bg: #161a21;
    --row-active: #22304f;
    --row-checked: #1f2840;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 30%);
    --shadow-lg: 0 8px 32px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #171b23;
  --surface-2: #1e232d;
  --surface-3: #282e3a;
  --border: #2a303c;
  --border-strong: #3a4250;
  --text: #e6e9ef;
  --text-2: #b4bbc8;
  --text-3: #8a93a3;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-soft: #1e2a47;
  --accent-text: #0b1020;
  --danger: #f87171;
  --danger-soft: #3a1d1f;
  --warning-soft: #3a3016;
  --unread-bg: #1b2029;
  --read-bg: #161a21;
  --row-active: #22304f;
  --row-checked: #1f2840;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 30%);
  --shadow-lg: 0 8px 32px rgb(0 0 0 / 50%);
  color-scheme: dark;
}

/* Black theme: the dark theme with true black surfaces, for OLED screens. */
:root[data-theme="black"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #121212;
  --surface-3: #1c1c1c;
  --border: #222222;
  --border-strong: #333333;
  --text: #e6e6e6;
  --text-2: #b0b0b0;
  --text-3: #858585;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-soft: #16203a;
  --accent-text: #0b1020;
  --danger: #f87171;
  --danger-soft: #2a1213;
  --warning-soft: #2a230f;
  --unread-bg: #0d0d0d;
  --read-bg: #000000;
  --row-active: #1a2643;
  --row-checked: #141d33;
  --shadow: 0 1px 2px rgb(0 0 0 / 60%), 0 4px 16px rgb(0 0 0 / 60%);
  --shadow-lg: 0 8px 32px rgb(0 0 0 / 80%);
  color-scheme: dark;
}

/* Accent colors. data-scheme (set by the app) says whether the page is dark right now. */

:root[data-accent="violet"] {
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #f1eafe;
  --accent-text: #ffffff;
  --row-active: #ebe1fd;
  --row-checked: #f5f0fe;
}

:root[data-accent="green"] {
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-soft: #e5f6eb;
  --accent-text: #ffffff;
  --row-active: #d8f1e1;
  --row-checked: #eef9f2;
}

:root[data-accent="teal"] {
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #e0f4f2;
  --accent-text: #ffffff;
  --row-active: #d2eeea;
  --row-checked: #ebf8f6;
}

:root[data-accent="orange"] {
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: #fdede3;
  --accent-text: #ffffff;
  --row-active: #fce2d2;
  --row-checked: #fef4ed;
}

:root[data-accent="rose"] {
  --accent: #e11d48;
  --accent-hover: #be123c;
  --accent-soft: #fde7ec;
  --accent-text: #ffffff;
  --row-active: #fbd9e1;
  --row-checked: #fef1f4;
}

:root[data-accent="graphite"] {
  --accent: #475569;
  --accent-hover: #334155;
  --accent-soft: #eceff3;
  --accent-text: #ffffff;
  --row-active: #e1e6ed;
  --row-checked: #f1f4f7;
}

:root[data-accent="violet"][data-scheme="dark"] {
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --accent-soft: #2a2045;
  --accent-text: #110a24;
  --row-active: #33275a;
  --row-checked: #2a2148;
}

:root[data-accent="green"][data-scheme="dark"] {
  --accent: #4ade80;
  --accent-hover: #86efac;
  --accent-soft: #16321f;
  --accent-text: #05140a;
  --row-active: #1c3d29;
  --row-checked: #173222;
}

:root[data-accent="teal"][data-scheme="dark"] {
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #123532;
  --accent-text: #041412;
  --row-active: #17403c;
  --row-checked: #133430;
}

:root[data-accent="orange"][data-scheme="dark"] {
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-soft: #3d2416;
  --accent-text: #1a0c03;
  --row-active: #4a2c1a;
  --row-checked: #3a2416;
}

:root[data-accent="rose"][data-scheme="dark"] {
  --accent: #fb7185;
  --accent-hover: #fda4af;
  --accent-soft: #3f1a24;
  --accent-text: #1a0509;
  --row-active: #4c2030;
  --row-checked: #3c1a25;
}

:root[data-accent="graphite"][data-scheme="dark"] {
  --accent: #94a3b8;
  --accent-hover: #cbd5e1;
  --accent-soft: #262d38;
  --accent-text: #0b0f15;
  --row-active: #2e3644;
  --row-checked: #262d39;
}

.accent-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0;
}

.accent-swatch {
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
}

.accent-swatch.active {
  box-shadow: 0 0 0 2px var(--text);
}

.accent-swatch.accent-blue {
  background: #2563eb;
}

.accent-swatch.accent-violet {
  background: #7c3aed;
}

.accent-swatch.accent-green {
  background: #16a34a;
}

.accent-swatch.accent-teal {
  background: #0d9488;
}

.accent-swatch.accent-orange {
  background: #ea580c;
}

.accent-swatch.accent-rose {
  background: #e11d48;
}

.accent-swatch.accent-graphite {
  background: #475569;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px / 1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
}

kbd {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
}

.icon {
  flex-shrink: 0;
}

.muted {
  color: var(--text-3);
}

.small {
  font-size: 12px;
}

.spacer {
  flex: 1;
}

/* Controls ------------------------------------------------------------------------------- */

button,
.button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--surface-2);
  text-decoration: none;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.primary:hover {
  background: var(--accent-hover);
}

button.ghost,
.button.ghost {
  background: transparent;
  border-color: transparent;
}

button.ghost:hover,
.button.ghost:hover {
  background: var(--surface-2);
}

button.small,
.button.small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 13px;
}

button.wide {
  width: 100%;
}

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

button.link {
  border: 0;
  background: none;
  padding: 0 4px;
  min-height: 0;
  color: var(--accent);
  font-weight: 500;
}

button.link:hover {
  text-decoration: underline;
  background: none;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
}

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

.icon-button.active {
  color: var(--flag);
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  min-height: 36px;
  width: 100%;
}

textarea {
  resize: vertical;
}

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

input[role="switch"] {
  appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}

input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
  transition: transform 0.15s;
}

input[role="switch"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

input[role="switch"]:checked::after {
  transform: translateX(16px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.field-label {
  font-weight: 600;
  font-size: 13px;
}

.hint {
  display: block;
  color: var(--text-3);
  font-size: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.toggle-label {
  display: block;
  font-weight: 500;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  cursor: pointer;
}

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

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

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 40px auto;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.boot {
  display: grid;
  place-items: center;
  height: 100%;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--text-3);
}

.empty h3 {
  color: var(--text-2);
  font-size: 16px;
}

.empty p {
  margin: 0;
  max-width: 340px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  user-select: none;
}

.avatar.small {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.avatar.tiny {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 7px;
  height: 18px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--chip);
  background: color-mix(in srgb, var(--chip) 14%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}

.label-chip button {
  border: 0;
  background: none;
  min-height: 0;
  padding: 0 0 0 2px;
  color: inherit;
}

/* Auth --------------------------------------------------------------------------------- */

.auth-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top, var(--accent-soft), var(--bg) 60%);
}

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

.auth-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  margin-bottom: 20px;
}

.auth-card .brand h1 {
  color: var(--text);
  font-size: 22px;
}

/* Shell -------------------------------------------------------------------------------- */

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bg);
  flex-shrink: 0;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(var(--sidebar-w) - 24px);
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
}

.topbar .brand span {
  color: var(--text);
}

.topbar .brand:hover {
  text-decoration: none;
}

.menu-button {
  display: none;
}

.search {
  flex: 1;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 14px;
  height: 42px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-3);
}

.search:focus-within {
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.search > input {
  border: 0;
  background: transparent;
  padding: 0;
  min-height: 0;
  height: 100%;
  outline: none;
}

.search > input:focus-visible {
  outline: none;
}

.search.inline {
  height: 36px;
  max-width: 320px;
}

.avatar-button {
  border: 0;
  padding: 0;
  min-height: 0;
  background: none;
  border-radius: 50%;
}

.avatar-button:hover {
  background: none;
}

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

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  margin: 0 12px 12px 0;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Sidebar ------------------------------------------------------------------------------ */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 4px 8px 16px;
  display: flex;
  flex-direction: column;
}

.compose-button {
  align-self: flex-start;
  height: 52px;
  padding: 0 22px 0 18px;
  margin: 4px 0 14px 4px;
  border-radius: 16px;
  border: 0;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  gap: 12px;
  box-shadow: var(--shadow);
}

.compose-button:hover {
  background: var(--accent-soft);
  box-shadow: var(--shadow-lg);
}

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

.nav-item {
  display: flex;
  align-items: center;
  border-radius: 0 999px 999px 0;
  margin-right: 4px;
  position: relative;
}

.nav-item a {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 34px;
  padding-right: 12px;
  color: var(--text-2);
  min-width: 0;
}

.nav-item a:hover {
  text-decoration: none;
}

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

.nav-item.active {
  background: var(--accent-soft);
}

.nav-item.active a {
  color: var(--accent);
  font-weight: 600;
}

.nav-item.drop {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
}

.nav-item a.unread {
  font-weight: 700;
  color: var(--text);
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  font-size: 12px;
  font-weight: 600;
}

.nav-more {
  width: 26px;
  height: 26px;
  opacity: 0;
}

.nav-item:hover .nav-more,
.nav-more:focus-visible {
  opacity: 1;
}

.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 4px 2px 6px;
}

.nav-toggle {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
  font-weight: 600;
  color: var(--text-2);
  gap: 4px;
}

.nav-toggle:hover {
  background: none;
  color: var(--text);
}

.nav-empty {
  margin: 4px 0 4px 36px;
  color: var(--text-3);
  font-size: 12px;
}

.nav-footer {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
}

.nav-footer a {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 34px;
  padding: 0 12px;
  color: var(--text-2);
  border-radius: 0 999px 999px 0;
}

.nav-footer a:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.nav-scrim {
  display: none;
}

/* Menus, modals, toasts ------------------------------------------------------------------ */

.menu-anchor {
  position: relative;
  display: inline-flex;
}

.menu {
  position: absolute;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 220px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
}

.menu.left {
  left: 0;
}

.menu.right {
  right: 0;
}

.menu button {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0 14px;
  min-height: 34px;
  gap: 10px;
  color: var(--text);
}

.menu button:hover {
  background: var(--surface-2);
}

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

.menu hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.menu-heading {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-spacer {
  width: 16px;
}

.menu-check {
  margin-left: auto;
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgb(10 14 20 / 45%);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.modal.wide {
  max-width: 760px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 6px 20px;
}

.modal-header h2 {
  font-size: 17px;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

.toasts {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 480px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--radius-sm);
  background: #222834;
  color: #f1f3f7;
  box-shadow: var(--shadow-lg);
}

.toast.error {
  background: #8f1d1d;
}

.toast span {
  flex: 1;
}

.toast .link {
  color: #9dbbff;
}

.toast .icon-button {
  color: #c3c9d4;
  width: 28px;
  height: 28px;
}

.toast .icon-button:hover {
  background: rgb(255 255 255 / 12%);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 8px 48px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
  color: var(--text-2);
  font-size: 13px;
}

.banner.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.spam-banner {
  flex-direction: column;
  align-items: stretch;
}

.spam-banner-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.spam-reasons {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
}

.spam-reasons li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.spam-reasons .points {
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.spam-reasons .points.bad {
  color: var(--danger);
}

.spam-reasons .points.good {
  color: var(--accent);
}

/* Mail page ----------------------------------------------------------------------------- */

.mail-page {
  flex: 1;
  display: flex;
  min-width: 0;
}

.mail-page.pane-bottom {
  flex-direction: column;
}

.list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 42%;
  max-width: 560px;
  border-right: 1px solid var(--border);
}

.pane-bottom .list-pane {
  width: auto;
  max-width: none;
  height: 45%;
  border-right: 0;
  border-bottom: 1px solid var(--border);
}

.pane-off .list-pane {
  width: 100%;
  max-width: none;
  border-right: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.select-all {
  margin-right: 8px;
}

.toolbar-title {
  margin-left: 8px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.toolbar-count {
  color: var(--text-3);
  font-size: 12px;
}

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

.message-row {
  display: flex;
  gap: 12px;
  padding: 10px 14px 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--read-bg);
  cursor: pointer;
  position: relative;
}

.message-row.unread {
  background: var(--unread-bg);
}

.message-row.unread::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.message-row:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.message-row.checked {
  background: var(--row-checked);
}

.message-row.active {
  background: var(--row-active);
}

.message-row.focused {
  box-shadow: inset 2px 0 0 var(--text-3);
}

.message-row.compact {
  padding-top: 6px;
  padding-bottom: 6px;
}

.row-lead {
  position: relative;
  width: 36px;
  display: grid;
  place-items: center;
  align-self: flex-start;
  flex-shrink: 0;
}

.compact .row-lead {
  width: 20px;
  align-self: center;
}

.row-lead .avatar {
  grid-area: 1 / 1;
}

.row-check {
  grid-area: 1 / 1;
  opacity: 0;
}

.compact .row-check,
.message-row:hover .row-check,
.message-row.checked .row-check,
.row-check:focus-visible {
  opacity: 1;
}

.message-row:hover .avatar,
.message-row.checked .avatar {
  opacity: 0;
}

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

.row-top,
.row-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.row-from {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.unread .row-from,
.unread .row-subject {
  color: var(--text);
  font-weight: 700;
}

.thread-count {
  margin-left: 6px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 400;
}

.draft-tag {
  color: var(--danger);
  margin-right: 6px;
  font-weight: 600;
}

.row-icons {
  display: inline-flex;
  gap: 4px;
  color: var(--text-3);
}

.row-date {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.unread .row-date {
  color: var(--accent);
  font-weight: 600;
}

.scheduled {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent);
}

.row-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}

.row-snippet {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
}

.row-snippet::before {
  content: "– ";
}

.flag {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
  color: var(--text-3);
  opacity: 0;
  margin-left: auto;
}

.flag:hover {
  background: none;
  color: var(--flag);
}

.message-row:hover .flag,
.flag.on,
.flag:focus-visible {
  opacity: 1;
}

.flag.on {
  color: var(--flag);
}

.flag.on svg {
  fill: var(--flag);
}

.load-more {
  display: block;
  margin: 16px auto;
}

/* Reader ------------------------------------------------------------------------------- */

.reader-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.empty-reader {
  justify-content: center;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-right .back-button {
  display: none;
}

.reader-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 40px;
}

.thread-header {
  margin: 0 0 16px 48px;
}

.thread-header h1 {
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.thread-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.message-card {
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.message-card.collapsed {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  cursor: pointer;
  min-width: 0;
}

.message-card.collapsed strong {
  white-space: nowrap;
}

.message-card.collapsed .snippet {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-card.collapsed .date {
  white-space: nowrap;
  font-size: 12px;
}

.message-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.message-head .avatar {
  cursor: pointer;
}

.message-meta {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.message-details {
  margin: 8px 0 0 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}

.message-frame {
  display: block;
  width: calc(100% - 48px);
  margin: 12px 0 0 48px;
  border: 0;
  background: #fff;
  border-radius: var(--radius-sm);
}

.message-frame.themed {
  background: transparent;
}

.attachments {
  margin: 16px 0 0 48px;
}

.attachments-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 8px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 0;
}

.attachment-thumb {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  flex-shrink: 0;
}

.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb.file span {
  font-size: 10px;
  font-weight: 700;
  color: var(--danger);
}

.attachment-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0 48px;
}

.reply-bar button {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}

.address-line span + span {
  margin-left: 2px;
}

/* Composer ----------------------------------------------------------------------------- */

.composer-dock {
  position: fixed;
  right: 16px;
  bottom: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.composer {
  pointer-events: auto;
  width: 560px;
  height: min(620px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.composer.minimized {
  width: 280px;
  height: auto;
}

.composer.maximized {
  position: fixed;
  inset: 5vh 10vw;
  width: auto;
  height: auto;
  border-radius: 12px;
  z-index: 90;
}

.composer.dragging {
  outline: 2px dashed var(--accent);
}

.composer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 14px;
  background: var(--surface-2);
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  flex-shrink: 0;
}

.composer-title {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-status {
  font-size: 12px;
  color: var(--text-3);
}

.composer-head-actions {
  display: flex;
}

.composer-head-actions .icon-button {
  width: 28px;
  height: 28px;
}

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

.composer-fields {
  padding: 0 14px;
  flex-shrink: 0;
}

.from-field,
.recipient-field,
.subject-input {
  border-bottom: 1px solid var(--border);
}

.from-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.from-field select {
  border: 0;
  padding: 0;
  min-height: 0;
  background: transparent;
}

.recipient-label {
  color: var(--text-3);
  width: 36px;
  flex-shrink: 0;
}

.recipient-row {
  display: flex;
  align-items: flex-start;
}

.recipient-row .recipient-field {
  flex: 1;
}

.cc-toggles {
  display: flex;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid var(--border);
}

.recipient-field {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  min-height: 40px;
  cursor: text;
}

.recipient-field .recipient-label {
  line-height: 30px;
}

.chips {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.chips input {
  flex: 1;
  min-width: 120px;
  border: 0;
  padding: 0;
  min-height: 30px;
  background: transparent;
  outline: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 4px 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
}

.chip button {
  border: 0;
  background: none;
  min-height: 0;
  padding: 0 6px;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 44px;
  right: 0;
  z-index: 70;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px 0;
}

.suggestions button {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  border-radius: 0;
  background: none;
  gap: 10px;
  padding: 0 12px;
  min-height: 38px;
}

.suggestions button.active,
.suggestions button:hover {
  background: var(--surface-2);
}

.subject-input {
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0;
  min-height: 40px;
  background: transparent;
}

.subject-input:focus-visible {
  outline: none;
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}

.editor-toolbar .icon-button {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

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

.color-swatch {
  font-weight: 700;
  text-decoration: underline 3px var(--danger);
}

.size-swatch {
  font-weight: 600;
  font-size: 13px;
}

.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  outline: none;
  min-height: 120px;
  overflow-wrap: anywhere;
}

.settings-page .editor-body {
  border: 1px solid var(--border-strong);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  min-height: 160px;
}

.settings-page .editor-toolbar {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.editor-body blockquote,
.cm-forward {
  margin: 0 0 0 4px;
  padding-left: 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-2);
}

.cm-quote-intro {
  color: var(--text-3);
  margin-bottom: 4px;
}

.editor-body img {
  max-width: 100%;
}

.plain-editor {
  flex: 1;
  border: 0;
  border-radius: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  resize: none;
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 0;
  max-height: 96px;
  overflow-y: auto;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 3px 4px 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}

.attachment-pill button {
  border: 0;
  min-height: 0;
  padding: 0 6px;
  background: none;
  font-size: 16px;
  color: var(--text-3);
}

.size-meter {
  margin: 6px 14px 0;
  font-size: 12px;
  color: var(--text-3);
}

.size-meter.over {
  color: var(--danger);
  font-weight: 600;
}

.uploading {
  margin: 6px 14px 0;
}

.composer-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  flex-shrink: 0;
}

.send-group {
  display: inline-flex;
}

.send-group > button {
  border-radius: 999px 0 0 999px;
  padding: 0 20px;
}

.send-group .menu-anchor > .send-more {
  border-radius: 0 999px 999px 0;
  padding: 0 10px;
  border-left: 1px solid rgb(255 255 255 / 30%);
}

.composer .menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.drop-hint {
  position: absolute;
  inset: 40px 0 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  pointer-events: none;
}

/* Settings, contacts, admin ------------------------------------------------------------ */

.settings-page {
  flex: 1;
  display: flex;
  min-width: 0;
}

.settings-tabs {
  width: 230px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-tabs h2 {
  font-size: 18px;
  margin: 0 10px 12px;
}

.settings-tabs a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
}

.settings-tabs a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.settings-tabs a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 48px;
  min-width: 0;
}

.settings-section {
  max-width: 760px;
}

.settings-section h3 {
  font-size: 16px;
  margin: 26px 0 12px;
}

.settings-section h3:first-child,
.section-head h3 {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.settings-section select {
  max-width: 340px;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form .field {
  flex: 1;
  min-width: 200px;
}

.inline-form > button {
  margin-bottom: 14px;
}

.stack-form {
  max-width: 400px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-row:last-child {
  border-bottom: 0;
}

.card-row.disabled {
  opacity: 0.6;
}

.card-row.tall {
  align-items: flex-start;
}

.card-row .grow {
  flex: 1;
  min-width: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.rotate-up svg {
  transform: rotate(90deg);
}

.address-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.address-chips .chip {
  padding-left: 10px;
}

.filter-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}

.filter-block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 10px;
}

.filter-block-head select {
  width: auto;
}

.filter-line {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.filter-line select {
  width: auto;
}

.filter-line input {
  flex: 1;
  min-width: 140px;
}

.filter-line input.short {
  flex: 0 1 140px;
}

.totp-setup .secret {
  display: inline-block;
  padding: 10px 14px;
  margin: 4px 0 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 16px;
  letter-spacing: 1px;
  word-break: break-all;
}

.shortcuts td {
  padding: 6px 16px 6px 0;
}

.contacts-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.page-head h2 {
  font-size: 18px;
  margin-right: 12px;
}

.contact-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  align-content: start;
}

.contact-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}

.contact-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}

.contact-card .row-actions {
  flex-direction: column;
  align-items: flex-end;
}

.fav {
  color: var(--flag);
  fill: var(--flag);
  margin-left: 4px;
}

/* Responsive --------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .list-pane {
    width: 46%;
  }
}

@media (max-width: 860px) {
  :root {
    --sidebar-w: 280px;
  }

  .menu-button {
    display: inline-flex;
  }

  .topbar {
    gap: 6px;
    padding: 0 8px;
  }

  .topbar .brand {
    width: auto;
  }

  .topbar .brand span,
  .hide-mobile {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.2s;
    padding-top: 12px;
  }

  .sidebar.open {
    transform: none;
  }

  .nav-scrim.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 79;
    background: rgb(0 0 0 / 35%);
  }

  .nav-more {
    opacity: 1;
  }

  .content {
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  /* One pane at a time: the list, or the open conversation. */
  .mail-page .list-pane {
    width: 100%;
    max-width: none;
    border-right: 0;
    height: auto;
    flex: 1;
  }

  .mail-page.has-open .list-pane,
  .mail-page:not(.has-open) .reader-pane {
    display: none;
  }

  .pane-right .back-button {
    display: inline-flex;
  }

  .reader-scroll {
    padding: 14px 16px 32px;
  }

  .thread-header,
  .banner,
  .tracker-note,
  .attachments,
  .reply-bar,
  .message-details {
    margin-left: 0;
  }

  .message-frame {
    width: 100%;
    margin-left: 0;
  }

  .row-snippet {
    display: none;
  }

  .row-bottom {
    flex-wrap: nowrap;
  }

  .composer-dock {
    right: 0;
    left: 0;
  }

  .composer,
  .composer.maximized {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .composer.minimized {
    inset: auto 0 0 auto;
    width: 220px;
    height: auto;
  }

  .composer-head {
    border-radius: 0;
  }

  .settings-page {
    flex-direction: column;
  }

  .settings-tabs {
    width: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px;
  }

  .settings-tabs h2 {
    display: none;
  }

  .settings-tabs a {
    white-space: nowrap;
  }

  .settings-body {
    padding: 16px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .card-row {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .toasts {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}

@media print {
  .topbar,
  .sidebar,
  .list-pane,
  .reader-toolbar,
  .reply-bar,
  .composer-dock,
  .toasts {
    display: none;
  }
}

/* API settings ----------------------------------------------------------------------------- */

.scope-chips .chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.scope-chips .chip {
  font-family: var(--mono);
  font-size: 12px;
  height: 24px;
}

.scope-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 0;
  padding: 0;
  margin: 0 0 14px;
}

.scope-list legend {
  font-weight: 600;
  margin-bottom: 8px;
}

.scope-list .checkbox {
  align-items: flex-start;
}

.scope-list .checkbox input {
  margin-top: 3px;
}

.event-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 22px;
}

.secret-box {
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-soft);
}

.secret-box p {
  margin: 0 0 8px;
}

.secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.secret-row code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 13px;
  user-select: all;
}

.code-block {
  margin: 0 0 16px;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.settings-section h4 {
  margin: 18px 0 8px;
  font-size: 14px;
}

.endpoint-group {
  margin-top: 8px;
}

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

.endpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  min-width: 0;
}

.endpoint:last-child {
  border-bottom: 0;
}

.endpoint .grow {
  flex: 1;
  min-width: 0;
  color: var(--text-2);
}

.endpoint code {
  font-family: var(--mono);
}

.break {
  overflow-wrap: anywhere;
}

.method {
  flex-shrink: 0;
  width: 56px;
  text-align: center;
  padding: 2px 0;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

.method.post {
  background: #e3f6e8;
  color: #15803d;
}

.method.patch,
.method.put {
  background: var(--warning-soft);
  color: #d97706;
}

.method.delete {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 720px) {
  .endpoint {
    flex-wrap: wrap;
  }

  .endpoint .grow {
    flex-basis: 100%;
  }
}

.settings-section + .settings-section {
  margin-top: 36px;
}

.inline-form.wrap .field {
  flex-basis: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

/* Calendar invitations ------------------------------------------------------------------ */

.invite-card {
  display: flex;
  gap: 14px;
  margin: 8px 0 12px 48px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.invite-card.cancelled .invite-title strong {
  text-decoration: line-through;
  color: var(--text-2);
}

.invite-date {
  flex: none;
  width: 52px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent);
}

.invite-month {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.invite-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.invite-body {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.invite-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.invite-flag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
}

.invite-flag.muted {
  background: var(--surface-3);
  color: var(--text-2);
}

.invite-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.invite-guests {
  list-style: none;
  margin: 2px 0;
  padding: 0 0 0 20px;
  display: grid;
  gap: 2px;
}

.invite-guests .partstat {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--text-3);
}

.invite-guests .partstat.accepted {
  background: #16a34a;
}

.invite-guests .partstat.tentative {
  background: var(--flag);
}

.invite-guests .partstat.declined {
  background: var(--danger);
}

.invite-note {
  margin-top: 6px;
  width: 100%;
  resize: vertical;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 700px) {
  .invite-card {
    margin-left: 0;
  }
}

/* Shared mailboxes */
.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 7px;
  height: 18px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}

.thread-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-2);
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  max-width: 560px;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.member-row select,
.member-list .add-member {
  width: auto;
}

.member-list .add-member {
  align-self: flex-start;
  margin-top: 4px;
}

/* Mail import */
.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.field-row > .field {
  flex: 1 1 200px;
  min-width: 0;
}

.import-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 640px;
}

.import-form > button {
  align-self: flex-start;
  margin-top: 4px;
}

.import-folders {
  max-width: 640px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px 12px;
}

.import-folder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.import-target {
  min-width: 120px;
}

.import-folders .row-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.progress {
  height: 6px;
  margin: 8px 0 4px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  max-width: 480px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress > span.indeterminate {
  animation: progress-slide 1.4s ease-in-out infinite;
}

@keyframes progress-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.upload-progress {
  max-width: 480px;
}

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

/* OpenPGP */
.fingerprint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin: 4px 0 2px;
  overflow-wrap: anywhere;
}

textarea.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

fieldset.plain {
  border: 0;
  padding: 0;
  margin: 0 0 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.pgp-banner {
  align-items: flex-start;
}

.pgp-banner.encrypted {
  background: var(--accent-soft);
}

.pgp-good {
  color: #15803d;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pgp-warn {
  color: #d97706;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pgp-bad {
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pgp-missing {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 6px 14px 10px;
  font-size: 12px;
  color: #d97706;
}

/* Masked addresses ----------------------------------------------------------------------- */

.masked-address {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  min-width: 0;
}

.masked-address code,
.masked-created code {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.masked-search {
  width: 100%;
  margin-bottom: 12px;
}

.masked-created {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.masked-bar {
  flex-wrap: nowrap;
  background: var(--surface-2);
}

.masked-bar > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.masked-bar > button {
  flex-shrink: 0;
}

.masked-bar code {
  font-size: 12px;
}

.tracker-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 4px 48px;
  color: var(--text-3);
  font-size: 12px;
}

/* Calendar and contacts sync ------------------------------------------------------------- */

.sync-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  align-items: center;
  margin: 12px 0 0;
}

.sync-facts dt {
  font-weight: 600;
  font-size: 13px;
}

.sync-facts dd {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.row-form .field {
  flex: 1 1 220px;
  margin-bottom: 0;
}

/* Admin dashboard */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0 20px;
}

.stat-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}

.chart {
  margin: 8px 0 20px;
}

.chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-axis {
  stroke: var(--border-strong);
}

.chart-hit {
  fill: transparent;
}

.chart-hit:hover {
  fill: var(--surface-2);
}

.chart-label {
  fill: var(--text-3);
  font-size: 10px;
  text-anchor: middle;
}

.chart-received {
  fill: var(--accent);
  background: var(--accent);
}

.chart-sent {
  fill: #10b981;
  background: #10b981;
}

.chart-spam {
  fill: var(--flag);
  background: var(--flag);
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
}

.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: -1px;
}

.quota-bar {
  height: 4px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.quota-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.data-table th,
.data-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tr.clickable {
  cursor: pointer;
}

.data-table tr.clickable:hover {
  background: var(--surface-2);
}

.data-table.compact {
  margin-top: 8px;
  border: 1px solid var(--border);
}

.data-table .badge {
  margin-left: 0;
}

.data-table .nowrap {
  white-space: nowrap;
}

.data-table .mono {
  font-family: var(--mono);
  font-size: 12px;
}

.badge.status-sent {
  background: #dcfce7;
  color: #15803d;
}

.badge.status-failed,
.badge.status-bounced {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.status-delayed {
  background: var(--warning-soft);
  color: #d97706;
}

.dmarc-detail {
  padding: 4px 0;
}

.load-more {
  display: block;
  margin: 12px auto 0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.status-sent {
    background: #12341f;
    color: #4ade80;
  }

  :root:not([data-theme="light"]) .badge.status-delayed {
    color: #fbbf24;
  }
}

:root[data-theme="dark"] .badge.status-sent {
  background: #12341f;
  color: #4ade80;
}

:root[data-theme="dark"] .badge.status-delayed {
  color: #fbbf24;
}

.section-head .toggle-row {
  border: 0;
  padding: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-3);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.auth-card button.wide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.passkey-list {
  margin-bottom: 12px;
}

/* Advanced search */
.search {
  position: relative;
}

.advanced-search {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  cursor: default;
}

.adv-field {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.adv-field > span {
  color: var(--text-2);
}

.advanced-search .adv-field input,
.advanced-search .adv-field select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.adv-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.adv-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.adv-toggles .toggle-row {
  border: 0;
  padding: 4px 0;
  gap: 10px;
}

.adv-preview {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.adv-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .advanced-search {
    position: fixed;
    top: 60px;
    left: 8px;
    right: 8px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  .adv-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Command palette */
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: rgb(16 24 40 / 35%);
}

.palette {
  width: min(620px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}

.palette-input input {
  flex: 1;
  height: 52px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

.palette-list {
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}

.palette-item.active {
  background: var(--accent-soft);
}

.palette-item .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-hint {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  max-width: 35%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-group {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.palette-empty {
  padding: 10px;
}

.choice-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 14px;
}

/* VirusTotal results on attachments. */
.scan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-3);
  text-decoration: none;
  white-space: nowrap;
}

.scan-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 8px;
}

button.link.scan-now {
  padding: 0;
  font-size: 12px;
  margin-top: 2px;
}

a.scan-badge:hover {
  text-decoration: underline;
}

.scan-badge.ok {
  color: #16a34a;
}

.scan-badge.warn {
  color: #d97706;
}

.scan-badge.danger {
  color: var(--danger);
  font-weight: 600;
}

.attachment.dangerous {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.attachment.dangerous .attachment-thumb.file {
  color: var(--danger);
}

/* Right-click menu */
.context-menu {
  position: fixed;
  z-index: 200;
  width: max-content;
  max-width: min(290px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  outline: none;
}

.context-menu button > span:not(.dot):not(.menu-spacer) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-menu button.open {
  background: var(--surface-2);
}

.context-menu .menu-arrow {
  margin-left: auto;
  color: var(--text-3);
}

.context-menu button:focus-visible {
  outline: none;
  background: var(--surface-2);
}

.scan-warning {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.scan-warning > svg {
  flex: none;
  margin-top: 2px;
  color: var(--flag);
}

.scan-warning p {
  margin: 0 0 10px;
}

.scan-warning p:last-child {
  margin-bottom: 0;
}
