/* Quill: one calm, dark work surface for every page. A workspace's brand shows only in its logo and in one
   accent colour (primary buttons, focus, selection); every page looks the same otherwise.
   Inter is self-hosted under the SIL Open Font License. */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #111111;
  --surface: #191919;
  --surface-2: #222222;
  --surface-3: #2a2a2a;
  --selected: #313131;
  --sunk: #141414;
  --line: #2a2a2a;
  --line-strong: #3a3a3a;
  --line-hover: #484848;
  --ink: #eeeeee;
  --ink-2: #c7c7c7;
  --muted: #a0a0a0;
  --faint: #8a8a8a;

  /* Neutral accent outside a workspace (sign-in pages). A workspace overrides it below. */
  --accent: #eeeeee; --accent-hover: #ffffff; --accent-ink: #111111;
  --accent-text: #eeeeee; --accent-soft: #ffffff10; --accent-line: #ffffff38;

  --ok: #4cc38a; --ok-soft: #4cc38a14; --ok-line: #4cc38a47;
  --warn: #ffca16; --warn-bg: #302008; --warn-line: #5c3d05; --warn-ink: #f3dfa4;
  --bad: #ff9592; --bad-bg: #3b1219; --bad-line: #72232d;
  --info: #b4b8ff; --info-soft: #8e94ff14; --info-line: #8e94ff40;

  --r-xs: 4px; --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --page: 1200px;
  --topbar: 52px;
  --shadow: 0 12px 32px -8px #000000c0;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
body[data-brand="upcomers"] {
  --accent: #7329f3; --accent-hover: #8143f7; --accent-ink: #ffffff;
  --accent-text: #baa7ff; --accent-soft: #7329f329; --accent-line: #7329f370;
}
body[data-brand="uzo"] {
  --accent: #3ee0a8; --accent-hover: #63ebbc; --accent-ink: #0a0a0a;
  --accent-text: #3ee0a8; --accent-soft: #3ee0a81f; --accent-line: #3ee0a857;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
/* Anything scrolled into view (guide steps, a copied reply) stops below the sticky top bar. */
html { scroll-padding-top: calc(var(--topbar-h, var(--topbar)) + 16px); }
body {
  background: var(--bg); color: var(--ink);
  font: 400 14px/20px var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; color: var(--ink); text-wrap: balance; }
h1 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -.005em; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
p, ul, ol, dl { margin: 0; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: var(--accent-line); color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 20px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.wrapany { overflow-wrap: anywhere; }
.label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: 500 11px/1 var(--font); padding: 2px 5px; border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--surface-2); color: var(--ink-2); }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.bad-text { color: var(--bad); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: calc(var(--page) + 48px); margin: 0 auto; padding: 0 24px; height: var(--topbar); display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 16px; letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ws-badge { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--line-strong); height: 18px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.brand-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.mainnav { display: flex; gap: 2px; margin-left: 10px; flex: 1; }
.mainnav a { color: var(--muted); font-size: 14px; font-weight: 500; padding: 5px 10px; border-radius: var(--r-sm); white-space: nowrap; }
.mainnav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.mainnav a.on { color: var(--ink); background: var(--surface-3); }
.topbar .who { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar .who form { margin: 0; display: flex; }
.help-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); font: 600 13px/1 var(--font); cursor: pointer; display: grid; place-items: center; flex: none; transition: color .12s, background .12s; }
.help-btn:hover { color: var(--ink); background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--ink); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.who-link { display: flex; align-items: center; gap: 10px; padding: 2px 10px 2px 2px; border-radius: 999px; color: inherit; transition: background .12s; }
.who-link:hover { background: var(--surface-2); text-decoration: none; }
.who-link.on { background: var(--surface-3); }
.who-text { display: flex; flex-direction: column; line-height: 16px; }
.who-text b { font-size: 13px; font-weight: 500; color: var(--ink); }
.who-text span { font-size: 12px; color: var(--faint); }
.linkbtn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); cursor: pointer; font: 500 13px/20px var(--font); padding: 4px 8px; border-radius: var(--r-sm); transition: color .12s, background .12s; }
.linkbtn:hover { color: var(--ink); background: var(--surface-2); }

