/* ==========================================================================
   MML Operations design system
   One token-driven stylesheet. Colours, type, space, radius, shadow and motion
   are tokens on :root; [data-theme="dark"] swaps the semantic layer. Components
   below only ever use semantic tokens, so both themes come for free.
   PW standard: motion is never gated on prefers-reduced-motion.
   ========================================================================== */

/* ---------- Fonts (self-hosted, OFL) ---------- */
@font-face { font-family: "Manrope"; src: url("/fonts/manrope-latin-var.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }

/* ---------- Primitive tokens ---------- */
:root {
  --font-ui: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif; /* headings: the UI face, professional over elegant */

  /* MML gold, sampled from the logo (#D9AC6E) and the site's accent (#CFA77D). */
  --gold-50: #FBF6EC; --gold-100: #F5E9D3; --gold-200: #ECD5AE; --gold-300: #E3C08A;
  --gold-400: #D9AC6E; --gold-500: #C8955A; --gold-600: #A87A43; --gold-700: #8A6233; --gold-800: #6B4B27;

  /* Warm graphite and stone (the site's beige is #ECE4DA). */
  --graphite-1000: #080706; --graphite-950: #0D0C0A; --graphite-900: #15130F; --graphite-850: #1B1915;
  --graphite-800: #23201B; --graphite-700: #2E2A24; --graphite-600: #3D3830; --graphite-500: #5B544A;
  --stone-400: #8C8477; --stone-300: #B2A99B; --stone-200: #D6CDBF; --stone-150: #E4DCCF;
  --stone-100: #ECE4DA; --stone-50: #F5F1EA; --stone-25: #FBF9F5;

  --r-xs: 2px; --r-sm: 3px; --r-md: 4px; --r-lg: 4px; --r-xl: 6px; --r-full: 999px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-7: 32px; --s-8: 40px; --s-9: 48px; --s-10: 64px; --s-11: 80px;

  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms; --dur-4: 560ms; --dur-5: 900ms;

  --z-sidebar: 30; --z-topbar: 40; --z-tabbar: 45; --z-fab: 50; --z-drawer: 70; --z-popover: 75; --z-dialog: 80; --z-toast: 90;

  /* Markup colours for screenshots (feedback): strong enough to read on any page. */
  --mark-red: #E0352B; --mark-amber: #F2A900; --mark-blue: #2F74E0; --mark-green: #1E9A55; --mark-ink: #15130F;

  --sidebar-w: 245px; --rail-w: 84px; --topbar-h: 64px; --tabbar-h: 70px;
  --page-max: 1480px;
}

/* ---------- Semantic tokens: light ---------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F3EFE8;
  --bg-elev: #FFFDF9;
  --bg-elev-2: #FAF7F1;
  --bg-sunken: #EBE5DB;
  --bg-hover: rgba(36, 30, 20, .045);
  --bg-press: rgba(36, 30, 20, .08);
  --line: #E6DFD3;
  --line-strong: #D5CBBB;
  --ink: #1B1915;
  --ink-2: #4A443B;
  --muted: #736B5F;
  --faint: #A0978A;
  --accent: #946A31;
  --accent-strong: #7A5624;
  --accent-bg: #F7ECDA;
  --accent-line: #E8D0A8;
  --brand: var(--gold-400);
  --on-brand: #1B1915;

  --shell: #15130F;
  --shell-2: #1D1A16;
  --shell-3: #26221D;
  --shell-ink: #F1EADF;
  --shell-muted: #9E9588;
  --shell-line: rgba(255, 244, 228, .08);

  --ok: #2B7F57; --ok-bg: #E6F2EA; --ok-line: #BFDCC9;
  --warn: #A9661A; --warn-bg: #FBF0DD; --warn-line: #EED3A3;
  --danger: #B33B2A; --danger-bg: #FBE9E5; --danger-line: #F0C4BB;
  --info: #3A6597; --info-bg: #E8EFF7; --info-line: #C3D3E7;

  --shadow-1: 0 1px 1px rgba(40, 30, 15, .04);
  --shadow-2: 0 1px 2px rgba(40, 30, 15, .06);
  --shadow-3: 0 4px 16px -6px rgba(40, 30, 15, .22);
  --shadow-gold: none;
  --focus-ring: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--gold-600);
  --grid-line: rgba(148, 106, 49, .07);
}

/* ---------- Semantic tokens: dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121110;
  --bg-elev: #1A1816;
  --bg-elev-2: #201E1B;
  --bg-sunken: #0D0C0B;
  --bg-hover: rgba(255, 244, 228, .05);
  --bg-press: rgba(255, 244, 228, .09);
  --line: #2A2723;
  --line-strong: #3A3630;
  --ink: #F2ECE2;
  --ink-2: #D3CBBE;
  --muted: #A1988B;
  --faint: #6F685E;
  --accent: #E3BC82;
  --accent-strong: #F0CE9A;
  --accent-bg: rgba(217, 172, 110, .12);
  --accent-line: rgba(217, 172, 110, .30);
  --on-brand: #15130F;

  --shell: #0A0908;
  --shell-2: #13110F;
  --shell-3: #1C1916;
  --shell-ink: #F1EADF;
  --shell-muted: #8F877B;
  --shell-line: rgba(255, 244, 228, .07);

  --ok: #5CC28D; --ok-bg: rgba(92, 194, 141, .12); --ok-line: rgba(92, 194, 141, .3);
  --warn: #E5A951; --warn-bg: rgba(229, 169, 81, .12); --warn-line: rgba(229, 169, 81, .3);
  --danger: #F08773; --danger-bg: rgba(240, 135, 115, .12); --danger-line: rgba(240, 135, 115, .3);
  --info: #86ADDB; --info-bg: rgba(134, 173, 219, .12); --info-line: rgba(134, 173, 219, .3);

  --shadow-1: 0 1px 1px rgba(0, 0, 0, .35);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-3: 0 6px 20px -6px rgba(0, 0, 0, .6);
  --shadow-gold: none;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--gold-300);
  --grid-line: rgba(217, 172, 110, .06);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0; font-family: var(--font-ui); font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11"; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
p { margin: 0 0 var(--s-3); }
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.2; }
h2 { font-size: 1.12rem; font-weight: 750; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 700; }
small { font-size: .82rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
::selection { background: rgba(217, 172, 110, .35); color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-xs); }
button { font: inherit; color: inherit; }
kbd { font-family: var(--font-ui); font-size: .72rem; font-weight: 700; padding: 2px 6px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--bg-elev-2); color: var(--muted); box-shadow: inset 0 -1px 0 var(--line-strong); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--gold-400); color: var(--on-brand); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 700; transition: top var(--dur-2) var(--ease-out); }
.skip-link:focus { top: 12px; }

.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 1.5em; height: 1.5em; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tabular { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-wrap { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.spacer { flex: 1; }
.serif { font-family: var(--font-display); }

/* ---------- Logo ---------- */
.logo { width: 100%; height: auto; overflow: visible; }
.logo-word { fill: currentColor; }
.logo-art polyline { fill: none; stroke: var(--gold-400); stroke-width: 4.4; stroke-linejoin: miter; stroke-linecap: butt; }
.logo-tagline { fill: var(--gold-400); font-family: var(--font-ui); font-size: 23px; font-weight: 750; }
.logo--draw .logo-art polyline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.5s var(--ease-in-out) forwards; animation-delay: calc(250ms + var(--d) * 220ms); }
.logo--draw .logo-tagline { opacity: 0; animation: fade-up .9s var(--ease-out) 1.1s forwards; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--bg-elev); --btn-ink: var(--ink); --btn-line: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--btn-line);
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 650; font-size: .9rem; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap; isolation: isolate; overflow: hidden;
  transition: background var(--dur-2) var(--ease-out), border-color var(--dur-2), color var(--dur-2), box-shadow var(--dur-2), transform var(--dur-1) var(--ease-out);
}
.btn:hover { background: var(--bg-elev-2); color: var(--btn-ink); border-color: var(--stone-300); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn .icon { width: 1.05em; height: 1.05em; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary {
  --btn-ink: var(--on-brand); --btn-line: transparent;
  background: var(--gold-400); --btn-line: var(--gold-500); border-color: var(--gold-500);
}
.btn-primary:hover { background: var(--gold-300); color: var(--on-brand); border-color: var(--gold-500); }
.btn-dark { --btn-bg: var(--graphite-900); --btn-ink: var(--gold-200); --btn-line: var(--graphite-900); }
.btn-dark:hover { background: var(--graphite-800); color: var(--gold-100); border-color: var(--graphite-800); }
[data-theme="dark"] .btn-dark { --btn-bg: var(--bg-elev-2); --btn-line: var(--line-strong); }
.btn-ghost { --btn-bg: transparent; --btn-line: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; }
.btn-danger { --btn-bg: var(--danger-bg); --btn-ink: var(--danger); --btn-line: var(--danger-line); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .84rem; border-radius: var(--r-sm); }
.btn-lg { min-height: 40px; padding: 0 18px; font-size: .94rem; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: var(--r-sm); }
.btn-icon.btn-sm { width: 30px; min-height: 30px; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: var(--btn-ink) transparent var(--btn-ink) transparent; animation: spin .7s linear infinite; color: var(--btn-ink); opacity: .85; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: .84rem; font-weight: 700; color: var(--ink-2); display: flex; align-items: baseline; gap: 6px; }
.field-label .optional { font-weight: 500; color: var(--faint); font-size: .78rem; }
.field-hint { font-size: .8rem; color: var(--muted); }
.field-error, .field-validation-error { font-size: .82rem; color: var(--danger); font-weight: 600; }
.field-validation-valid { display: none; }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 11px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color var(--dur-2), box-shadow var(--dur-2), background var(--dur-2);
}
@media (min-width: 900px) { .input, .select, .textarea { font-size: .9rem; } }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--stone-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(217, 172, 110, .22); background: var(--bg-elev); }
.input.input-validation-error, .input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23946A31' 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 12px center; background-size: 18px; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-left: 40px; }
.input-wrap .input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center; cursor: pointer; }
.input-wrap .input-action:hover { background: var(--bg-hover); color: var(--ink); }
.input-wrap .input-action ~ .input, .input-wrap .input:has(~ .input-action) { padding-right: 46px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: var(--s-3); justify-content: flex-end; flex-wrap: wrap; }

