/* ---------- tokens ---------- */
/* Every tinted colour is derived from --hue, so the whole UI shifts hue as one. */
:root {
  --hue: 262;
  --bg: oklch(95.6% .012 var(--hue));
  --bg-dots: oklch(55% .04 var(--hue) / .16);
  --glass: oklch(100% 0 0 / .66);
  --glass-strong: oklch(100% 0 0 / .84);
  --glass-edge: oklch(100% 0 0 / .75);
  --surface: oklch(100% 0 0 / .78);
  --surface-2: oklch(50% .03 var(--hue) / .045);
  --field: oklch(100% 0 0 / .72);
  --hover: oklch(50% .06 var(--hue) / .075);
  --selected: oklch(60% .2 var(--hue) / .12);
  --border: oklch(40% .04 var(--hue) / .11);
  --border-strong: oklch(40% .04 var(--hue) / .2);
  --text: oklch(22% .02 var(--hue));
  --text-2: oklch(40% .025 var(--hue));
  --muted: oklch(55% .02 var(--hue));
  --accent: oklch(58% .2 var(--hue));
  --accent-hover: oklch(53% .21 var(--hue));
  --accent-soft: oklch(58% .2 var(--hue) / .13);
  --accent-ring: oklch(58% .2 var(--hue) / .22);
  --on-accent: #fff;
  --danger: oklch(57% .21 25);
  --danger-soft: oklch(57% .21 25 / .12);
  --success: oklch(55% .15 150);
  --success-soft: oklch(60% .15 150 / .14);
  --warning: oklch(60% .15 65);
  --warning-soft: oklch(75% .15 75 / .2);
  --amber: #ffb648;
  --shadow: 0 1px 2px oklch(30% .05 var(--hue) / .06), 0 6px 24px -10px oklch(30% .08 var(--hue) / .18);
  --shadow-lg: 0 2px 6px oklch(25% .05 var(--hue) / .08), 0 30px 70px -20px oklch(25% .1 var(--hue) / .35);
  --inner: inset 0 1px 0 oklch(100% 0 0 / .7);
  --scrim: oklch(25% .03 var(--hue) / .28);
  --blur: blur(22px) saturate(170%);
  --radius-xl: 22px;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: oklch(15.5% .012 var(--hue));
  --bg-dots: oklch(80% .04 var(--hue) / .07);
  --glass: oklch(22% .015 var(--hue) / .62);
  --glass-strong: oklch(24% .015 var(--hue) / .86);
  --glass-edge: oklch(100% 0 0 / .075);
  --surface: oklch(26% .015 var(--hue) / .7);
  --surface-2: oklch(100% 0 0 / .035);
  --field: oklch(100% 0 0 / .045);
  --hover: oklch(100% 0 0 / .06);
  --selected: oklch(70% .17 var(--hue) / .16);
  --border: oklch(100% 0 0 / .075);
  --border-strong: oklch(100% 0 0 / .13);
  --text: oklch(94% .008 var(--hue));
  --text-2: oklch(82% .012 var(--hue));
  --muted: oklch(66% .015 var(--hue));
  --accent: oklch(68% .17 var(--hue));
  --accent-hover: oklch(73% .15 var(--hue));
  --accent-soft: oklch(68% .17 var(--hue) / .17);
  --accent-ring: oklch(68% .17 var(--hue) / .3);
  --on-accent: #fff;
  --danger: oklch(70% .17 22);
  --danger-soft: oklch(65% .18 22 / .16);
  --success: oklch(76% .16 150);
  --success-soft: oklch(70% .15 150 / .14);
  --warning: oklch(82% .14 80);
  --warning-soft: oklch(78% .14 75 / .14);
  --shadow: 0 1px 2px oklch(0% 0 0 / .3), 0 8px 28px -12px oklch(0% 0 0 / .55);
  --shadow-lg: 0 2px 8px oklch(0% 0 0 / .3), 0 30px 80px -20px oklch(0% 0 0 / .7);
  --inner: inset 0 1px 0 oklch(100% 0 0 / .06);
  --scrim: oklch(5% .01 var(--hue) / .5);
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--text);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* The dot grid is drawn as a mask over a solid colour so it follows the theme. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bg-dots);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='1.5' cy='1.5' r='1.1'/%3E%3C/svg%3E");
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Ccircle cx='1.5' cy='1.5' r='1.1'/%3E%3C/svg%3E");
}
a { color: var(--accent); text-decoration: none; transition: color .2s var(--ease); }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 25px; letter-spacing: -.02em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-ring); }

/* thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* smooth theme switching (enabled only for the moment of the switch) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
  transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease), fill .45s var(--ease), box-shadow .45s var(--ease) !important;
}

#app { height: 100%; }
/* Inline SVG icons without a size of their own (an unstyled <svg> is
   300×150): roughly the size of the text around them. Zero specificity, so
   any component rule wins. */
:where(svg:not([width])) { width: 1.15em; height: 1.15em; flex: none; }

