/* =====================================================================
   LIPAT by TRABAHO.AE — styles
   Brand tokens follow trabaho.ae / SnapStock (tokens.css).
   Sections: fonts · tokens · base · header · workspace/panes · account ·
   tree · message list · rail · buttons/forms · modals · progress · jobs
   tray · preview · billing · toasts · skeletons · responsive · motion
   ===================================================================== */

/* ---------- 0. Fonts (self-hosted, latin subsets) ---------- */
@font-face { font-family: "Instrument Sans"; src: url("/brand/instrument-sans-latin.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Big Shoulders Display"; src: url("/brand/big-shoulders-display-latin.woff2") format("woff2"); font-weight: 600 900; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/brand/ibm-plex-mono-latin.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: light;
  /* brand */
  --ink: #16140f;
  --accent: #fdc82e;          /* hard-hat yellow: fills only, never text on light */
  --accent-strong: #e3af14;
  --accent-soft: #fff2c6;
  --accent-text: #72580f;     /* yellow-family text: 6.7:1 on white */
  --on-accent: #16140f;
  --band: #16140f;            /* near-black header band (both themes) */
  --on-band: #ffffff;
  --on-band-muted: #bdb6a8;
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='100,50 85.36,64.64 85.36,85.36 64.64,85.36 50,100 35.36,85.36 14.64,85.36 14.64,64.64 0,50 14.64,35.36 14.64,14.64 35.36,14.64 50,0 64.64,14.64 85.36,14.64 85.36,35.36' fill='none' stroke='%2316140F' stroke-opacity='0.13' stroke-width='1.6'/%3E%3C/svg%3E");
  --girih-band: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='100,50 85.36,64.64 85.36,85.36 64.64,85.36 50,100 35.36,85.36 14.64,85.36 14.64,64.64 0,50 14.64,35.36 14.64,14.64 35.36,14.64 50,0 64.64,14.64 85.36,14.64 85.36,35.36' fill='none' stroke='%23FDC82E' stroke-opacity='0.16' stroke-width='1.6'/%3E%3C/svg%3E");

  --bg: #f5f1e8;              /* warm cream canvas behind panes */
  --bg-grad: linear-gradient(180deg, #f5f1e8 0%, #f5f1e8 100%);
  --surface: #ffffff;         /* raised */
  --surface-2: #faf7f1;
  --surface-3: #efe9de;
  --border: #ede8dd;
  --border-soft: #f3efe7;
  --border-strong: #8a857b;   /* control boundaries: 3.7:1 on white */
  --text: #16140f;
  --text-2: #5c584f;          /* 7.1:1 on white */
  --text-3: #6b665c;          /* 5.1:1 on cream */

  /* Mailbox A = brand yellow family, Mailbox B = brand info blue (identity only — never a direction) */
  --mba: #fdc82e;  --mba-weak: #fff2c6;  --mba-strong: #72580f;  --on-mba: #16140f; --mba-edge: #16140f;
  --mbb: #235a8b;  --mbb-weak: #e3edf6;  --mbb-strong: #235a8b;  --on-mbb: #ffffff; --mbb-edge: #235a8b;

  --ok: #0a6b3f;     --ok-weak: #dcefe5;
  --warn: #875d00;   --warn-weak: #f8edcc;
  --danger: #a02520; --danger-weak: #f6dfdc; --on-danger: #ffffff;
  --info: #235a8b;   --info-weak: #e3edf6;
  --focus: #16140f;

  --radius: 10px;
  --radius-xl: 20px;
  --shadow-1: 0 1px 2px rgb(22 20 15 / .06);
  --shadow-2: 0 7px 22px rgb(22 20 15 / .055);
  --shadow-modal: 0 24px 70px rgb(22 20 15 / .18), 0 2px 8px rgb(22 20 15 / .08);
  --backdrop: rgb(22 20 15 / .5);

  --font: "Instrument Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --display: "Big Shoulders Display", "Instrument Sans", "Arial Narrow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;

  --header-h: 64px;
  --modal-pad-x: 24px;   /* one side gutter for modal head, body and foot */
  --gutter: 16px;         /* one page edge: header, banner and workspace line up on it */
  --mark: 40px;
  --rail-w: 116px;
  --tree-w: clamp(200px, 18vw, 236px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* Dark theme: app.js always sets data-theme to the effective theme (System follows the OS live). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent-strong: #ffda6c; --accent-soft: #372e17; --accent-text: #fdc82e;
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='100,50 85.36,64.64 85.36,85.36 64.64,85.36 50,100 35.36,85.36 14.64,85.36 14.64,64.64 0,50 14.64,35.36 14.64,14.64 35.36,14.64 50,0 64.64,14.64 85.36,14.64 85.36,35.36' fill='none' stroke='%23FFFFFF' stroke-opacity='0.07' stroke-width='1.6'/%3E%3C/svg%3E");
  --band: #0f0e0a;
  --bg: #16140f;
  --bg-grad: linear-gradient(180deg, #16140f 0%, #16140f 100%);
  --surface: #211e18;
  --surface-2: #27241e;
  --surface-3: #312d25;
  --border: #3a352c;
  --border-soft: #2c2821;
  --border-strong: #857e70;
  --text: #fbf9f4;
  --text-2: #bdb6a8;
  --text-3: #a39c8e;
  --mba: #fdc82e;  --mba-weak: #372e17;  --mba-strong: #fdc82e;  --on-mba: #16140f; --mba-edge: #fdc82e;
  --mbb: #83b7e7;  --mbb-weak: #1a2a3a;  --mbb-strong: #83b7e7;  --on-mbb: #16140f; --mbb-edge: #83b7e7;
  --ok: #3dd58a;     --ok-weak: #123522;
  --warn: #f1bd50;   --warn-weak: #2e2611;
  --danger: #ff7a73; --danger-weak: #3a1a18; --on-danger: #16140f;
  --info: #83b7e7;   --info-weak: #1a2a3a;
  --focus: #ffda6c;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 8px 26px rgb(0 0 0 / .32);
  --shadow-modal: 0 30px 80px rgb(0 0 0 / .6), 0 0 0 1px rgb(255 255 255 / .04);
  --backdrop: rgb(0 0 0 / .72);
}

/* pane accent scoping */
[data-role="a"], .acc-a { --acc: var(--mba); --acc-weak: var(--mba-weak); --acc-strong: var(--mba-strong); --on-acc: var(--on-mba); --acc-edge: var(--mba-edge); }
[data-role="b"], .acc-b { --acc: var(--mbb); --acc-weak: var(--mbb-weak); --acc-strong: var(--mbb-strong); --on-acc: var(--on-mbb); --acc-edge: var(--mbb-edge); }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--text); text-decoration-color: var(--accent-strong); text-underline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-soft); }
.ico { flex: none; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.eyebrow { font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: var(--radius);
  box-shadow: var(--shadow-2); transition: top .15s var(--ease);
}
.skip-link:focus { top: 10px; }

/* ---------- 3. Header (near-black brand band) ---------- */
.app-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--gutter);
  --hdr-btn: 36px;        /* header icon-button width; the last one's glyph is pulled onto the gutter */
  background: var(--girih-band) 0 0 / 84px 84px repeat, var(--band);
  color: var(--on-band);
  position: relative; z-index: 5;
  --focus: #ffda6c;
  --warn: #f1bd50;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: none; color: inherit; text-decoration: none; }
.brand-mark {
  width: auto; height: var(--mark); flex: none; display: block;
  /* the viewBox is tight to the artwork, so the speed lines start right on the gutter like the pane borders */
}
.brand-text { display: flex; align-items: center; gap: 12px; min-width: 0; height: var(--mark); }
.brand-name {
  font-family: var(--display); font-weight: 800; font-size: 32px; line-height: 1;
  /* centre the cap height itself on the logo, whatever the font's ascent/descent metrics */
  text-box: trim-both cap alphabetic;
  letter-spacing: .06em; margin-right: -.06em; /* drop the trailing tracking so the gaps either side of the T match */
  text-transform: uppercase; white-space: nowrap; color: var(--on-band);
}
.brand-sub {
  display: flex; flex-direction: column; gap: 7px; padding: 2px 0 2px 12px;
  border-left: 1px solid rgb(255 255 255 / .18);
  font: 500 10.5px/1.15 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--on-band-muted); white-space: nowrap;
}
.brand-sub .ae { color: var(--accent); }
.brand-sub .by { color: var(--on-band); }
.brand-sub > span { text-box: trim-both cap alphabetic; }
@supports not (text-box: trim-both cap alphabetic) { .brand-name { padding-top: 3px; } }
/* the help glyph, not its 36px hit area, sits on the right gutter (mirrors the logo tile on the left) */
.header-actions > .icon-btn:last-child { margin-right: calc((18px - var(--hdr-btn)) / 2); }
.header-spacer { flex: 1; }
.menu-host { position: relative; display: inline-flex; }
.theme-btn { width: 36px; height: 36px; }
.app-header .menu { color: var(--text); --focus: #16140f; --warn: #875d00; }
:root[data-theme="dark"] .app-header .menu { --focus: #ffda6c; --warn: #f1bd50; }
.menu-item[aria-checked="true"] { font-weight: 700; background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.app-header .btn-ghost, .app-header .icon-btn { color: var(--on-band); }
.app-header .btn-ghost:hover:not(:disabled), .app-header .icon-btn:hover:not(:disabled) { background: rgb(255 255 255 / .09); color: var(--on-band); }
.jobs-btn { position: relative; width: 36px; height: 36px; }
.jobs-btn .badge {
  position: absolute; top: 1px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font: 500 10.5px/1 var(--mono);
  display: inline-grid; place-items: center; box-shadow: 0 0 0 2px var(--band);
}
.jobs-btn.busy .jobs-ico { animation: spin 1.6s linear infinite; }
.billing-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid rgb(253 200 46 / .55); background: rgb(253 200 46 / .07); color: var(--on-band);
  font-weight: 650; font-size: 13.5px; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.billing-btn:hover { background: rgb(253 200 46 / .16); border-color: var(--accent); }
.billing-btn .ico { color: var(--accent); }
.billing-btn.empty { border-color: var(--warn); }
.billing-btn.empty .ico { color: var(--warn); }
.billing-short, .code-short { display: none; }
.billing-pill {
  font: 500 10.5px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 8px; border-radius: 999px; background: rgb(255 255 255 / .12); color: var(--on-band-muted);
}

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gutter); font-size: 13.5px;
  background: var(--warn-weak); color: var(--text); border-bottom: 1px solid var(--border);
}
.banner .ico { color: var(--warn); }
.banner.danger { background: var(--danger-weak); }
.banner.danger .ico { color: var(--danger); }
.banner .btn { margin-left: auto; }

/* ---------- 4. Workspace & panes ---------- */
#main { display: flex; flex-direction: column; height: calc(100dvh - var(--header-h) - var(--banner-h, 0px)); }
body.gated { overflow: auto; }
body.gated #main { height: auto; }
.workspace {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rail-w) minmax(0, 1fr);
  padding: var(--gutter);
  gap: 0;
}
.pane {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  position: relative;
}
.pane-head {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 66px;
  flex: none;
}
.pane-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pane-role {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 11.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  padding: 4px 10px 4px 4px; border-radius: 9px; white-space: nowrap;
  background: var(--acc-weak); color: var(--acc-strong);
}
.role-letter, .pt-letter {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--acc); color: var(--on-acc); border: 1.5px solid var(--acc-edge);
  font: 800 14px/1 var(--display); letter-spacing: 0;
}
.pt-letter { width: 16px; height: 16px; font-size: 11px; border-radius: 4px; border-width: 1px; }
.account-slot { min-width: 0; display: flex; justify-content: flex-end; }

