/* ==== base:begin ==========================================================
 * 02AI Workbench design system: tokens, reset and shared primitives.
 *
 * Canonical copy. This file is NOT served: every page stylesheet
 * (web/studio/style.css, web/admin/style.css, web/auth/style.css) starts with a
 * verbatim copy of everything between the base:begin and base:end markers, so
 * each page stays one same-origin stylesheet (CSP style-src 'self', and the
 * sign-in page is served before the sign-in gate). tests/frontend-base.test.ts
 * fails when a copy drifts. Edit here, then paste into all three.
 *
 * Rules the browser code follows (tests/server.test.ts, admin-routes.test.ts):
 * no inline styles and no `.style.` from script. Dynamic visuals use classes,
 * SVG attributes, <progress>/<meter> or data-* attributes.
 * ======================================================================== */

:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", Charter, "Source Serif 4", "Source Serif Pro", "Palatino Linotype", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-base: 13.5px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  --lh-tight: 1.25;
  --lh-base: 1.5;
  --lh-prose: 1.65;

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

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 999px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 280ms;

  /* Light theme (default). */
  --bg: #fafafb;
  --bg-sunken: #f4f4f6;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --surface-3: #efeff3;
  --overlay: rgba(14, 14, 22, 0.32);
  --border: #e8e8ed;
  --border-strong: #d7d7df;
  --text: #17171f;
  --text-2: #4b4b59;
  --text-3: #6b6b78;
  --text-inverse: #ffffff;

  --accent: #5b4cdb;
  --accent-hover: #4c3ec6;
  --accent-text: #4b3dc0;
  --accent-soft: #f2f0fd;
  --accent-soft-2: #e7e3fb;
  --accent-border: #d6d0f6;
  --accent-solid: #5b4cdb;
  --accent-solid-hover: #4c3ec6;

  --success: #16794c;
  --success-soft: #eaf6ef;
  --success-border: #c5e5d3;
  --warning: #93590a;
  --warning-soft: #fcf4e4;
  --warning-border: #efd9ac;
  --danger: #c0352c;
  --danger-hover: #a82c24;
  --danger-soft: #fdeeec;
  --danger-border: #f3c9c4;
  --info: #2a62c4;
  --info-soft: #ecf2fd;
  --info-border: #c9daf7;

  --chart-1: #5b4cdb;
  --chart-2: #0e9384;
  --chart-3: #dc8a1c;
  --chart-4: #d4466c;
  --chart-5: #3878e0;
  --chart-6: #8b8b99;
  --chart-grid: #ececf1;

  --shadow-xs: 0 1px 2px rgba(17, 17, 32, 0.04);
  --shadow-sm: 0 1px 2px rgba(17, 17, 32, 0.05), 0 1px 3px rgba(17, 17, 32, 0.05);
  --shadow-md: 0 1px 2px rgba(17, 17, 32, 0.04), 0 6px 16px -4px rgba(17, 17, 32, 0.1);
  --shadow-lg: 0 2px 6px rgba(17, 17, 32, 0.05), 0 22px 48px -12px rgba(17, 17, 32, 0.22);
  --ring: 0 0 0 3px rgba(91, 76, 219, 0.24);
  --scrollbar: #d4d4dc;
}