.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input[type="checkbox"] { appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0; border-radius: var(--r-sm); border: 1.5px solid var(--line-strong); background: var(--bg-elev); display: grid; place-items: center; cursor: pointer; transition: all var(--dur-2) var(--ease-out); }
.check input[type="checkbox"]::after { content: ""; width: 10px; height: 6px; border-left: 2px solid var(--on-brand); border-bottom: 2px solid var(--on-brand); transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform var(--dur-2) var(--ease-spring); }
.check input[type="checkbox"]:checked { background: var(--gold-400); border-color: var(--gold-500); }
.check input[type="checkbox"]:checked::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.check input[type="checkbox"]:focus-visible { box-shadow: var(--focus-ring); }

.switch { position: relative; display: inline-flex; flex: none; }
.switch input[type="checkbox"] { appearance: none; width: 42px; height: 24px; margin: 0; border-radius: var(--r-sm); background: var(--line-strong); cursor: pointer; transition: background var(--dur-2) var(--ease-out); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--dur-3) var(--ease-spring); }
.switch input:checked { background: var(--gold-500); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: .55; cursor: not-allowed; }
.switch input:focus-visible { box-shadow: var(--focus-ring); }

.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-md); background: var(--bg-sunken); border: 1px solid var(--line); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: var(--r-md); font-size: .86rem; font-weight: 650; color: var(--muted); cursor: pointer; transition: all var(--dur-2) var(--ease-out); }
.segmented input:checked + span { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); }

.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.strength i { height: 4px; border-radius: 4px; background: var(--line); transition: background var(--dur-3) var(--ease-out); }
.strength[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.strength[data-score="3"] i:nth-child(-n+3) { background: var(--gold-500); }
.strength[data-score="4"] i { background: var(--ok); }
.strength-label { font-size: .78rem; color: var(--muted); margin-top: 6px; min-height: 1.2em; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg-elev-2); font-size: .9rem; }
.alert .icon { margin-top: 2px; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.alert-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert strong { color: inherit; }
.alert p { margin: 0; color: var(--ink-2); }
.validation-summary-valid { display: none; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

/* ---------- Cards ---------- */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-pad { padding: var(--s-4); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 52px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: .95rem; }
.card-head .card-sub { font-size: .8rem; color: var(--muted); margin: 1px 0 0; }
.card-body { padding: var(--s-4); }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg-elev-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-icon { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); flex: none; }
.card-danger { border-color: var(--danger-line); }
.card-danger .card-head { border-bottom-color: var(--danger-line); }
.card-danger .card-icon { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
@media (max-width: 640px) { .card-pad, .card-body { padding: var(--s-4); } .card-head { padding: 10px 14px; } }

.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-aside { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-aside { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); } }

/* ---------- Badges, chips, status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-sm); font-size: .76rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; background: var(--bg-sunken); color: var(--ink-2); border: 1px solid var(--line); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge-gold { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }
.badge-ok .dot { box-shadow: 0 0 0 3px rgba(43, 127, 87, .15); animation: pulse-dot 2.4s var(--ease-out) infinite; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-md); font-size: .8rem; font-weight: 650; background: var(--bg-sunken); color: var(--ink-2); border: 1px solid var(--line); }
.chip-admin { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }
.chip-dev { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.chip .icon { width: 14px; height: 14px; }

/* ---------- Avatars ---------- */
.avatar {
  --h: 30; width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-weight: 750; font-size: .82rem; letter-spacing: .02em; color: #fff;
  background: linear-gradient(140deg, hsl(var(--h) 42% 52%), hsl(calc(var(--h) + 28) 46% 36%));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 1px 2px rgba(0, 0, 0, .15);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .2);
}
.avatar-sm { width: 30px; height: 30px; font-size: .7rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.avatar-xl { width: 88px; height: 88px; font-size: 1.7rem; }
.avatar-gold { background: linear-gradient(140deg, var(--gold-300), var(--gold-600)); color: var(--graphite-900); text-shadow: none; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -9px; box-shadow: 0 0 0 2px var(--bg-elev); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--bg-sunken); color: var(--muted); text-shadow: none; }

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { overflow: hidden; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; background: var(--bg-elev-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child { padding-left: 16px; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td:first-child { padding-left: 16px; }
.table td:last-child, .table th:last-child { padding-right: 16px; }
.table tbody tr { transition: background var(--dur-2); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .cell-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.table .cell-person a { color: var(--ink); font-weight: 700; text-decoration: none; }
.table .cell-person a:hover { color: var(--accent); }
.table .cell-person small { display: block; color: var(--muted); font-size: .8rem; }
.table .cell-actions { text-align: right; white-space: nowrap; }
@media (max-width: 760px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 14px 18px; border-bottom: 1px solid var(--line); }
  .table-stack td { border: 0; padding: 4px 0 !important; }
  .table-stack td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
  .table-stack td.cell-actions { text-align: left; padding-top: 10px !important; }
  .table-stack td.num { text-align: left !important; }
  .table-stack td.num small { display: inline; margin-left: 8px; }
  .table-stack tfoot, .table-stack tfoot tr { display: flex; width: 100%; }
  .table-stack tfoot th, .table-stack tfoot td { flex: 1; border-top: 0; }
  .table-stack tr.row-group { padding: 0; }
  .table-stack tr.row-group th { display: block; }
}

/* ---------- Page header ---------- */
.page { max-width: var(--page-max); margin: 0 auto; padding: 20px 28px 48px; }
@media (max-width: 900px) { .page { padding: 16px 16px calc(var(--tabbar-h) + 32px); } }
.page-head { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-4); }
.page-head-text { flex: 1 1 420px; min-width: 0; }
.kicker { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.kicker::before { content: ""; width: 14px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--gold-400), var(--gold-200)); }
.page-title { font-family: var(--font-display); font-weight: 750; font-size: clamp(1.35rem, 1.1rem + .6vw, 1.65rem); line-height: 1.2; letter-spacing: -.015em; color: var(--ink); text-wrap: balance; }
.page-lede { margin: 4px 0 0; max-width: 80ch; color: var(--muted); font-size: .9rem; }
.page-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: var(--s-2); }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.crumbs .icon { width: 14px; height: 14px; color: var(--faint); }
.section-title { display: flex; align-items: center; gap: 12px; margin: var(--s-6) 0 var(--s-3); }
.section-title h2 { font-size: 1.05rem; }
.section-title .count { font-size: .8rem; color: var(--muted); font-weight: 600; }

/* ---------- App shell ---------- */
.app { background: var(--shell); min-height: 100dvh; }
.shell { display: grid; min-height: 100dvh; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--topbar-h) 1fr; grid-template-areas: "side top" "side main"; transition: grid-template-columns var(--dur-4) var(--ease-out); }
[data-sidebar="collapsed"] .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

.sidebar { grid-area: side; position: sticky; top: 0; height: 100dvh; z-index: var(--z-sidebar); display: flex; flex-direction: column; padding: 18px 14px 14px; color: var(--shell-ink); background: var(--shell); overflow: hidden; view-transition-name: sidebar; }
.sidebar::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(420px 260px at 0% 0%, rgba(217, 172, 110, .09), transparent 70%), radial-gradient(300px 300px at 100% 100%, rgba(217, 172, 110, .05), transparent 70%); }
.sidebar-brand { position: relative; display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; text-decoration: none; color: var(--shell-ink); }
.sidebar-brand .logo { width: 148px; color: var(--shell-ink); }
.sidebar-brand .brand-mark { display: none; width: 44px; }
.sidebar-nav { position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .1) transparent; }
.nav-section + .nav-section { margin-top: 18px; }
.nav-heading { margin: 0 10px 6px; font-size: .66rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--shell-muted); opacity: .8; white-space: nowrap; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px; margin: 1px 0; border-radius: var(--r-md); color: rgba(241, 234, 223, .78); text-decoration: none; font-size: .92rem; font-weight: 600; white-space: nowrap; transition: background var(--dur-2), color var(--dur-2); }
.nav-link .icon { width: 19px; height: 19px; opacity: .85; transition: transform var(--dur-3) var(--ease-spring); }
.nav-link:hover { background: rgba(255, 244, 228, .055); color: var(--shell-ink); }
.nav-link:hover .icon { transform: translateX(1px) scale(1.06); }
.nav-link.is-active { color: var(--gold-200); background: rgba(217, 172, 110, .12); }
.nav-link.is-active .icon { opacity: 1; color: var(--gold-300); }
.nav-indicator { position: absolute; left: -6px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-400); view-transition-name: nav-indicator; }
.nav-badge { margin-left: auto; flex: none; font-size: .58rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-300); padding: 2px 6px; border-radius: var(--r-sm); border: 1px solid rgba(217, 172, 110, .32); background: rgba(217, 172, 110, .07); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { position: relative; display: flex; align-items: center; gap: 8px; padding-top: 12px; margin-top: 10px; border-top: 1px solid var(--shell-line); }
.sidebar-credit { display: flex; flex-direction: column; gap: 2px; padding-left: 10px; font-size: .72rem; color: var(--shell-muted); white-space: nowrap; }
.sidebar-credit .ver { font-size: .68rem; letter-spacing: .04em; opacity: .75; font-variant-numeric: tabular-nums; }
.rail-toggle { margin-left: auto; width: 34px; height: 34px; border-radius: var(--r-md); border: 0; background: transparent; color: var(--shell-muted); display: grid; place-items: center; cursor: pointer; transition: all var(--dur-2); }
.rail-toggle:hover { background: rgba(255, 244, 228, .07); color: var(--shell-ink); }
.rail-toggle .icon { transition: transform var(--dur-4) var(--ease-out); }

/* Collapsed rail */
[data-sidebar="collapsed"] .sidebar { padding-inline: 12px; }
[data-sidebar="collapsed"] .sidebar-brand { justify-content: center; padding-inline: 0; }
[data-sidebar="collapsed"] .sidebar-brand .logo { display: none; }
[data-sidebar="collapsed"] .sidebar-brand .brand-mark { display: block; }
[data-sidebar="collapsed"] .nav-heading, [data-sidebar="collapsed"] .nav-label, [data-sidebar="collapsed"] .nav-badge, [data-sidebar="collapsed"] .sidebar-credit { display: none; }
[data-sidebar="collapsed"] .nav-link { justify-content: center; padding: 0; }
[data-sidebar="collapsed"] .nav-section + .nav-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--shell-line); }
[data-sidebar="collapsed"] .sidebar-foot { justify-content: center; }
[data-sidebar="collapsed"] .rail-toggle { margin: 0; }
[data-sidebar="collapsed"] .rail-toggle .icon { transform: rotate(180deg); }