.pane-body { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--tree-w) minmax(0, 1fr); }
.pane-loading { flex: 1; display: grid; place-items: center; }

/* signed-out empty state (centred with auto margins, so a tall form still scrolls from its top) */
.pane-empty {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  text-align: center; padding: 32px 28px; gap: 10px;
  background:
    radial-gradient(ellipse 46% 42% at 50% 50%, var(--surface) 55%, transparent 100%),
    var(--girih) center / 84px 84px repeat,
    var(--surface);
}
.empty-art {
  width: 132px; height: 132px; border-radius: 28px;
  display: grid; place-items: center; margin-bottom: 14px;
  position: relative;
}
.empty-art svg { display: block; overflow: visible; }
.art-ink { stroke: var(--text); }
.art-fill { fill: var(--acc); }
.art-soft { fill: var(--acc-weak); }
.art-paper { fill: var(--surface); }
.art-inkfill { fill: var(--text); }
.art-on-ink { stroke: var(--surface); }
.pane-empty .eyebrow { color: var(--acc-strong); }
.pane-empty h2 { font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: .01em; text-transform: uppercase; max-width: 380px; }
.pane-empty p { color: var(--text-2); max-width: 360px; }
.login-btn { margin-top: 12px; height: 48px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.hint-toggle { margin-top: 2px; }
.hint-row { display: flex; gap: 8px; width: min(360px, 100%); margin-top: 4px; }
.hint-row .input { flex: 1; }
.empty-tip {
  margin-top: 18px; max-width: 390px; font-size: 12.5px; color: var(--text-2);
  display: flex; gap: 8px; text-align: left;
  padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border);
}
.empty-tip .ico { margin-top: 2px; color: var(--text-3); }
.pane-empty > :first-child { margin-top: auto; }
.pane-empty > :last-child { margin-bottom: auto; }

