/* Cipher design system, part 1: tokens, base and the generic components (buttons, forms, dialogs, menus, tabs, toasts...).
   Part 2 (mail.css) holds the mail-specific components and the three layouts. Same family look as Quill, Stash, ClosedDoor and SkyNet:
   deep navy, the logo's electric blue and gold. No external fonts or images: these two files are the whole look.
   Themes: light is the default; dark follows prefers-color-scheme; <html data-theme="light|dark"> (set by js/theme-init.js from the
   Light / Dark / System control) overrides the OS. The two dark blocks below MUST stay identical: tests/contrast.py fails on drift. */

/* ---------- Tokens: light ---------- */
:root {
  color-scheme: light;

  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --surface-3: #eaeff7;
  --line: #e1e7f0;
  --line-strong: #c9d3e2;
  --input-line: #75839a;
  --text: #0c1424;
  --muted: #47546a;
  --accent: #1560d4;
  --accent-hover: #0f4fb3;
  --on-accent: #ffffff;
  --accent-soft: #e6f0ff;
  --ring: #1560d4;
  --gold: #f0a30a;
  --gold-light: #ffcb52;
  --gold-text: #8a5800;
  --navy: #0a1630;
  --silver: #a9b4c6;

  --danger: #b42318;   --danger-bg: #fef3f2;  --danger-line: #fecdca;
  --success: #067647;  --success-bg: #ecfdf3; --success-line: #abefc6;
  --warn: #93370d;     --warn-bg: #fffaeb;    --warn-line: #fedf89;
  --info: #175cd3;     --info-bg: #eff8ff;    --info-line: #b2ddff;

  /* message rows */
  --row-read-bg: #f4f7fc;
  --row-hover-bg: #eaf0fa;
  --row-sel-bg: #e6f0ff;
  --star: #b87500;

  /* inverse surfaces: toast, compose header, tooltips */
  --inv-bg: #0a1630;
  --inv-fg: #eef3ff;
  --inv-accent: #ffcb52;
  --thumb: #ffffff;

  /* mailbox colours (dots, stripes) and label chips; 3:1 against the surfaces, chips 4.5:1 text on tint */
  --acct-0: #1560d4; --acct-1: #0b7a6b; --acct-2: #7c3aed; --acct-3: #c2410c; --acct-4: #be185d; --acct-5: #15803d; --acct-6: #a16207; --acct-7: #475569;
  --lc-0-bg: #dfe8ff; --lc-0-fg: #1e3a8a;
  --lc-1-bg: #fce7f3; --lc-1-fg: #9d174d;
  --lc-2-bg: #dcfce7; --lc-2-fg: #166534;
  --lc-3-bg: #fef3c7; --lc-3-fg: #92400e;
  --lc-4-bg: #e0f2fe; --lc-4-fg: #075985;
  --lc-5-bg: #f3e8ff; --lc-5-fg: #6b21a8;
  --lc-6-bg: #ffedd5; --lc-6-fg: #9a3412;
  --lc-7-bg: #e2e8f0; --lc-7-fg: #334155;

  --av-0-bg: #dfe8ff; --av-0-fg: #1e3a8a;
  --av-1-bg: #fce7f3; --av-1-fg: #9d174d;
  --av-2-bg: #dcfce7; --av-2-fg: #166534;
  --av-3-bg: #fef3c7; --av-3-fg: #92400e;
  --av-4-bg: #e0f2fe; --av-4-fg: #075985;
  --av-5-bg: #f3e8ff; --av-5-fg: #6b21a8;
  --av-6-bg: #ffedd5; --av-6-fg: #9a3412;
  --av-7-bg: #e2e8f0; --av-7-fg: #334155;

  --shadow-sm: 0 1px 2px rgba(12, 20, 36, .06);
  --shadow-md: 0 1px 3px rgba(12, 20, 36, .08), 0 8px 24px rgba(12, 20, 36, .07);
  --shadow-lg: 0 2px 6px rgba(12, 20, 36, .08), 0 22px 54px rgba(12, 20, 36, .16);
  --scrim: rgba(10, 22, 48, .55);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-w: 16rem;
  --rail-w: 4.5rem;
  --topbar-h: 3.5rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- Tokens: dark (OS preference, unless the person chose light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #070b14;
    --surface: #0f1626;
    --surface-2: #131c2f;
    --surface-3: #1a2540;
    --line: #1f2b45;
    --line-strong: #2f3e5e;
    --input-line: #6a7b9a;
    --text: #e8eefa;
    --muted: #a3b0c8;
    --accent: #5aa3ff;
    --accent-hover: #86bcff;
    --on-accent: #04101f;
    --accent-soft: #112442;
    --ring: #86bcff;
    --gold-text: #f7c85a;
    --silver: #7d8aa3;

    --danger: #ff9a92;   --danger-bg: #2a1517;  --danger-line: #5c2a2e;
    --success: #5ddc9a;  --success-bg: #0f2a1c; --success-line: #1f5a3a;
    --warn: #f5b04a;     --warn-bg: #2b2010;    --warn-line: #5c4416;
    --info: #7db4ff;     --info-bg: #0f2036;    --info-line: #1f4676;

    --row-read-bg: #0b1220;
    --row-hover-bg: #18233b;
    --row-sel-bg: #112442;
    --star: #f5b942;

    --inv-bg: #22304f;
    --inv-fg: #eef3ff;
    --inv-accent: #ffcb52;
    --thumb: #0f1626;

    --acct-0: #5aa3ff; --acct-1: #2dd4bf; --acct-2: #a78bfa; --acct-3: #fb923c; --acct-4: #f472b6; --acct-5: #4ade80; --acct-6: #facc15; --acct-7: #94a3b8;
    --lc-0-bg: #1b2a5e; --lc-0-fg: #c7d6ff;
    --lc-1-bg: #4a1530; --lc-1-fg: #fbcfe8;
    --lc-2-bg: #123524; --lc-2-fg: #bbf7d0;
    --lc-3-bg: #3d2a0a; --lc-3-fg: #fde68a;
    --lc-4-bg: #0c2a40; --lc-4-fg: #bae6fd;
    --lc-5-bg: #34154d; --lc-5-fg: #e9d5ff;
    --lc-6-bg: #3f1d0b; --lc-6-fg: #fed7aa;
    --lc-7-bg: #252b38; --lc-7-fg: #cbd5e1;

    --av-0-bg: #1b2a5e; --av-0-fg: #c7d6ff;
    --av-1-bg: #4a1530; --av-1-fg: #fbcfe8;
    --av-2-bg: #123524; --av-2-fg: #bbf7d0;
    --av-3-bg: #3d2a0a; --av-3-fg: #fde68a;
    --av-4-bg: #0c2a40; --av-4-fg: #bae6fd;
    --av-5-bg: #34154d; --av-5-fg: #e9d5ff;
    --av-6-bg: #3f1d0b; --av-6-fg: #fed7aa;
    --av-7-bg: #252b38; --av-7-fg: #cbd5e1;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
    --shadow-md: 0 1px 3px rgba(0, 0, 0, .55), 0 8px 24px rgba(0, 0, 0, .4);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .55), 0 22px 54px rgba(0, 0, 0, .55);
    --scrim: rgba(2, 6, 16, .7);
  }
}