/* ---------- page and layout ---------- */
.page { max-width: calc(var(--page) + 48px); margin: 0 auto; padding: 24px 24px 64px; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 480px; padding-top: 14vh; }
.pagehead { display: flex; flex-direction: column; gap: 2px; }
.pagehead > p.muted { max-width: 80ch; }
.pagehead-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section { margin-top: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 200px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

/* ---------- controls ---------- */
label, .seg legend { font-size: 13px; font-weight: 500; color: var(--ink-2); }
label .muted { font-weight: 400; color: var(--faint); }
.field { display: flex; flex-direction: column; gap: 6px; }
.hint { font-size: 12px; line-height: 18px; color: var(--faint); font-weight: 400; }
input, select, textarea { font: 400 14px/20px var(--font); color: var(--ink); background: var(--sunk); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 5px 10px; max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input, select { min-height: 32px; }
textarea { width: 100%; resize: vertical; line-height: 22px; padding: 8px 10px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--line-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
select { padding-right: 26px; }
option { background: var(--surface-2); color: var(--ink); }
input[type="file"] { padding: 3px; }
input[type="file"]::file-selector-button { font: 500 13px var(--font); color: var(--ink); background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--r-xs); padding: 3px 10px; margin-right: 10px; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; min-height: 0; margin: 0; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row label { font-weight: 400; color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); font: 500 13px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--surface-3); border-color: var(--line-hover); color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.ghost.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.btn.large { min-height: 36px; padding: 0 16px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.done, .btn.primary.done { background: var(--ok); border-color: var(--ok); color: #06130c; }
.btn svg.icon { width: 15px; height: 15px; }

.chip { font: 400 13px/20px var(--font); padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; text-align: left; transition: background .12s, border-color .12s, color .12s; }
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }

.seg { border: 0; padding: 0; margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.seg legend { float: left; padding: 0; color: var(--faint); font-weight: 400; }
.seg-options { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 2px 10px; border-radius: var(--r-xs); cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px; line-height: 20px; }
.seg label:hover { color: var(--ink); }
.seg input:checked + label { background: var(--selected); color: var(--ink); }
.seg input:focus-visible + label { outline: 2px solid var(--accent-text); outline-offset: 1px; }

/* Segmented links: the brand switcher and the period switcher */
.switcher { display: inline-flex; align-items: center; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }
.switcher a { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 26px; padding: 0 10px; border-radius: var(--r-xs); color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.switcher a:hover { color: var(--ink); text-decoration: none; }
.switcher a.on { background: var(--selected); color: var(--ink); }

/* ---------- brand logos ---------- */
.brand-logo { display: block; width: auto; height: 16px; flex: none; }
.brand-logo.uzo-logo { height: 12px; }
.switcher a .brand-logo { height: 14px; }
.switcher a .brand-logo.uzo-logo { height: 10px; }
.switcher a:not(.on) .brand-logo { opacity: .45; transition: opacity .12s; }
.switcher a:not(.on):hover .brand-logo { opacity: .85; }

/* ---------- messages to the user ---------- */
.callout { display: flex; gap: 10px; align-items: flex-start; border: 1px solid; border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; line-height: 20px; }
.callout b { display: block; font-weight: 600; color: var(--ink); }
.callout ul { padding-left: 1.1em; display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.callout li b { display: inline; font-weight: 500; }
.callout .help { color: var(--muted); }
.callout p { color: var(--ink-2); }
.callout.info { background: var(--info-soft); border-color: var(--info-line); }
.callout.info > .icon { color: var(--info); margin-top: 2px; }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout.warn > .icon { color: var(--warn); margin-top: 2px; }
.callout.warn li b { color: var(--warn-ink); }
.callout.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.callout.ok > .icon { color: var(--ok); margin-top: 2px; }
.callout.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.callout.bad > .icon { color: var(--bad); margin-top: 2px; }
.alert { border-radius: var(--r-sm); padding: 9px 12px; border: 1px solid transparent; font-size: 13px; }
.alert.error { background: var(--bad-bg); border-color: var(--bad-line); color: #ffd1cf; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.alert.ok { background: var(--ok-soft); border-color: var(--ok-line); color: #c3f0d7; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--r-xs); background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; margin: 1px 2px 1px 0; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.info { color: var(--info); background: var(--info-soft); }
.status { color: var(--muted); font-size: 13px; }
.status.error { color: var(--bad); }
.status:empty { display: none; }
.toast { width: max-content; max-width: calc(100vw - 32px); position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 8px); background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); padding: 8px 14px; border-radius: var(--r); font-size: 13px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .12s ease-out, transform .12s ease-out; z-index: 80; display: flex; align-items: center; gap: 8px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg.icon { color: var(--ok); }
.toast.warn svg.icon { color: var(--warn); }

/* ---------- lists and tables ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { grid-column: 1; font-size: 12px; line-height: 16px; color: var(--faint); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-item .sub .brand-logo { height: 10px; opacity: .6; }
.list-item .sub .brand-logo.uzo-logo { height: 8px; }
.list-item .side { grid-row: 1 / span 2; grid-column: 2; align-self: center; display: flex; gap: 4px; align-items: center; }
.searchbox { width: 280px; max-width: 100%; }
.searchbox input { width: 100%; }
.pager { display: flex; gap: 16px; font-size: 13px; }
.empty-state { padding: 40px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.empty-state .btn { margin-top: 12px; }

.tablewrap, .card.flush.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 20px; }
th, td { text-align: left; vertical-align: middle; padding: 9px 14px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; font-weight: 500; color: var(--faint); white-space: nowrap; padding-top: 7px; padding-bottom: 7px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #ffffff05; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.dim td { color: var(--faint); }
tr.selected td { background: var(--accent-soft); }
td input, td select { min-height: 28px; padding: 3px 8px; font-size: 13px; }
td form { margin: 0; }
td .btn { min-height: 28px; padding: 0 10px; font-size: 12.5px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; }
.filters label { color: var(--muted); font-weight: 400; }
.inline-form { display: flex; flex-direction: column; gap: 12px; }
.inline-form .row { gap: 8px 10px; }
.invite { border-color: var(--accent-line); background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 16px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-family: var(--mono); font-size: 12.5px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- admin ---------- */
.adminhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap-reverse; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-bottom: -1px; }
.tabs a { padding: 8px 8px 10px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.adminhead .switcher { margin-bottom: 8px; }
.usage-tools { margin: 0 0 14px; gap: 8px; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tile { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tile:nth-child(5n) { border-right: 0; }
.tile:nth-last-child(-n + 5) { border-bottom: 0; }
.tile .label { font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 400; }
.tile b { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile b small { font-size: 12px; color: var(--faint); font-weight: 400; letter-spacing: 0; }
.tile b a { color: inherit; }
.tile.bad b { color: var(--bad); }
.logturn { display: flex; flex-direction: column; gap: 8px; }
.logturn > .label { margin-top: 6px; }
.boxed { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; line-height: 22px; }
.boxed.note { background: var(--info-soft); border-color: var(--info-line); }
.boxed.final { background: var(--ok-soft); border-color: var(--ok-line); }
.sources { font-size: 13px; color: var(--muted); }
.sources b { color: var(--ink-2); font-weight: 500; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details summary:hover { color: var(--ink); }
details[open] > summary { margin-bottom: 6px; }
textarea.mono { font-size: 12.5px; line-height: 20px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.check { font-size: 12px; line-height: 18px; padding: 1px 7px; border-radius: var(--r-xs); background: var(--surface-2); color: var(--ink-2); }
.check.ok::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.check.fixed::before { content: "↻ "; color: var(--accent-text); font-weight: 700; }
.check.warn { background: var(--warn-bg); color: var(--warn); }
.check.warn::before { content: "! "; font-weight: 700; }
.req { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.clamp { max-height: 12em; overflow: auto; }
.chartwrap { overflow-x: auto; margin-top: 8px; }
.chart { display: block; width: 100%; min-width: 640px; height: auto; }
.chart .bar { fill: var(--accent); }
.chart .col.on .bar, .chart .col:hover .bar, .chart .col:focus-visible .bar { fill: var(--accent-text); }
.chart .hit { fill: transparent; }
.chart .col:focus-visible .hit { stroke: var(--accent-text); stroke-width: 2; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--line-strong); stroke-width: 1; }
.chart .axis { fill: var(--faint); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .value { fill: var(--ink); font: 600 11px var(--font); font-variant-numeric: tabular-nums; }

/* ---------- the chat ---------- */
.page.chat-page { padding-top: 16px; padding-bottom: 16px; gap: 0; }
.chat { padding: 0; display: flex; flex-direction: column; height: calc(100vh - var(--topbar) - 32px); height: calc(100dvh - var(--topbar) - 32px); min-height: 520px; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-title > div { min-width: 0; }
.chat-title b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .muted { display: block; font-size: 12px; line-height: 16px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assistant-icon { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
.assistant-icon .brand-mark { width: 16px; height: 16px; }
.chat-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.chat-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 24px max(16px, calc((100% - 760px) / 2)); display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.studio-welcome { margin: auto 0 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.studio-welcome h2 { font-size: 16px; }
.studio-welcome > p { color: var(--muted); }
.studio-welcome .steps { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: step; width: 100%; }
.studio-welcome .steps li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; color: var(--ink-2); counter-increment: step; }
.studio-welcome .steps li::before { content: counter(step); width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.studio-welcome code { font: 12.5px var(--mono); color: var(--ink); background: var(--surface-2); border-radius: var(--r-xs); padding: 1px 5px; }
.chat-body:has(.msg.me) .studio-welcome { display: none; }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 24px 0 auto; }
.examples .label { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }
.examples .chip { display: flex; align-items: center; gap: 10px; }
.examples .chip > span { margin-left: auto; color: var(--faint); }
.examples .chip:hover > span { color: var(--accent-text); }

.msg { display: flex; flex-direction: column; max-width: 85%; gap: 4px; scroll-margin-top: 16px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; }
.msg.bot.reply { align-self: stretch; max-width: 100%; }
.bubble { position: relative; padding: 8px 12px 20px; border-radius: var(--r); line-height: 22px; min-width: 96px; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--surface-2); border: 1px solid var(--line-strong); }
.msg.me .mine { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-strong); }
.msg.bot .bubble { background: var(--surface); border: 1px solid var(--line-strong); }
.msg.bot.reply .bubble { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px 28px; }
.bubble .who { display: block; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--faint); margin-bottom: 4px; }
.msg.bot.reply .bubble .who { margin-bottom: 0; }
.bubble time { position: absolute; right: 12px; bottom: 5px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.turn.reply .old-label { display: none; }
.turn.reply.old .old-label { display: inline; }
.turn.reply.old .bubble { opacity: .65; }
.turn.reply.old .btn.primary.copy { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.rich p { margin: 0 0 8px; }
.rich p:last-child { margin-bottom: 0; }
.rich b { font-weight: 600; color: var(--ink); }
.rich ul, .rich ol { margin: 0 0 8px; padding-left: 1.2em; display: flex; flex-direction: column; gap: 2px; }
.rich ul:last-child, .rich ol:last-child { margin-bottom: 0; }
.rich li::marker { color: var(--faint); }
.ready { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--ok); font-weight: 500; font-size: 13px; }
.ready span { color: var(--muted); font-weight: 400; }
textarea.reply-text { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-sm); min-height: 150px; padding: 12px 14px; font-size: 15px; line-height: 24px; color: var(--ink); resize: none; overflow: hidden; }
.chat-parts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.chat-parts .btn { min-height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.chat-parts .btn svg.icon { width: 14px; height: 14px; }
textarea.reply-text:hover { border-color: var(--line-strong); }
.reply-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.meta { font-size: 12px; color: var(--faint); display: inline-flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.edited-flag { display: inline-flex; align-items: center; gap: 2px; }
.edit-checks { border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; }
.edit-checks ul { margin: 4px 0 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 2px; }
.edit-checks li.warn { color: var(--warn-ink); }
.next-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--ok-soft); border: 1px solid var(--ok-line); border-radius: var(--r-sm); padding: 6px 6px 6px 12px; }
.next-bar span { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 500; font-size: 13px; }
.msg-extra { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 12px; padding: 0 2px; font-size: 12px; color: var(--faint); }
.msg-extra .warn-line { flex-basis: 100%; }
.msg-actions { display: flex; align-items: center; gap: 0; }
.msg-actions .linkbtn { font-size: 12px; padding: 3px 6px; }
.msg-actions .linkbtn svg.icon { width: 14px; height: 14px; }
.iconbtn { border: 1px solid transparent; background: transparent; color: var(--faint); width: 28px; height: 28px; border-radius: var(--r-sm); display: inline-grid; place-items: center; cursor: pointer; transition: color .12s, background .12s; }
.iconbtn:hover { color: var(--ink); background: var(--surface-2); }
.iconbtn.on { color: var(--accent-text); background: var(--accent-soft); }
.iconbtn.small { width: 26px; height: 26px; }
.iconbtn.small svg.icon { width: 14px; height: 14px; }
.warn-line { color: var(--warn); display: flex; gap: 6px; align-items: flex-start; }
.warn-line svg.icon { width: 14px; height: 14px; margin-top: 1px; }
details.src summary { font-size: 12px; color: var(--faint); }
details.src summary:hover { color: var(--ink); }
details.src ul { padding-left: 1.1em; margin: 4px 0 2px; display: flex; flex-direction: column; gap: 2px; color: var(--ink-2); }
details.src ul.checks { list-style: none; padding: 4px 0 2px; flex-direction: row; flex-wrap: wrap; gap: 4px; }
.typing .dots { display: inline-flex; gap: 4px; padding: 6px 2px 0; }
.typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing .dots i:nth-child(2) { animation-delay: .2s; }
.typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* The composer: one box with the text on top and its tools underneath */
.chat-input { padding: 12px max(16px, calc((100% - 760px) / 2)) 16px; }
.composer { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); transition: border-color .12s, box-shadow .12s; }
.composer:hover { border-color: var(--line-hover); }
.composer:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { display: block; border: 0; background: transparent; box-shadow: none; resize: none; overflow-y: auto; min-height: 68px; max-height: 40vh; padding: 12px 14px 4px; font-size: 14px; }
.composer textarea:focus { box-shadow: none; }
.chat-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 8px 12px; }
.send-group { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.kbd-hint { font-size: 12px; }
.chat-tools .btn.primary { min-height: 32px; }

/* ---------- sign-in pages ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 20px; }
.auth-card .brand { font-size: 18px; }
.auth-card .brand-mark { width: 26px; height: 26px; }
.auth-card .pagehead { gap: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card input { min-height: 36px; }
.auth-card .btn.primary { margin-top: 4px; }
.auth-card .hint { line-height: 18px; }
.auth-points { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.auth-points li { display: flex; gap: 8px; align-items: flex-start; }
.auth-points svg.icon { color: var(--ok); margin-top: 3px; width: 14px; height: 14px; }
.auth-brands { display: flex; align-items: center; gap: 14px; color: var(--faint); font-size: 12px; }
.auth-brands .brand-logo { height: 15px; opacity: .55; }
.auth-brands .brand-logo.uzo-logo { height: 11px; }
.brand-divider { height: 14px; width: 1px; background: var(--line-strong); }

/* ---------- the guide: pop-ups that explain the screen ---------- */
.guide { position: fixed; inset: 0; z-index: 70; }
.guide.dim { background: #000000a6; }
.guide-spot { position: fixed; border-radius: var(--r-sm); box-shadow: 0 0 0 9999px #000000a6; outline: 2px solid var(--accent-text); pointer-events: none; transition: left .15s, top .15s, width .15s, height .15s; }
.guide-card { position: fixed; width: min(340px, calc(100vw - 32px)); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; animation: guide-in .12s ease-out; }
.guide-card.sheet { left: 12px !important; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); top: auto !important; width: auto; }
.guide-card.sheet.top { top: calc(12px + env(safe-area-inset-top, 0px)) !important; bottom: auto; }
.guide-card h3 { font-size: 15px; }
.guide-card p { color: var(--ink-2); font-size: 13px; }
.guide-count { font-size: 12px; font-weight: 500; color: var(--faint); }
.guide-put { align-self: flex-start; margin-top: 2px; }
.guide-example { margin: 4px 0 0; padding: 8px 10px; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-sm); font: 12.5px/1.5 var(--mono); color: var(--ink); white-space: pre-wrap; }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.guide-nav { display: flex; gap: 6px; margin-left: auto; }
@keyframes guide-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- smaller screens ---------- */
@media (max-width: 900px) {
  .who-text { display: none; }
  .who-link { padding: 2px; }
  .who-link.on .avatar { box-shadow: 0 0 0 2px var(--accent); }
  .tile { padding: 10px 12px 12px; }
}
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding: 10px 16px 0; row-gap: 8px; gap: 12px; }
  .mainnav { order: 3; flex-basis: 100%; margin: 0 -4px; overflow-x: auto; padding-bottom: 8px; }
  .mainnav a { flex: 1; text-align: center; }
  .ws-badge { padding-left: 12px; }
  .topbar .who { gap: 4px; }
  .page { padding: 16px 16px 48px; }
  .page.chat-page { padding: 8px; }
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(n) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .tile:nth-child(2n) { border-right: 0; }
  .tile:nth-last-child(-n + 2) { border-bottom: 0; }
  .chat { height: calc(100dvh - 112px); min-height: 440px; }
  .chat-head { padding: 8px 8px 8px 12px; }
  .chat-head .assistant-icon { display: none; }
  .chat-head .btn { padding: 0 10px; }
  .chat-body { padding: 16px 12px; }
  .chat-input { padding: 8px; }
  .msg { max-width: 94%; }
  .msg.bot.reply .bubble { padding: 10px 10px 26px; }
  .examples { grid-template-columns: 1fr; margin-top: 16px; }
  .kbd-hint, .wide-only { display: none !important; }
  .filters, .inline-form .row { display: grid; grid-template-columns: 1fr; align-items: stretch; gap: 6px; }
  .filters .btn, .inline-form .row .btn { justify-self: start; }
  .searchbox { width: 100%; }
  .adminhead .switcher { margin: 4px 0 0; }
  .iconbtn.small { width: 32px; height: 32px; }
  /* On phones the toast sits at the top, clear of the composer and its Send button. */
  .toast { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; transform: translate(-50%, -8px); }
}
@media (max-width: 560px) {
  #chat-new { padding: 0 9px; }
  #chat-new span { display: none; }
}
@media (max-width: 420px) {
  .chat-head .switcher a { padding: 0 8px; }
  .chat-tools .btn.primary span { display: none; }
}
@media (hover: none) { .kbd-hint { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .chat-body { scroll-behavior: auto; }
}

/* Forms laid out in one row on wide screens */
.form-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(120px, .6fr) auto; gap: 12px; align-items: end; }
.form-grid.with-brand { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(110px, .55fr) minmax(130px, .65fr) auto; }
.form-grid input, .form-grid select { width: 100%; }
@media (max-width: 760px) { .form-grid, .form-grid.with-brand { grid-template-columns: 1fr; } .form-grid .btn { justify-self: start; } }

tr.has-sub td { border-bottom: 0; }
tr.group-row td, tbody tr.group-row:hover td { background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500; padding-top: 7px; padding-bottom: 7px; }
tr.group-row .hint { margin-left: 8px; }
@media (max-width: 760px) { tr.group-row .hint { display: block; margin: 2px 0 0; max-width: calc(100vw - 64px); white-space: normal; } }
tr.sub td { padding-top: 0; }
tbody tr.has-sub:hover + tr.sub td { background: #ffffff05; }
.sig summary, .sig-static { font-size: 12.5px; color: var(--faint); }
.sig-label { color: var(--muted); margin-right: 4px; }
.sig-preview { display: inline-block; max-width: min(56ch, 70vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.sig[open] .sig-preview { display: none; }
.sig-form { display: flex; flex-direction: column; gap: 8px; max-width: min(460px, calc(100vw - 72px)); padding: 2px 0 6px; }
.sig-form textarea { font-size: 13px; line-height: 20px; }
.sig-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.sig-card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.sig-card-title span { color: var(--muted); font-weight: 500; }
.sig-card textarea { font-size: 14px; }
textarea[aria-invalid="true"] { border-color: var(--bad-line); }

/* Files in a message (2026-09-28): an Intercom export or screenshots, in the message box tray and in the chat */
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 28px; padding: 3px 4px 3px 8px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font-size: 12.5px; }
.file-chip.image { padding-left: 3px; }
.file-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; display: block; }
.file-chip .icon { width: 15px; height: 15px; flex: none; color: var(--muted); }
.file-chip .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-remove { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; }
.file-remove:hover { background: var(--surface-3); color: var(--ink); }
.file-remove .icon { width: 13px; height: 13px; }
.msg.me .bubble .file-chip { margin: 0 6px 6px 0; }
.attach-btn .icon { width: 15px; height: 15px; }
.chat-input.dropping .composer { outline: 2px dashed var(--accent); outline-offset: 2px; }
details.attached { margin: 0 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
details.attached > summary { display: flex; align-items: center; gap: 6px; padding: 6px 8px; cursor: pointer; font-size: 13px; list-style: none; }
details.attached > summary::-webkit-details-marker { display: none; }
details.attached > summary .icon { width: 15px; height: 15px; color: var(--muted); flex: none; }
details.attached pre { margin: 0; padding: 8px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.5 var(--font); border-top: 1px solid var(--line); }
details.attached p { margin: 6px 8px 0; }
.shots { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 0; }
.shots img { display: block; max-width: 160px; max-height: 120px; border-radius: 4px; border: 1px solid var(--line); }

/* Dictation (2026-09-30): the microphone next to File. While it records, the ring grows with the voice level. */
.mic-btn { justify-content: center; min-width: 34px; padding-left: 9px; padding-right: 9px; }
.mic-btn .icon { width: 15px; height: 15px; }
.mic-btn.recording { color: var(--bad); border-color: var(--bad-line); background: var(--bad-bg); font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 calc(var(--level, 0) * 5px) var(--bad-line); transition: box-shadow .08s; }
.mic-btn.working { cursor: progress; }
/* On a phone the tools row holds Email/Chat, File, the microphone and Send: File keeps only its paperclip. */
@media (max-width: 420px) { .chat-tools .attach-btn span { display: none; } .chat-tools .attach-btn { padding: 0 9px; } }