.topbar { grid-area: top; position: sticky; top: 0; z-index: var(--z-topbar); display: flex; align-items: center; gap: 12px; padding: 0 24px 0 28px; background: var(--shell); color: var(--shell-ink); view-transition-name: topbar; }
.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: .86rem; color: var(--shell-muted); }
.topbar-context b { color: var(--shell-ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-context .sep { opacity: .4; }
.topbar-brand { display: none; color: var(--shell-ink); }
.topbar-brand .logo { width: 104px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-btn { width: 40px; height: 40px; border-radius: var(--r-md); border: 0; background: transparent; color: var(--shell-muted); display: grid; place-items: center; cursor: pointer; transition: all var(--dur-2); position: relative; }
.topbar-btn:hover { background: rgba(255, 244, 228, .07); color: var(--shell-ink); }
.topbar-btn .icon { width: 20px; height: 20px; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme="dark"] .theme-icon-light { display: none; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; margin-left: 6px; border-radius: var(--r-sm); border: 1px solid var(--shell-line); background: rgba(255, 244, 228, .03); cursor: pointer; color: var(--shell-ink); transition: all var(--dur-2); }
.user-btn:hover { background: rgba(255, 244, 228, .07); border-color: rgba(255, 244, 228, .14); }
.user-btn .user-name { font-size: .86rem; font-weight: 650; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .icon { width: 16px; height: 16px; color: var(--shell-muted); }

.main { grid-area: main; position: relative; min-width: 0; background: var(--bg); border-top-left-radius: 28px; /* the shell's corner: keep */ box-shadow: -1px -1px 0 var(--shell-line); isolation: isolate; view-transition-name: main; }
.main::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 360px; pointer-events: none; z-index: -1; border-top-left-radius: inherit; background: radial-gradient(900px 300px at 70% -120px, rgba(217, 172, 110, .12), transparent 70%); }
.site-foot { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--s-8) var(--s-7); display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--faint); }
.site-foot a { color: var(--faint); }

/* Mobile shell */
.tabbar { display: none; }
.drawer-scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr) !important; grid-template-areas: "top" "main"; grid-template-rows: 58px 1fr; }
  .topbar { padding: 0 10px 0 16px; height: 58px; }
  .topbar-context { display: none; }
  .topbar-brand { display: block; }
  .user-btn .user-name, .user-btn > .icon { display: none; }
  .user-btn { padding: 3px; margin-left: 2px; }
  .main { border-radius: 22px 22px 0 0; min-height: calc(100dvh - 58px); }
  .site-foot { padding: 0 var(--s-4) calc(var(--tabbar-h) + var(--s-6)); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: var(--z-drawer); transform: translateX(-104%); transition: transform var(--dur-4) var(--ease-out); box-shadow: 30px 0 60px rgba(0, 0, 0, .4); padding-top: max(18px, env(safe-area-inset-top)); }
  .sidebar .rail-toggle { display: none; }
  [data-drawer="open"] .sidebar { transform: none; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: rgba(8, 7, 6, .55); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity var(--dur-3); }
  [data-drawer="open"] .drawer-scrim { opacity: 1; pointer-events: auto; }
  [data-sidebar="collapsed"] .sidebar-brand .logo, [data-sidebar="collapsed"] .nav-label, [data-sidebar="collapsed"] .nav-heading, [data-sidebar="collapsed"] .nav-badge { display: revert; }
  [data-sidebar="collapsed"] .sidebar-credit { display: flex; }
  [data-sidebar="collapsed"] .sidebar-brand .brand-mark { display: none; }
  [data-sidebar="collapsed"] .nav-link { justify-content: flex-start; padding: 0 12px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: rgba(13, 12, 10, .92); backdrop-filter: blur(16px) saturate(1.3); border-top: 1px solid var(--shell-line); view-transition-name: tabbar;
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: var(--tabbar-h); border: 0; background: none; color: var(--shell-muted); font-size: .68rem; font-weight: 700; letter-spacing: .02em; text-decoration: none; cursor: pointer; }
  .tab .icon { width: 22px; height: 22px; transition: transform var(--dur-3) var(--ease-spring); }
  .tab.is-active { color: var(--gold-300); }
  .tab.is-active .icon { transform: translateY(-1px); }
}

/* ---------- Popover menus ---------- */
.menu { position: fixed; inset: auto; margin: 0; min-width: 240px; padding: 6px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-3); opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right; transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), display var(--dur-3) allow-discrete, overlay var(--dur-3) allow-discrete; }
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(-6px) scale(.98); } }
.menu-head { display: flex; gap: 12px; align-items: center; padding: 12px 12px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.menu-head b { display: block; font-size: .93rem; }
.menu-head small { color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-md); background: none; color: var(--ink-2); font-size: .9rem; font-weight: 600; text-decoration: none; text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-hover); color: var(--ink); box-shadow: none; }
.menu-item .icon { color: var(--muted); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-label { padding: 8px 12px 4px; font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.menu .segmented { margin: 4px 8px 8px; display: flex; }
.menu .segmented label { flex: 1; }
.menu .segmented span { justify-content: center; width: 100%; padding: 7px 6px; }

/* ---------- Dialogs ---------- */
.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-3); opacity: 0; transform: translateY(14px) scale(.97); transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-4) var(--ease-out), display var(--dur-4) allow-discrete, overlay var(--dur-4) allow-discrete; }
.dialog[open] { opacity: 1; transform: none; }
@starting-style { .dialog[open] { opacity: 0; transform: translateY(14px) scale(.97); } }
.dialog::backdrop { background: rgba(10, 9, 8, .55); backdrop-filter: blur(5px); opacity: 0; transition: opacity var(--dur-3), display var(--dur-3) allow-discrete, overlay var(--dur-3) allow-discrete; }
.dialog[open]::backdrop { opacity: 1; }
@starting-style { .dialog[open]::backdrop { opacity: 0; } }
.dialog-body { padding: var(--s-5) var(--s-5) var(--s-4); }
.dialog-icon { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: 16px; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); }
.dialog-icon .icon { width: 22px; height: 22px; }
.dialog-body.is-danger .dialog-icon { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.dialog h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 750; margin-bottom: 6px; }
.dialog p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: var(--s-3) var(--s-5) var(--s-5); }
.link-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border-radius: var(--r-md); background: var(--bg-sunken); border: 1px dashed var(--accent-line); }
.link-box code { flex: 1; min-width: 0; font-size: .78rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box code.secret-code { font-size: 1.05rem; font-weight: 700; letter-spacing: .06em; color: var(--ink); }


/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 36px)); pointer-events: none; }
@media (max-width: 900px) { .toasts { top: auto; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; } }
.toast { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px 16px; border-radius: var(--r-md); overflow: hidden; pointer-events: auto; background: var(--graphite-900); color: #F4EEE4; border: 1px solid rgba(255, 244, 228, .1); box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .6); animation: toast-in var(--dur-4) var(--ease-spring) both; }
.toast.is-leaving { animation: toast-out var(--dur-3) var(--ease-in-out) forwards; }
.toast .t-icon { width: 30px; height: 30px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: rgba(92, 194, 141, .16); color: #6FD39F; }
.toast.is-error .t-icon { background: rgba(240, 135, 115, .16); color: #F49C8A; }
.toast p { margin: 4px 0 0; font-size: .9rem; line-height: 1.45; }
.toast .t-close { margin-left: auto; border: 0; background: none; color: rgba(244, 238, 228, .55); cursor: pointer; padding: 2px; border-radius: var(--r-sm); }
.toast .t-close:hover { color: #fff; }
.toast .t-progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: linear-gradient(90deg, var(--gold-500), var(--gold-300)); transform-origin: left; animation: shrink 6s linear forwards; }

/* ---------- Empty, skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--s-7) var(--s-5); }
.empty-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: 12px; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); }
.empty-icon .icon { width: 20px; height: 20px; }
.empty h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 750; margin-bottom: 4px; }
.empty p { color: var(--muted); max-width: 44ch; }
.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-elev-2) 50%, var(--bg-sunken) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: var(--s-4) var(--s-6); border-bottom: 1px solid var(--line); }
.toolbar .input-wrap { flex: 1 1 260px; max-width: 380px; }
.toolbar .select { width: auto; min-width: 170px; }
@media (max-width: 640px) { .toolbar { padding: var(--s-4); } .toolbar .select { flex: 1; } }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 0; border-bottom: 1px solid var(--line-strong); max-width: 100%; }
.tab-link { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px 8px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: .88rem; font-weight: 650; text-decoration: none; white-space: nowrap; transition: all var(--dur-2) var(--ease-out); }
.tab-link:hover { color: var(--ink); border-bottom-color: var(--line-strong); }
.tab-link .n { font-size: .72rem; font-weight: 800; padding: 0 6px; border-radius: var(--r-sm); background: var(--bg-elev); color: var(--muted); border: 1px solid var(--line); }
.tab-link.is-active { color: var(--ink); border-bottom-color: var(--gold-500); }
.tab-link.is-active .n { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-line); }

/* ---------- Stats ---------- */
.stat { position: relative; padding: var(--s-5) var(--s-6); overflow: hidden; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat-label .icon { color: var(--accent); }
.stat-value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 750; line-height: 1.1; margin-top: 8px; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.stat-note { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.stat a.stretched::after { content: ""; position: absolute; inset: 0; }
.stat:has(a.stretched):hover { border-color: var(--accent-line); }
@media (max-width: 640px) { .stat { padding: var(--s-4); } .stat-value { font-size: 2.1rem; } }

/* ---------- Projects (start page) ---------- */
@media (max-width: 760px) { .portfolio.is-empty .table-wrap { display: none; } }
.portfolio.is-empty .table-wrap { border-bottom: 1px solid var(--line); }
.portfolio:not(.is-empty) .table-wrap { border-bottom: 0; }
.cell-project a { color: var(--ink); font-weight: 700; text-decoration: none; }
.cell-project a:hover { color: var(--accent); }
.cell-project small { display: block; color: var(--muted); font-size: .8rem; }
.portfolio .table th { background: transparent; }
.portfolio-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: clamp(48px, 9vh, 96px) var(--s-6) clamp(56px, 10vh, 112px); }
.portfolio-mark { width: 132px; margin-bottom: 22px; opacity: .55; }
.portfolio-mark polyline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.8s var(--ease-in-out) forwards; }
.portfolio-mark polyline:nth-child(2) { animation-delay: .25s; } .portfolio-mark polyline:nth-child(3) { animation-delay: .5s; }
.portfolio-empty-title { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.15rem; font-weight: 750; color: var(--ink); }
.portfolio-empty .muted { max-width: 46ch; margin: 0; }
.stage-tool { display: flex; align-items: center; gap: 14px; margin-top: 26px; padding: 12px 16px 12px 12px; min-width: min(100%, 380px); text-align: left; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--ink); text-decoration: none; transition: border-color var(--dur-2), background var(--dur-2), transform var(--dur-3) var(--ease-out); }
.stage-tool:hover { border-color: var(--accent-line); background: var(--accent-bg); color: var(--ink); transform: translateY(-1px); }
.stage-tool b { display: block; font-size: .93rem; }
.stage-tool small { color: var(--muted); }
.stage-tool > .icon { margin-left: auto; color: var(--accent); }
.stage-tool-icon { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: var(--accent-bg); border: 1px solid var(--accent-line); color: var(--accent); }
.scene line, .scene polyline, .scene path, .scene rect, .scene circle { vector-effect: non-scaling-stroke; }
.scene .s-frame { fill: none; stroke: var(--gold-400); stroke-width: 2.4; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.2s var(--ease-in-out) forwards; animation-delay: calc(200ms + var(--d, 0) * 260ms); filter: drop-shadow(0 0 6px rgba(217, 172, 110, .35)); }
.scene .s-floor { fill: none; stroke: rgba(217, 172, 110, .35); stroke-width: 1; stroke-dasharray: 3 5; opacity: 0; animation: fade-in .9s var(--ease-out) forwards; animation-delay: calc(1500ms + var(--d, 0) * 90ms); }
.scene .s-ground { stroke: rgba(244, 237, 226, .22); stroke-width: 1; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.6s var(--ease-out) .1s forwards; }
.scene .s-dim { fill: none; stroke: rgba(244, 237, 226, .35); stroke-width: 1; opacity: 0; animation: fade-in .8s var(--ease-out) 2.3s forwards; }
.scene .s-label { fill: rgba(244, 237, 226, .5); font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: .22em; opacity: 0; animation: fade-in .8s var(--ease-out) 2.5s forwards; }
.scene .s-node { fill: var(--gold-300); opacity: 0; transform-box: fill-box; transform-origin: center; animation: node-pop .6s var(--ease-spring) forwards, pulse-node 3.2s var(--ease-in-out) infinite; animation-delay: calc(1900ms + var(--d, 0) * 140ms), calc(2600ms + var(--d, 0) * 300ms); }
.scene .s-glow { fill: url(#scene-glow); opacity: .9; }

.launcher { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-5); }
.module-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: var(--s-6); border-radius: var(--r-lg); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-2); text-decoration: none; color: var(--ink); overflow: hidden; isolation: isolate; transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3), border-color var(--dur-3); }
.module-card::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity var(--dur-4) var(--ease-out); background: radial-gradient(400px 200px at var(--mx, 80%) var(--my, 0%), rgba(217, 172, 110, .16), transparent 70%); }
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); border-color: var(--accent-line); color: var(--ink); }
.module-card:hover::before { opacity: 1; }
.module-card .m-icon { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); }
.module-card .m-icon .icon { width: 23px; height: 23px; }
.module-card .m-area { font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.module-card h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 750; }
.module-card p { color: var(--muted); font-size: .9rem; margin: 0; }
.module-card .m-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; font-size: .84rem; font-weight: 700; color: var(--accent); }
.module-card .m-foot .icon { transition: transform var(--dur-3) var(--ease-out); }
.module-card:hover .m-foot .icon { transform: translateX(4px); }
.module-card .m-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .f-icon { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; background: var(--bg-sunken); color: var(--muted); border: 1px solid var(--line); }
.feed .f-icon.tone-positive { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.feed .f-icon.tone-warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.feed .f-icon.tone-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.feed .f-text { min-width: 0; font-size: .9rem; }
.feed .f-text b { font-weight: 700; }
.feed .f-text .f-sub { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.feed time { margin-left: auto; font-size: .78rem; color: var(--faint); white-space: nowrap; padding-left: 8px; }

.progress { height: 8px; border-radius: var(--r-sm); background: var(--bg-sunken); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold-500), var(--gold-300)); transform-origin: left; animation: grow 1.2s var(--ease-out) both .3s; }

