/* Jarvis in the ZAZ Operations visual language (app-operations docs/29, v2). The tokens are the
   same values as [data-zaz] in Operations' src/styles.css, so the two apps look like one product.
   Teal is identity and interaction, never a status. No framework, no font files, no build. */

[data-zaz] {
  --zaz-teal: oklch(0.75 0.11 179);
  --zaz-teal-deep: oklch(0.43 0.075 188);
  --zaz-ink: oklch(0.255 0.024 205);
  --radius: 0.625rem;
  --background: oklch(0.972 0.005 175);
  --card: oklch(0.997 0.0015 175);
  --surface-2: oklch(0.955 0.007 175);
  --surface-raised: oklch(1 0 0);
  --surface-brand: oklch(0.955 0.022 182);
  --sidebar: oklch(0.946 0.014 182);
  --foreground: var(--zaz-ink);
  --fg-2: oklch(0.43 0.02 190);
  --muted-foreground: oklch(0.515 0.016 180);
  --brand: var(--zaz-teal-deep);
  --brand-bright: var(--zaz-teal);
  --brand-muted: color-mix(in oklch, var(--zaz-teal-deep) 13%, var(--card));
  --primary: var(--zaz-teal-deep);
  --primary-foreground: oklch(0.99 0.003 175);
  --on-solid: oklch(0.99 0.003 175);
  --link: var(--zaz-teal-deep);
  --ring: var(--zaz-teal-deep);
  --info: oklch(0.48 0.17 263);
  --sev1: oklch(0.47 0.135 35);
  --sev2: oklch(0.475 0.1 75);
  --ok: oklch(0.49 0.1 148);
  --border: oklch(0.255 0.024 205 / 0.1);
  --border-strong: oklch(0.255 0.024 205 / 0.2);
  --input: oklch(0.255 0.024 205 / 0.2);
  --elev-1: 0 1px 2px oklch(0.255 0.024 205 / 0.05), 0 0 0 1px oklch(0.255 0.024 205 / 0.07);
  --elev-2: 0 4px 12px -2px oklch(0.255 0.024 205 / 0.08), 0 16px 32px -8px oklch(0.255 0.024 205 / 0.12),
    0 0 0 1px oklch(0.255 0.024 205 / 0.06);
  --display-face: 'Segoe UI Variable Display', 'Segoe UI', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --text-face: 'Segoe UI Variable Text', 'Segoe UI', ui-sans-serif, system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --code-face: ui-monospace, 'Cascadia Mono', 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
}

[data-theme="dark"][data-zaz] {
  --zaz-teal: oklch(0.78 0.11 182);
  --zaz-teal-deep: oklch(0.8 0.1 186);
  --zaz-ink: oklch(0.94 0.008 180);
  --background: oklch(0.178 0.017 186);
  --card: oklch(0.225 0.018 186);
  --surface-2: oklch(0.197 0.016 186);
  --surface-raised: oklch(0.255 0.019 186);
  --surface-brand: oklch(0.24 0.035 184);
  --sidebar: oklch(0.158 0.022 186);
  --fg-2: oklch(0.82 0.012 180);
  --muted-foreground: oklch(0.72 0.014 180);
  --brand-muted: color-mix(in oklab, var(--zaz-teal) 14%, var(--card));
  --primary: oklch(0.56 0.09 186);
  --primary-foreground: oklch(0.985 0.004 180);
  --info: oklch(0.77 0.12 258);
  --sev1: oklch(0.75 0.125 30);
  --sev2: oklch(0.8 0.105 80);
  --ok: oklch(0.78 0.13 140);
  --border: oklch(1 0 0 / 0.085);
  --border-strong: oklch(1 0 0 / 0.17);
  --input: oklch(1 0 0 / 0.16);
  --elev-1: inset 0 1px 0 oklch(1 0 0 / 0.04), 0 0 0 1px oklch(1 0 0 / 0.09);
  --elev-2: inset 0 1px 0 oklch(1 0 0 / 0.05), 0 0 0 1px oklch(1 0 0 / 0.09), 0 12px 28px -8px oklch(0 0 0 / 0.55);
}