/* ---------- 4b. Connect: provider picker and sign-in forms ---------- */
.empty-art.sm { width: 104px; height: 104px; margin-bottom: 2px; }
.empty-art.sm svg { width: 90px; height: auto; }
.connect-h { outline: none; }
.provider-grid {
  list-style: none; width: min(460px, 100%); margin-top: 8px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; text-align: left;
}
.provider-grid > li { display: flex; min-width: 0; }
.pv-tile {
  width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  text-align: left; transition: border-color .12s, box-shadow .12s, transform .12s;
}
.pv-tile:hover { border-color: var(--text); box-shadow: var(--shadow-1); }
.pv-tile:active { transform: translateY(1px); }
.pv-ico {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--acc-weak); color: var(--acc-strong);
}
.pv-ico.lg { width: 44px; height: 44px; border-radius: 12px; background: var(--acc); color: var(--on-acc); border: 1.5px solid var(--acc-edge); }
.pv-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; }
.pv-name { font-weight: 700; font-size: 13.5px; overflow-wrap: anywhere; }
.pv-sub { font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.pv-badge {
  margin-top: 4px; padding: 2px 7px; border-radius: 999px;
  font: 500 10px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface-3); color: var(--text-2);
}
.pv-tile.is-off { background: var(--surface-2); border-style: dashed; }
.pv-tile.is-off:hover { border-color: var(--border-strong); }
.pv-tile.is-off .pv-ico { background: var(--surface-3); color: var(--text-3); }
.pv-tile.is-off .pv-name { color: var(--text-2); }
/* phones: the icon sits above the name, so names keep one line in two columns */
@media (max-width: 520px) {
  .pane-empty { padding: 24px 16px; }
  .pv-tile { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; }
  .pv-ico { width: 30px; height: 30px; border-radius: 8px; }
}
@media (max-width: 340px) { .provider-grid { grid-template-columns: minmax(0, 1fr); } }