/* ---------- Project ---------- */
.page-narrow { max-width: 920px; }
.project-head { margin-bottom: var(--s-5); }
.project-tabs { margin-bottom: var(--s-6); }
.project-tabs .icon { width: 16px; height: 16px; }
.project-overview > .stack { min-width: 0; }
.project-overview .table td:first-child { min-width: 210px; }
.project-description { margin: var(--s-4) 0 0; font-size: .9rem; white-space: pre-line; }
.small { font-size: .84rem; }
.strong { font-weight: 700; color: var(--ink); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }
.table small.over, .table small.under, .num small { display: block; font-size: .76rem; font-weight: 700; }
.over { color: var(--danger); }
.under { color: var(--ok); }
.table .cell-by { display: block; font-size: .78rem; }
.table tr.is-superseded td { color: var(--muted); }
.table tr.is-superseded .badge { opacity: .8; }
.table tr.row-group th { padding: 6px 12px 5px 16px; background: var(--bg-elev-2); color: var(--accent); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.table tr.row-note td { padding-top: 0; color: var(--muted); font-size: .84rem; }
.table tr.row-note .icon { width: 14px; height: 14px; vertical-align: -2px; color: var(--faint); }
.table tr:has(+ tr.row-note) td { border-bottom: 0; }
.table tfoot th, .table tfoot td { padding: 9px 12px; border-top: 1px solid var(--line-strong); background: var(--bg-elev-2); font-size: .9rem; text-align: left; }
.table tfoot th:first-child { padding-left: 16px; }
.table tfoot td:last-child { padding-right: 16px; }
.inline-form { display: inline-flex; margin: 0; }
.input-sm, .select-sm { min-height: 34px; height: 34px; padding-top: 0; padding-bottom: 0; font-size: .86rem; border-radius: var(--r-md); }
.select-sm { padding-right: 34px; background-position: right 10px center; }
.input-file { padding: 9px 12px; height: auto; }
.input-file::file-selector-button { margin-right: 12px; border: 1px solid var(--line-strong); background: var(--bg-elev-2); color: var(--ink); font: inherit; font-weight: 700; font-size: .84rem; padding: 6px 12px; border-radius: var(--r-md); cursor: pointer; }
.danger-text { color: var(--danger); }
.danger-text:hover { background: var(--danger-bg); color: var(--danger); }
.danger-zone { display: flex; justify-content: flex-end; margin-top: var(--s-5); }
.form-foot { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; justify-content: space-between; }
.empty-compact { padding: var(--s-7) var(--s-6); gap: 14px; }
.empty-compact p { margin: 0; }
.facts dd.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; font-size: .82rem; }
.dialog-wide { width: min(640px, calc(100vw - 32px)); }

/* Documents: the pre-con folder beside its contents */
.folder-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.folder-nav { position: sticky; top: calc(var(--topbar-h) + 24px); display: flex; flex-direction: column; gap: 2px; }
.folder-nav-title { margin: 0 0 8px 14px; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.folder-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; border-radius: var(--r-md); color: var(--muted); font-weight: 650; text-decoration: none; font-size: .9rem; transition: background var(--dur-2), color var(--dur-2); }
.folder-nav a:hover { background: var(--bg-hover); color: var(--ink); }
.folder-nav a.is-active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
.folder-nav a.is-active .icon { color: var(--accent); }
.folder-nav a .n { margin-left: auto; font-size: .74rem; font-weight: 800; padding: 1px 8px; border-radius: var(--r-sm); background: var(--bg-sunken); color: var(--muted); }
.folder-nav a.is-active .n { background: var(--accent-bg); color: var(--accent); }
@media (max-width: 860px) {
  .folder-layout { grid-template-columns: minmax(0, 1fr); }
  .folder-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .folder-nav-title { display: none; }
  .folder-nav a { white-space: nowrap; }
}