/* Base ------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font-family: var(--text-face); font-size: 0.9375rem; line-height: 1.5;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
:where(a, button, summary, select, input, textarea, li) {
  transition: color 120ms var(--ease-out), background-color 120ms var(--ease-out),
    border-color 120ms var(--ease-out), box-shadow 120ms var(--ease-out), opacity 120ms var(--ease-out);
}
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 0.25rem; }
::selection { background: color-mix(in oklch, var(--link) 24%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklch, var(--foreground) 22%, transparent) transparent; }
html[data-theme-switching] *, html[data-theme-switching] *::before, html[data-theme-switching] *::after { transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
code, .code { font-family: var(--code-face); font-size: 0.95em; letter-spacing: -0.01em; }

/* Type roles (docs/29 §7): page 22/28, section 17/24, group 15/20, body 14/20, label 12/16. */
h1.page { font-family: var(--display-face); font-size: 1.375rem; line-height: 1.75rem; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2.section { font-family: var(--display-face); font-size: 1.0625rem; line-height: 1.5rem; font-weight: 600; letter-spacing: -0.005em; margin: 0 0 0.75rem; }
.eyebrow { font-size: 0.75rem; line-height: 1rem; font-weight: 550; letter-spacing: 0.005em; color: var(--muted-foreground); }
.muted { color: var(--muted-foreground); } .fg2 { color: var(--fg-2); }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; } .text-xs { font-size: 0.75rem; line-height: 1rem; }
.sev1 { color: var(--sev1); }

/* Shell: sidebar + content on wide screens, stacked below 1024px. ------------------- */
.shell { min-height: 100vh; }
@media (min-width: 1024px) { .shell { display: grid; grid-template-columns: 15rem 1fr; } }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
@media (min-width: 1024px) { .sidebar { position: sticky; top: 0; height: 100vh; } }
/* The sidebar mirrors Operations' app-shell.tsx measure for measure: Operations is the source. */
.sidebar .brand { display: flex; flex-direction: column; align-items: flex-start; padding: 1.25rem 1rem 0.75rem; margin-bottom: 0.75rem; }
.wordmark { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; text-decoration: none; color: var(--foreground); }
.wordmark img { display: block; height: 2rem; width: auto; }
.wordmark .light { display: block; } .wordmark .dark { display: none; }
[data-theme="dark"] .wordmark .light { display: none; } [data-theme="dark"] .wordmark .dark { display: block; }
.wordmark span { font-family: var(--display-face); font-size: 0.9375rem; line-height: 1.5; font-weight: 600; letter-spacing: -0.01em; padding-left: 0.125rem; }
/* The environment chip (Operations' EnvChip): amber tint for every environment but production. */
/* 0.875rem = Operations' mt-3 wrapper plus the 2px its line box adds above the chip. */
.pill { display: inline-flex; align-items: center; gap: 0.375rem; height: 1.5rem; padding: 0 0.625rem; border-radius: 999px; margin-top: 0.875rem;
  font-size: 0.75rem; font-weight: 500; text-transform: capitalize; background: color-mix(in oklch, var(--sev2) 12%, transparent); color: var(--sev2); }
.pill i { width: 0.375rem; height: 0.375rem; border-radius: 999px; background: var(--sev2); }
.pill.production { background: var(--sev1); color: var(--on-solid); }
.pill.production i { background: var(--on-solid); }
.nav { flex: 1; overflow-y: auto; padding: 0 0.5rem 1rem; }
.nav .eyebrow { margin: 0 0 0.125rem; padding: 0.75rem 0.625rem 0.25rem; }
.nav a { display: flex; align-items: center; gap: 0.625rem; height: 2.25rem; padding: 0 0.625rem; margin-bottom: 0.125rem; border-radius: 0.5rem;
  color: var(--fg-2); text-decoration: none; font-size: 0.875rem; font-weight: 500; min-width: 0; }
.nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a svg { width: 1.125rem; height: 1.125rem; flex: none; color: inherit; }
.nav a:hover { background: color-mix(in oklch, var(--card) 60%, transparent); color: var(--foreground); }
.nav .divider { border-top: 1px solid var(--border); margin: 0.75rem 0.5rem; }
.nav a.active { background: var(--card); color: var(--foreground); font-weight: 600; box-shadow: var(--elev-1); }
.nav a.active svg { color: var(--brand); }
.nav .closed { opacity: 0.7; }
/* The module you are in: named, not raised. The raised tile marks the place inside the module. */
.nav a.current { color: var(--foreground); font-weight: 600; }
.nav a.current svg { color: var(--brand); }
.nav a svg.ext { width: 0.875rem; height: 0.875rem; margin-left: auto; color: var(--muted-foreground); }
.user { border-top: 1px solid var(--border); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.user .row { display: flex; align-items: center; gap: 0.625rem; padding: 0 0.25rem; }
.avatar { width: 2rem; height: 2rem; flex: none; border-radius: 999px; background: var(--brand-muted); color: var(--brand);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.user .who { min-width: 0; flex: 1; } .user .who p { margin: 0; }
.user .who .name { font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .who .role { font-size: 0.75rem; color: var(--muted-foreground); }
.iconbtn { width: 2rem; height: 2rem; display: grid; place-items: center; border: 0; border-radius: 0.5rem; background: transparent;
  color: var(--muted-foreground); cursor: pointer; padding: 0; }
.iconbtn:hover { color: var(--foreground); background: var(--card); }
.iconbtn svg { width: 1rem; height: 1rem; }
.appearance { display: flex; align-items: center; justify-content: space-between; padding: 0 0.25rem; }
/* The appearance control (Operations' Segmented, size sm, inside [data-zaz]). */
.seg { display: inline-grid; grid-template-columns: repeat(3, 2.75rem); gap: 2px; padding: 2px; border-radius: calc(var(--radius) - 2px); background: var(--surface-2); }
.seg button { height: 1.75rem; display: grid; place-items: center; border: 0; border-radius: calc(var(--radius) - 4px); background: transparent;
  color: var(--muted-foreground); cursor: pointer; padding: 0; }
.seg button:hover { color: var(--foreground); }
.seg button svg { width: 0.875rem; height: 0.875rem; }
html[data-theme-pref="light"] .seg [data-pref="light"], html[data-theme-pref="dark"] .seg [data-pref="dark"], html[data-theme-pref="system"] .seg [data-pref="system"] {
  background: var(--surface-raised); color: var(--foreground); box-shadow: var(--elev-1), inset 0 0 0 1px var(--border-strong); }

.content { min-width: 0; }
main { max-width: 1680px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
@media (min-width: 640px) { main { padding-left: 1.5rem; padding-right: 1.5rem; } }
@media (min-width: 1024px) { main { padding: 2rem 2.5rem 2.5rem; } }
.titlerow { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.5rem; }
.titlerow .sub { margin-top: 0.25rem; max-width: 48rem; font-size: 0.875rem; color: var(--muted-foreground); }
.titlerow .side { display: flex; align-items: center; gap: 0.75rem; font-size: 0.75rem; color: var(--muted-foreground); }

/* Surfaces ------------------------------------------------------------------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--elev-1); padding: 1rem 1.125rem; }
.well { background: var(--surface-2); border-radius: 0.5rem; padding: 0.875rem 1rem; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .grid2 { grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; } }
.rail { display: flex; flex-direction: column; gap: 1rem; }
/* The portal (ADR 0012): one card per module, then the person's cases. */
.modules { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.module { display: flex; flex-direction: column; gap: 0.375rem; color: inherit; text-decoration: none; transition: box-shadow 120ms var(--ease-out); }
.module:hover { box-shadow: var(--elev-2); }
.module .icon svg { width: 1.375rem; height: 1.375rem; color: var(--brand); }
.module .name { display: flex; align-items: baseline; gap: 0.375rem; font-weight: 600; font-size: 0.9375rem; }
.module svg.ext { width: 0.875rem; height: 0.875rem; color: var(--muted-foreground); align-self: center; }
.module .desc { font-size: 0.875rem; line-height: 1.35; color: var(--fg-2); }
.cases { margin-top: 1rem; } .cases .eyebrow { margin: 0 0 0.5rem; }
.chip { display: inline-flex; align-items: center; height: 1.25rem; padding: 0 0.375rem; border-radius: 0.25rem; font-size: 0.75rem; font-weight: 500;
  background: var(--surface-2); color: var(--fg-2); }

/* Controls --------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; height: 2.25rem; padding: 0 1rem; border-radius: 0.5rem;
  border: 1px solid transparent; font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-foreground); }
.btn:hover { background: color-mix(in oklch, var(--primary) 90%, var(--card)); }
.btn.secondary { background: var(--card); color: var(--foreground); border-color: var(--input); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
label.field { display: block; font-size: 0.75rem; font-weight: 500; margin-top: 0.75rem; }
input[type=text], input[type=password], input[type=email], select, textarea {
  display: block; width: 100%; margin-top: 0.25rem; height: 2.25rem; padding: 0 0.625rem; border-radius: 0.5rem;
  border: 1px solid var(--input); background: var(--card); color: var(--foreground); font: inherit; font-size: 0.875rem; }
textarea { height: auto; min-height: 5rem; padding: 0.5rem 0.625rem; line-height: 1.4; resize: vertical; }
input[type=file] { font-size: 0.8125rem; color: var(--fg-2); margin-top: 0.25rem; }
.htmx-indicator { display: none; } .htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* Sign-in: a centred column, like Operations' login. -------------------------------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2.5rem 1rem; }
.auth .box { width: 100%; max-width: 28rem; }
.auth .brandline { margin-bottom: 1rem; }
.auth .personas { margin-top: 2rem; padding: 1rem; border-radius: 0.5rem;
  border: 1px dashed color-mix(in oklch, var(--sev2) 40%, transparent); background: color-mix(in oklch, var(--sev2) 5%, transparent); }

/* Conversation ------------------------------------------------------------------------ */
.msg { padding: 0.75rem 0.875rem; border-radius: 0.5rem; margin-bottom: 0.625rem; font-size: 0.875rem; line-height: 1.5; }
.msg p { margin: 0 0 0.5rem; } .msg p:last-child { margin-bottom: 0; }
.msg.user { background: var(--surface-2); }
.msg.assistant { background: var(--brand-muted); box-shadow: inset 3px 0 0 var(--brand-bright); }
.msg .who { font-size: 0.75rem; line-height: 1rem; font-weight: 550; color: var(--muted-foreground); margin-bottom: 0.25rem; }
a.cite { font-weight: 600; }
.warn { color: var(--sev2); }
form.ask { margin-top: 0.875rem; }
form.ask .actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }

/* Sources and evidence ---------------------------------------------------------------- */
.list { margin: 0; padding: 0; list-style: none; }
.list li { padding: 0.5rem 0; border-top: 1px solid var(--border); font-size: 0.875rem; }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .meta { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; margin-top: 0.125rem; font-size: 0.75rem; color: var(--muted-foreground); }
.ev { padding: 0.625rem 0.75rem; margin: 0 -0.75rem; border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.45; }
.ev + .ev { margin-top: 0.25rem; }
.ev.cited { background: var(--brand-muted); box-shadow: inset 3px 0 0 var(--brand-bright); }
.ev .n { font-family: var(--code-face); font-weight: 600; color: var(--brand); margin-right: 0.375rem; }
.ev .where { font-size: 0.75rem; color: var(--muted-foreground); margin: 0.125rem 0 0.25rem; }
.ev .text { color: var(--fg-2); }
.empty { font-size: 0.875rem; color: var(--muted-foreground); margin: 0; }