/* Dark theme: follows the system unless the page set data-theme="light". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f13;
    --bg-sunken: #0b0b0e;
    --surface: #16161c;
    --surface-2: #1c1c24;
    --surface-3: #25252f;
    --overlay: rgba(0, 0, 0, 0.55);
    --border: #282832;
    --border-strong: #383844;
    --text: #ededf2;
    --text-2: #b7b7c3;
    --text-3: #8e8e9c;
    --text-inverse: #101015;
    --accent: #8f84f6;
    --accent-hover: #a198f8;
    --accent-text: #aca4f9;
    --accent-soft: rgba(143, 132, 246, 0.13);
    --accent-soft-2: rgba(143, 132, 246, 0.2);
    --accent-border: rgba(143, 132, 246, 0.36);
    --accent-solid: #6656e0;
    --accent-solid-hover: #5a4ad6;
    --success: #4cc48c;
    --success-soft: rgba(76, 196, 140, 0.12);
    --success-border: rgba(76, 196, 140, 0.32);
    --warning: #e2a543;
    --warning-soft: rgba(226, 165, 67, 0.12);
    --warning-border: rgba(226, 165, 67, 0.32);
    --danger: #f0716a;
    --danger-hover: #f48a84;
    --danger-soft: rgba(240, 113, 106, 0.12);
    --danger-border: rgba(240, 113, 106, 0.34);
    --info: #6ea0f2;
    --info-soft: rgba(110, 160, 242, 0.12);
    --info-border: rgba(110, 160, 242, 0.32);
    --chart-1: #8f84f6;
    --chart-2: #2cc2ae;
    --chart-3: #eba443;
    --chart-4: #ef6f92;
    --chart-5: #6ea0f2;
    --chart-6: #8a8a98;
    --chart-grid: #26262f;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 56px -12px rgba(0, 0, 0, 0.7);
    --ring: 0 0 0 3px rgba(143, 132, 246, 0.32);
    --scrollbar: #3a3a46;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f13;
  --bg-sunken: #0b0b0e;
  --surface: #16161c;
  --surface-2: #1c1c24;
  --surface-3: #25252f;
  --overlay: rgba(0, 0, 0, 0.55);
  --border: #282832;
  --border-strong: #383844;
  --text: #ededf2;
  --text-2: #b7b7c3;
  --text-3: #8e8e9c;
  --text-inverse: #101015;
  --accent: #8f84f6;
  --accent-hover: #a198f8;
  --accent-text: #aca4f9;
  --accent-soft: rgba(143, 132, 246, 0.13);
  --accent-soft-2: rgba(143, 132, 246, 0.2);
  --accent-border: rgba(143, 132, 246, 0.36);
  --accent-solid: #6656e0;
  --accent-solid-hover: #5a4ad6;
  --success: #4cc48c;
  --success-soft: rgba(76, 196, 140, 0.12);
  --success-border: rgba(76, 196, 140, 0.32);
  --warning: #e2a543;
  --warning-soft: rgba(226, 165, 67, 0.12);
  --warning-border: rgba(226, 165, 67, 0.32);
  --danger: #f0716a;
  --danger-hover: #f48a84;
  --danger-soft: rgba(240, 113, 106, 0.12);
  --danger-border: rgba(240, 113, 106, 0.34);
  --info: #6ea0f2;
  --info-soft: rgba(110, 160, 242, 0.12);
  --info-border: rgba(110, 160, 242, 0.32);
  --chart-1: #8f84f6;
  --chart-2: #2cc2ae;
  --chart-3: #eba443;
  --chart-4: #ef6f92;
  --chart-5: #6ea0f2;
  --chart-6: #8a8a98;
  --chart-grid: #26262f;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 56px -12px rgba(0, 0, 0, 0.7);
  --ring: 0 0 0 3px rgba(143, 132, 246, 0.32);
  --scrollbar: #3a3a46;
}

/* ---- Reset ------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
dl,
dd {
  margin: 0;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}
img,
svg {
  display: block;
  max-width: 100%;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
a {
  color: var(--accent-text);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
::selection {
  background: var(--accent-soft-2);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}
:focus {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Accessibility helpers -------------------------------------------- */
/* !important: it must beat element rules such as input[type="email"] { width: 100% }. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  box-shadow: none !important;
}
.skip-link {
  position: fixed;
  top: -80px;
  left: var(--s-4);
  z-index: 100;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-weight: 500;
}
.skip-link:focus {
  top: var(--s-3);
}

/* ---- Icons (inline <svg><use href="#i-…"></svg>, sprite in each page) ---- */
.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm {
  width: 14px;
  height: 14px;
}
.icon-lg {
  width: 20px;
  height: 20px;
}

/* ---- Buttons ------------------------------------------------------------
 * <button> is a quiet secondary button by default; .primary, .danger, .ghost,
 * .small and .icon-button modify it. Links styled as buttons use .button.
 */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled),
.button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  text-decoration: none;
}
button:active:not(:disabled) {
  background: var(--surface-3);
}
button:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary,
.button.primary {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.primary:hover:not(:disabled),
.button.primary:hover {
  background: var(--accent-solid-hover);
  border-color: var(--accent-solid-hover);
}
button.danger,
.button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--surface);
}
button.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}
button.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
button.danger-solid:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
button.ghost,
.button.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}
button.ghost:hover:not(:disabled),
.button.ghost:hover {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--text);
}
button.small,
.button.small {
  min-height: 26px;
  padding: 0 9px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}