/* ---------- Tokens: dark (chosen explicitly) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #070b14;
  --surface: #0f1626;
  --surface-2: #131c2f;
  --surface-3: #1a2540;
  --line: #1f2b45;
  --line-strong: #2f3e5e;
  --input-line: #6a7b9a;
  --text: #e8eefa;
  --muted: #a3b0c8;
  --accent: #5aa3ff;
  --accent-hover: #86bcff;
  --on-accent: #04101f;
  --accent-soft: #112442;
  --ring: #86bcff;
  --gold-text: #f7c85a;
  --silver: #7d8aa3;

  --danger: #ff9a92;   --danger-bg: #2a1517;  --danger-line: #5c2a2e;
  --success: #5ddc9a;  --success-bg: #0f2a1c; --success-line: #1f5a3a;
  --warn: #f5b04a;     --warn-bg: #2b2010;    --warn-line: #5c4416;
  --info: #7db4ff;     --info-bg: #0f2036;    --info-line: #1f4676;

  --row-read-bg: #0b1220;
  --row-hover-bg: #18233b;
  --row-sel-bg: #112442;
  --star: #f5b942;

  --inv-bg: #22304f;
  --inv-fg: #eef3ff;
  --inv-accent: #ffcb52;
  --thumb: #0f1626;

  --acct-0: #5aa3ff; --acct-1: #2dd4bf; --acct-2: #a78bfa; --acct-3: #fb923c; --acct-4: #f472b6; --acct-5: #4ade80; --acct-6: #facc15; --acct-7: #94a3b8;
  --lc-0-bg: #1b2a5e; --lc-0-fg: #c7d6ff;
  --lc-1-bg: #4a1530; --lc-1-fg: #fbcfe8;
  --lc-2-bg: #123524; --lc-2-fg: #bbf7d0;
  --lc-3-bg: #3d2a0a; --lc-3-fg: #fde68a;
  --lc-4-bg: #0c2a40; --lc-4-fg: #bae6fd;
  --lc-5-bg: #34154d; --lc-5-fg: #e9d5ff;
  --lc-6-bg: #3f1d0b; --lc-6-fg: #fed7aa;
  --lc-7-bg: #252b38; --lc-7-fg: #cbd5e1;

  --av-0-bg: #1b2a5e; --av-0-fg: #c7d6ff;
  --av-1-bg: #4a1530; --av-1-fg: #fbcfe8;
  --av-2-bg: #123524; --av-2-fg: #bbf7d0;
  --av-3-bg: #3d2a0a; --av-3-fg: #fde68a;
  --av-4-bg: #0c2a40; --av-4-fg: #bae6fd;
  --av-5-bg: #34154d; --av-5-fg: #e9d5ff;
  --av-6-bg: #3f1d0b; --av-6-fg: #fed7aa;
  --av-7-bg: #252b38; --av-7-fg: #cbd5e1;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, .55), 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .55), 0 22px 54px rgba(0, 0, 0, .55);
  --scrim: rgba(2, 6, 16, .7);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.012em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
h3 { font-size: .9375rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: .875em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .1em .4em; word-break: break-all; }
small { font-size: .8125rem; }
img, svg { max-width: 100%; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .75rem; top: -4rem; z-index: 200; background: var(--accent); color: var(--on-accent); padding: .6rem 1rem; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; }
.skip-link:focus { top: .75rem; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 1rem; height: 1rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-xl { width: 2rem; height: 2rem; }
.stack > * + * { margin-top: 1rem; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; }
form { margin: 0; }
noscript .empty { margin: 4rem auto; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); border-radius: 10px; }
.brand:hover { text-decoration: none; }
.logo-nav { display: block; height: 2.25rem; width: auto; filter: drop-shadow(0 1px 6px color-mix(in srgb, var(--accent) 35%, transparent)); }
.brand-text { font-weight: 800; letter-spacing: -.02em; font-size: 1.25rem; }
.brand:not(.no-logo) .brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.logo-hero { display: block; width: min(25rem, 100%); height: auto; margin: 0 auto; filter: drop-shadow(0 12px 38px color-mix(in srgb, var(--accent) 38%, transparent)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.375rem; padding: .4rem 1rem; font-weight: 600; font-size: .9rem; line-height: 1.2;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); border-color: var(--input-line); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; transform: none; }
.btn .icon { width: 1.125rem; height: 1.125rem; }
.btn-primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: #fff; background: #b42318; border-color: #b42318; }
.btn-danger:hover { background: #912018; border-color: #912018; }
:root[data-theme="dark"] .btn-danger { background: #f04438; border-color: #f04438; color: #1a0a09; }
:root[data-theme="dark"] .btn-danger:hover { background: #ff6a5e; border-color: #ff6a5e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-danger { background: #f04438; border-color: #f04438; color: #1a0a09; }
  :root:not([data-theme="light"]) .btn-danger:hover { background: #ff6a5e; border-color: #ff6a5e; }
}
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-gold { color: #2a1c00; background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: #c98600; }
.btn-gold:hover { filter: brightness(1.05); background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: #c98600; }
.btn-sm { min-height: 2rem; padding: .2rem .8rem; font-size: .8125rem; }
.btn-block { display: flex; width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn[aria-busy="true"] { position: relative; color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; inset: 0; margin: auto; width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin .8s linear infinite; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; padding: 0;
  color: var(--muted); background: transparent; border: 0; border-radius: 50%; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { background: var(--line); }
.icon-btn:disabled { opacity: .45; cursor: default; background: transparent; color: var(--muted); }
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn-sm { width: 1.875rem; height: 1.875rem; }
.icon-btn-sm .icon { width: 1.125rem; height: 1.125rem; }

/* toolbar button: compact, rounded square (formatting bar, bulk bar) */
.tbtn {
  display: inline-grid; grid-auto-flow: column; place-items: center; gap: .35rem; flex: none; min-width: 2rem; height: 2rem; padding: 0 .4rem;
  font-size: .8125rem; font-weight: 600; color: var(--text); background: none; border: 0; border-radius: 8px; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.tbtn .icon { width: 1.125rem; height: 1.125rem; }
.tbtn:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.tbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tbtn:disabled { opacity: .4; cursor: default; background: none; }
.tsep { width: 1px; height: 1.25rem; margin: 0 .3rem; background: var(--line-strong); flex: none; }

/* split button (Send | v) */
.split { display: inline-flex; }
.split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 1.1rem; }
.split-toggle { min-width: 2.25rem; padding: 0 .4rem; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-color: color-mix(in srgb, var(--on-accent) 35%, transparent); }
.btn-primary.split-toggle:hover { border-left-color: color-mix(in srgb, var(--on-accent) 35%, transparent); }