/* step 2: one provider's form (left-aligned, still centred in the pane; no pattern behind the fields) */
.provider-grid ~ .empty-tip { width: min(460px, 100%); max-width: none; }
.pane-empty.is-step { text-align: left; background: var(--surface); }
.connect { width: min(440px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: left; }
.connect-back { display: inline-flex; align-items: center; gap: 4px; }
.connect > .btn-link { align-self: flex-start; }
.connect .hint-row { width: 100%; margin-top: 0; }
.connect .empty-tip { max-width: none; margin-top: 4px; }
.connect-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.connect-head-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.connect-head .eyebrow { color: var(--acc-strong); }
.pane-empty .connect h2 { font-size: 26px; max-width: none; }
.pane-empty .connect p { max-width: none; }
.connect .login-btn { width: 100%; margin-top: 0; }
.connect-lead { color: var(--text-2); font-size: 13.5px; }
.connect-pw { display: flex; flex-direction: column; gap: 14px; }
.connect-form { display: flex; flex-direction: column; gap: 12px; }
.connect-fields { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.connect-fields > .btn-link { align-self: flex-start; font-size: 13px; }
.connect-status:not(:empty) { margin-top: 6px; } /* stays in the page (empty) so screen readers hear it appear */
.connect .err-tip { display: block; margin-top: 4px; }
.connect .fold-body { padding: 10px 14px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.connect .steps { gap: 4px; }
.how-notes { list-style: none; display: flex; flex-direction: column; gap: 4px; color: var(--text-2); font-size: 12.5px; }
.how-notes li { padding-left: 14px; position: relative; }
.how-notes li::before { content: "·"; position: absolute; left: 4px; font-weight: 800; }
.how-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.how-links a, .help-list a { font-weight: 600; white-space: nowrap; }
.how-links .ico, .help-list a .ico { vertical-align: -1px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 120px); gap: 10px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-eye { position: absolute; right: 5px; top: 5px; }
select.input { padding-right: 8px; }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.connect-fields:disabled { opacity: .7; }
.privacy .ico { color: var(--text-3); }
.help-list { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.help-list .steps { margin-top: 6px; }

/* ---------- 5. Account chip & menu ---------- */
.account-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 4px 4px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  min-width: 0; max-width: 100%;
  position: relative;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--acc); color: var(--on-acc); border: 1.5px solid var(--acc-edge);
  font: 800 15px/1 var(--display); letter-spacing: .04em;
}
.acct-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.acct-name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-email { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-email.solo { font-weight: 700; font-size: 14px; color: var(--text); }
.tenant-tag {
  font: 500 11px/1.2 var(--mono); letter-spacing: .02em; padding: 4px 8px; border-radius: 999px;
  background: var(--acc-weak); color: var(--acc-strong); white-space: nowrap;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 56px;
}
.tenant-tag.copy-only { background: var(--warn-weak); color: var(--warn); flex: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  animation: pop-in .12s var(--ease);
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px; border: 0; background: transparent; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-head { padding: 8px 10px 6px; font-size: 12px; color: var(--text-3); }

/* ---------- 6. Folder tree ---------- */
.folders {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
}
.folders-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 16px; }
.section-label { font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.tree-scroll { flex: 1; overflow: auto; padding: 2px 0 14px; overscroll-behavior: contain; }
.tree, .tree ul { list-style: none; }
.tree-row {
  display: flex; align-items: center; gap: 7px;
  height: 34px; margin: 1px 8px; padding: 0 8px 0 calc(4px + var(--lvl, 0) * 16px);
  border-radius: 8px; cursor: pointer; user-select: none;
  color: var(--text);
  transition: background-color .12s, color .12s;
  position: relative;
}
.tree-row:hover { background: var(--surface-3); }
.tree-row button:focus-visible { outline-offset: -2px; }
.tree-row.is-selected { background: var(--acc-weak); color: var(--acc-strong); font-weight: 600; }
.tree-row.is-selected .f-ico { color: var(--acc-strong); }
.tree-btn {
  flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 7px;
  padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; font-weight: inherit; text-align: left;
}
.twisty {
  width: 20px; height: 20px; flex: none; display: grid; place-items: center;
  padding: 0; border: 0; background: none;
  border-radius: 5px; color: var(--text-3);
  transition: transform .15s var(--ease), background-color .12s;
}
.twisty:not(.leaf):hover { background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
.twisty[aria-expanded="true"] { transform: rotate(90deg); }
.f-ico { color: var(--text-2); }
.f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-unread {
  font: 500 11px/1.5 var(--mono); padding: 0 7px; border-radius: 999px;
  background: var(--acc); color: var(--on-acc); font-variant-numeric: tabular-nums;
}
.f-total { font: 500 11px/1 var(--mono); color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; font-weight: 400; }
.tree-msg { padding: 8px 16px 8px calc(16px + var(--lvl, 0) * 16px); color: var(--text-3); font-size: 13px; }
.tree-msg .btn-link { margin-left: 4px; }
.tree-row.is-current { color: var(--text-3); }
.tree-row.is-header { color: var(--text-2); }
.tree-row.is-header .f-name { font: 500 11px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.f-badge { font: 500 9px/1.4 var(--mono); letter-spacing: .04em; text-transform: uppercase; padding: 0 4px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-2); flex: none; }
/* folder picker: the choice is a filled accent with a check; keyboard focus is a ring */
.picker-tree .tree-row.is-selected { background: var(--acc); color: var(--on-acc); }
.picker-tree .tree-row.is-selected .f-ico { color: inherit; }

/* ---------- 7. Message list ---------- */
.list-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-head { padding: 12px 16px 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; flex: none; }
.list-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-title { min-width: 0; flex: 1; }
.folder-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.folder-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* mid widths: the destination tag goes icon-only (title still explains it) so both list heads keep one height */
@media (max-width: 1179px) and (min-width: 900px) { .list-title-row .dest-tag { font-size: 0; gap: 0; padding: 4px; } .list-title-row .dest-tag svg { width: 13px; height: 13px; } }
.dest-tag {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font: 500 10.5px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px 4px 7px; border-radius: 999px;
  background: var(--acc-weak); color: var(--acc-strong);
}
.list-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 160px; position: relative; display: flex; align-items: center;
}
.search > .ico { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search-input {
  width: 100%; height: 36px; padding: 0 34px 0 34px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2);
  transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.search-input:hover { border-color: var(--border-strong); }
.search-input:focus { background: var(--surface); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { appearance: none; margin: 0; width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background-color .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); transition: transform .15s var(--ease), background-color .15s; }
.switch input:checked { background: var(--acc); border-color: var(--acc); }
.switch input:checked::after { transform: translateX(14px); background: var(--on-acc); }
/* The count never clips: actions wrap, then go icon-only when the list column is narrow. */
.selbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; row-gap: 6px; min-height: 24px; min-width: 0; font-size: 13px; color: var(--text-2); container-type: inline-size; }
.selbar .sel-count { flex: 0 0 auto; min-width: max-content; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.selbar .sel-count.has { color: var(--acc-strong); }
.selbar .sel-size { white-space: nowrap; color: var(--text-3); }
.selbar .spacer { flex: 1; }
.selbar .btn-link { white-space: nowrap; }
@container (max-width: 460px) { .selbar .sel-size { display: none; } }
/* Narrow: icon-only, except an irreversible "Delete permanently" always keeps its words
   (next to it, Move goes icon-only a little earlier to leave room). */
@container (max-width: 340px) { .sel-actions:has(.is-perm) .btn:not(.is-perm) { width: 32px; height: 32px; padding: 0; } .sel-actions:has(.is-perm) .btn:not(.is-perm) .act-label { display: none; } }
@container (max-width: 280px) { .sel-actions .btn:not(.is-perm) { width: 32px; height: 32px; padding: 0; } .sel-actions .btn:not(.is-perm) .act-label { display: none; } }

.msg-list { flex: 1; min-height: 200px; overflow: auto; outline: none; overscroll-behavior: contain; position: relative; display: flex; flex-direction: column; }
.list-state-slot:not(:empty) { margin: auto 0; }
.msg {
  display: grid; grid-template-columns: 40px minmax(0, 1fr);
  padding: 10px 16px 10px 4px;
  border-bottom: 1px solid var(--border-soft);
  cursor: default; position: relative;
  transition: background-color .1s;
  content-visibility: auto; contain-intrinsic-size: auto 72px;
}
/* unread = dot + weight; selected = tinted row + accent edge; hover = neutral */
.msg:hover { background: var(--surface-2); }
.msg.is-selected { background: color-mix(in srgb, var(--acc) 10%, var(--surface)); box-shadow: inset 3px 0 0 var(--acc); }
.msg.is-selected:hover { background: color-mix(in srgb, var(--acc) 16%, var(--surface)); }
.msg.is-selected :is(.preview-txt, .size) { color: var(--text-2); }
.c-check { display: grid; place-items: start center; padding-top: 1px; cursor: pointer; align-self: stretch; }
.c-check:hover .cbox { box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 35%, transparent); }
.cbox {
  appearance: none; margin: 0; width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; position: relative;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
/* larger hit areas than the visuals */
.cbox::before, .row-peek::before { content: ""; position: absolute; inset: -4px; }
@media (pointer: coarse) { .cbox::before, .row-peek::before { inset: -13px; } }
.cbox::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-acc, var(--ink)); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .12s var(--ease); }
.cbox:checked, .cbox:indeterminate { background: var(--acc, var(--accent)); border-color: var(--acc-edge, var(--ink)); }
.cbox:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.cbox:indeterminate::after { width: 9px; height: 0; border-left: 0; border-bottom-width: 2px; transform: none; }
.c-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.l1, .l2, .l3 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.msg.unread .from, .msg.unread .subject { font-weight: 700; }
/* the unread dot hangs in the strip left of the checkbox so sender, subject and preview share one text edge */
.msg.unread .l1 { position: relative; }
.msg.unread .l1::before { content: ""; position: absolute; left: -37.5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 0 1px var(--acc-edge); }
.m-icons { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.m-icons .hi { color: var(--danger); }
.m-icons .flag { color: var(--danger); }
.date { font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg.unread .date { color: var(--text); font-weight: 600; }
.subject { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.preview-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-3); }
.size { font: 500 11px/1 var(--mono); color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip-draft { font: 500 10.5px/1 var(--mono); color: var(--danger); text-transform: uppercase; letter-spacing: .08em; flex: none; }
.row-peek {
  margin-left: auto; position: relative;
  opacity: 0; border: 0; background: transparent; padding: 2px; border-radius: 6px; color: var(--text-2);
  display: inline-grid; place-items: center; transition: opacity .1s;
}
.msg:hover .row-peek, .msg:focus-within .row-peek { opacity: 1; }
@media (pointer: coarse) { .row-peek { opacity: 1; } }
.row-peek:hover { background: var(--surface-3); color: var(--text); }

.list-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3);
  min-height: 52px;
}
.list-state { padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-2); }
.list-state .state-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); margin-bottom: 4px; }
.list-state.error .state-ico { background: var(--danger-weak); color: var(--danger); }
.list-state h3 { font-size: 15px; color: var(--text); }