button.icon-button,
.icon-button {
  width: 32px;
  min-width: 32px;
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-3);
}
button.icon-button:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--text);
}
button.icon-button.small {
  width: 26px;
  min-width: 26px;
}

/* ---- Form controls ----------------------------------------------------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-3);
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--text-3);
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--accent);
}
label {
  font-weight: 500;
}

/* ---- Pills, badges, status dots --------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.tone-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: var(--success-border);
}
.tone-warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--warning-border);
}
.tone-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-border);
}
.tone-info {
  color: var(--info);
  background: var(--info-soft);
  border-color: var(--info-border);
}
.tone-accent {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.tone-neutral {
  color: var(--text-2);
  background: var(--surface-2);
  border-color: var(--border);
}
kbd {
  display: inline-flex;
  align-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: var(--fs-2xs);
  font-weight: 500;
}

/* ---- Spinner ----------------------------------------------------------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}
.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---- Cards, menus, dialogs -------------------------------------------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.menu {
  min-width: 200px;
  padding: var(--s-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 400;
  text-align: left;
  text-decoration: none;
}
.menu-item:hover:not(:disabled),
a.menu-item:hover {
  background: var(--surface-3);
  text-decoration: none;
}
.menu-item:focus-visible {
  box-shadow: none;
  background: var(--surface-3);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.menu-item .icon {
  color: var(--text-3);
}
.menu-item.danger,
button.menu-item.danger {
  color: var(--danger);
  border: 0;
}
.menu-item.danger .icon {
  color: var(--danger);
}
.menu-sep {
  height: 1px;
  margin: var(--s-1) calc(-1 * var(--s-1));
  background: var(--border);
}
dialog {
  width: min(440px, calc(100vw - 32px));
  padding: var(--s-6);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}
dialog[open] {
  animation: dialog-in var(--dur-slow) var(--ease);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}
dialog h2 {
  font-size: var(--fs-lg);
  margin-bottom: var(--s-2);
}
dialog p {
  color: var(--text-2);
  line-height: var(--lh-base);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-6);
}

/* ---- Brand ------------------------------------------------------------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  width: 26px;
  height: 27px;
  object-fit: contain;
  flex: none;
}
/* ==== base:end ========================================================== */

/* ==== page: sign-in and set password (web/auth) ===========================
 * docs/frontend-design.md 5. From 960px a split layout: an ink-violet brand panel
 * (the same in both themes; its colours are defined once, in .auth-brand) and
 * the form, max 360px, vertically centred. Below 960px one column with a logo
 * row. This sheet also styles the admin 403 page (src/admin-routes.ts
 * FORBIDDEN_PAGE links /auth.css: it is served before the gate and the 403
 * page's CSP allows only same-origin stylesheets).
 * ======================================================================== */