/* Tender */
.closing-soon { display: flex; gap: 12px; align-items: flex-start; padding: 12px var(--s-6); background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--warn-line); font-size: .88rem; }
.closing-soon > .icon { margin-top: 2px; flex: none; }
.closing-soon b { margin-right: 6px; }
.closing-soon span { display: block; color: var(--ink-2); }
.closing-soon a { color: var(--ink); font-weight: 700; }
.scope-head .kicker { margin: 0 0 2px; }
.scope-title { font-family: var(--font-display); font-size: 1.15rem !important; font-weight: 750; }
.scope-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin: 0; }
.scope-facts dt { font-size: .72rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.scope-facts dd { margin: 0; font-weight: 650; }
.scope-description { margin: var(--s-4) 0 0; white-space: pre-line; }
.scope-head + .card, .card + .card { margin-top: var(--s-5); }
@media (max-width: 760px) { .scope-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.trade-picker { columns: 3 280px; column-gap: var(--s-7); }
.trade-group { break-inside: avoid; border: 0; margin: 0 0 var(--s-5); padding: 0; }
.trade-group legend { padding: 0; margin-bottom: 8px; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.trade-group .check { padding: 4px 0; font-size: .9rem; }
.check.is-disabled { opacity: .55; cursor: default; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }
.pick-list .check { padding: 9px 10px; border-radius: var(--r-md); }
.pick-list .check:hover { background: var(--bg-hover); }
.pick-list small { display: block; margin-top: 2px; }

/* Bid levelling: bidders as columns, lowest first */
.level-wrap { overflow-x: auto; }
.level { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.level th, .level td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.level th:first-child { text-align: left; padding-left: var(--s-6); min-width: 240px; position: sticky; left: 0; background: var(--bg-elev); z-index: 1; font-weight: 650; }
.level td:last-child, .level thead th:last-child { padding-right: var(--s-6); }
.level thead th { vertical-align: bottom; min-width: 150px; padding-top: 16px; }
.level thead th .level-rank { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.level thead th .level-co { display: block; font-size: .92rem; font-weight: 750; color: var(--ink); white-space: normal; }
.level thead th .badge { margin-top: 6px; }
.level thead th .badge .icon { width: 13px; height: 13px; }
.level thead th.is-low .level-rank { color: var(--accent); }
.level th.is-selected, .level td.is-selected { background: var(--ok-bg); }
.level .level-base td { font-weight: 700; color: var(--ink); }
.level .level-line th { font-weight: 500; }
.level .level-line th:has(.input) { display: flex; align-items: center; gap: 8px; }
.level .level-line .input { min-width: 0; }
.level .level-line td .input { width: 128px; text-align: right; margin-left: auto; }
.level .level-line.is-new .input { border-style: dashed; }
.level .level-remove { display: inline-flex; align-items: center; gap: 4px; color: var(--faint); cursor: pointer; }
.level .level-remove input { accent-color: var(--danger); }
.level .level-remove:has(input:checked) { color: var(--danger); }
.level tfoot th, .level tfoot td { background: var(--bg-elev-2); }
.level tfoot th:first-child { background: var(--bg-elev-2); }
.level .level-total th, .level .level-total td { font-weight: 800; color: var(--ink); border-top: 1px solid var(--line-strong); font-size: .95rem; }
.level .level-diff th, .level .level-diff td { font-size: .84rem; color: var(--muted); }
.level .level-diff td.over { color: var(--danger); font-weight: 700; }
.level .level-diff td.under { color: var(--ok); font-weight: 700; }
.level .level-select th, .level .level-select td { border-bottom: 0; }
.link-icon { display: inline-flex; align-items: center; gap: 6px; }
.link-icon .icon { width: 15px; height: 15px; flex: none; }
.feed .f-text a { color: var(--ink); text-decoration: none; }
.feed .f-text a:hover { color: var(--accent); }
@media (max-width: 760px) {
  .card-head { flex-wrap: wrap; }
  .card-head > div { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .card-head > .spacer { display: none; }
  .card-head > .btn { margin-left: 50px; }
  .level th:first-child { min-width: 150px; padding-left: var(--s-4); }
  .level thead th { min-width: 118px; }
  .level .level-line td .input { width: 96px; }
  .level .level-line th:has(.input) { flex-wrap: wrap; }
}

/* ---------- People / roles / activity ---------- */
.profile-card { text-align: center; padding: var(--s-7) var(--s-6) var(--s-6); position: relative; overflow: hidden; }
.profile-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 96px; background: radial-gradient(240px 120px at 50% 0%, rgba(217, 172, 110, .28), transparent 70%), linear-gradient(180deg, var(--accent-bg), transparent); }
.profile-card .avatar { margin: 0 auto 14px; position: relative; box-shadow: 0 0 0 5px var(--bg-elev), 0 10px 24px -8px rgba(0, 0, 0, .35); }
.profile-card h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 750; }
.profile-card .p-title { color: var(--muted); margin: 2px 0 12px; }
.facts { display: grid; gap: 0; margin: 0; text-align: left; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .87rem; }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); white-space: nowrap; }
.facts dd { margin: 0; font-weight: 650; text-align: right; }
.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-list form { display: contents; }
.action-list .btn { justify-content: flex-start; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-5); }
.role-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: var(--s-6); border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--bg-elev); box-shadow: var(--shadow-2); text-decoration: none; color: var(--ink); transition: transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3), border-color var(--dur-3); }
.role-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--accent-line); color: var(--ink); }
.role-card.is-system { background: linear-gradient(160deg, rgba(217, 172, 110, .12), var(--bg-elev) 55%); border-color: var(--accent-line); }
.role-card h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 750; }
.role-card p { color: var(--muted); font-size: .88rem; margin: 0; }
.role-card .r-foot { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.meter { display: flex; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); }
.meter .progress { flex: 1; height: 6px; }

.role-pick { display: grid; gap: 10px; }
.role-option { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--bg-elev); cursor: pointer; transition: all var(--dur-2) var(--ease-out); }
.role-option:hover { border-color: var(--stone-300); }
.role-option:has(input:checked) { border-color: var(--gold-500); background: var(--accent-bg); box-shadow: 0 0 0 3px rgba(217, 172, 110, .16); }
.role-option b { display: block; font-size: .93rem; }
.role-option small { color: var(--muted); display: block; margin-top: 2px; }
.role-option .r-meta { margin-left: auto; text-align: right; font-size: .76rem; color: var(--faint); white-space: nowrap; }

.perm-module { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-elev); overflow: hidden; }
.perm-module + .perm-module { margin-top: var(--s-4); }
.perm-module-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; background: var(--bg-elev-2); border-bottom: 1px solid var(--line); }
.perm-module-head h3 { font-size: .98rem; }
.perm-module-head small { color: var(--muted); }
.perm-row { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background var(--dur-2); }
.perm-row:last-child { border-bottom: 0; }
.perm-row:hover { background: var(--bg-hover); }
.perm-row b { display: block; font-size: .92rem; }
.perm-row small { color: var(--muted); }
.perm-row .perm-key { margin-left: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .74rem; color: var(--faint); padding-right: 6px; }
@media (max-width: 640px) { .perm-row .perm-key { display: none; } }

.timeline-day { margin: var(--s-6) 0 var(--s-3); font-size: .74rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); display: flex; align-items: center; gap: 12px; }
.timeline-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.timeline-day:first-child { margin-top: 0; }

.settings-nav { position: sticky; top: calc(var(--topbar-h) + 24px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); color: var(--muted); font-weight: 650; text-decoration: none; font-size: .9rem; }
.settings-nav a:hover { background: var(--bg-hover); color: var(--ink); }
.kv { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 0; }
.kv > div { display: contents; }
.kv dt, .kv dd { padding: 12px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; word-break: break-word; }
.kv > div:last-child dt, .kv > div:last-child dd { border-bottom: 0; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } .kv dt { border: 0; padding-bottom: 0; } }
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-card { position: relative; cursor: pointer; }
.theme-card input { position: absolute; opacity: 0; }
/* Theme previews: a miniature of the app in each theme (fixed colours, so each always shows its own theme). */
.tc-preview { position: relative; display: grid; grid-template-columns: 24% 1fr; height: 104px; border-radius: var(--r-md); border: 2px solid var(--line); overflow: hidden; transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out); }
.theme-card:hover .tc-preview { transform: translateY(-2px); border-color: var(--line-strong); }
.tc-preview i, .tc-preview u, .tc-preview s { display: block; text-decoration: none; }
.tc-side { display: flex; flex-direction: column; gap: 6px; padding: 12px 8px; background: #15130F; }
.tc-dark .tc-side { background: #0A0908; }
.tc-side u { height: 5px; border-radius: 3px; background: rgba(241, 234, 223, .16); }
.tc-side u.on { background: #D9AC6E; box-shadow: 0 0 6px rgba(217, 172, 110, .6); }
.tc-main { display: flex; flex-direction: column; gap: 7px; padding: 12px 11px; min-width: 0; }
.tc-title { width: 52%; height: 7px; border-radius: 4px; }
.tc-card { height: 22px; border-radius: var(--r-sm); border: 1px solid; }
.tc-card.tc-short { width: 68%; height: 16px; }
.tc-l { background: #F3EFE8; } .tc-l .tc-title { background: #1B1915; opacity: .75; } .tc-l .tc-card { background: #FFFDF9; border-color: #E6DFD3; }
.tc-d { background: #121110; } .tc-d .tc-title { background: #F2ECE2; opacity: .8; } .tc-d .tc-card { background: #1A1816; border-color: #2E2A24; }
.tc-split { position: absolute; top: 0; bottom: 0; left: 24%; right: 0; clip-path: polygon(58% 0, 100% 0, 100% 100%, 38% 100%); }
.theme-card .tc-label { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 10px; font-size: .86rem; font-weight: 650; color: var(--muted); }
.theme-card input:checked + .tc-preview { border-color: var(--gold-400); box-shadow: 0 0 0 4px rgba(217, 172, 110, .22); }
.theme-card input:checked ~ .tc-label { color: var(--ink); }
.theme-card input:focus-visible + .tc-preview { box-shadow: var(--focus-ring); }

/* ---------- Module overview ---------- */
.module-hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: var(--s-9) var(--s-8); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-2); isolation: isolate; }
.module-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px); background-size: 28px 28px; mask-image: linear-gradient(110deg, transparent 30%, #000 80%); }
.module-hero .m-icon { width: 64px; height: 64px; border-radius: var(--r-lg); display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); margin-bottom: 20px; }
.module-hero .m-icon .icon { width: 30px; height: 30px; }
.highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s-4); }
.highlight { position: relative; padding: var(--s-5) var(--s-5) var(--s-5) var(--s-5); border-radius: var(--r-lg); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.highlight .h-num { position: absolute; right: 18px; top: 14px; font-family: var(--font-display); font-size: 1.4rem; font-weight: 750; color: var(--line-strong); }
.highlight .h-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); margin-bottom: 14px; }
.highlight h3 { margin-bottom: 4px; }
.highlight p { color: var(--muted); font-size: .88rem; margin: 0; }

