/* AdametherzLab portal: base tokens and components (architect, read-only for builders).
   Area sheets (auth.css B1, client.css B2, admin.css B3) build on these tokens and classes and never redefine them.
   CSP: style-src 'self', so no inline styles anywhere. Progress uses <progress>, not width styles.

   Brand pass (2026-11-09). The palette comes from the AdametherzLab mark: its indigo ground (#18143c) for the header and
   the main buttons, teal, gold and magenta from its petals for small accents. Fraunces for headings, Figtree for text,
   both self-hosted (SIL OFL, static/fonts). Icons are Lucide line icons from static/img/icons.svg. */

@font-face {
  font-family: "Figtree";
  src: url("/static/fonts/figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/static/fonts/fraunces.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Brand */
  --night: #18143c;
  --night-2: #241d5a;
  --night-ink: #f4f1ff;
  --night-muted: #bdb6e0;
  --teal: #19d8a9;
  --gold: #eebb45;
  --magenta: #b90f8a;
  /* The flower-of-life line pattern for indigo panels; the area sheets use var(--pattern) and carry no url(). */
  --pattern: url("/static/img/pattern.svg");
  --brand-line: linear-gradient(90deg, #19d8a9 0%, #8fe3a8 30%, #eebb45 60%, #e0679f 85%, #b90f8a 100%);

  /* Surfaces and text */
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b1838;
  --muted: #5c5873;
  --line: #e6e2ec;
  --line-strong: #cfc9dc;

  /* Actions and states */
  --accent: #2a2170;
  --accent-hover: #372b8f;
  --accent-ink: #ffffff;
  --accent-soft: #eeebfa;
  --accent-text: #3a2f9a;
  --good: #116a4e;
  --good-soft: #e1f4ec;
  --warn: #8a5300;
  --warn-soft: #fdf1d8;
  --bad: #b02331;
  --bad-soft: #fcebec;
  --info: #3a2f9a;
  --info-soft: #eeebfa;
  --focus: #0e8c78;

  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --text: 1rem;
  --text-sm: 0.9rem;
  --text-lg: 1.125rem;
  --leading: 1.6;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(24, 20, 60, 0.05), 0 14px 34px -20px rgba(24, 20, 60, 0.28);
  --shadow-lift: 0 2px 4px rgba(24, 20, 60, 0.06), 0 20px 40px -22px rgba(24, 20, 60, 0.38);
  --tap: 44px;
  --wrap: 1040px;
  --tabbar: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0c24;
    --surface: #1a1640;
    --surface-2: #211c4c;
    --ink: #efecfa;
    --muted: #aaa4c8;
    --line: #2e2862;
    --line-strong: #433b80;
    --accent: #2fdcb0;
    --accent-hover: #5ae6c3;
    --accent-ink: #0f0c24;
    --accent-soft: #1b3a45;
    --accent-text: #7ff0d0;
    --good: #5fe0a8;
    --good-soft: #15342b;
    --warn: #ffc865;
    --warn-soft: #3a2c14;
    --bad: #ff8f94;
    --bad-soft: #3d1a25;
    --info: #b3a8ff;
    --info-soft: #262058;
    --focus: #eebb45;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 34px -20px rgba(0, 0, 0, 0.7);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 20px 40px -22px rgba(0, 0, 0, 0.8);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--text)/var(--leading) var(--font);
  font-feature-settings: "ss01";
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
main { flex: 1; outline: none; padding-top: var(--space-6); padding-bottom: var(--space-7); }
img, video, audio { max-width: 100%; }
audio, video { display: block; width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--space-3); color: var(--ink); }
h1, h2 { font-family: var(--display); font-weight: 600; letter-spacing: -0.012em; }
h1 { font-size: clamp(1.7rem, 1.35rem + 1.4vw, 2.2rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
b, strong { font-weight: 700; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
.emoji { font-style: normal; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.eyebrow {
  margin: 0 0 var(--space-2); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-text);
}

/* Icons: <svg class="icon"><use href="/static/img/icons.svg#name"></use></svg>, sized by the text around them. */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
/* A heading's leading icon sits in a soft tile. */
h1 > .icon:first-child, h2 > .icon:first-child {
  box-sizing: content-box; width: 0.78em; height: 0.78em; padding: 0.3em; margin-right: 0.4em;
  border-radius: 0.42em; background: var(--accent-soft); color: var(--accent-text); vertical-align: -0.36em;
}
h3 > .icon:first-child { color: var(--accent-text); margin-right: 0.25em; }
/* A long page title wraps beside its icon tile, not under it. */
h1:has(> .icon:first-child) { display: flex; align-items: flex-start; gap: 0.4em; }
h1:has(> .icon:first-child) > .icon:first-child { margin-right: 0; margin-top: -0.04em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: var(--space-3); top: var(--space-3); background: var(--surface); padding: var(--space-2) var(--space-3); z-index: 30; border-radius: var(--radius-sm); }

/* Layout */
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding-left: var(--space-4); padding-right: var(--space-4); }
@media (min-width: 720px) { .wrap { padding-left: var(--space-5); padding-right: var(--space-5); } }
.stack > * + * { margin-top: var(--space-4); }
.grid { display: grid; gap: var(--space-4); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }

/* Header: the mark on its own indigo, a thin line in the mark's colors underneath. */
.site-header { position: relative; background: var(--night); color: var(--night-ink); }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--brand-line); }
.header-row { display: flex; align-items: center; gap: var(--space-4); min-height: 68px; padding-top: var(--space-2); padding-bottom: calc(var(--space-2) + 3px); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--night-ink); text-decoration: none; margin-right: auto; min-height: var(--tap); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 1.2rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-top: 3px; }
.brand:hover .brand-name { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--space-1); align-items: center; }
.site-nav a {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); color: var(--night-muted); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.site-nav a:hover { color: var(--night-ink); background: rgba(255, 255, 255, 0.07); }
.site-nav a[aria-current="page"] { color: var(--night-ink); background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 -2px 0 var(--gold); }
.site-nav .icon { width: 1.1em; height: 1.1em; vertical-align: 0; }