.auth-page {
  min-height: 100dvh;
}
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---- Brand panel (wide screens only) ----------------------------------- */
.auth-brand {
  /* The one place this page defines colours: a deep ink-violet surface. */
  --ink-bg: #110f24;
  --ink-bg-2: #1b1742;
  --ink-text: #f4f2ff;
  --ink-text-2: rgba(226, 222, 255, 0.72);
  --ink-text-3: rgba(226, 222, 255, 0.5);
  --ink-line: rgba(186, 176, 255, 0.11);
  --ink-cell: rgba(143, 132, 246, 0.07);
  --ink-cell-line: rgba(186, 176, 255, 0.3);
  --ink-tile: rgba(255, 255, 255, 0.055);
  --ink-tile-border: rgba(255, 255, 255, 0.09);
  --ink-icon: #b9b0ff;
  --ink-glow: rgba(104, 88, 240, 0.45);
  --ink-glow-2: rgba(91, 76, 219, 0.2);
  position: relative;
  isolation: isolate;
  display: none;
  overflow: hidden;
  color: var(--ink-text);
  background:
    radial-gradient(85% 55% at 0% 100%, var(--ink-glow), transparent 70%),
    radial-gradient(60% 45% at 100% 0%, var(--ink-glow-2), transparent 70%),
    linear-gradient(165deg, var(--ink-bg-2) 0%, var(--ink-bg) 62%);
}
.auth-brand-art {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
/* Anchored to the panel's right edge (the panel is at most 680px wide), so the logo's three cells
   sit in the top-right corner at every width. */
.lattice {
  position: absolute;
  top: 0;
  right: 0;
  width: 680px;
  height: 100%;
  max-width: none;
}
.lattice-line {
  fill: none;
  stroke: var(--ink-line);
  stroke-width: 1;
}
.lattice-cells {
  fill: var(--ink-cell);
  stroke: var(--ink-cell-line);
  stroke-width: 1;
}
.auth-brand .brand {
  gap: 12px;
  color: var(--ink-text);
  font-size: var(--fs-md);
}
.brand-tile {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--ink-text);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 8px 24px -8px rgba(0, 0, 0, 0.6);
}
.brand-tile .brand-mark {
  width: 24px;
  height: 25px;
}
/* The violet logo on a dark page background: lifted to the dark accent's lightness. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand > .brand-mark {
    filter: brightness(1.85) saturate(0.9);
  }
}
:root[data-theme="dark"] .brand > .brand-mark {
  filter: brightness(1.85) saturate(0.9);
}
.auth-brand-body {
  max-width: 460px;
}
.auth-lede {
  font-family: var(--font-serif);
  font-size: 31px;
  font-weight: 400;
  line-height: 1.22;
  letter-spacing: -0.012em;
  color: var(--ink-text);
  text-wrap: balance;
}
.capabilities {
  display: grid;
  gap: var(--s-5);
  margin: var(--s-10) 0 0;
  padding: 0;
  list-style: none;
}
.capabilities li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  color: var(--ink-text-2);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}
.capabilities strong {
  display: block;
  margin-bottom: 1px;
  color: var(--ink-text);
  font-weight: 500;
}
.capability-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--ink-tile-border);
  border-radius: var(--r-md);
  background: var(--ink-tile);
  color: var(--ink-icon);
}
.auth-brand-foot {
  color: var(--ink-text-3);
  font-size: var(--fs-xs);
  letter-spacing: 0.01em;
}

/* ---- Form column -------------------------------------------------------- */
.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: var(--s-5) var(--s-5) var(--s-10);
}
.auth-mobile-brand {
  width: 100%;
  max-width: 360px;
  margin-bottom: var(--s-12);
}
.auth-panel {
  width: 100%;
  max-width: 360px;
}
.auth-head {
  margin-bottom: var(--s-8);
}
.auth-head h1 {
  font-size: var(--fs-2xl);
  letter-spacing: -0.022em;
}
.auth-subtitle {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
}

/* Whose password is being set (setup links). */
.account {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: calc(-1 * var(--s-3)) 0 var(--s-6);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.account-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.account-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: var(--lh-tight);
}
.account-label {
  margin-bottom: 3px;
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.account strong {
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* "Checking your link…" */
.status {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-5);
  color: var(--text-2);
}
.status::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--accent-soft-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.status:empty {
  display: none;
}

/* Errors: a calm danger callout (the icon is a sibling, so textContent never removes it). */
.callout {
  position: relative;
}
.error {
  margin-bottom: var(--s-5);
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-md);
  background: var(--danger-soft);
  color: var(--text);
  line-height: var(--lh-base);
  overflow-wrap: anywhere;
  animation: callout-in var(--dur) var(--ease);
}
.callout-icon {
  position: absolute;
  top: 12px;
  left: 13px;
  color: var(--danger);
}
.error:empty,
.error:empty + .callout-icon {
  display: none;
}
@keyframes callout-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
}