/* ---------- Forms ---------- */
.field { margin: 0 0 1rem; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: .8125rem; font-weight: 650; margin-bottom: .3rem; }
.hint { display: block; font-size: .8125rem; color: var(--muted); margin: 0 0 .4rem; font-weight: 400; }
.input {
  display: block; width: 100%; min-height: 2.5rem; padding: .5rem .75rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--input-line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .85; }
select.input { appearance: none; padding-right: 2.25rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23778' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 24%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled { opacity: .6; background: var(--surface-2); }
textarea.input { min-height: 6rem; resize: vertical; }
.field-error, .form-error { color: var(--danger); font-size: .8125rem; margin: .3rem 0 0; font-weight: 600; }
.check { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-size: .9rem; }
.check input, .msg-chk input, .acct-chk input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }

/* toggle switch: a real checkbox with role="switch" */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; position: relative; }
.switch-text { display: grid; gap: .1rem; min-width: 0; }
.switch-label { font-weight: 600; font-size: .9rem; }
.switch-hint { font-size: .8125rem; color: var(--muted); }
.switch-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { position: relative; flex: none; width: 2.5rem; height: 1.4rem; border-radius: 999px; background: var(--input-line); transition: background-color .18s; }
.switch-thumb { position: absolute; top: .2rem; left: .2rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--thumb); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .18s; }
.switch-input:checked ~ .switch-track { background: var(--accent); }
.switch-input:checked ~ .switch-track .switch-thumb { transform: translateX(1.1rem); background: var(--on-accent); }
.switch-input:focus-visible ~ .switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }
.switch-input:disabled ~ .switch-track { opacity: .5; }