/* ---------- preloader ---------- */
#preloader {
  position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; justify-items: center; gap: 30px;
  background: var(--bg);
  transition: opacity .55s var(--ease), transform .55s var(--ease), filter .55s var(--ease), visibility 0s .55s;
}
/* Hidden as soon as the app drops #app.boot (works with any app.js version). */
#app:not(.boot) + #preloader { opacity: 0; transform: scale(1.06); filter: blur(10px); visibility: hidden; pointer-events: none; }
.pl-brand { display: flex; align-items: center; gap: 16px; animation: pl-in .8s var(--spring) both; }
/* The inline critical styles keep the brand hidden until this sheet applies. */
#preloader .pl-brand { visibility: visible; }
.pl-brand .logo-mark {
  width: 64px; height: 64px; padding: 12px; border-radius: 18px; color: var(--accent);
  background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--inner), 0 18px 30px -14px oklch(45% .2 var(--hue) / .45);
}
/* Endless loop: the strokes draw in, hold, then the tail chases them out.
   Paths use pathLength="100", so the dash maths is independent of geometry. */
.pl-brand .logo-mark .lm-frame, .pl-brand .logo-mark .lm-env { stroke-dasharray: 100; animation: pl-draw 2.8s var(--ease) infinite both; }
.pl-brand .logo-mark .lm-env { animation-delay: .25s; }
.pl-brand .wordmark { font-size: 32px; }
@keyframes pl-in { from { opacity: 0; transform: scale(.8) translateY(8px); } }
@keyframes pl-float { 50% { translate: 0 -6px; } }
@keyframes pl-draw {
  0% { stroke-dashoffset: 100; }
  40%, 70% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -100; }
}

/* ---------- motion primitives ---------- */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.96); filter: blur(4px); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(8px) scale(.97); filter: blur(4px); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-right-color: var(--accent);
  animation: spin .9s cubic-bezier(.55, .15, .45, .85) infinite;
}

/* ---------- controls ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 550 14.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--inner), 0 1px 2px oklch(30% .05 var(--hue) / .05);
  transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease), transform .25s var(--ease);
}
.btn:hover { background: var(--glass-strong); border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); transition-duration: .08s; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--accent); border-color: transparent; color: var(--on-accent);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .22), 0 6px 18px -6px oklch(55% .2 var(--hue) / .6);
}
.btn.primary:hover { background: var(--accent-hover); color: var(--on-accent); box-shadow: inset 0 1px 0 oklch(100% 0 0 / .22), 0 10px 24px -8px oklch(55% .2 var(--hue) / .7); transform: translateY(-1px); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: oklch(57% .21 25 / .4); color: var(--danger); }
/* .loading swaps the label for a spinner, keeping the button's size. */
.btn.loading, .btn.loading:disabled { color: transparent !important; opacity: 1; cursor: progress; }
.btn.loading svg { opacity: 0; }
.btn.loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.btn.primary.loading::after { border-color: oklch(100% 0 0 / .3); border-top-color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: var(--radius-xs); }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn svg { width: 17px; height: 17px; flex: none; transition: transform .3s var(--spring); }
.btn.icon:hover svg { transform: scale(1.1); }

input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; height: 40px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--field); color: var(--text);
  font: 15px var(--font);
  transition: border-color .2s var(--ease), box-shadow .25s var(--ease), background-color .2s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: oklch(45% .06 var(--hue) / .32); }
input:disabled, select:disabled, textarea:disabled { opacity: .65; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23889' 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 11px center; background-size: 16px;
}
select option { background: var(--bg); color: var(--text); }
textarea { height: auto; padding: 10px 13px; resize: vertical; line-height: 1.55; }
textarea.mono { font: 13px/1.55 var(--mono); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); background-color: var(--glass-strong); }

input[type=checkbox] {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--field);
  display: inline-grid; place-content: center;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
input[type=checkbox]::after {
  content: ""; width: 12px; height: 12px; background: var(--on-accent); transform: scale(0); transition: transform .25s var(--spring);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type=checkbox]:hover { border-color: var(--accent); }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { transform: scale(1); }
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
input[type=checkbox]:disabled { opacity: .5; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-weight: 550; font-size: 14px; color: var(--text-2); }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { margin-top: 2px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* ---------- glass surfaces ---------- */
.card, .topbar, .modal, .sidenav {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--inner), var(--shadow);
}

/* ---------- cards / tables ---------- */
.card { border-radius: var(--radius-xl); overflow: hidden; transition: box-shadow .3s var(--ease), border-color .3s var(--ease); }
.card-body { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.card + .card { margin-top: 18px; }
.content-inner { counter-reset: section; }
.content-inner .card-head > h3::before {
  counter-increment: section; content: counter(section, decimal-leading-zero);
  margin-right: 10px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.section-title p { margin: 5px 0 0; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr td { transition: background-color .2s var(--ease); }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl td.actions { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 25px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--hover); color: var(--text-2); white-space: nowrap;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge svg { width: 14px; height: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; position: relative; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.dot.err { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); animation: pulse 2s ease-in-out infinite; }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--text); font-size: 14px; border: 1px solid oklch(58% .2 var(--hue) / .14); }
.notice svg { width: 19px; height: 19px; flex: none; color: var(--accent); margin-top: 1px; }
.notice.warn { background: var(--warning-soft); border-color: oklch(70% .15 70 / .25); }
.notice.warn svg { color: var(--warning); }
.notice.err { background: var(--danger-soft); border-color: oklch(57% .21 25 / .2); }
.notice.err svg { color: var(--danger); }
.notice.ok { background: var(--success-soft); border-color: oklch(60% .15 150 / .2); }
.notice.ok svg { color: var(--success); }

.secret-box { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1.5px dashed var(--border-strong); font: 16px var(--mono); word-break: break-all; }
pre.code { margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); font: 12.5px/1.6 var(--mono); overflow: auto; white-space: pre; max-height: 480px; }