/* ---------- Auth (sign-in, invitations, resets) ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); background: var(--graphite-950); }
.auth-scene { position: relative; overflow: hidden; isolation: isolate; color: #F4EDE2; padding: 44px 56px; display: flex; flex-direction: column; background: radial-gradient(90% 70% at 70% 15%, #3B2E1D 0%, #17140F 55%, #0B0A08 100%); }
.auth-scene::before { content: ""; position: absolute; inset: -50%; z-index: -2; background-image: linear-gradient(rgba(217, 172, 110, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(217, 172, 110, .08) 1px, transparent 1px); background-size: 40px 40px; transform: perspective(900px) rotateX(58deg) translateY(10%); transform-origin: center 70%; mask-image: radial-gradient(60% 50% at 50% 60%, #000 10%, transparent 75%); animation: grid-pan 30s linear infinite; }
.auth-scene::after { content: ""; position: absolute; width: 700px; height: 700px; left: 40%; top: -260px; z-index: -1; border-radius: 50%; background: radial-gradient(circle, rgba(217, 172, 110, .26), transparent 62%); filter: blur(8px); animation: glow-drift 16s var(--ease-in-out) infinite alternate; }
.auth-brand { width: 210px; color: #F4EDE2; }
.auth-art { flex: 1; display: grid; place-items: center; padding: 24px 0; min-height: 280px; }
.auth-art svg { width: min(100%, 700px); height: auto; overflow: visible; }
.auth-copy .kicker { color: var(--gold-300); }
.auth-copy h1 { font-family: var(--font-display); font-weight: 750; font-size: clamp(1.9rem, 1.2rem + 2vw, 2.9rem); line-height: 1.02; letter-spacing: -.015em; color: #FBF5EA; max-width: 16ch; text-wrap: balance; }
.auth-copy h1 em { font-style: italic; background: linear-gradient(100deg, var(--gold-200), var(--gold-400) 60%, var(--gold-300)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-copy p { margin-top: 14px; color: rgba(244, 237, 226, .66); max-width: 48ch; }
.auth-copy > * { opacity: 0; animation: fade-up .9s var(--ease-out) forwards; }
.auth-copy > :nth-child(1) { animation-delay: .5s; } .auth-copy > :nth-child(2) { animation-delay: .62s; } .auth-copy > :nth-child(3) { animation-delay: .74s; }
.auth-foot { display: flex; gap: 18px; margin-top: 28px; font-size: .74rem; color: rgba(244, 237, 226, .4); letter-spacing: .04em; }
.auth-panel { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 5vw, 72px); background: var(--bg); border-top-left-radius: 32px; border-bottom-left-radius: 32px; box-shadow: -30px 0 80px rgba(0, 0, 0, .35); }
.auth-panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; background: radial-gradient(500px 260px at 100% 0%, rgba(217, 172, 110, .14), transparent 70%); }
.auth-form { position: relative; width: 100%; max-width: 400px; margin: 0 auto; }
.auth-form > * { animation: fade-up .7s var(--ease-out) both; }
.auth-form > :nth-child(2) { animation-delay: .06s; } .auth-form > :nth-child(3) { animation-delay: .12s; } .auth-form > :nth-child(4) { animation-delay: .18s; } .auth-form > :nth-child(5) { animation-delay: .24s; } .auth-form > :nth-child(6) { animation-delay: .3s; }
.auth-form h2 { font-family: var(--font-display); font-weight: 750; font-size: 1.6rem; line-height: 1.05; letter-spacing: -.01em; margin-bottom: 8px; }
.auth-form .lede { color: var(--muted); margin-bottom: 28px; }
.auth-form .stack { gap: 18px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .88rem; }
.auth-row a { font-weight: 650; }
.auth-note { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); display: flex; gap: 10px; align-items: flex-start; }
.auth-note .icon { color: var(--accent); margin-top: 2px; }
.auth-mobile-brand { display: none; }
.auth-success { text-align: center; }
.auth-success .empty-icon { margin: 0 auto 18px; }
@media (max-width: 1000px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-scene { padding: 28px 24px 34px; min-height: 0; }
  .auth-art { min-height: 0; padding: 18px 0 8px; }
  .auth-art svg { max-width: 460px; }
  .auth-copy h1 { font-size: 2.2rem; }
  .auth-copy p, .auth-foot { display: none; }
  .auth-panel { border-radius: 28px 28px 0 0; margin-top: -26px; padding: 36px 22px 48px; box-shadow: 0 -20px 60px rgba(0, 0, 0, .35); }
  .auth-brand { width: 160px; }
}

/* Sign-in fits the window. Desktop: exactly one viewport, nothing scrolls; the drawing is the
   part that gives way, and type and spacing follow the window's height. */
@media (min-width: 1001px) {
  .auth { height: 100dvh; min-height: 0; overflow: hidden; }
  .auth-scene { min-height: 0; padding: clamp(22px, 4.5vh, 44px) clamp(32px, 4vw, 56px); }
  .auth-brand { flex: none; width: clamp(150px, 22vh, 210px); }
  .auth-art { flex: 1 1 0; min-height: 0; padding: clamp(6px, 2.4vh, 24px) 0; }
  .auth-art svg { width: 100%; height: 100%; max-width: 700px; }
  .auth-copy { flex: none; }
  .auth-copy h1 { font-size: clamp(2rem, min(1.4rem + 2.8vw, 6.6vh), 4rem); }
  .auth-copy p { margin-top: clamp(8px, 1.6vh, 14px); }
  .auth-foot { flex: none; margin-top: clamp(12px, 3vh, 28px); }
  .auth-panel { overflow-y: auto; padding-block: clamp(20px, 4vh, 48px); }
  .auth-form h2 { font-size: clamp(1.9rem, 4.4vh, 2.4rem); }
  .auth-form .lede { margin-bottom: clamp(14px, 3vh, 28px); }
  .auth-form .stack { gap: clamp(11px, 2vh, 18px); }
  .auth-note { margin-top: clamp(14px, 2.8vh, 26px); padding-top: clamp(12px, 2.2vh, 20px); }
}
@media (min-width: 1001px) and (max-height: 880px) { .auth-copy p { display: none; } }
@media (min-width: 1001px) and (max-height: 740px) { .auth-foot, .auth-note { display: none; } }
/* Phones and tablets: a compact scene so the form is in view without scrolling. */
@media (max-width: 1000px) {
  .auth-scene { padding: 18px 22px 30px; }
  .auth-brand { width: 132px; }
  .auth-art { padding: 6px 0 0; }
  .auth-art svg { max-height: 17vh; width: auto; max-width: 100%; }
  .auth-copy { display: none; }
  .auth-panel { padding: 28px 22px 32px; }
  .auth-form h2 { font-size: 1.95rem; }
  .auth-form .lede { margin-bottom: 18px; }
  .auth-form .stack { gap: 13px; }
  .auth-note { margin-top: 16px; padding-top: 14px; }
}
@media (max-width: 1000px) and (max-height: 760px) { .auth-art, .auth-note { display: none; } .auth-scene { padding-bottom: 34px; } .auth-panel { padding-top: 20px; } }

/* ---------- Status pages ---------- */
.status-page { min-height: 60vh; display: grid; place-items: center; text-align: center; padding: var(--s-9) var(--s-5); }
.status-code { font-family: var(--font-display); font-size: clamp(5rem, 3rem + 8vw, 9rem); font-weight: 800; line-height: .9; background: linear-gradient(180deg, var(--gold-300), var(--gold-600)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.status-page h1 { font-family: var(--font-display); font-weight: 750; font-size: 1.5rem; margin: 10px 0 8px; }
.status-page p { color: var(--muted); max-width: 46ch; margin: 0 auto 24px; }

/* ---------- Entrance choreography ---------- */
.reveal > * { animation: fade-up .7s var(--ease-out) both; }
.reveal > :nth-child(2) { animation-delay: .05s; } .reveal > :nth-child(3) { animation-delay: .1s; } .reveal > :nth-child(4) { animation-delay: .15s; }
.reveal > :nth-child(5) { animation-delay: .2s; } .reveal > :nth-child(6) { animation-delay: .25s; } .reveal > :nth-child(7) { animation-delay: .3s; } .reveal > :nth-child(n+8) { animation-delay: .35s; }

/* ---------- View transitions (page-to-page, no JS) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(main) { animation: vt-out 180ms var(--ease-in-out) both; }
::view-transition-new(main) { animation: vt-in 380ms var(--ease-out) both; }
::view-transition-group(nav-indicator) { animation-duration: 420ms; animation-timing-function: var(--ease-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 250ms; }

/* ---------- Keyframes ---------- */
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes shrink { to { transform: scaleX(0); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 60% { box-shadow: 0 0 0 5px transparent; } }
@keyframes ring { 0% { transform: scale(.92); opacity: .7; } 100% { transform: scale(1.18); opacity: 0; } }
@keyframes grid-pan { to { background-position: 0 340px, 340px 0; } }
@keyframes glow-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-60px, 40px) scale(1.12); } }
@keyframes node-pop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse-node { 0%, 100% { filter: drop-shadow(0 0 0 rgba(217, 172, 110, 0)); } 50% { filter: drop-shadow(0 0 6px rgba(217, 172, 110, .9)); } }
@keyframes count-glow { from { text-shadow: 0 0 18px rgba(217, 172, 110, .6); } to { text-shadow: none; } }

/* ---------- Late additions ---------- */
@media (max-width: 900px) {
  [data-settings-layout] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-settings-layout] .settings-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  [data-settings-layout] .settings-nav a { white-space: nowrap; }
}

/* Install as an app: a quiet bar at the bottom, above the phone tab bar. */
.install-bar { position: fixed; z-index: var(--z-toast); left: 50%; bottom: 18px; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: var(--r-lg); background: var(--graphite-900); color: var(--shell-ink); border: 1px solid rgba(255, 244, 228, .1); box-shadow: var(--shadow-3); }
.install-bar[hidden] { display: none; }
.install-bar p { margin: 0; flex: 1; min-width: 0; font-size: .86rem; line-height: 1.35; }
.install-bar p b { display: block; }
.install-bar p span { color: var(--shell-muted); }
.install-bar .btn-ghost { color: var(--shell-muted); }
.install-bar .btn-ghost:hover { background: rgba(255, 244, 228, .07); color: var(--shell-ink); }
.install-bar-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: var(--r-md); background: rgba(217, 172, 110, .14); color: var(--gold-300); }
@media (max-width: 900px) { .install-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); } }
@media (max-width: 480px) { .install-bar p span { display: none; } }
.install-steps { margin: 0 0 12px; padding-left: 20px; color: var(--ink-2); }
.install-steps li + li { margin-top: 6px; }