/* segmented control (radio group) */
.segmented { display: inline-flex; margin: 0; padding: .2rem; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg > span { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .9rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; color: var(--muted); }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--ring); outline-offset: 1px; }
.seg .icon { width: 1rem; height: 1rem; }

/* ---------- Alerts, badges, pills, keys ---------- */
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem .95rem; border-radius: var(--radius-sm); border: 1px solid var(--info-line); background: var(--info-bg); color: var(--text); font-size: .9rem; }
.alert .icon { margin-top: .1rem; color: var(--info); }
.alert-error { background: var(--danger-bg); border-color: var(--danger-line); } .alert-error .icon { color: var(--danger); }
.alert-ok { background: var(--success-bg); border-color: var(--success-line); } .alert-ok .icon { color: var(--success); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); } .alert-warn .icon { color: var(--warn); }
.badge, .pill {
  display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 650; line-height: 1.5;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--line);
}
.pill .icon, .badge .icon { width: .875rem; height: .875rem; }
.badge-ok, .pill-ok { color: var(--success); background: var(--success-bg); border-color: var(--success-line); }
.badge-warn, .pill-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.badge-danger, .pill-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.badge-info, .pill-info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.badge-gold, .pill-gold { color: var(--gold-text); background: var(--warn-bg); border-color: var(--warn-line); }
.kbd, kbd {
  display: inline-block; min-width: 1.5rem; padding: .05rem .4rem; text-align: center; font: 600 .75rem/1.5 var(--mono); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px;
}
.kbd-seq { display: inline-flex; align-items: center; gap: .3rem; }
.kbd-then { font-size: .6875rem; color: var(--muted); }

/* avatars: initials on a colour picked from the address */
.avatar { display: inline-grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; font-size: .875rem; font-weight: 700; letter-spacing: .01em; user-select: none; }
.avatar-sm { width: 1.75rem; height: 1.75rem; font-size: .6875rem; }
.avatar-lg { width: 3.25rem; height: 3.25rem; font-size: 1.0625rem; }
.av-0 { background: var(--av-0-bg); color: var(--av-0-fg); } .av-1 { background: var(--av-1-bg); color: var(--av-1-fg); }
.av-2 { background: var(--av-2-bg); color: var(--av-2-fg); } .av-3 { background: var(--av-3-bg); color: var(--av-3-fg); }
.av-4 { background: var(--av-4-bg); color: var(--av-4-fg); } .av-5 { background: var(--av-5-bg); color: var(--av-5-fg); }
.av-6 { background: var(--av-6-bg); color: var(--av-6-fg); } .av-7 { background: var(--av-7-bg); color: var(--av-7-fg); }