.meter { height: 7px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s var(--ease); }
.meter.warn > i { background: var(--warning); }
.meter.err > i { background: var(--danger); }

/* ---------- shell ---------- */
.shell {
  display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); gap: 12px; height: 100%;
  padding: 12px; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 4px; height: 60px; padding: 0 10px 0 12px;
  border-radius: var(--radius-xl);
}
.logo-mark { flex: none; color: var(--accent); }
.wordmark { font-weight: 700; letter-spacing: -.035em; color: var(--text); line-height: 1; }
.wordmark b { font-weight: inherit; color: var(--accent); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 16px; padding: 4px 8px 4px 4px; border-radius: var(--radius-sm); color: var(--text); }
.brand .logo-mark {
  width: 36px; height: 36px; padding: 6px; border-radius: 10px;
  background: var(--accent-soft); box-shadow: inset 0 0 0 1px oklch(58% .2 var(--hue) / .16);
  transition: transform .5s var(--spring);
}
.brand .wordmark { font-size: 18px; }
.brand:hover { color: var(--text); }
.brand:hover .logo-mark { transform: rotate(-8deg) scale(1.08); }
.nav-tab {
  height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 15px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550;
  transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.nav-tab svg { width: 18px; height: 18px; transition: transform .35s var(--spring); }
.nav-tab:hover { background: var(--hover); color: var(--text); }
.nav-tab:hover svg { transform: translateY(-1px) scale(1.06); }
.nav-tab.active { background: var(--accent-soft); color: var(--accent); }
.topbar .spacer { flex: 1; }
.seg { display: inline-flex; gap: 2px; padding: 3px; margin: 0 4px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  border: 0; background: none; height: 26px; padding: 0 10px; border-radius: 99px; cursor: pointer;
  font: 650 11.5px var(--font); letter-spacing: .04em; color: var(--muted); transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--glass-strong); color: var(--accent); box-shadow: var(--inner), 0 1px 3px oklch(30% .05 var(--hue) / .12), 0 0 0 1px var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; margin: 0 4px; color: var(--text-2); font: 14px var(--font); border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.user-chip:hover, .user-chip[aria-expanded="true"] { background: var(--hover); border-color: var(--border-strong); color: var(--text); }
.user-chip .chev { width: 15px; height: 15px; color: var(--muted); margin-left: -2px; transition: transform .3s var(--ease); }
.user-chip[aria-expanded="true"] .chev { transform: rotate(180deg); }
.topbar-prefs { display: flex; align-items: center; }

/* account menu (under the user chip) */
.acct-menu {
  position: absolute; top: calc(100% + 8px); right: 6px; z-index: 30; width: min(340px, calc(100vw - 24px));
  padding: 6px; border-radius: var(--radius); background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge); box-shadow: var(--inner), var(--shadow-lg);
  animation: pop .35s var(--spring) both; transform-origin: top right;
}
.acct-head { display: flex; align-items: center; gap: 4px; padding-right: 4px; }
.acct-head .acct-item { flex: 1; }
.acct-item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-width: 0; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); font: 14px var(--font); text-align: left;
}
button.acct-item { cursor: pointer; transition: background-color .2s var(--ease); }
button.acct-item:hover { background: var(--hover); }
.acct-item .avatar { width: 36px; height: 36px; }
.acct-who { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.acct-who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who b { font-weight: 600; }
.acct-check { width: 18px; height: 18px; color: var(--accent); }
.acct-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.acct-others:not(:empty), .acct-actions { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.acct-action {
  display: flex; align-items: center; gap: 11px; width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-2); font: 550 14px var(--font); cursor: pointer; text-align: left; transition: background-color .2s var(--ease), color .2s var(--ease);
}
.acct-action > span, .acct-action { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-action svg { width: 18px; height: 18px; }
.acct-action:hover { background: var(--hover); color: var(--text); }
.acct-action.danger:hover { background: var(--danger-soft); color: var(--danger); }
.acct-prefs { display: none; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); margin-top: 6px; padding: 8px 4px 2px; }
.acct-continue { margin-bottom: 4px; }
.acct-continue .acct-label { padding-left: 0; }
.acct-continue .acct-item { padding-left: 6px; border: 1px solid var(--border); margin-top: 6px; }
/* a name with an icon in a table cell (passkeys, ...) */
.cell-ic { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.cell-ic svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.user-chip:active { transform: scale(.97); transition-duration: .08s; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 13px;
  background: var(--accent); color: var(--on-accent); flex: none; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .25);
}
.main { min-height: 0; overflow: hidden; }
.mail { animation: rise .55s var(--ease) both; }

/* side-nav layouts (settings/admin) */
.page { display: grid; grid-template-columns: 260px 1fr; gap: 12px; height: 100%; }
.sidenav { border-radius: var(--radius-xl); padding: 12px 10px; overflow-y: auto; }
.sidenav a {
  display: flex; align-items: center; gap: 11px; height: 42px; padding: 0 13px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; position: relative;
  transition: background-color .25s var(--ease), color .25s var(--ease), padding .3s var(--ease);
}
.sidenav a svg { width: 19px; height: 19px; opacity: .8; transition: opacity .2s, transform .35s var(--spring); }
.sidenav a + a { margin-top: 3px; }
.sidenav a:hover { background: var(--hover); color: var(--text); }
.sidenav a:hover svg { opacity: 1; transform: scale(1.08); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.sidenav a.active svg { opacity: 1; }
.sidenav a.active::before { content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); animation: fade .4s var(--ease); }
.sidenav .group { margin: 8px 13px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.content { overflow-y: auto; padding: 18px 20px 56px; border-radius: var(--radius-xl); }
.content-inner { max-width: 1040px; margin: 0 auto; animation: rise .5s var(--ease) both; }

/* ---------- login ---------- */
.auth-wrap { position: relative; min-height: 100%; display: grid; place-items: center; padding: 28px 16px; animation: fade .5s var(--ease) both; }
.auth-card { position: relative; z-index: 1; width: 100%; max-width: 780px; animation: pop .7s var(--ease) both; }
/* No frame: a light edge would show as a white line beside the tinted panel. */
/* No live backdrop blur either: the background animates, and re-blurring it
   every frame is expensive. Only the static glow shows through the glass. */
.auth-card .card { display: grid; grid-template-columns: 340px 1fr; border: 0; box-shadow: var(--shadow-lg); -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--glass-strong); }
:root[data-theme="dark"] .auth-card .card { box-shadow: 0 0 0 1px oklch(100% 0 0 / .05), var(--shadow-lg); }

/* Sign-in background: the dot grid gives way to a flowing ribbon of lines. */
body:has(.auth-wrap)::before { display: none; }
.auth-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; animation: fade 1.2s var(--ease) both;
  --aw-a: oklch(62% .2 var(--hue) / .2); --aw-b: oklch(60% .21 var(--hue)); --aw-c: oklch(72% .14 225 / .55);
}
:root[data-theme="dark"] .auth-bg { --aw-b: oklch(68% .18 var(--hue)); }
/* The glow is static and sits on its own layer, so redrawing the lines above
   it never re-runs the blur. */