/* ---------- 8. Center rail ---------- */
.rail { display: flex; align-items: center; align-items: safe center; justify-content: center; padding: 0 12px; min-height: 0; overflow-y: auto; }
.rail-inner { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: 100%; }
.rail-count {
  align-self: center; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 999px; background: var(--acc-weak); color: var(--acc-strong);
  font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap;
}
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 6px; border-radius: 14px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 13px; line-height: 1.2; text-align: center;
  box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease), box-shadow .12s, background-color .12s, opacity .12s;
}
.rail-btn .rail-ico { display: flex; align-items: center; gap: 2px; }
.rail-btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.rail-btn:not(:disabled):active { transform: translateY(0); }
.rail-btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--ink); }
.rail-btn.primary:disabled { background: var(--surface-2); color: var(--text-3); border: 1.5px dashed var(--border-strong); opacity: 1; }
.rail-btn:disabled .ico { color: var(--text-3); }
.rail-btn.primary:not(:disabled):hover { background: var(--accent-strong); }
:root[data-theme="dark"] .rail-btn.primary { border-color: var(--accent); }
.rail-btn.warn .ico:first-child { color: var(--warn); }
.rail-btn:disabled { opacity: .42; box-shadow: none; border-color: var(--border); }
.rail-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.rail-hint { font-size: 11.5px; color: var(--text-3); text-align: center; line-height: 1.35; overflow-wrap: anywhere; }
.rail-hint:empty { display: none; }
.rail-note { color: var(--text-2); }
@media (max-width: 1179px) { .rail-idle { display: none; } }
.rail-group { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.rail-group + .rail-group:not(.rail-folders) { margin-top: 4px; padding-top: 12px; }
.rail-group + .rail-group:not(.rail-folders)::before { content: ''; height: 1px; margin: -12px 8px 6px; background: linear-gradient(90deg, var(--border-strong) 50%, transparent 0) 0 0 / 6px 1px repeat-x; }
.rail-count:empty { display: none; }
.rail-label { display: inline-flex; align-items: center; gap: 4px; }
.rail-arrow { font-weight: 800; }
.rail-cap {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  font-size: 11.5px; font-weight: 500; letter-spacing: .02em; color: var(--text-2); overflow-wrap: anywhere;
}
.rail-btn.primary:not(:disabled) .rail-cap { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.rail-folders .rail-btn { padding: 9px 6px; }

/* ---------- 9. Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 650; font-size: 13.5px; white-space: nowrap; text-decoration: none;
  transition: background-color .12s, border-color .12s, box-shadow .12s, transform .08s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn-primary:disabled, .btn-danger:disabled { opacity: 1; background: var(--surface-3); color: var(--text-3); border-color: var(--border); box-shadow: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--ink); font-weight: 750; box-shadow: 0 1px 0 rgb(22 20 15 / .12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--ink); }
:root[data-theme="dark"] .btn-primary { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: var(--on-danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-ghost-danger:hover:not(:disabled) { background: var(--danger-weak); border-color: transparent; }
.btn-link { border: 0; background: none; padding: 0; color: var(--acc-strong, var(--text)); text-decoration-color: currentColor; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.btn-link:hover { text-decoration-thickness: 2px; }
.btn .spinner { width: 14px; height: 14px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  display: inline-grid; place-items: center; color: var(--text-2); flex: none;
  transition: background-color .12s, color .12s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 6px; }

.input {
  height: 38px; padding: 0 12px; border-radius: 10px; width: 100%;
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus-visible, .search-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 13px; }
.field-help { font-size: 12.5px; color: var(--text-2); }
.field-help.warn { color: var(--warn); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check .cbox { margin-top: 1px; --acc: var(--accent); --on-acc: var(--on-accent); --acc-edge: var(--mba-edge); }
.check-text { display: flex; flex-direction: column; gap: 2px; }
.check-text strong { font-weight: 600; }
.check-text span { font-size: 12.5px; color: var(--text-2); }
.form-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-weak); color: var(--text); font-size: 13px; }
.form-error .ico { color: var(--danger); margin-top: 1px; }
[aria-invalid="true"] { border-color: var(--danger); }

/* segmented radio cards */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 0; padding: 0; margin: 0; }
.seg legend { font-weight: 600; font-size: 13px; margin-bottom: 6px; padding: 0; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface);
  transition: border-color .12s, background-color .12s, box-shadow .12s; height: 100%;
}
.seg-card .ico { margin-top: 1px; color: var(--text-2); }
.seg-card strong { display: block; font-size: 13.5px; }
.seg-card span { font-size: 12.5px; color: var(--text-2); }
.seg-opt input:hover + .seg-card { border-color: var(--border-strong); }
.seg-opt input:checked + .seg-card { border-color: var(--text); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--text); }
.seg-opt input:checked + .seg-card .ico { color: var(--accent-text); }
.seg-opt.danger input:checked + .seg-card { border-color: var(--danger); background: var(--danger-weak); box-shadow: 0 0 0 1px var(--danger); }
.seg-opt.danger input:checked + .seg-card .ico { color: var(--danger); }
.seg-opt input:focus-visible + .seg-card { outline: 2px solid var(--focus); outline-offset: 2px; }
.seg-opt input:disabled { cursor: not-allowed; }
.seg-opt input:disabled + .seg-card { background: var(--surface-2); border-style: dashed; }
.seg-opt input:disabled + .seg-card strong, .seg-opt input:disabled + .seg-card .ico { color: var(--text-3); }