/* mailbox colour dot + label colour classes */
.acct-0 { --acct: var(--acct-0); } .acct-1 { --acct: var(--acct-1); } .acct-2 { --acct: var(--acct-2); } .acct-3 { --acct: var(--acct-3); }
.acct-4 { --acct: var(--acct-4); } .acct-5 { --acct: var(--acct-5); } .acct-6 { --acct: var(--acct-6); } .acct-7 { --acct: var(--acct-7); }
.lc-0 { --lc-bg: var(--lc-0-bg); --lc-fg: var(--lc-0-fg); } .lc-1 { --lc-bg: var(--lc-1-bg); --lc-fg: var(--lc-1-fg); }
.lc-2 { --lc-bg: var(--lc-2-bg); --lc-fg: var(--lc-2-fg); } .lc-3 { --lc-bg: var(--lc-3-bg); --lc-fg: var(--lc-3-fg); }
.lc-4 { --lc-bg: var(--lc-4-bg); --lc-fg: var(--lc-4-fg); } .lc-5 { --lc-bg: var(--lc-5-bg); --lc-fg: var(--lc-5-fg); }
.lc-6 { --lc-bg: var(--lc-6-bg); --lc-fg: var(--lc-6-fg); } .lc-7 { --lc-bg: var(--lc-7-bg); --lc-fg: var(--lc-7-fg); }
.dot { display: inline-block; flex: none; width: .65rem; height: .65rem; border-radius: 50%; background: var(--acct, var(--silver)); }