/* Fields */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.field label {
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.auth-panel input[type="email"],
.auth-panel input[type="password"],
.auth-panel input[type="text"] {
  min-height: 40px;
  padding: 9px 12px;
  border-radius: var(--r-md);
}
/* The hidden username field for password managers: base's input[type="email"] rule outranks
   .visually-hidden, so restate its size here (else it is a viewport-wide absolute box). */
.auth-panel input.visually-hidden {
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}
.auth-panel input[aria-invalid="true"] {
  border-color: var(--danger);
}
.auth-panel input[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.password {
  position: relative;
}
.auth-panel .password input {
  padding-right: 44px;
}
button.reveal {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-color: transparent;
  border-radius: var(--r-sm);
  background: transparent;
  box-shadow: none;
  color: var(--text-3);
}
button.reveal:hover:not(:disabled) {
  border-color: transparent;
  background: var(--surface-3);
  color: var(--text);
}
button.reveal:active:not(:disabled) {
  background: var(--surface-3);
}
button.reveal[aria-pressed="true"] {
  color: var(--text-2);
}
.reveal .icon-hide,
.reveal[aria-pressed="true"] .icon-show {
  display: none;
}
.reveal[aria-pressed="true"] .icon-hide {
  display: block;
}
.hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.hint .icon {
  width: 14px;
  height: 14px;
}

/* Buttons: full width, 40px; the busy state shows a spinner before the label. */
.block {
  width: 100%;
}
.auth-panel button.primary,
.auth-panel .button.block {
  min-height: 40px;
  font-size: var(--fs-base);
}
.auth-panel button.primary {
  margin-top: var(--s-1);
}
.auth-panel button[aria-busy="true"] {
  opacity: 0.85;
  cursor: progress;
}
.auth-panel button[aria-busy="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid color-mix(in srgb, currentColor 32%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.signin-link {
  margin-top: var(--s-1);
}

/* Invitation and activity notes */
.auth-notes {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-top: var(--s-8);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}
.note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  line-height: var(--lh-base);
}
.note .icon {
  width: 14px;
  height: 14px;
  margin-top: 2.5px;
}

/* Phones: 16px inputs (no zoom on focus in iOS Safari). */
@media (max-width: 959.98px) {
  .auth-panel input[type="email"],
  .auth-panel input[type="password"],
  .auth-panel input[type="text"] {
    font-size: 16px;
  }
}
@media (max-width: 380px) {
  .auth-main {
    padding-inline: var(--s-4);
  }
  .auth-mobile-brand {
    margin-bottom: var(--s-10);
  }
  .auth-head h1 {
    font-size: var(--fs-xl);
  }
}

/* ---- Split layout --------------------------------------------------------- */
@media (min-width: 960px) {
  .auth {
    grid-template-columns: clamp(440px, 44vw, 680px) minmax(0, 1fr);
  }
  .auth-brand {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--s-10);
    height: 100dvh;
    min-height: 600px;
    padding: var(--s-10) var(--s-12);
  }
  .auth-mobile-brand {
    display: none;
  }
  .auth-main {
    justify-content: center;
    padding: var(--s-12) var(--s-10);
  }
}
@media (min-width: 960px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth-brand {
    box-shadow: inset -1px 0 0 var(--border);
  }
}
@media (min-width: 960px) {
  :root[data-theme="dark"] .auth-brand {
    box-shadow: inset -1px 0 0 var(--border);
  }
}
@media (min-width: 1280px) {
  .auth-brand {
    padding: var(--s-12) 64px;
  }
  .auth-lede {
    font-size: 34px;
  }
}

/* ---- Admin 403 page (src/admin-routes.ts FORBIDDEN_PAGE) ----------------- */
.forbidden-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}
.status-top {
  padding: var(--s-5) var(--s-6);
}
.forbidden-card {
  align-self: center;
  justify-self: center;
  width: min(440px, calc(100% - 32px));
  margin-bottom: 12vh;
  padding: var(--s-8);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.status-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.status-icon .icon {
  width: 20px;
  height: 20px;
}
.forbidden-card h1 {
  font-size: var(--fs-xl);
  letter-spacing: -0.015em;
}
.forbidden-card p {
  margin-top: var(--s-2);
  color: var(--text-2);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}
.forbidden-card .status-actions {
  margin-top: var(--s-6);
}
.status-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--accent-solid);
  border-radius: var(--r-md);
  background: var(--accent-solid);
  color: #fff;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur-fast) var(--ease);
}
.status-actions a:hover {
  background: var(--accent-solid-hover);
  border-color: var(--accent-solid-hover);
  text-decoration: none;
}
.status-actions a:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
@media (max-width: 480px) {
  .forbidden-card {
    padding: var(--s-6);
  }
}