/* ---------- Feedback: the floating button, the panel and the markup editor ---------- */
.feedback-fab { position: fixed; z-index: var(--z-fab); right: 24px; bottom: 24px; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 12px; border-radius: var(--r-xl); border: 1px solid rgba(255, 244, 228, .14); background: var(--graphite-900); color: var(--shell-ink); font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-3); transition: background var(--dur-2), transform var(--dur-2) var(--ease-out), bottom var(--dur-3) var(--ease-out); animation: fab-in var(--dur-4) var(--ease-out) .4s backwards; }
.feedback-fab .icon { width: 18px; height: 18px; color: var(--gold-300); }
.feedback-fab:hover { background: var(--graphite-800); transform: translateY(-1px); }
.feedback-fab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
[data-theme="dark"] .feedback-fab { background: var(--bg-elev-2); border-color: var(--line-strong); }
.app:has(.feedback-fab) .page { padding-bottom: 88px; }
@media (max-width: 900px) {
  .feedback-fab { right: 12px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); width: 48px; height: 48px; padding: 0; justify-content: center; }
  .feedback-fab span { display: none; }
  .feedback-fab .icon { width: 22px; height: 22px; }
  /* Above the install bar while it's offered (it spans the bottom on phones). */
  .app:has(.install-bar:not([hidden])) .feedback-fab { bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom)); }
  .app:has(.feedback-fab) .page { padding-bottom: calc(var(--tabbar-h) + 88px); }
}
@keyframes fab-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.feedback { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.feedback[open] { display: flex; }
.feedback-form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.feedback-head { display: flex; align-items: flex-start; gap: 12px; padding: var(--s-4) var(--s-3) var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.feedback-head .dialog-icon { width: 36px; height: 36px; margin: 0; flex: none; }
.feedback-head .dialog-icon .icon { width: 18px; height: 18px; }
.feedback-head h2 { margin: 0 0 2px; font-size: 1.05rem; }
.feedback-head p { margin: 0; font-size: .84rem; }
.feedback-head > .btn-icon { margin-left: auto; flex: none; }
.feedback-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4) var(--s-5); }
.feedback-kinds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.feedback-kinds span { justify-content: center; width: 100%; padding: 7px 6px; }
.feedback-kinds .icon { width: 15px; height: 15px; flex: none; }
.feedback-note { position: relative; }
.feedback-note .textarea { min-height: 124px; padding-right: 50px; }
.feedback-mic { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-elev-2); color: var(--ink-2); cursor: pointer; transition: background var(--dur-2), color var(--dur-2), border-color var(--dur-2); }
.feedback-mic[hidden] { display: none; }
.feedback-mic:hover { border-color: var(--line-strong); color: var(--ink); }
.feedback-mic:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.feedback-mic .icon { width: 18px; height: 18px; }
.feedback-mic.is-listening { background: var(--danger); border-color: var(--danger); color: #fff; animation: mic-pulse 1.4s var(--ease-out) infinite; }
@keyframes mic-pulse { from { box-shadow: 0 0 0 0 rgba(179, 59, 42, .45); } to { box-shadow: 0 0 0 10px rgba(179, 59, 42, 0); } }
.feedback-attach { display: flex; flex-wrap: wrap; gap: 8px; }
.feedback-attach .btn { flex: 1 1 180px; }
.feedback-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.feedback-list:empty { display: none; }
.feedback-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 6px 6px 6px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-elev-2); font-size: .86rem; }
.feedback-item.is-shot { padding-left: 6px; }
.feedback-item > .icon { flex: none; color: var(--muted); }
.feedback-item-name { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback-item-name > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.feedback-item-name small { display: block; font-weight: 500; color: var(--muted); }
.feedback-thumb { flex: none; width: 76px; height: 50px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--bg-sunken); cursor: pointer; }
.feedback-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.feedback-thumb:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.feedback-actions { align-items: center; border-top: 1px solid var(--line); padding: var(--s-3) var(--s-5) max(var(--s-3), env(safe-area-inset-bottom)); }
.dialog .feedback-context { margin: 0 auto 0 0; font-size: .78rem; color: var(--faint); }
.alert[hidden] { display: none; }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
@media (max-width: 640px) {
  /* A sheet from the bottom of the screen. */
  .feedback { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); }
  .feedback-head { padding-left: var(--s-4); }
  .feedback-body { padding: var(--s-4); }
  .feedback-actions { padding-inline: var(--s-4); }
  .feedback-context { display: none; }
  .feedback-actions .btn { flex: 1; }
}
@media (max-width: 420px) { .feedback-kinds .icon { display: none; } }

.markup { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--graphite-1000); color: var(--shell-ink); }
.markup[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.markup::backdrop { background: var(--graphite-1000); }
.markup-bar { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--shell-line); background: var(--shell); overflow-x: auto; scrollbar-width: none; }
.markup-group { display: flex; flex: none; gap: 2px; padding: 3px; border-radius: var(--r-md); border: 1px solid var(--shell-line); background: rgba(255, 244, 228, .04); }
.markup-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; min-width: 38px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--shell-muted); font: inherit; font-size: .84rem; font-weight: 650; cursor: pointer; transition: background var(--dur-2), color var(--dur-2); }
.markup-btn:hover { background: rgba(255, 244, 228, .06); color: var(--shell-ink); }
.markup-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.markup-btn[aria-pressed="true"] { background: rgba(217, 172, 110, .16); color: var(--gold-200); }
.markup-btn .icon { width: 18px; height: 18px; }
.markup-swatch { padding: 0; }
.markup-swatch i { width: 18px; height: 18px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.markup-swatch[aria-pressed="true"] { background: transparent; }
.markup-swatch[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--shell), 0 0 0 4px var(--swatch); }
.markup-swatch[data-markup-colour="red"] { --swatch: var(--mark-red); }
.markup-swatch[data-markup-colour="amber"] { --swatch: var(--mark-amber); }
.markup-swatch[data-markup-colour="blue"] { --swatch: var(--mark-blue); }
.markup-swatch[data-markup-colour="green"] { --swatch: var(--mark-green); }
.markup-swatch[data-markup-colour="ink"] { --swatch: var(--mark-ink); }
.markup-swatch[data-markup-colour="ink"] i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5); }
.markup-stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; padding: 12px; }
.markup-stage canvas { display: block; touch-action: none; cursor: crosshair; border: 1px solid var(--shell-line); box-shadow: 0 12px 40px rgba(0, 0, 0, .5); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.markup-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--shell-line); background: var(--shell); }
.markup-foot p { margin: 0 auto 0 0; font-size: .84rem; color: var(--shell-muted); }
.markup-foot .btn:not(.btn-primary) { --btn-bg: transparent; --btn-ink: var(--shell-ink); --btn-line: rgba(255, 244, 228, .16); }
.markup-foot .btn:not(.btn-primary):hover { background: rgba(255, 244, 228, .07); color: var(--shell-ink); border-color: rgba(255, 244, 228, .24); }
@media (max-width: 640px) {
  .markup-btn span { display: none; }
  /* Tools and history on one row, the colours on the next. */
  .markup-bar { flex-wrap: wrap; justify-content: center; gap: 6px; padding-inline: 8px; }
  .markup-btn { height: 40px; min-width: 40px; }
  .markup-colours { order: 2; }
  .markup-foot p { display: none; }
  .markup-foot .btn { flex: 1; }
}

/* Developers' list of feedback (/admin/feedback) */
.feedback-cell { min-width: 0; max-width: 620px; }
.feedback-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.feedback-title .badge .icon { width: 13px; height: 13px; }
.feedback-message { margin-top: 4px; font-size: .86rem; }
.feedback-message summary { cursor: pointer; color: var(--accent); font-weight: 650; }
.feedback-message p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); }
.feedback-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 4px 0 0; font-size: .8rem; color: var(--muted); }
.feedback-meta a { color: var(--muted); overflow-wrap: anywhere; }
.feedback-files { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; }
.feedback-files .chip { text-decoration: none; }
.feedback-files .chip .muted { font-weight: 500; }
.feedback-remote { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: .84rem; font-weight: 650; }
.feedback-remote .icon { width: 13px; height: 13px; }
.feedback-table td small { display: block; margin-top: 3px; font-size: .78rem; }
.feedback-error { color: var(--danger); overflow-wrap: anywhere; }

/* ---------- Tender Portal (MML side) ---------- */
.cell-wrap { white-space: nowrap; }
@media (max-width: 1100px) { .cell-wrap { white-space: normal; overflow-wrap: anywhere; } }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.card-actions .inline-form { display: contents; }
.count-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px; border-radius: var(--r-sm); background: var(--warn); color: #fff; font-size: .74rem; font-weight: 800; line-height: 1; }

/* Status strip: the portal's address, who's in, and how bidders get in */
.portal-strip { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px; }
.portal-strip-main { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.portal-addr { display: flex; align-items: center; gap: 10px; flex: 1 1 260px; min-width: 0; }
.portal-strip-title { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0; }
.portal-host { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.portal-figures { display: flex; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-elev-2); }
.portal-figures div { padding: 5px 14px; border-left: 1px solid var(--line); text-align: right; }
.portal-figures div:first-child { border-left: 0; }
.portal-figures dt { white-space: nowrap; font-size: .66rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.portal-figures dd { margin: 0; font-size: 1.05rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.portal-figures dd a { color: inherit; text-decoration: none; }
.portal-figures .is-due dd, .portal-figures .is-due dt { color: var(--warn); }
.portal-how { margin: 0; font-size: .84rem; color: var(--muted); }
.portal-strip .alert { padding: 9px 12px; font-size: .85rem; }
.portal-strip .alert code { font-size: .8rem; }

/* Questions: unanswered first, each with its answer or the form to answer it */
.portal-qs { list-style: none; margin: 0; padding: 0; }
.portal-q { padding: 12px 16px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.portal-q:last-child { border-bottom: 0; }
.portal-q.is-open { border-left-color: var(--warn); background: var(--bg-elev-2); }
.portal-q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .8rem; color: var(--muted); }
.portal-q-meta .strong { font-size: .86rem; }
.portal-q-meta .btn { margin-left: auto; }
.portal-q-text { margin: 6px 0 0; font-weight: 600; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.portal-a { margin-top: 8px; padding: 8px 12px; border-left: 2px solid var(--accent-line); background: var(--bg-elev-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.portal-a > p { margin: 0 0 4px; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink-2); font-size: .9rem; }
.portal-answer-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.portal-answer-form .textarea { min-height: 76px; }
.portal-answer-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.portal-share { font-size: .88rem; flex: 1 1 280px; }
.portal-share small { display: block; margin-top: 2px; }

/* Downloads beside activity on wide screens */
.portal-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s-5); margin-top: var(--s-5); align-items: start; }
.portal-split > .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .portal-split { grid-template-columns: minmax(0, 1fr); } }
.portal-who summary { cursor: pointer; font-size: .88rem; }
.portal-who summary b { color: var(--ink); }
.portal-who p { margin: 4px 0 0; font-size: .82rem; color: var(--ink-2); overflow-wrap: anywhere; }
.portal-who-label { display: inline-block; min-width: 76px; font-size: .7rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.portal-activity td { font-size: .86rem; }
.portal-activity .cell-project { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; }
.portal-activity .cell-project small { display: inline; }
.portal-activity .link-icon .icon { color: var(--faint); }

/* On a scope's bidders: each person's place in the portal */
.portal-contacts { list-style: none; margin: 2px 0 0; padding: 0; font-size: .8rem; color: var(--muted); }
.portal-contacts li.has-access { color: var(--ink-2); }
.portal-contacts li.has-access::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--ok); vertical-align: 1px; }
.portal-send { margin-top: 6px; }
@media (max-width: 760px) {
  .card-head > .card-actions { margin-left: 38px; justify-content: flex-start; }
  .portal-figures { width: 100%; }
  .portal-figures div { flex: 1; text-align: left; padding: 5px 10px; }
  .portal-q-meta .btn { margin-left: 0; }
  .portal-activity tr { padding: 8px 16px; }
  .portal-activity td[data-label]::before { display: none; }
}

/* ---------- Tender Portal (bidder side) ----------
   Bidders' pages on the portal's own host: a compact bar, one readable column, phone first
   (375 px, no sideways scroll, 44 px tap targets on touch screens). */
.portal { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.portal-bar { position: sticky; top: 0; z-index: var(--z-topbar); display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 16px; background: var(--shell); color: var(--shell-ink); border-bottom: 1px solid var(--shell-line); }
.portal-brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--shell-ink); text-decoration: none; }
.portal-brand:hover { color: var(--shell-ink); }
.portal-brand .logo { width: 88px; flex: none; }
.portal-brand-name { padding-left: 12px; border-left: 1px solid var(--shell-line); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-300); white-space: nowrap; }
.portal-who { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; line-height: 1.25; text-align: right; }
.portal-who b { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.portal-who small { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; color: var(--shell-muted); }
.portal-signout { --btn-bg: transparent; --btn-ink: var(--shell-ink); --btn-line: rgba(255, 244, 228, .18); }
.portal-signout:hover { background: rgba(255, 244, 228, .07); color: var(--shell-ink); border-color: var(--shell-muted); }
.portal-main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 24px 40px; }
.portal-foot { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); text-align: center; font-size: .76rem; color: var(--muted); }