/* ---------- Toasts and the snackbar ---------- */
.toasts { position: fixed; z-index: 300; left: 1rem; bottom: 1rem; width: min(26rem, calc(100vw - 2rem)); pointer-events: none; }
.toasts-live { display: grid; gap: .5rem; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .65rem; padding: .55rem .5rem .55rem .9rem; min-height: 3rem; color: var(--inv-fg); background: var(--inv-bg);
  border: 1px solid color-mix(in srgb, var(--inv-fg) 14%, transparent); border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .875rem; animation: toast-in .2s ease-out;
}
.toast .icon { color: #7ee8b0; }
.toast-error .icon { color: #ff9a92; } .toast-info .icon { color: #86bcff; } .toast-warn .icon { color: var(--inv-accent); }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action { flex: none; padding: .35rem .7rem; font-weight: 700; font-size: .8125rem; color: var(--inv-accent); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.toast-action:hover { background: color-mix(in srgb, var(--inv-fg) 12%, transparent); }
.toast .icon-btn { color: var(--inv-fg); } .toast .icon-btn:hover { background: color-mix(in srgb, var(--inv-fg) 14%, transparent); color: var(--inv-fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(.5rem); } }

/* ---------- Dialogs (native <dialog>) ---------- */
.dlg { width: min(32rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: dlg-in .16s ease-out; }
.dlg-sm { width: min(26rem, calc(100vw - 2rem)); } .dlg-lg { width: min(44rem, calc(100vw - 2rem)); } .dlg-xl { width: min(56rem, calc(100vw - 2rem)); }
.dlg::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.dlg-inner { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem .5rem 1.4rem; }
.dlg-title { font-size: 1.125rem; }
.dlg-body { padding: .25rem 1.4rem 1.1rem; overflow: auto; min-height: 0; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.2rem; border-top: 1px solid var(--line); background: var(--surface-2); }
.dlg-foot-inline { margin: 1.1rem -1.4rem -1.1rem; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(.5rem) scale(.985); } }

/* ---------- Popovers and menus ---------- */
.pop { position: fixed; left: var(--px, 0); top: var(--py, 0); z-index: 250; min-width: 10rem; max-width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: pop-in .12s ease-out; }
.pop-menu { padding: .35rem; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-.25rem); } }
.menu { display: grid; min-width: 14rem; }
.menu-item { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .5rem .7rem; font-size: .875rem; color: var(--text); background: none; border: 0; border-radius: 8px; cursor: pointer; text-align: left; text-decoration: none; white-space: nowrap; }
.menu-item .icon { color: var(--muted); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--surface-3); outline: none; text-decoration: none; }
.menu-item:disabled { opacity: .5; cursor: default; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item[aria-checked="true"] { font-weight: 650; }
.menu-item[aria-checked="true"] > .icon:last-child { color: var(--accent); }
.menu-label { flex: 1; min-width: 0; }
.menu-meta { color: var(--muted); font-size: .8125rem; margin-left: 1.5rem; }
.menu-kbd { margin-left: 1.5rem; }
.menu-sep { height: 1px; margin: .35rem .25rem; background: var(--line); }
.menu-heading { padding: .5rem .7rem .25rem; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu-note { padding: .35rem .7rem; font-size: .8125rem; color: var(--muted); max-width: 18rem; white-space: normal; }
.swatches { display: grid; grid-template-columns: repeat(4, 1.75rem); gap: .4rem; padding: .6rem; }
.swatch { width: 1.75rem; height: 1.75rem; padding: 0; background: var(--sw, #000); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); border-radius: 50%; cursor: pointer; }
.swatch:hover { transform: scale(1.12); }

/* ---------- Tabs ---------- */
.tablist { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tablist::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: .7rem 1rem; font-size: .875rem; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-radius: 8px 8px 0 0; cursor: pointer; white-space: nowrap; transition: color .15s, background-color .15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"], .tab[aria-current="true"] { color: var(--text); }
.tab[aria-selected="true"]::after, .tab[aria-current="true"]::after { content: ""; position: absolute; left: .5rem; right: .5rem; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.tab-count { padding: 0 .45rem; font-size: .6875rem; font-weight: 700; color: var(--gold-text); background: var(--warn-bg); border-radius: 999px; }
.tabpanel { padding-top: 1rem; }

/* ---------- Chips (filter chips, e.g. search operators) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .75rem; font-size: .8125rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; }
.chip:hover { background: var(--surface-3); }
.chip[aria-pressed="true"], .chip[aria-current="true"] { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- Loading, skeletons, empty states ---------- */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; padding: 3rem 1rem; color: var(--muted); font-size: .875rem; }
.loading.inline { flex-direction: row; padding: .5rem; }
.orbit { position: relative; display: inline-block; width: 3rem; height: 3rem; }
.orbit-core { position: absolute; inset: 28%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #6fb1ff 45%, var(--accent) 75%, #0a2a66); box-shadow: 0 0 16px 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.orbit-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--gold); border-bottom-color: var(--accent); animation: spin 1.6s linear infinite; }
.orbit-dot { position: absolute; left: 50%; top: -3px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px 2px color-mix(in srgb, var(--gold) 55%, transparent); transform-origin: 50% calc(1.5rem + 3px); animation: spin 1.6s linear infinite; }
.loading.inline .orbit { width: 1.5rem; height: 1.5rem; }
.loading.inline .orbit-dot { transform-origin: 50% calc(.75rem + 3px); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeletons { display: grid; gap: .6rem; }
.skeleton { height: 1rem; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: grid; justify-items: center; gap: .6rem; padding: 3.5rem 1.5rem; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 50%; color: var(--accent); background: var(--accent-soft); margin-bottom: .4rem; }
.empty-icon .icon { width: 2rem; height: 2rem; }
.empty-error .empty-icon { color: var(--danger); background: var(--danger-bg); }
.empty p { max-width: 28rem; }
.empty-actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; margin-top: .5rem; }

/* ---------- Cards, tables, page chrome ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-sub { margin-top: .25rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th { text-align: left; padding: .6rem .8rem; font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl-wrap { overflow-x: auto; }

/* sign-in card with the brand gradient strip */
.auth-card { position: relative; width: min(26rem, 100%); margin: 0 auto; padding: 2rem 1.75rem 1.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--accent), #6fb1ff 40%, var(--gold-light) 70%, var(--gold)); }

/* connection banner (offline) */
.conn-banner { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: .45rem 1rem; font-size: .8125rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); }

/* ---------- Command palette (Ctrl/Cmd+K) ---------- */
.cmdk { width: min(40rem, calc(100vw - 1.5rem)); max-height: min(34rem, calc(100dvh - 6rem)); margin: 10vh auto auto; padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk[open] { display: block; animation: dlg-in .14s ease-out; }
.cmdk::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.cmdk-box { display: flex; flex-direction: column; max-height: inherit; }
.cmdk-head { display: flex; align-items: center; gap: .75rem; padding: .25rem 1.1rem; border-bottom: 1px solid var(--line); color: var(--muted); }
.cmdk-input { flex: 1; min-width: 0; padding: .9rem 0; font-size: 1.0625rem; color: var(--text); background: none; border: 0; outline: none; }
.cmdk-status { padding: .75rem 1.2rem; color: var(--muted); font-size: .875rem; margin: 0; }
.cmdk-status:empty { display: none; }
.cmdk-list { list-style: none; overflow: auto; padding: .4rem; }
.cmdk-group { padding: .6rem .75rem .25rem; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cmdk-opt { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: 10px; cursor: pointer; }
.cmdk-opt.active { background: var(--accent-soft); }
.cmdk-ic { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; color: var(--muted); background: var(--surface-3); flex: none; }
.cmdk-opt.active .cmdk-ic { color: var(--accent); background: var(--surface); }
.cmdk-text { display: grid; flex: 1; min-width: 0; }
.cmdk-label { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-sub { font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-foot { margin: 0; padding: .6rem 1.1rem; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface-2); }

/* ---------- Shortcut sheet ---------- */
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1.5rem 2.25rem; }
.sc-group h3 { margin-bottom: .5rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); font-size: .8125rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sc-list { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 0; align-items: center; }
.sc-list dt { font-size: .875rem; }
.sc-list dd { margin: 0; display: flex; gap: .35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.sc-or { font-size: .6875rem; color: var(--muted); }

/* ---------- Settings layout ---------- */
.settings { display: grid; grid-template-columns: 14rem minmax(0, 1fr); gap: 1.5rem; align-items: start; max-width: 62rem; margin: 0 auto; padding: 1.5rem; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 1rem); display: grid; gap: .15rem; }
.settings-nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem; border-radius: 999px; font-size: .9rem; font-weight: 600; color: var(--text); text-decoration: none; }
.settings-nav a:hover { background: var(--surface-3); }
.settings-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.settings-nav .icon { color: var(--muted); }
.settings-nav a[aria-current="page"] .icon { color: var(--accent); }
.settings-panel { display: grid; gap: 1.25rem; min-width: 0; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-card > header { padding: 1rem 1.25rem .5rem; }
.panel-card > header p { margin-top: .2rem; font-size: .875rem; color: var(--muted); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; }
.setting-text { min-width: 0; }
.setting-text strong { display: block; font-size: .9rem; }
.setting-text span { display: block; font-size: .8125rem; color: var(--muted); }
.setting-control { flex: none; }
.setting-row .switch { width: 100%; }

/* ---------- Motion, contrast and print preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .orbit-ring, .orbit-dot { animation: none !important; }
  .skeleton { animation: none !important; }
}
@media (forced-colors: active) {
  .btn, .input, .chip, .card, .panel-card, .dlg, .pop, .toast { border: 1px solid CanvasText; }
  .btn-primary, .seg input:checked + span, .tab[aria-selected="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .tbtn[aria-pressed="true"], .icon-btn[aria-pressed="true"], .chip[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .switch-track { border: 1px solid CanvasText; background: Canvas; } .switch-input:checked ~ .switch-track { background: Highlight; }
  .switch-thumb { background: CanvasText; } .switch-input:checked ~ .switch-track .switch-thumb { background: HighlightText; }
  .dot { forced-color-adjust: none; }
}
@media (max-width: 48rem) {
  body { font-size: 16px; }
  .settings { grid-template-columns: 1fr; padding: 1rem; }
  .settings-nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; padding-bottom: .25rem; }
  .settings-nav a { white-space: nowrap; }
  .setting-row { flex-direction: column; align-items: stretch; gap: .6rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .toasts { left: .75rem; right: .75rem; bottom: 5.25rem; width: auto; }
  .dlg { max-height: calc(100dvh - 1rem); }
  .btn { min-height: 2.75rem; }
  .btn-sm { min-height: 2.25rem; }
}

/* pages: settings and admin ------------------------------------------------------------------------------------------------- */
.mm-page { scrollbar-width: thin; }
.card-pad { padding: .9rem 1.25rem 1.1rem; }
.panel-card > .card-pad:first-of-type:not(:only-child) { padding-top: .5rem; }
.card-note { padding: 0 .25rem; font-size: .8125rem; }
.card-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.settings-panel > .page-head { margin-bottom: 0; }
.settings-panel > .page-head h1 { outline: none; }
.settings-panel .stack > * + * { margin-top: 1rem; }
.lazy { display: grid; gap: 1.25rem; min-width: 0; }
.lazy > .field { max-width: 28rem; margin-bottom: 0; }
.setting-control { max-width: 62%; }
.setting-row .setting-text { flex: 1; }
.setting-row .setting-control:has(.input), .setting-row .setting-control:has(.server-sum) { flex: 1 1 14rem; max-width: 26rem; }
.setting-row .setting-control .input { min-width: 10rem; }
.tr { text-align: right; }
.mono { font-family: var(--mono); font-size: .8125rem; }
.sha { margin-top: .15rem; }
.switch-compact { justify-content: flex-end; }
.switch-compact .switch-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

/* mailbox cards */
.acct-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; padding: 1rem 1.25rem .6rem; }
.acct-card-head .dot { width: .9rem; height: .9rem; }
.acct-card-id h2 { font-size: 1.0625rem; }
.acct-card-id p { margin: 0; font-size: .875rem; }
.server-sum { display: grid; gap: .35rem; justify-items: start; }
.server-sum code { font-size: .75rem; }
.color-picker { display: flex; gap: .35rem; margin: 0; padding: 0; border: 0; }
.color-opt { position: relative; display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; cursor: pointer; }
.color-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.color-sw { width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--sw, var(--silver)); box-shadow: 0 0 0 1px var(--line-strong); transition: transform .1s; }
.color-opt:hover .color-sw { transform: scale(1.12); }
.color-opt input:checked + .color-sw { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.color-opt input:focus-visible + .color-sw { outline: 2px solid var(--ring); outline-offset: 4px; }

/* labels, identities, filters, forms in cards */
.label-row { flex-wrap: wrap; justify-content: flex-start; }
.label-row .chip-label { width: 9rem; max-width: 9rem; justify-content: center; }
.label-edit { flex: 1 1 12rem; max-width: 18rem; }
.label-count { min-width: 5rem; font-size: .8125rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
.inline-form .inline-field { flex: 1 1 16rem; }
.inline-form .field { margin-bottom: 0; }
.inline-form .form-error { flex-basis: 100%; }
.ident-row { align-items: flex-start; }
.ident-row .setting-text { display: grid; gap: .35rem; }
.sig-preview { max-height: 6.5rem; overflow: hidden; padding: .5rem .75rem; font-size: .8125rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.sig-preview p { margin: 0; }
.sig-editor { border: 1px solid var(--input-line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.sig-editor .editor { min-height: 6rem; padding: .6rem .8rem; }
.sig-editor .etoolbar { margin: .35rem .5rem; }
.filter-row { align-items: flex-start; }
.filter-row .setting-text { display: grid; gap: .4rem; }
.filter-sw { display: block; max-width: 22rem; }
.filter-sw .switch-label { font-size: .9375rem; }
.filter-sum { font-size: .875rem; color: var(--text); }
.fs { margin: 0 0 1rem; padding: .75rem 1rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
.fs legend { padding: 0 .4rem; font-size: .8125rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.fs > .check { margin-top: .25rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem 1rem; margin-bottom: .75rem; }
.forward-field { margin-top: .5rem; }
.filter-editor .alert { margin-top: .5rem; }
.vac-dates { margin-top: 1rem; }

/* add-mailbox wizard */
.wizard-steps { display: flex; gap: 1.25rem; margin: 0 0 1.1rem; padding: 0; list-style: none; font-size: .8125rem; font-weight: 650; color: var(--muted); }
.wizard-steps li { display: inline-flex; align-items: center; gap: .45rem; }
.wizard-steps li[aria-current="step"] { color: var(--text); }
.step-n { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; font-size: .75rem; color: var(--muted); background: var(--surface-3); border-radius: 50%; }
.wizard-steps li[aria-current="step"] .step-n { color: var(--on-accent); background: var(--accent); }
.wizard-steps li[data-done="true"] .step-n { color: var(--success); background: var(--success-bg); }
.server-fields { display: grid; grid-template-columns: minmax(0, 2fr) 6.5rem minmax(0, 1.3fr); gap: 0 .75rem; margin-bottom: .25rem; }
.dlg .server-fields .field { margin-bottom: .75rem; }
@media (max-width: 40rem) { .server-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .server-fields .field:first-child { grid-column: 1 / -1; } }
.test-result { display: grid; gap: .5rem; margin: .75rem 0; }
.test-result:empty { display: none; }
.test-line { display: flex; gap: .65rem; padding: .6rem .8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.test-line p { margin: .15rem 0 0; font-size: .8125rem; }
.test-line[data-ok="true"] { background: var(--success-bg); border-color: var(--success-line); }
.test-line[data-ok="true"] .icon { color: var(--success); }
.test-line[data-ok="false"] { background: var(--danger-bg); border-color: var(--danger-line); }
.test-line[data-ok="false"] .icon { color: var(--danger); }
.wizard-done { display: grid; justify-items: center; gap: .5rem; padding: 1rem 0 0; text-align: center; }
.wizard-done .empty-icon { color: var(--success); background: var(--success-bg); }
.wizard-done .dlg-foot { width: calc(100% + 2.8rem); }

/* admin */
.engine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .9rem; padding: .5rem 1.25rem 1.25rem; }
.engine-card { display: grid; align-content: start; gap: .35rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.engine-card[data-ok="false"] { background: var(--danger-bg); border-color: var(--danger-line); }
.engine-card p { margin: 0; font-size: .8125rem; }
.engine-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.engine-head h3 { font-size: 1rem; }
.engine-detail { font-weight: 600; color: var(--text); }
.engine-bad { color: var(--danger); }
.engine-time { margin-top: .15rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; padding: .5rem 1.25rem 1.25rem; }
.stat { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.stat .icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
.stat strong { display: block; font-size: 1.375rem; line-height: 1.1; }
.stat span { font-size: .8125rem; color: var(--muted); }
.audit-filters .field { margin-bottom: 0; }
.audit-tbl td, .audit-tbl th { white-space: nowrap; }
.audit-tbl td:last-child { white-space: normal; min-width: 12rem; }
.sig-cell { overflow-wrap: anywhere; min-width: 9rem; }
.sc-settings { padding: .25rem 1.25rem 1rem; }
.sc-settings dt { font-size: .875rem; }
@media (max-width: 48rem) {
  .setting-control, .setting-row .setting-control:has(.input), .setting-row .setting-control:has(.server-sum) { max-width: none; flex: none; }
  .setting-row .setting-text { flex: none; }
  .grid-2 > .field:last-child { margin-bottom: 1rem; }
  .fs .check, .filter-editor > .check { margin-top: .25rem; }
  .label-row .chip-label { width: auto; }
  .engine-grid, .stat-grid { padding-inline: 1rem; }
  .acct-card-head { padding-inline: 1rem; }
  .wizard-steps { gap: .6rem; font-size: .75rem; }
}