.aw-glow { position: absolute; inset: 0; width: 100%; height: 100%; transform: translateZ(0); }
.aw-glow path { fill: none; stroke: oklch(62% .2 var(--hue) / .22); stroke-width: 90; stroke-linecap: round; filter: blur(40px); }
:root[data-theme="dark"] .aw-glow path { stroke: oklch(55% .2 var(--hue) / .35); }
.auth-bg canvas { position: absolute; left: 0; width: 100%; }
/* Left: brand panel. Its tint is drawn on a layer that reaches under the form
   and fades out, so the two halves blend without a seam. */
.auth-side { position: relative; z-index: 0; display: flex; flex-direction: column; gap: 14px; padding: 38px 34px; }
.auth-side::before {
  content: ""; position: absolute; inset: 0 -160px 0 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 70% at 0% 0%, oklch(62% .2 var(--hue) / .2), transparent 60%),
    radial-gradient(90% 60% at 30% 100%, oklch(70% .15 calc(var(--hue) - 40) / .14), transparent 65%),
    var(--accent-soft);
  -webkit-mask: linear-gradient(90deg, #000 45%, transparent);
  mask: linear-gradient(90deg, #000 45%, transparent);
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .logo-mark {
  width: 52px; height: 52px; padding: 10px; border-radius: 15px;
  background: var(--glass-strong); box-shadow: inset 0 0 0 1px oklch(58% .2 var(--hue) / .16), 0 14px 28px -14px oklch(50% .2 var(--hue) / .55);
  animation: pl-in .8s var(--spring) .1s both;
}
.auth-brand .wordmark { font-size: 27px; }
.auth-tagline { color: var(--text-2); font-size: 15px; line-height: 1.5; margin: 6px 0 0; max-width: 260px; }
.auth-feats { list-style: none; margin: auto 0 0; padding: 22px 0 0; display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: var(--text-2); }
.auth-feats li { display: flex; align-items: center; gap: 11px; animation: rise .6s var(--ease) both; }
.auth-feats li:nth-child(2) { animation-delay: .08s; }
.auth-feats li:nth-child(3) { animation-delay: .16s; }
.auth-feats .ic {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--glass-strong); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border);
}
.auth-feats .ic svg { width: 17px; height: 17px; }
/* Right: the form. */
.auth-main { position: relative; z-index: 1; padding: 38px 38px 32px; min-width: 0; }
.auth-head { margin-bottom: 24px; }
.auth-head p { color: var(--muted); margin-top: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 18px 0; text-transform: uppercase; letter-spacing: .06em; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-foot { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; }
@media (max-width: 760px) {
  .auth-card { max-width: 430px; }
  .auth-card .card { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 26px 8px; }
  .auth-side::before { inset: 0 0 -70px 0; -webkit-mask: linear-gradient(180deg, #000 30%, transparent); mask: linear-gradient(180deg, #000 30%, transparent); }
  .auth-tagline, .auth-feats { display: none; }
  .auth-brand .logo-mark { width: 44px; height: 44px; padding: 8px; border-radius: 13px; }
  .auth-brand .wordmark { font-size: 23px; }
  .auth-main { padding: 26px 26px 24px; }
}
.otp-input { text-align: center; letter-spacing: .4em; font: 600 22px var(--mono) !important; height: 52px !important; }

/* ---------- webmail ---------- */
.mail { display: grid; grid-template-columns: 252px minmax(320px, 430px) 1fr; gap: 12px; height: 100%; }
.folders, .list-pane, .reader {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge); box-shadow: var(--inner), var(--shadow);
  border-radius: var(--radius-xl); min-height: 0;
}
.folders { display: flex; flex-direction: column; overflow: hidden; }
.folders .compose-btn { margin: 14px 12px 12px; height: 46px; font-size: 15px; border-radius: var(--radius); }
.folders .compose-btn svg { width: 18px; height: 18px; overflow: visible; }
/* Compose keeps its blue on hover; a highlight sweeps across instead, and the
   pencil writes out its line again. */
.compose-btn { overflow: hidden; }
.compose-btn::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, oklch(100% 0 0 / .32) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn.primary.compose-btn:hover {
  background: var(--accent); filter: brightness(1.06);
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / .22), 0 10px 24px -8px oklch(55% .2 var(--hue) / .7);
}
.compose-btn:hover::after { transform: translateX(120%); transition: transform .8s var(--ease); }
.compose-btn svg path { transform-box: view-box; }
.compose-btn .pen { transform-origin: 5px 18px; }
.compose-btn .ink { stroke-dasharray: 10; }
.compose-btn:hover .pen { animation: ic-scribble .9s var(--ease); }
.compose-btn:hover .ink { animation: ic-ink .9s linear; }
@keyframes ic-scribble {
  0% { transform: translate(0, 0); }
  15% { transform: translate(2px, 1.5px) rotate(-6deg); }
  35% { transform: translate(4.5px, 1px) rotate(4deg); }
  55% { transform: translate(7px, 1.5px) rotate(-6deg); }
  75% { transform: translate(9.5px, 1px) rotate(3deg); }
}
@keyframes ic-ink {
  0%, 10% { stroke-dashoffset: 10; }
  80%, 100% { stroke-dashoffset: 0; }
}
.folder-list { overflow-y: auto; padding: 0 10px 12px; flex: 1; }
.folder {
  display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; user-select: none; position: relative;
  transition: background-color .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.folder svg { width: 19px; height: 19px; flex: none; opacity: .8; transition: transform .35s var(--spring), opacity .2s; }
.folder .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--on-accent); background: var(--accent); }
.folder + .folder { margin-top: 3px; }
.folder .count.muted { color: var(--text-2); background: var(--hover); }
.folder:hover { background: var(--hover); color: var(--text); }
.folder:hover svg { opacity: 1; }