/* callouts */
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; border: 1px solid transparent; }
.callout > .ico { margin-top: 2px; }
.callout-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.callout strong { font-weight: 650; }
.callout.info { background: var(--info-weak); }
.callout.info > .ico { color: var(--info); }
.callout.warn { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout.warn > .ico { color: var(--warn); }
.callout.danger { background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger > .ico { color: var(--danger); }
.callout.ok { background: var(--ok-weak); }
.callout.ok > .ico { color: var(--ok); }

/* ---------- 10. Modals ---------- */
dialog.modal {
  padding: 0; border: 0; background: transparent; color: var(--text);
  width: min(560px, calc(100vw - 32px)); max-width: none;
  max-height: calc(100dvh - 40px); overflow: visible;
}
dialog.modal.modal-sm { width: min(440px, calc(100vw - 32px)); }
dialog.modal.modal-lg { width: min(860px, calc(100vw - 32px)); }
dialog.modal.consent-modal { width: min(640px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modal-in .16s var(--ease); }
dialog.modal[open]::backdrop { animation: fade-in .16s ease; }
.modal-card {
  background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; max-height: calc(100dvh - 40px); overflow: hidden;
  border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 4px var(--modal-pad-x); }
.modal-head-text { flex: 1; min-width: 0; }
.modal-title { font-family: var(--display); font-size: 27px; font-weight: 800; letter-spacing: .015em; line-height: 1.08; text-transform: uppercase; overflow-wrap: anywhere; }
.preview .modal-title { font-family: var(--font); font-size: 19px; font-weight: 700; letter-spacing: -.01em; text-transform: none; line-height: 1.3; }
.modal-subtitle { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.modal-x { margin: -6px -8px 0 0; }
.modal-body { padding: 14px var(--modal-pad-x) 20px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; row-gap: 8px; padding: 14px var(--modal-pad-x); border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-alert:empty { display: none; }
.modal-body > details { flex: none; } /* the body scrolls; an opened fold keeps its height */
/* completed job: the hero is the headline, the job title becomes an eyebrow */
.progress-modal.is-done .modal-title { font: 500 13px/1.4 var(--mono); letter-spacing: .02em; text-transform: none; color: var(--text-2); }
.modal-foot:empty { display: none; }
.modal-foot .spacer { flex: 1; }

/* route card (from → to) */
.route { display: grid; grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); align-items: stretch; }
.route-end {
  border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-top: 3px solid var(--acc);
}
.route-tag { font: 500 10.5px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--acc-strong); }
.route-acct { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-folder { display: flex; align-items: flex-start; gap: 7px; font-weight: 650; min-width: 0; }
.route-folder > .ico { color: var(--acc-strong); margin-top: 2px; }
.rf-text { min-width: 0; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; }
.route-folder .btn-link { flex: none; white-space: nowrap; font-size: 13px; }
.rf-parent { color: var(--text-3); font-weight: 500; }
.route-folder.empty .rf-name { color: var(--text-3); font-weight: 500; font-style: italic; }
.route-arrow { display: grid; place-items: center; color: var(--text-3); align-self: center; }
.pills { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pill-opt { display: flex; align-self: stretch; align-items: flex-start; gap: 8px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.pill-opt input { margin: 2px 0 0; accent-color: var(--text); }
.pill-opt:has(input:checked) { border-color: var(--text); background: var(--accent-soft); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
/* move confirmation: compact, not a wall of red */
.move-note { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 13px; border: 1px solid var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.move-note > p { display: flex; gap: 10px; }
.move-note > p .ico { color: var(--danger); margin-top: 2px; }
.stat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.stat-chip strong { color: var(--text); }
.confirm-type { display: flex; flex-direction: column; gap: 6px; }
.confirm-type label { font-size: 13px; }
.confirm-type code { user-select: all; }
.options-stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- 11. Progress ---------- */
.state-badge {
  display: inline-flex; align-items: center; gap: 6px; font: 500 10.5px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.state-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state-badge.s-running, .state-badge.s-scanning { background: var(--mba-weak); color: var(--mba-strong); }
.state-badge.s-running::before, .state-badge.s-scanning::before { animation: pulse 1.2s ease-in-out infinite; }
.state-badge.s-queued { background: var(--surface-3); color: var(--text-2); }
.state-badge.s-waitingForLogin { background: var(--warn-weak); color: var(--warn); }
.state-badge.s-completed { background: var(--ok-weak); color: var(--ok); }
.state-badge.s-failed { background: var(--danger-weak); color: var(--danger); }
.state-badge.s-cancelled { background: var(--surface-3); color: var(--text-2); }
.state-badge.s-partial, .state-badge.s-payment { background: var(--warn-weak); color: var(--warn); }

.prog-route { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.prog-route .pt { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--acc-weak); color: var(--acc-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--acc); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-wrap { display: flex; flex-direction: column; gap: 8px; }
.bar-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bar-pct { font-family: var(--display); font-size: 40px; font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; line-height: 1; text-transform: uppercase; }
.bar-count { font: 500 12px/1.3 var(--mono); letter-spacing: .02em; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; position: relative; box-shadow: inset 0 0 0 1px var(--border); }
.bar.lg { height: 10px; padding: 0; box-shadow: inset 0 0 0 1px var(--border-strong); }
.bar-phase { font-size: 12px; color: var(--text-2); }
.bar-phase:empty { display: none; }
.credit-used { font-size: 13px; color: var(--text-2); }
.credit-used:empty { display: none; }
.bar-fill { height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .45s var(--ease); position: relative; overflow: hidden; }
.bar-fill.live::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .35), transparent); transform: translateX(-100%); animation: shimmer 1.8s infinite; }
.bar.indeterminate .bar-fill { width: 35% !important; animation: indet 1.4s var(--ease) infinite; }
.bar.s-failed .bar-fill { background: var(--danger); }
.bar.s-cancelled .bar-fill { background: var(--text-3); }
.bar.s-partial .bar-fill { background: var(--warn); }
.bar.s-ok .bar-fill { background: var(--ok); }
.bar.s-payment .bar-fill { background: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font: 500 10.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: .01em; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.ok .stat-label .ico { color: var(--ok); }
.stat.skip .stat-label .ico { color: var(--text-3); }
.stat.fail .stat-label .ico { color: var(--danger); }
.stat.fail.has .stat-value { color: var(--danger); }
.stat-of { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-line { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); min-width: 0; }
.now-line .now-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 500; }
.meta-line { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.meta-line span { display: inline-flex; gap: 8px; align-items: center; }

.progress-modal.is-done .prog-route { justify-content: center; }
.summary-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 6px 0 4px; }
.hero-art { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.hero-art::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; opacity: .45; background: inherit; z-index: -1; }
.hero-art { isolation: isolate; }
.hero-art.ok { background: var(--ok-weak); color: var(--ok); }
.hero-art.partial { background: var(--warn-weak); color: var(--warn); }
.hero-art.failed { background: var(--danger-weak); color: var(--danger); }
.hero-art.cancelled { background: var(--surface-3); color: var(--text-2); }
.hero-art.payment { background: var(--accent-soft); color: var(--accent-text); }
.hero-art .ico { animation: pop-in .35s var(--ease); }
.summary-hero h3 { font-family: var(--display); font-size: 30px; font-weight: 800; letter-spacing: .015em; text-transform: uppercase; line-height: 1.05; }
.summary-hero p { color: var(--text-2); max-width: 460px; }
.warn-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.warn-list li { display: flex; gap: 8px; font-size: 13px; }
.warn-list .ico { color: var(--warn); margin-top: 2px; }
details.fold { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
details.fold > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; background: var(--surface-2); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { transition: transform .15s var(--ease); color: var(--text-3); }
details.fold[open] > summary .chev { transform: rotate(90deg); }
.fail-table-wrap { max-height: 240px; overflow: auto; }
table.fail-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fail-table th, .fail-table td { text-align: left; padding: 8px 14px; border-top: 1px solid var(--border-soft); vertical-align: top; }
.fail-table th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 12px; }
.fail-table td:first-child { font-weight: 500; max-width: 260px; overflow-wrap: anywhere; }
.fail-table td:last-child { color: var(--danger); }

/* ---------- 12. Jobs tray (drawer) ---------- */
dialog.modal.modal-drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(440px, 100vw);
}
dialog.modal.modal-drawer[open] { animation: drawer-in .2s var(--ease); }
.modal-drawer .modal-card { height: 100%; max-height: 100dvh; border-radius: var(--radius-xl) 0 0 var(--radius-xl); border-right: 0; }
.modal-drawer .modal-body { flex: 1; padding: 12px 16px 20px; gap: 10px; }
.modal-drawer .modal-head { padding-left: 16px; padding-right: 15px; }
.job-item {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.job-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.job-top { display: flex; align-items: flex-start; gap: 10px; }
.job-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.job-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.job-item .bar { height: 6px; }
.job-route { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-2); }
.job-route .jr-end { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: var(--acc-weak); color: var(--acc-strong); font-weight: 600; }
.job-route .jr-arrow { flex: none; font-weight: 800; }
.jobs-empty { text-align: center; padding: 48px 20px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.jobs-empty .state-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }

/* ---------- 13. Message preview ---------- */
.preview-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; font-size: 13px; }
.preview-meta dt { color: var(--text-3); font-weight: 600; }
.preview-meta dd { margin: 0; overflow-wrap: anywhere; }
.att-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.att-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; max-width: 100%; }
.att-chip .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.att-chip .att-size { color: var(--text-2); }
.att-chip.inline-att { border-style: dashed; }
.mail-frame-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; flex: 1; min-height: 340px; display: flex; }
.mail-frame { border: 0; width: 100%; min-height: 340px; height: 55vh; background: #fff; display: block; }
.privacy-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.preview .modal-body { gap: 14px; }

/* ---------- 14. Folder picker ---------- */
.picker-tree { border: 1px solid var(--border); border-radius: 12px; max-height: min(46vh, 420px); overflow: auto; padding: 6px 0; background: var(--surface); }
.picker-tree .tree-row { margin: 1px 6px; }
.newfolder { display: flex; gap: 8px; align-items: center; }
.newfolder .input { flex: 1; }

/* ---------- 15. Help / setup ---------- */
.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .input { flex: 1; min-width: 0; height: auto; min-height: 38px; }
.step-line { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; font-weight: 600; counter-reset: step; }
.step-line li { counter-increment: step; display: inline-flex; align-items: center; gap: 6px; }
.step-line li::before { content: counter(step); display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font: 500 11px/1 var(--mono); }
.step-line li:not(:last-child)::after { content: "→"; color: var(--text-3); margin-left: 4px; }
.help-section { display: flex; flex-direction: column; gap: 10px; }
.help-section h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.domain-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 15b. Email credits ---------- */
/* banded modal header: near-black with girih texture */
.modal-banded .modal-head {
  padding: 22px 20px 20px 24px; color: var(--on-band);
  background: var(--girih-band) 0 0 / 84px 84px repeat, var(--band);
  --focus: #ffda6c;
}
.modal-banded .modal-title { color: var(--on-band); font-size: 32px; }
.modal-banded .modal-subtitle { color: var(--on-band-muted); font: 500 11px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; margin-top: 6px; }
.modal-banded .modal-x { color: var(--on-band); margin-top: -1px; }
.modal-banded .modal-x:hover:not(:disabled) { background: rgb(255 255 255 / .1); color: var(--on-band); }

/* pricing step (before sign-in) */
body.gated .workspace { display: none; }
.pricing {
  min-height: calc(100dvh - var(--header-h) - var(--banner-h, 0px));
  display: grid; place-items: center; align-content: center; gap: 24px; padding: 32px 16px;
  background: radial-gradient(ellipse 50% 46% at 50% 50%, var(--bg) 50%, transparent 100%), var(--girih) center / 84px 84px repeat, var(--bg);
}
@media (min-width: 1100px) {
  .pricing { grid-template-columns: minmax(0, 440px) minmax(0, 560px); justify-content: center; gap: 56px; }
}
.pricing[hidden] { display: none; }
.pricing-intro { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pricing-intro h1 { font-family: var(--display); font-weight: 800; font-size: clamp(34px, 6vw, 52px); line-height: .98; letter-spacing: .015em; text-transform: uppercase; outline: none; }
.pricing-sub { font-size: 15.5px; color: var(--text-2); }
.trust { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.trust li, .prereqs li { display: flex; gap: 10px; align-items: flex-start; }
.trust .ico { color: var(--accent-text); margin-top: 1px; }
.pricing-card {
  width: 100%; max-width: 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px;
  padding: clamp(18px, 5vw, 32px); border-radius: var(--radius-xl); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-modal);
}
.pricing-title { font-family: var(--display); font-weight: 800; font-size: 36px; line-height: 1; letter-spacing: .02em; text-transform: uppercase; }
.prereqs { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.prereqs h3 { font-size: 14px; }
.prereqs ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.prereqs li .ico { color: var(--ok); margin-top: 1px; }
.prereqs .fold-body { padding: 12px 14px; }
.price-line { font-size: 15px; color: var(--text-2); }
.price-line strong { font-family: var(--display); font-weight: 800; font-size: 30px; color: var(--text); letter-spacing: .01em; margin-right: 4px; }
.fine-print { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); }
.fine-print .ico { flex: none; margin-top: 2px; color: var(--ok); }
.buy-form { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.buy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.buy-qty { width: 130px; font: 500 16px/1 var(--mono); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 500 12.5px/1 var(--mono);
}
.chip:hover { border-color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.buy-total { font-size: 14px; color: var(--text-2); }
.buy-total strong { font-family: var(--display); font-size: 26px; font-weight: 800; color: var(--text); margin-left: 4px; }
.restore { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.restore-box { width: 100%; }
.next-steps { list-style: none; padding: 12px 14px; margin: 0; border-radius: 12px; background: var(--surface-2); font-size: 13px; color: var(--text-2); }

/* credits dialog + paid dialog */
.credits-modal .modal-body { gap: 18px; padding-top: 20px; }
.credit-stats { display: flex; gap: 28px; flex-wrap: wrap; }
.credit-stats > div { display: flex; flex-direction: column; gap: 4px; }
.big-num { font-family: var(--display); font-weight: 800; font-size: 48px; line-height: .95; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.big-num.muted { color: var(--text-3); }
.credit-stats .unit { font: 500 11px/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.access-code { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; border: 1.5px dashed var(--border-strong); background: var(--surface-2); }
.code-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.code-big { font: 500 19px/1.3 var(--mono); letter-spacing: .06em; color: var(--text); overflow-wrap: anywhere; user-select: all; padding: 0; border: 0; background: none; border-radius: 0; }
.topup .fold-body { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px 16px; }
.paid-art { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-weak); color: var(--ok); }
.hist-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.hist-table th { text-align: left; font: 500 10.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.hist-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.hist-table td.num { font-family: var(--mono); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.hist-table th:nth-child(2), .hist-table th:nth-child(3), .hist-table td:nth-child(2), .hist-table td:nth-child(3) { text-align: right; }
.hist-table td.who { overflow-wrap: anywhere; color: var(--text-2); }
.hist-wrap { border: 1px solid var(--border); border-radius: 14px; overflow: auto; max-height: 220px; }

/* billing line in confirmation dialogs */
.bill-line {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; border: 1px solid var(--border); background: var(--surface-2);
}
.bill-line > .ico { flex: none; color: var(--accent-text); }
.bill-line .bl-text { flex: 1; min-width: 0; }
.bill-line .bl-tag { font: 500 10px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); display: block; margin-bottom: 2px; }

/* in-mailbox selection actions */
.sel-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; gap: 6px; }
.sel-actions[hidden] { display: none; }

/* ---------- 16. Toasts ---------- */
/* bottom centre, lifted above the list footers (Load more) */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 12px 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  animation: toast-in .22s var(--ease);
  border-left: 4px solid var(--info);
}
.toast.leaving { animation: toast-out .18s ease forwards; }
.toast > .ico { margin-top: 1px; color: var(--info); }
.toast.success { border-left-color: var(--ok); } .toast.success > .ico { color: var(--ok); }
.toast.warn { border-left-color: var(--warn); } .toast.warn > .ico { color: var(--warn); }
.toast.error { border-left-color: var(--danger); } .toast.error > .ico { color: var(--danger); }
.toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast-title { font-weight: 700; font-size: 13.5px; }
.toast-msg { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.toast-actions { margin-top: 6px; display: flex; gap: 8px; }
.toast .icon-btn { margin: -4px -4px 0 0; }

/* ---------- 17. Skeletons & spinners ---------- */
.sk { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: sk 1.3s ease-in-out infinite; }
.sk-row { padding: 12px 16px 12px 44px; border-bottom: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 7px; }
.sk-tree { list-style: none; padding: 7px 16px 7px calc(16px + var(--lvl, 0) * 16px); display: flex; gap: 8px; align-items: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin .7s linear infinite; display: inline-block; flex: none; }
.spinner.lg { width: 28px; height: 28px; border-width: 3px; color: var(--accent-text); }

/* ---------- 18. Responsive ---------- */
@media (max-width: 1240px) {
  :root { --rail-w: 100px; }
}
@media (max-width: 1080px) {
  .acct-name { display: none; }
  .tenant-tag:not(.copy-only) { display: none; }
}
/* short viewports (200% zoom, phone landscape): the page scrolls and the list keeps a usable height */
@media (max-height: 600px) {
  body { overflow: auto; }
  #main { height: auto; }
  .workspace > .pane { height: max(460px, 70dvh); }
}
@media (max-width: 899px) {
  :root { --header-h: 56px; }
  .app-header { gap: 8px; }
  .brand-sub { display: none; }
  :root { --mark: 36px; }
  .brand-name { font-size: 26px; }
  .billing-btn { padding: 0 10px; }
  .billing-btn .billing-pill { display: none; }
  .modal-title { font-size: 24px; }
  .modal-banded .modal-title { font-size: 27px; }
  .modal-banded .modal-x { margin-top: -4px; }
  /* the panes stack (A, the rail, B) and the page scrolls */
  body { overflow: auto; }
  #main { height: auto; }
  .workspace { display: flex; flex-direction: column; }
  .workspace > .pane { height: auto; }
  .pane-body { flex: none; height: max(520px, 80dvh); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .folders { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--border); }
  .rail { padding: 12px 0; overflow: visible; }
  .rail-inner { display: grid; grid-template-columns: 1fr 1fr; }
  .rail-folders { grid-column: 1 / -1; flex-direction: row; }
  .rail-folders .rail-btn { flex: 1; }
  .rail-group + .rail-group:not(.rail-folders) { margin: 0; padding: 0; }
  .rail-sep, .rail-group + .rail-group:not(.rail-folders)::before { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .route { grid-template-columns: 1fr; gap: 6px; }
  .route-arrow { transform: rotate(90deg); height: 24px; }
  .seg { grid-template-columns: 1fr; }
  dialog.modal { --modal-pad-x: 18px; }
  .modal-body { padding: 12px var(--modal-pad-x) 18px; }
  .modal-foot { padding: 12px var(--modal-pad-x); }
  .modal-head { padding: 18px 16px 4px var(--modal-pad-x); }
  .modal-banded .modal-head { padding: 18px 14px 16px 18px; }
}
@media (max-width: 520px) {
  .tenant-tag.copy-only { display: none; } /* the rail says it; the address needs the room */
  .header-actions { gap: 2px; }
  .billing-btn .billing-ico-slot { display: none; }
  .billing-btn { padding: 0 9px; font-size: 12.5px; }
  .app-header { gap: 6px; }
  .brand { gap: 8px; }
  :root { --mark: 34px; }
  .brand-name { font-size: 24px; letter-spacing: .04em; }
  .app-header .icon-btn { width: 34px; }
  .app-header { --hdr-btn: 34px; }
  .hist-table th, .hist-table td { padding: 8px; }
  .hist-table th, .hist-table td.num { white-space: normal; }
  .code-row .btn { flex: 1 1 auto; }
  .hist-table td:first-child { min-width: calc(7ch + 16px); }
  /* the centred A → B route would wrap into staggered rows; stack it instead */
  .progress-modal.is-done .prog-route { flex-direction: column; }
  .progress-modal.is-done .prog-route > svg { transform: rotate(90deg); }
  /* dialog footers: the primary action on its own full-width row, the rest share one */
  .modal-foot .btn-primary, .modal-foot .btn-danger { order: -1; flex: 1 1 100%; }
  .modal-foot .btn:not(.btn-primary):not(.btn-danger) { flex: 1 1 0; }
  .modal-foot .spacer { display: none; }
  .preview .btn-text, .preview .preview-close { display: none; }
}
@media (max-width: 360px) { .hist-table th, .hist-table td { padding: 8px 6px; } }
@media (max-width: 430px) {
  /* narrow phones: a smaller mark and wordmark keep the name visible beside the header buttons */
  :root { --mark: 30px; }
  .brand-name { font-size: 22px; }
  .billing-label, .code-full { display: none; }
  .billing-short, .code-short { display: inline; }
}
@media (pointer: coarse) {
  .modal-foot .btn, .btn, .btn-sm { min-height: 44px; }
  .icon-btn, .icon-btn.sm { min-width: 40px; min-height: 40px; }
  .app-header { --hdr-btn: 40px; }
  .chip { min-height: 40px; }
  .btn-link { padding: 12px 4px; margin: -12px -4px; }
  .billing-btn, .switch { min-height: 40px; min-width: 40px; }
  .sel-actions .btn { min-width: 44px; }
}
@media (forced-colors: active) {
  .tree-row.is-selected, .msg.is-selected, .chip[aria-pressed="true"], .menu-item[aria-checked="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .menu-item[aria-checked="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ---------- 19. Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .bar.indeterminate .bar-fill { width: 100% !important; opacity: .5; }
}

/* wrapper that doesn't take part in layout (keeps flex gaps intact) */
.slot-contents { display: contents; }