.nav-form { margin: 0; }
.btn-signout {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap); padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: var(--radius-sm); background: transparent;
  color: var(--night-muted); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.btn-signout:hover { color: var(--night-ink); border-color: rgba(255, 255, 255, 0.4); }
.site-header :focus-visible { outline-color: var(--gold); }

/* On a phone the main links are a tab bar fixed to the bottom of the screen (E2E-m9: one row that never wraps).
   Sign out stays in the header as a compact button. */
@media (max-width: 719px) {
  .header-row { min-height: 60px; gap: var(--space-2); }
  .brand-mark { width: 36px; height: 36px; border-radius: 9px; }
  .brand-name { font-size: 1.08rem; }
  .btn-signout { padding: var(--space-2); font-size: 0.85rem; }
  body.has-tabs { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }
  .site-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -16px rgba(24, 20, 60, 0.35);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .site-nav ul { flex-wrap: nowrap; overflow-x: auto; justify-content: space-around; align-items: stretch; gap: 0; scrollbar-width: none; }
  .site-nav li { flex: 1 0 auto; display: flex; }
  .site-nav a {
    flex-direction: column; justify-content: center; gap: 3px; width: 100%; min-height: var(--tabbar);
    padding: var(--space-1) 6px; border-radius: 0; font-size: 0.72rem; font-weight: 650; line-height: 1.1; color: var(--muted);
    white-space: nowrap; text-align: center;
  }
  .site-nav a .icon { width: 22px; height: 22px; }
  .site-nav a:hover { background: transparent; color: var(--ink); }
  .site-nav a[aria-current="page"] { color: var(--accent-text); background: transparent; box-shadow: inset 0 3px 0 var(--accent-text); }
}
@media (max-width: 380px) {
  .btn-signout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm); padding: var(--space-5) 0; }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-5); }
.site-footer p { margin: 0; }
.footer-brand { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--display); font-weight: 600; color: var(--ink); }
.footer-brand img { width: 24px; height: 24px; border-radius: 6px; }
.footer-note { display: flex; gap: var(--space-2); align-items: flex-start; max-width: 62ch; }
.footer-note .icon { margin-top: 3px; color: var(--accent-text); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--space-4); }
.card-tight { padding: var(--space-4); }
@media (max-width: 719px) { .card { padding: 20px; } }
.error-card { max-width: 560px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: var(--space-2) 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; line-height: 1.25;
  text-decoration: none; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--accent-text); background: var(--surface-2); }
.btn .icon { width: 1.1em; height: 1.1em; vertical-align: 0; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 18px -12px rgba(42, 33, 112, 0.8); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-big {
  min-height: 64px; font-size: var(--text-lg); padding: var(--space-3) var(--space-5); border-radius: var(--radius);
  width: 100%; justify-content: flex-start;
}
.btn-link { background: none; border: 0; padding: var(--space-2) var(--space-1); min-height: var(--tap); color: var(--accent-text); font: inherit; text-decoration: underline; cursor: pointer; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* Forms */
form { margin: 0; }
.field { margin-bottom: var(--space-4); }
.field > label, .field > .label, fieldset > legend { display: block; font-weight: 650; margin-bottom: 6px; }
.help { color: var(--muted); font-size: var(--text-sm); margin: 0 0 var(--space-2); }
.required-mark { color: var(--bad); }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="url"],
input[type="number"], input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: var(--space-2) 14px;
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="tel"]:focus, input[type="url"]:focus,
input[type="number"]:focus, input[type="datetime-local"]:focus, input[type="search"]:focus, select:focus, textarea:focus {
  border-color: var(--accent-text); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { min-height: 120px; resize: vertical; }
input[type="file"] { font: inherit; max-width: 100%; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-4); min-width: 0; }
.choice { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-2) 0; min-height: var(--tap); }
.choice input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.choice .icon { color: var(--muted); }
[aria-invalid="true"] { border-color: var(--bad); }
.error-text { color: var(--bad); font-size: var(--text-sm); margin: var(--space-1) 0 0; font-weight: 600; }

/* Flash and callouts */
.flash { border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); border: 1px solid transparent; border-left-width: 4px; font-weight: 600; }
.flash-success { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.callout { border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); }
.callout p:last-child { margin-bottom: 0; }
.callout-info { background: var(--info-soft); border-left: 4px solid var(--info); }
.callout-warning { background: var(--warn-soft); border-left: 4px solid var(--warn); font-weight: 700; }
.callout .icon { color: inherit; }

/* Pills and badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; border: 1px solid transparent; line-height: 1.5;
}
.pill .icon { width: 1em; height: 1em; vertical-align: 0; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }

/* Progress: <progress class="bar" value="40" max="100">, filled in the mark's teal to gold. */
progress.bar { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--line); overflow: hidden; }
progress.bar::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress.bar::-webkit-progress-value { background: linear-gradient(90deg, #14b892, #eebb45); border-radius: 999px; }
progress.bar::-moz-progress-bar { background: linear-gradient(90deg, #14b892, #eebb45); border-radius: 999px; }
progress.bar.done::-webkit-progress-value { background: var(--good); }
progress.bar.done::-moz-progress-bar { background: var(--good); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 10px var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }

/* Lists */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.plain-list > li:last-child { border-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .skip-link, .site-nav { display: none; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .card { box-shadow: none; }
}