/* Folder icons: each one moves its own way on hover. */
.folder svg { overflow: visible; }
.folder svg path { transform-box: fill-box; transition: transform .45s var(--spring), opacity .3s var(--ease); }
/* inbox: the arrow drops into the tray and comes back from above */
.folder:hover [data-icon="f-inbox"] .arrow { animation: ic-drop .7s var(--ease); }
@keyframes ic-drop {
  45% { transform: translateY(7px); opacity: 0; }
  46% { transform: translateY(-7px); opacity: 0; }
}
/* drafts: the pencil scribbles */
[data-icon="f-drafts"] .pen { transform-origin: 0 100%; }
.folder:hover [data-icon="f-drafts"] .pen { animation: ic-write .8s var(--ease); }
@keyframes ic-write {
  20% { transform: translate(-2px, 1px) rotate(-8deg); }
  40% { transform: translate(0, -1px) rotate(4deg); }
  60% { transform: translate(-2px, 1px) rotate(-8deg); }
  80% { transform: translate(0, -1px) rotate(4deg); }
}
/* sent: the plane flies off and lands back */
[data-icon="f-sent"] .plane { transform-box: view-box; transform-origin: 12px 12px; }
.folder:hover [data-icon="f-sent"] .plane { animation: ic-fly .8s var(--ease); }
@keyframes ic-fly {
  40% { transform: translate(10px, -10px) scale(.7); opacity: 0; }
  41% { transform: translate(-10px, 10px) scale(.7); opacity: 0; }
}
/* archive: the lid lifts and tilts while hovered */
[data-icon="f-archive"] .lid { transform-origin: 0 100%; }
.folder:hover [data-icon="f-archive"] .lid { transform: translateY(-2.5px) rotate(-9deg); }
/* junk: the sign shakes, the exclamation mark blinks */
.folder:hover [data-icon="f-junk"] { animation: ic-shake .55s var(--ease); }
.folder:hover [data-icon="f-junk"] .mark { animation: ic-blink .55s steps(2) 2; }
@keyframes ic-shake {
  20% { transform: rotate(-12deg); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(3deg); }
}
@keyframes ic-blink { 50% { opacity: .15; } }
/* trash: the lid flips open while hovered */
/* both lid paths pivot around the same hinge, so they move as one piece */
[data-icon="f-trash"] .lid { transform-box: view-box; transform-origin: 3.5px 6.5px; }
.folder:hover [data-icon="f-trash"] .lid { transform: translateY(-1.5px) rotate(-16deg); }
/* custom folders: the front flap opens while hovered */
[data-icon="f-folder"] .flap { transform-origin: 50% 100%; }
.folder:hover [data-icon="f-folder"] .flap { transform: skewX(-20deg) scaleY(.74); }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder.active svg { opacity: 1; }
.folder.drop { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); transform: scale(1.02); }
.folders-foot { padding: 14px 14px 10px; border-top: 1px solid var(--border); }
.folders-foot .row { gap: 2px; }
.quota-line { font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .1em; }
.quota-line span + span { font-size: 12px; font-weight: 550; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }

.list-pane { display: flex; flex-direction: column; overflow: hidden; }
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 12px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; transition: color .2s; }
.search input { padding-left: 39px; border-radius: 99px; background: var(--surface-2); border-color: transparent; }
.search input:focus { background: var(--glass-strong); }
.search:focus-within svg { color: var(--accent); }
.list-tools { display: flex; align-items: center; gap: 2px; min-height: 32px; }
.list-tools .sel-count { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); margin-left: 6px; }
.list-tools .sel-count:not(:empty) { animation: fade .3s var(--ease); }
.msg-list { overflow-y: auto; flex: 1; padding: 6px 8px; }
.msg {
  display: grid; grid-template-columns: 20px 1fr auto; gap: 3px 12px; padding: 12px 14px 12px 14px;
  border-radius: var(--radius); cursor: pointer; position: relative; margin-bottom: 2px;
  transition: background-color .22s var(--ease), box-shadow .22s var(--ease), transform .22s var(--ease);
}
.msg + .msg::after { content: ""; position: absolute; left: 48px; right: 14px; top: -1px; border-top: 1px solid var(--border); transition: opacity .2s; }
.msg:hover::after, .msg:hover + .msg::after, .msg.active::after, .msg.active + .msg::after { opacity: 0; }
.msg:hover { background: var(--hover); }
.msg.active { background: var(--selected); box-shadow: inset 0 0 0 1px oklch(58% .2 var(--hue) / .18); }
.msg.unread .from, .msg.unread .subj { font-weight: 650; color: var(--text); }
.msg.unread::before { content: ""; position: absolute; left: 4px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.msg .cb { grid-row: 1 / span 3; padding-top: 2px; }
.msg .from { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.msg .date { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg.unread .date { color: var(--accent); font-weight: 600; }
.msg .subj { grid-column: 2 / span 2; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; font-size: 14.5px; }
.msg .snip { grid-column: 2 / span 2; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .icons { display: inline-flex; gap: 4px; color: var(--muted); flex: none; }
.msg .icons svg { width: 15px; height: 15px; }
.msg .icons .flag { color: var(--amber); }
.msg .icons .lock { color: var(--success); }
.list-more { padding: 12px; text-align: center; }

.reader { overflow-y: auto; position: relative; }
.reader-empty { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; animation: fade .4s var(--ease); }
.reader-empty svg { width: 64px; height: 64px; opacity: .25; margin-bottom: 12px; stroke-width: 1.2; animation: pl-float 4s ease-in-out infinite; }
.reader-toolbar {
  position: sticky; top: 0; z-index: 2; display: flex; gap: 2px; padding: 10px 14px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.reader-body { padding: 26px 32px 48px; animation: rise .45s var(--ease) both; }
.reader h1 { font-size: 24px; line-height: 1.3; margin-bottom: 18px; word-break: break-word; }
.msg-meta { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.msg-meta .avatar { width: 44px; height: 44px; font-size: 15px; }
.msg-meta .who { flex: 1; min-width: 0; }
.msg-meta .who b { font-weight: 650; }
.msg-meta .who .addr { color: var(--muted); }
.msg-meta .to { color: var(--muted); font-size: 13.5px; word-break: break-word; }
.msg-meta .when { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.msg-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.msg-frame { width: 100%; border: 0; display: block; min-height: 80px; background: #fff; border-radius: var(--radius); }
.msg-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.65; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.att {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; max-width: 300px; color: var(--text);
  transition: border-color .2s var(--ease), background-color .2s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
.att:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow); }
.att svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.att .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.mobile-back { display: none; }

/* ---------- modal / compose ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(10px) saturate(120%); backdrop-filter: blur(10px) saturate(120%);
  animation: fade .3s var(--ease) both;
}
.overlay.closing { animation: fade-out .22s var(--ease) both; }
.modal {
  width: 100%; max-width: 500px; max-height: calc(100vh - 40px); overflow: auto;
  background: var(--glass-strong); border-radius: var(--radius-xl); box-shadow: var(--inner), var(--shadow-lg);
  animation: pop .45s var(--spring) both;
}
.overlay.closing .modal { animation: pop-out .22s var(--ease) both; }
.modal.wide { max-width: 800px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 16px 24px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.compose { max-width: 860px; display: flex; flex-direction: column; height: min(800px, calc(100vh - 40px)); }
.compose .modal-body { flex: 1; display: flex; flex-direction: column; gap: 0; padding: 0; overflow: auto; }
.cline { display: flex; align-items: center; gap: 8px; padding: 6px 24px; border-bottom: 1px solid var(--border); transition: background-color .2s var(--ease); }
.cline:focus-within { background: var(--surface-2); }
.cline > label { width: 70px; color: var(--muted); font-size: 14px; flex: none; }
.cline input { border: 0; box-shadow: none !important; padding: 0; height: 36px; background: transparent !important; }
.compose textarea.body { flex: 1; border: 0; border-radius: 0; padding: 18px 24px; min-height: 260px; resize: none; box-shadow: none !important; font-size: 15px; background: transparent !important; }
.compose .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 24px 0; }
/* rich-text editor */
.rte { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.rte-toolbar {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 1px; flex-wrap: wrap;
  padding: 6px 14px; border-bottom: 1px solid var(--border); background: var(--glass-strong);
}
.rte-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px; height: 32px; min-width: 30px; padding: 0 5px;
  border: 0; border-radius: var(--radius-xs); background: none; color: var(--text-2); cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.rte-btn svg { width: 17px; height: 17px; }
.rte-btn .rte-caret { width: 11px; height: 11px; opacity: .6; }
.rte-btn:hover { background: var(--hover); color: var(--text); }
.rte-btn.on { background: var(--accent-soft); color: var(--accent); }
.rte-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border-strong); flex: none; }
.rte-pop {
  position: absolute; z-index: 5; padding: 6px; border-radius: var(--radius-sm); background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-lg);
  animation: pop .25s var(--spring) both;
}
.rte-swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.rte-swatch { width: 26px; height: 26px; border-radius: 8px; border: 1px solid oklch(0% 0 0 / .12); cursor: pointer; padding: 0; display: grid; place-items: center; transition: transform .2s var(--spring); }
.rte-swatch:hover { transform: scale(1.12); }
.rte-swatch.none { background: var(--surface-2); color: var(--muted); }
.rte-swatch.none svg { width: 14px; height: 14px; }
.rte-menu { display: flex; flex-direction: column; min-width: 150px; }
.rte-menu button { border: 0; background: none; text-align: left; padding: 7px 12px; border-radius: var(--radius-xs); color: var(--text); cursor: pointer; font-family: var(--font); }
.rte-menu button:hover { background: var(--hover); }
.rte-size-small { font-size: 13px; } .rte-size-normal { font-size: 15px; } .rte-size-large { font-size: 19px; } .rte-size-huge { font-size: 24px; }
.rte-body { flex: 1; min-height: 240px; padding: 18px 24px; outline: none; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; cursor: text; }
.rte-body.is-empty::before { content: attr(data-placeholder); position: absolute; color: var(--muted); pointer-events: none; }
.rte-body blockquote { margin: 6px 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.rte-body ul, .rte-body ol { margin: 4px 0; padding-left: 26px; }
.rte-body a { text-decoration: underline; }
.rte-body pre, .rte-body code { font-family: var(--mono); font-size: 13.5px; background: var(--surface-2); border-radius: 5px; }
.rte-body code { padding: 1px 4px; }
.rte-body pre { padding: 10px 12px; white-space: pre-wrap; }
.rte-body h1, .rte-body h2, .rte-body h3 { margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 10px; border-radius: 999px; background: var(--hover); font-size: 13px; animation: pop .35s var(--spring) both; }
.chip svg { width: 14px; height: 14px; color: var(--muted); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 5px; font-size: 16px; line-height: 1; border-radius: 99px; transition: color .2s, background-color .2s; }
.chip button:hover { color: var(--danger); background: var(--danger-soft); }
.enc-bar { display: flex; align-items: center; gap: 10px; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; font-size: 14px; }
.enc-bar .grow { color: var(--muted); }
.suggest { position: absolute; z-index: 60; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-edge); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 260px; overflow: hidden; padding: 4px; }
.suggest div { padding: 8px 12px; cursor: pointer; font-size: 14px; border-radius: var(--radius-xs); }
.suggest div:hover, .suggest div.on { background: var(--hover); }
.suggest small { color: var(--muted); margin-left: 6px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; z-index: 100; pointer-events: none; }
.toast {
  min-width: 260px; max-width: 400px; padding: 13px 18px; border-radius: var(--radius);
  background: oklch(24% .02 var(--hue) / .82); color: oklch(97% .005 var(--hue));
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid oklch(100% 0 0 / .1);
  box-shadow: var(--shadow-lg); font-size: 14px; pointer-events: auto;
  animation: toast-in .5s var(--spring) both;
}
:root[data-theme="dark"] .toast { background: oklch(32% .02 var(--hue) / .8); }
.toast.err { background: oklch(55% .2 25 / .9); color: #fff; }
.toast.out { animation: toast-out .3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.92); filter: blur(4px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.96); filter: blur(4px); } }

/* ---------- stats ---------- */
.grid-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 18px; overflow: hidden;
  border-radius: var(--radius-xl); background: var(--glass); border: 1px solid var(--glass-edge); box-shadow: var(--inner), var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.grid-stats:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, 1fr); }
/* Each cell draws its right and bottom hairline; the outer ones are clipped by the frame. */
.grid-stats > .stat {
  background: none; border: 0; border-radius: 0; margin: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
  box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border);
}
.stat { padding: 18px 20px; transition: background-color .3s var(--ease); }
.stat:hover { background: var(--hover); }
.grid-stats > .stat { animation: rise .55s var(--ease) both; }
.grid-stats > .stat:nth-child(2) { animation-delay: .04s; }
.grid-stats > .stat:nth-child(3) { animation-delay: .08s; }
.grid-stats > .stat:nth-child(4) { animation-delay: .12s; }
.grid-stats > .stat:nth-child(5) { animation-delay: .16s; }
.grid-stats > .stat:nth-child(6) { animation-delay: .2s; }
.grid-stats > .stat:nth-child(7) { animation-delay: .24s; }
.grid-stats > .stat:nth-child(8) { animation-delay: .28s; }
.stat .k { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .1em; }
.stat .v { font-size: 28px; font-weight: 700; line-height: 1.25; margin-top: 6px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.svc .a.mono { font-size: 12px; }
.svc {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  transition: border-color .25s var(--ease), background-color .25s var(--ease);
}
.svc:hover { border-color: var(--border-strong); background: var(--hover); }
.svc .n { font-weight: 600; }
.svc .a { color: var(--muted); font-size: 12.5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 8px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin-bottom: 8px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.tabs { display: inline-flex; gap: 2px; padding: 4px; margin-bottom: 16px; flex-wrap: wrap; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.tabs button {
  border: 0; background: none; height: 34px; padding: 0 14px; border-radius: var(--radius-xs); color: var(--muted); font: 550 14px var(--font); cursor: pointer;
  transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); background: var(--glass-strong); box-shadow: var(--inner), 0 1px 3px oklch(30% .05 var(--hue) / .12), 0 0 0 1px var(--border); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 160px; }
.lvl-error td:first-child { box-shadow: inset 3px 0 var(--danger); }
.lvl-warn td:first-child { box-shadow: inset 3px 0 var(--warning); }
.qr { width: 196px; height: 196px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; padding: 8px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 20px; font: 15px var(--mono); padding: 14px 18px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .mail { grid-template-columns: 220px minmax(280px, 360px) 1fr; }
}
@media (max-width: 1000px) {
  .grid-stats, .grid-stats:has(> :nth-child(3):last-child) { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { gap: 8px; padding: 8px; }
  .topbar { height: 56px; border-radius: var(--radius); padding: 0 6px 0 8px; }
  .topbar .label, .brand .wordmark { display: none; }
  .seg { margin: 0 2px; }
  .brand { margin-right: 4px; }
  .nav-tab { padding: 0 12px; }
  .page { grid-template-columns: 1fr; grid-template-rows: auto 1fr; gap: 8px; }
  .sidenav { display: flex; overflow-x: auto; padding: 6px; gap: 2px; border-radius: var(--radius); }
  .sidenav .group { display: none; }
  .sidenav a { flex: none; height: 38px; }
  .sidenav a.active::before { display: none; }
  .content { padding: 8px 2px 40px; }
  .mail { grid-template-columns: 1fr; gap: 8px; }
  .mail .folders { display: none; }
  .mail.show-folders .folders {
    display: flex; position: fixed; top: 72px; bottom: 8px; left: 8px; width: min(300px, 78vw); z-index: 40;
    background: var(--glass-strong); box-shadow: var(--inner), var(--shadow-lg); animation: slide-in .4s var(--ease) both;
  }
  .mail.reading .list-pane { display: none; }
  .mail:not(.reading) .reader { display: none; }
  .mail.reading .reader { animation: slide-in-r .4s var(--ease) both; }
  .reader-body { padding: 20px 18px 40px; }
  .mobile-back { display: inline-flex; }
  .two-col { grid-template-columns: 1fr; }
  .rte-toolbar { padding: 4px 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rte-body { padding: 14px 16px; }
  .cline { padding: 6px 16px; }
  .compose .chips { padding: 10px 16px 0; }
  .enc-bar { padding: 10px 16px; }
  .overlay:has(.compose) { padding: 0; }
  .modal.compose { height: 100%; max-height: none; border-radius: 0; }
  .compose .modal-foot { padding: 12px 16px; gap: 8px; }
  .compose .modal-foot .btn-label { display: none; }
  .compose .modal-foot .btn { padding: 0 13px; }
  .kv { grid-template-columns: 1fr; }
  .user-chip { padding: 2px; background: none; border: 0; margin: 0 0 0 2px; }
  .user-chip .email, .user-chip .chev { display: none; }
  /* language and theme move into the account menu */
  .topbar-prefs { display: none; }
  .acct-menu .acct-prefs { display: flex; }
  .acct-menu { right: 0; }
  .topbar { gap: 2px; }
  .nav-tab { padding: 0 11px; }
  .section-title { flex-wrap: wrap; }
  .filters select, .filters input { min-width: 0; flex: 1 1 140px; }
  #toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
}
@keyframes slide-in { from { opacity: 0; transform: translateX(-24px); } }
@keyframes slide-in-r { from { opacity: 0; transform: translateX(24px); } }
.msg .icons:empty { display: none; }
.card-head > .row { justify-content: flex-end; }
.grid-stats > .card, .two-col > .card { margin-top: 0; }
.two-col { align-items: start; margin-bottom: 18px; }

/* ---------- mailer nodes & routing ---------- */
.cond-group { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.cond-group .cond-group { background: var(--surface); margin-top: 8px; }
.cond-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cond-head select { width: auto; }
.cond-items { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cond-row { display: grid; grid-template-columns: minmax(180px, 240px) minmax(100px, 120px) 1fr auto; gap: 6px; align-items: start; }
.cond-row .hint { grid-column: 1 / -1; margin-top: -2px; }
.cond-empty { color: var(--muted); font-size: 14px; padding: 4px 2px; }
.rule { display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px; border-bottom: 1px solid var(--border); transition: background-color .2s var(--ease); }
.rule:hover { background: var(--hover); }
.rule:last-child { border-bottom: 0; }
.rule.off { opacity: .55; }
.rule .num { font-weight: 700; color: var(--muted); min-width: 24px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.rule .cond-text { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); word-break: break-word; margin-top: 4px; }
.rule .ops { display: flex; gap: 2px; flex: none; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.bars > div { flex: 1; display: flex; flex-direction: column-reverse; min-width: 4px; height: 100%; transform-origin: bottom; animation: bar-up .7s var(--ease) both; }
.settled .bars > div, .settled .grid-stats > .stat { animation: none; }
.bars i { display: block; background: var(--success); border-radius: 3px 3px 0 0; }
.bars i.fail { background: var(--danger); border-radius: 0; }
.bars i.temp { background: var(--warning); border-radius: 0; }
@keyframes bar-up { from { transform: scaleY(0); } }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--success); vertical-align: -1px; }
.legend .temp::before { background: var(--warning); }
.legend .fail::before { background: var(--danger); }
@media (max-width: 720px) {
  .cond-row { grid-template-columns: 1fr 1fr; }
  .cond-row input { grid-column: 1 / -1; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  /* the looping draw would otherwise settle on its erased end frame */
  .pl-brand .logo-mark path { animation: none !important; }
}
.overlay.closing, .toast.out { pointer-events: none; }