/* Sign-in, link, code and status: one narrow card. */
.portal-auth { display: grid; justify-items: center; padding-top: clamp(4px, 5vh, 56px); }
.portal-auth-card { width: 100%; max-width: 440px; padding: var(--s-6); }
.portal-auth-card h1 { font-size: 1.4rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; margin-bottom: 8px; text-wrap: balance; }
.portal-auth-card > .alert { margin-bottom: var(--s-3); }
.portal-auth-card form { margin-top: var(--s-4); }
.portal-auth-icon { width: 44px; height: 44px; margin-bottom: var(--s-4); border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-line); }
.portal-auth-icon.is-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.portal-auth-icon .icon { width: 22px; height: 22px; }
.portal-auth-note { display: flex; gap: 10px; align-items: flex-start; margin: var(--s-5) 0 0; padding-top: var(--s-4); border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.portal-auth-note .icon { margin-top: 2px; color: var(--accent); }
.portal-email { color: var(--ink); overflow-wrap: anywhere; }
.portal-code-input { min-height: 56px; text-align: center; font-size: 1.6rem !important; font-weight: 750; letter-spacing: .32em; font-variant-numeric: tabular-nums; }
.portal-status { text-align: center; }
.portal-status .status-code { font-size: 4.5rem; margin-bottom: var(--s-2); }

/* Your tenders */
.portal-head { margin-bottom: var(--s-4); }
.portal-page > .crumbs a { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.portal-tenders { display: grid; gap: var(--s-3); }
.portal-tender { display: block; color: inherit; text-decoration: none; transition: border-color var(--dur-2), box-shadow var(--dur-2); }
.portal-tender:hover { color: inherit; border-color: var(--accent-line); box-shadow: var(--shadow-2); }
.portal-tender-head { display: flex; align-items: center; gap: var(--s-3); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.portal-tender-title { flex: 1; min-width: 0; }
.portal-tender-title h2 { font-size: 1.02rem; }
.portal-tender-title p { margin: 2px 0 0; }
.portal-tender-go { color: var(--accent); }
.portal-scope-list { list-style: none; margin: 0; padding: 0; }
.portal-scope-list li { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.portal-scope-list li:last-child { border-bottom: 0; }
.portal-scope-list-name { min-width: 0; }
.portal-scope-list-name b { display: block; font-weight: 650; }
.portal-scope-list-name small { color: var(--muted); }
.portal-scope-list-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* One tender */
.portal-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0; font-size: .86rem; color: var(--muted); }
.portal-facts span { display: inline-flex; align-items: center; gap: 6px; }
.portal-facts .icon { width: 15px; height: 15px; color: var(--accent); }
.portal-facts .portal-facts-close { color: var(--ink); font-weight: 650; }
.portal-jump { display: flex; gap: 6px; margin-top: var(--s-3); overflow-x: auto; scrollbar-width: none; }
.portal-jump a { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg-elev); color: var(--ink-2); font-size: .84rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.portal-jump a:hover { border-color: var(--accent-line); color: var(--ink); }
.portal-jump .n, .portal-folder-title .n { font-size: .72rem; font-weight: 800; padding: 0 6px; border-radius: var(--r-sm); background: var(--bg-sunken); color: var(--muted); border: 1px solid var(--line); letter-spacing: 0; }
.portal-section { margin-top: var(--s-6); scroll-margin-top: 72px; }
.portal-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.portal-section-title { font-size: 1.05rem; margin-bottom: 10px; }
.portal-section-head .portal-section-title { margin: 0; }
.portal-latest { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 650; color: var(--ok); }

.portal-scope { scroll-margin-top: 72px; }
.portal-scope-title { flex: 1; min-width: 0; }
.portal-scope-title h3 { font-size: .98rem; }
.portal-scope-desc { margin: 0; white-space: pre-line; color: var(--ink-2); font-size: .9rem; }
.portal-closes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; font-size: .88rem; }
.portal-closes .icon { color: var(--accent); }
.portal-countdown { font-weight: 700; color: var(--accent); }
.portal-closes.is-closed, .portal-closes.is-closed .portal-countdown { color: var(--muted); }
.portal-bid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px 12px; background: var(--ok-bg); border: 1px solid var(--ok-line); border-radius: var(--r-md); }
.portal-bid small { display: block; font-size: .7rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.portal-bid b { font-size: 1.08rem; }
.portal-file-name { overflow-wrap: anywhere; }
.portal-intent { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.portal-intent .inline-form, .portal-intent .btn { width: 100%; }
.btn.is-chosen { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent); }
.portal-bid-form > summary { list-style: none; width: 100%; }
.portal-bid-form > summary::-webkit-details-marker { display: none; }
.portal-bid-form[open] > summary { --btn-bg: var(--bg-elev); --btn-line: var(--line-strong); --btn-ink: var(--ink); background: var(--bg-elev); border-color: var(--line-strong); }
.portal-bid-form > form { margin-top: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-elev-2); }
.portal-notes { min-height: 72px; }
.portal-closed-note { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .88rem; font-weight: 600; color: var(--muted); }

.portal-folder + .portal-folder { border-top: 1px solid var(--line); }
.portal-folder-title { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--bg-elev-2); border-bottom: 1px solid var(--line); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); }
.portal-folder:first-child .portal-folder-title { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.portal-folder-title .icon { width: 15px; height: 15px; }
.portal-docs { list-style: none; margin: 0; padding: 0; }
.portal-docs li + li { border-top: 1px solid var(--line); }
.portal-doc { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: 8px 16px; color: inherit; text-decoration: none; transition: background var(--dur-2); }
.portal-doc:hover { background: var(--bg-hover); color: inherit; }
.portal-doc-icon { color: var(--faint); }
.portal-doc-text { flex: 1; min-width: 0; }
.portal-doc-text b { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 650; overflow-wrap: anywhere; }
.portal-doc-text small { display: block; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.portal-doc-get { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--bg-elev); color: var(--accent); }
.portal-doc:hover .portal-doc-get { border-color: var(--accent-line); }

.portal-ask .textarea { min-height: 88px; }
.portal-ask-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); flex-wrap: wrap; }
.portal-ask-closed { margin: 0; }
.portal-qa { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.portal-qa li { padding: 12px 16px; }
.portal-qa li + li { border-top: 1px solid var(--line); }
.portal-qa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 4px; font-size: .8rem; color: var(--muted); }
.portal-qa-meta b { color: var(--ink-2); }
.portal-qa-q { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.portal-qa-a { margin-top: var(--s-2); padding: 8px 12px; border-left: 3px solid var(--gold-400); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--bg-elev-2); }
.portal-qa-a small { font-size: .76rem; font-weight: 700; color: var(--accent); }
.portal-qa-a p { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.portal-qa-none { margin: 0; }

@media (max-width: 900px) {
  .portal .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .portal-bar { flex-wrap: wrap; gap: 6px 8px; padding: 0 12px; }
  .portal-brand { min-height: 52px; gap: 10px; }
  .portal-brand .logo { width: 72px; }
  .portal-brand-name { padding-left: 10px; font-size: .68rem; }
  .portal-signout span { display: none; }
  .portal-signout { width: 40px; padding: 0; }
  /* Who's signed in: a slim second line under the bar. */
  .portal-who { order: 9; flex: 1 0 100%; flex-direction: row; align-items: baseline; gap: 6px; margin: 0 -12px; padding: 5px 12px; border-top: 1px solid var(--shell-line); background: var(--shell-2); text-align: left; }
  .portal-who b, .portal-who small { max-width: none; }
  .portal-who small::before { content: "· "; }
  .portal-main { padding: 14px 12px 32px; }
  .portal-auth-card { padding: var(--s-5) var(--s-4); }
  .portal-bid { grid-template-columns: 1fr 1fr; }
  .portal-bid > div:last-child:nth-child(3) { grid-column: 1 / -1; }
  .portal-tender-head, .portal-scope-list li, .portal-doc, .portal-qa li, .portal-folder-title { padding-left: 12px; padding-right: 12px; }
  .portal-ask-foot .btn { width: 100%; }
  .portal-jump a { flex: 1 1 0; justify-content: center; padding: 0 8px; }
}
/* Touch screens: every control at least 44 px tall. */
@media (pointer: coarse) {
  .portal .btn, .portal .input, .portal .select { min-height: 44px; }
  .portal .btn-lg { min-height: 48px; }
  .portal-jump a { min-height: 40px; }
  .portal-doc-get { width: 44px; height: 44px; }
}
