/* XataWorks theme (canvas 01 §11). Brand values are copied from the xataworks.ca
   stylesheet; the role tokens below them are what every feature rule uses. */
:root {
  --ink: #10131a;
  --ink-soft: #5b6270;
  --ink-faint: #878e9c;
  --line: #e3e5ea;
  --line-soft: #eef0f3;
  --paper: #ffffff;
  --tint: #f4f5f7;
  --dark: #0a0d13;
  --dark-line: rgba(255,255,255,.11);
  --on-dark: #f2f4f8;
  --on-dark-soft: #a6adbb;
  --brand-accent: #0b5fd4;
  --brand-accent-hover: #0a55bd;

  --bg: var(--tint);
  --panel: var(--paper);
  --panel-2: var(--line-soft);
  --text: var(--ink);
  --muted: var(--ink-soft);
  --border: var(--line);
  --border-strong: var(--ink-faint);
  --accent: var(--brand-accent);
  --accent-hover: var(--brand-accent-hover);
  --danger: #c42b1c;
  --ok: #137333;
  --warn: #875a00;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }

/* Top bar: the brand's dark band with the XataWorks lockup (canvas 01 §11). */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.5rem;
  background: var(--dark); color: var(--on-dark);
  border-bottom: 1px solid var(--dark-line);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 1.02rem; letter-spacing: -.02em;
  color: var(--on-dark); text-decoration: none;
}
.brand-mark { flex: 0 0 auto; width: 24px; height: 24px; opacity: .95; }
.brand-sub {
  font-weight: 500; color: var(--on-dark-soft);
  border-left: 1px solid var(--dark-line); padding-left: 9px;
}
.topbar .muted { color: var(--on-dark-soft); }
.userbar { display: flex; align-items: center; gap: 1rem; color: var(--on-dark-soft); font-size: .9rem; }
/* Signed out: the auth listener sets [hidden]; keep it from losing to display:flex above. */
.userbar[hidden] { display: none; }
.topbar .btn-ghost { color: var(--on-dark); border-color: var(--dark-line); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.08); }

.app { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem; }
.loading { color: var(--muted); text-align: center; padding: 3rem; }

/* Dashboard navigation shell (canvas 01). One <nav>: a sticky left sidebar on wide
   viewports, a slide-in drawer opened from the sticky section bar on narrow ones. The
   content area shows one panel at a time. */
.app.dashboard-mode { max-width: 1080px; }
.dash { display: flex; align-items: flex-start; gap: 1.75rem; }
.sidenav {
  flex: 0 0 210px; position: sticky; top: 1.5rem;
  max-height: calc(100vh - 1.5rem); overflow-y: auto;
}
.navgroup { margin-bottom: 1.25rem; }
.navgroup:last-child { margin-bottom: 0; }
.navgroup-label {
  text-transform: uppercase; font-size: .7rem; letter-spacing: .06em;
  color: var(--muted); padding: 0 .75rem; margin-bottom: .35rem;
}
.navitem {
  position: relative; display: flex; align-items: center; gap: .65rem;
  width: 100%; text-align: left; font: inherit; font-size: .92rem;
  background: transparent; border: none; color: var(--muted);
  padding: .5rem .75rem; border-radius: 8px; cursor: pointer;
}
.navitem svg { flex: 0 0 auto; opacity: .85; }
.navitem span { min-width: 0; }
.navitem:hover { background: var(--panel-2); color: var(--text); }
.navitem.active { background: var(--panel); color: var(--text); font-weight: 600; }
.navitem.active svg { color: var(--accent); opacity: 1; }
.navitem.active::before {
  content: ""; position: absolute; left: 0; top: .4rem; bottom: .4rem;
  width: 3px; border-radius: 3px; background: var(--accent);
}
.navitem:focus-visible, .navtoggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dash-content { flex: 1 1 auto; min-width: 0; }
.panel[hidden] { display: none; }
.panel .card:last-child { margin-bottom: 0; }

/* Section bar + drawer backdrop: narrow viewports only. */
.sectionbar { display: none; }
.nav-backdrop { display: none; }
.navtoggle {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .45rem;
  font: inherit; font-size: .9rem; cursor: pointer; color: var(--text);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .7rem; min-height: 40px;
}
.navtoggle:hover { background: var(--panel-2); }
.sectiontitle {
  font-weight: 600; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@media (max-width: 760px) {
  .app.dashboard-mode { padding: 0 1.5rem 1.5rem; }
  .dash { display: block; }
  .sectionbar {
    display: flex; align-items: center; gap: .75rem;
    position: sticky; top: 0; z-index: 30;
    margin: 0 -1.5rem 1rem; padding: .6rem 1.5rem;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .sidenav {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1001;
    width: min(300px, 85vw); max-height: none;
    padding: 1rem .75rem; background: var(--panel);
    border-right: 1px solid var(--border); box-shadow: 0 0 40px rgba(16,19,26,.18);
    transform: translateX(-100%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  .dash.nav-open .sidenav {
    transform: none; visibility: visible;
    transition: transform .2s ease;
  }
  .navitem { min-height: 44px; }
  .navitem.active { background: var(--panel-2); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1000;
    background: rgba(10,13,19,.45);
  }
  .nav-backdrop[hidden] { display: none; }
}
@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .sidenav, .dash.nav-open .sidenav { transition: none; }
}

/* Density on small screens: more room for content, and a top bar that never wraps. */
@media (max-width: 600px) {
  .topbar { padding: .75rem 1rem; gap: .75rem; }
  .brand { white-space: nowrap; }
  .brand-sub { display: none; }
  .userbar { gap: .6rem; min-width: 0; }
  #userEmail { min-width: 0; max-width: 45vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .userbar .btn { flex: 0 0 auto; padding: .45rem .75rem; }
  .app { padding: 1rem; }
  .app.dashboard-mode { padding: 0 1rem 1rem; }
  .sectionbar { margin: 0 -1rem 1rem; padding: .6rem 1rem; }
  .card { padding: 1rem; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2 { margin: 0 0 1rem; font-size: 1rem; }
.card h1 { margin: 0 0 .25rem; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.btn {
  font: inherit; cursor: pointer; border: none; border-radius: 8px;
  padding: .6rem 1rem; background: var(--accent); color: white; font-weight: 600;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: .35rem .7rem; font-size: .85rem; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-block { width: 100%; }

.badge { padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-pro { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.badge-free { background: color-mix(in srgb, var(--muted) 10%, transparent); color: var(--muted); }
.badge-ok { background: color-mix(in srgb, var(--ok) 10%, transparent); color: var(--ok); }
.badge-warn { background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); }
.badge-off { background: color-mix(in srgb, var(--muted) 10%, transparent); color: var(--muted); }

.auth { max-width: 380px; margin: 3rem auto; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
input[type=email], input[type=password], input[type=text], textarea, select {
  width: 100%; padding: .6rem .75rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font: inherit;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
textarea { resize: vertical; }
.field code { font-family: var(--mono); font-size: .8rem; word-break: break-all; }
.toklim { display: flex; flex-direction: column; gap: .5rem; margin-top: .4rem; }
.toklim .toklim-row {
  display: grid; grid-template-columns: 7rem 1fr auto; gap: .5rem;
  align-items: center; margin-bottom: 0;
}
.toklim .toklim-row > span { font-size: .85rem; color: var(--muted); margin: 0; }
.toklim input[type=number] {
  width: 100%; padding: .6rem .75rem; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font: inherit;
}
.toklim select { width: auto; }
.error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin: .5rem 0; }
.divider { text-align: center; color: var(--muted); font-size: .8rem; margin: 1rem 0; }
.toggle { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--muted); }
.toggle a { color: var(--accent); cursor: pointer; }

.token { font-family: var(--mono); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem; word-break: break-all; font-size: .85rem; margin: .5rem 0; }
.hint { color: var(--warn); font-size: .8rem; }

/* Add-member form: keep the email the primary, growing control; the role select stays
   compact and the row wraps on narrow viewports so the email never collapses. */
.member-add { margin-top: .5rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.member-add .member-email { flex: 1 1 240px; min-width: 200px; }
.member-add select { flex: 0 0 auto; width: auto; }

/* Input group: a field paired with inline action buttons (reveal / paste). */
.input-group { display: flex; gap: .4rem; align-items: stretch; }
.input-group > input { flex: 1 1 auto; min-width: 0; }
.btn-icon {
  flex: 0 0 auto; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: 0 .7rem; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-icon:hover { background: var(--panel-2); }
.btn-icon svg { display: block; }

/* Services tag selector: chips + a freeform add-control with a preset dropdown. */
.tag-input {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  min-height: 2.5rem; padding: .35rem .5rem; margin-bottom: .5rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.tag {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .3rem .2rem .6rem; border-radius: 999px;
  background: var(--panel-2); color: var(--text); font-size: .85rem;
}
.tag-x {
  font: inherit; line-height: 1; cursor: pointer; font-size: 1rem;
  background: transparent; border: none; color: var(--muted);
  padding: 0 .25rem; border-radius: 999px;
}
.tag-x:hover { color: var(--danger); }
.tag-add { display: flex; gap: .5rem; align-items: center; }
.tag-add > input { flex: 1 1 auto; min-width: 0; }
.tag-add > button { flex: 0 0 auto; }

/* Agent row actions: a three-dot (kebab) button that toggles a popover menu, so a
   row stays compact instead of carrying an inline strip of full-size buttons. */
.menu-wrap { position: relative; flex: 0 0 auto; }
.kebab {
  font: inherit; cursor: pointer; line-height: 1;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: .3rem .6rem; font-size: 1.15rem;
}
.kebab:hover { background: var(--panel-2); }
.menu {
  position: absolute; right: 0; top: calc(100% + .25rem); z-index: 20;
  min-width: 190px; padding: .35rem;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(16,19,26,.12);
  display: flex; flex-direction: column; gap: .1rem;
}
.menu[hidden] { display: none; }
.menu-item {
  font: inherit; cursor: pointer; text-align: left; white-space: nowrap;
  background: transparent; border: none; color: var(--text);
  padding: .45rem .6rem; border-radius: 6px;
}
.menu-item:hover { background: var(--panel); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* Modal shell: a dimmed overlay + centered card, reused by the Create Link and
   Manage links dialogs (canvas 26). Toggled via the [hidden] attribute. */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(10,13,19,.45);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 92vw; max-width: 560px; max-height: 88vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(16,19,26,.22);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal-title { font-size: 1.05rem; }
.modal-close {
  font: inherit; cursor: pointer; line-height: 1; font-size: 1.1rem;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: .2rem .55rem;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }
.modal-body { display: flex; flex-direction: column; gap: .9rem; }

/* Copy-pastable usage snippet: a caption, a read-only block, and a Copy button. */
.snippet { display: flex; flex-direction: column; gap: .35rem; }
.snippet .snippet-cap { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.snippet .snippet-cap label { font-size: .85rem; color: var(--muted); margin: 0; }
.snippet pre {
  margin: 0; font-family: var(--mono); font-size: .8rem;
  white-space: pre-wrap; word-break: break-all;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem; overflow: auto; max-height: 9rem;
}
.snippet .copy {
  flex: 0 0 auto; font: inherit; cursor: pointer; font-size: .8rem;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: .25rem .6rem;
}
.snippet .copy:hover { background: var(--panel-2); }

/* Manage links: one row per active link, tagged with its type. */
.link-row {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem;
}
.link-row .link-main { flex: 1 1 auto; min-width: 0; }
.link-row .link-meta { color: var(--muted); font-size: .8rem; }
.link-badge { padding: .15rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.link-badge-persistent { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.link-badge-encrypted { background: color-mix(in srgb, var(--ok) 10%, transparent); color: var(--ok); }

/* Vertical stack used inside modals (form fields, snippets, link rows). */
.field-group { display: flex; flex-direction: column; gap: .85rem; }
.field-group .field { margin-bottom: 0; }

/* Request filters (canvas 32): one card per gate, in the order they run. */
.filters-row {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem .75rem; margin-bottom: .6rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.filters-head { display: flex; align-items: center; gap: .6rem; }
.filters-head .fName { flex: 1 1 auto; min-width: 0; }
.filters-actions { flex: 0 0 auto; display: flex; gap: .3rem; }
.filters-actions .btn { padding: .25rem .55rem; font-size: .8rem; }
.filters-actions .btn[disabled] { opacity: .4; cursor: default; }
/* Scripts and sample payloads are code: monospace, and never wrapped mid-token. */
.filters-row .fScript,
.filters-row .fSample {
  font-family: var(--mono);
  font-size: .82rem; white-space: pre; overflow-x: auto;
}
.filters-test summary { cursor: pointer; color: var(--muted); font-size: .82rem; }
.filters-test > * { margin-top: .5rem; }
.filters-testbar { display: flex; align-items: center; gap: .6rem; }
.filters-verdict { margin-top: .5rem; }
.verdict-allowed { color: var(--ok); }
.verdict-rejected { color: var(--warn); }
.verdict-failed { color: var(--danger); }
.filters-console {
  margin: .4rem 0 0; padding: .5rem .6rem;
  background: var(--panel-2); border-radius: 8px;
  font-size: .78rem; white-space: pre-wrap; overflow-x: auto;
}

/* Direct chat + one-off prompt (canvas 33). */
/* The agent form's "use this agent" bar, offered only once the agent is saved. */
.agActions {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border);
}
.agActions .muted { flex: 1 1 100%; }
/* One prompt's result. The reply is agent output, so it is rendered as text in a bounded block. */
.prompt-out { display: flex; flex-direction: column; gap: .4rem; margin-top: .25rem; }
.prompt-out pre {
  margin: 0; font-family: var(--mono); font-size: .8rem;
  white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem; overflow: auto; max-height: 18rem;
}
.prompt-status-ok { color: var(--ok); }
.prompt-status-bad { color: var(--warn); }
/* An <a> wearing .btn needs the block/centring a <button> gets for free. */
.btn-anchor { display: block; text-align: center; text-decoration: none; }

/* ---- Shared report viewer (canvas 34) ---- */
.report-viewer { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.report-head { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: flex-end;
  justify-content: space-between; margin: 1rem 0; }
.report-title { margin: 0 0 .25rem; overflow-wrap: anywhere; }
.report-files { display: flex; flex-wrap: wrap; gap: .5rem; }
.report-frame { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline;
  padding: .5rem 0; border-bottom: 1px solid var(--border); }
.report-gone { max-width: 560px; margin: 2rem auto; }
@media (max-width: 600px) { .report-frame { height: 70vh; } }

/* ---- My computers (canvas 40) ---- */
.wa-list { list-style: none; padding: 0; margin: 0; }
.wa-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border); }
.wa-row-main { flex: 1 1 10rem; min-width: 0; }
.wa-row-name { font-weight: 600; overflow-wrap: anywhere; }
.wa-row-actions { display: flex; gap: .5rem; }
.wa-heading { margin: 1.25rem 0 .25rem; font-size: 1rem; }
/* Theme tokens only (Canvas 40 §4): the badges mirror .badge-ok / .badge-off. */
.wa-badge { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: color-mix(in srgb, var(--muted) 10%, transparent); color: var(--muted); }
.wa-badge.wa-online { background: color-mix(in srgb, var(--ok) 10%, transparent); color: var(--ok); }
.wa-badge.wa-offline { background: color-mix(in srgb, var(--muted) 10%, transparent); color: var(--muted); }
.wa-view { display: flex; flex-direction: column; gap: .5rem;
  height: calc(100vh - 7rem); height: calc(100dvh - 7rem); min-height: 320px; }
.wa-bar { display: flex; align-items: baseline; gap: .75rem; min-width: 0; }
.wa-bar .wa-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wa-bar .wa-status { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* The back control: the link and the button look alike (Canvas 40 §4). */
.wa-back { flex: none; white-space: nowrap; color: var(--text); text-decoration: none; background: none;
  border: 0; padding: 0; font: inherit; cursor: pointer; }
.wa-back[hidden] { display: none; }
.wa-back:hover { text-decoration: underline; }
/* The computer's items (STORY-039-001): databases, then documents by kind. */
.wa-items { flex: 1 1 auto; overflow: auto; min-height: 0; }
.wa-items[hidden], .wa-frames[hidden] { display: none; }
.wa-items .wa-heading:first-child { margin-top: .25rem; }
.wa-items .wa-list li { border-bottom: 1px solid var(--border); }
.wa-item { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%;
  min-height: 44px; padding: .55rem .5rem; background: none; border: 0; border-radius: 6px;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wa-item:hover { background: var(--panel-2); }
.wa-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.wa-item-name { font-weight: 600; overflow-wrap: anywhere; max-width: 100%; }
.wa-frames { flex: 1 1 auto; display: flex; min-height: 0; }
/* The frame's white is the computer page's canvas, not portal chrome (Canvas 40 §4). */
.wa-frame { flex: 1 1 auto; width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
/* The agent's frame, kept behind an item it opened (STORY-041-001). */
.wa-frame[hidden] { display: none; }
/* While a computer is open the portal page itself never scrolls (STORY-041-001). */
html.wa-locked, html.wa-locked body { overflow: hidden; overscroll-behavior: none; }
/* The agent's view with the iOS keyboard up: pinned to the visual viewport; top and height come
   from the script (Canvas 40 R, Fit to the visible area). */
.wa-view.wa-pinned { position: fixed; left: 0; right: 0; z-index: 30; min-height: 0;
  padding: .25rem .5rem 0; background: var(--bg); }
.wa-message { overflow-wrap: anywhere; }
/* Canvas 47: the "See plans" link after the owner's needs_pro sentence. */
.wa-message .wa-upgrade { color: var(--accent); font-weight: 600; }
.wa-download { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); }
.wa-download[hidden] { display: none; }
/* Canvas 44 D5: a link from a message, opened only on a tap; the download bar's look. */
.wa-link { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .5rem .75rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--text); }
.wa-link[hidden] { display: none; }
.wa-link-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-download-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-gone { max-width: 560px; margin: 2rem auto; }
.app:has(.wa-view) { max-width: 1080px; }
@media (max-width: 600px) {
  .app:has(.wa-view) { padding: .5rem .5rem 0; }
  .wa-view { height: calc(100dvh - 4.5rem); }
  .wa-bar { flex-wrap: wrap; gap: .25rem .75rem; }
  .wa-bar .wa-status { margin-left: 0; flex-basis: 100%; }
  .wa-frame { border-radius: 0; border-left: 0; border-right: 0; }
}

/* Organization groups (canvas 43): usable at 360 px. */
.og-create { margin: .5rem 0 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.og-create .og-name { flex: 1 1 200px; min-width: 160px; }
.og-group { border-top: 1px solid var(--border); }
.og-group:first-child { border-top: none; }
.og-group > .row { border-bottom: none; flex-wrap: wrap; }
.og-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.og-members { margin: 0 0 .6rem 1rem; }
.og-members .row { padding: .35rem 0; }
.og-add { margin-top: .4rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.og-add .og-pick { flex: 1 1 200px; min-width: 160px; width: auto; }

/* ---- Feature flags (canvas 42) ---- */
.ff-section { margin-top: 1.25rem; }
.ff-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.ff-form > .error[data-ff-error="general"], .ff-form > .btn { grid-column: 1 / -1; justify-self: start; }
.ff-form .field input, .ff-form .field select { width: 100%; }
.ff-form input[type=number] {
  width: 100%; padding: .6rem .75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.ff-form .field .error { margin: .25rem 0 0; min-height: 0; }
.ff-checks { display: flex; flex-wrap: wrap; gap: .75rem; padding-top: .35rem; }
.ff-checks label { display: inline-flex; align-items: center; gap: .35rem; color: var(--text); font-size: .9rem; margin: 0; }
.ff-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.ff-history { list-style: none; padding: 0; margin: 0; }
.ff-history li { padding: .55rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.ff-history li:last-child { border-bottom: none; }
.ffArchiveConfirm { width: 100%; max-width: 24rem; margin: .25rem 0; }
@media (max-width: 760px) {
  .ff-form { grid-template-columns: minmax(0, 1fr); }
}
/* Canvas 52 D4: the one-line notice after Stripe Checkout returns. */
.notice { padding: .6rem .8rem; margin: 0 0 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }

/* Canvas 53 D10: the AI credit section. */
.ai-credit-figures { display: grid; grid-template-columns: 1fr; gap: .75rem; margin: .5rem 0 1rem; }
@media (min-width: 761px) { .ai-credit-figures { grid-template-columns: 1fr 1fr; } }
.ai-credit-figure { padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 8px; }
.ai-credit-value { font-size: 1.4rem; font-weight: 600; }
.ai-credit-heading { margin: 1.25rem 0 .5rem; font-size: 1rem; }
.ai-credit-packs { display: flex; flex-wrap: wrap; gap: .5rem; }
.ai-credit-scroll { overflow-x: auto; }
.ai-credit-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.ai-credit-table th, .ai-credit-table td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }

/* Canvas 54 D11: automatic top-up and the out-of-credit / failure warnings. */
.ai-credit-auto { margin: .25rem 0 .5rem; }
.ai-credit-auto-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: .5rem 0; }
.ai-credit-auto-row select { margin-left: .35rem; }
.ai-credit-warning { padding: .6rem .8rem; margin: 0 0 1rem; border: 1px solid var(--border); border-left: 4px solid #c0392b; border-radius: 8px; background: var(--bg); }

/* Canvas 56 D9: "Confirm your email address" — the .notice look, its buttons in a row. */
.confirm-notice { padding: .6rem .8rem; margin: 0 0 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.confirm-notice p { margin: 0 0 .5rem; }
.confirm-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
/* ---- Admin dashboard (Canvas 58) ------------------------------------------------------------------------------
   Series slots are the validated reference palette (light); text stays in the portal's text tokens. */
.adm {
  --adm-s1: #2a78d6; --adm-s2: #eb6834; --adm-s3: #1baf7a; --adm-s4: #eda100;
  --adm-grid: var(--line-soft);
  position: relative; min-width: 0;
}
.adm-window { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.adm-win { font: inherit; font-size: .85rem; cursor: pointer; padding: .35rem .75rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.adm-win[aria-checked="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.adm-asof { margin-left: auto; }
.adm-section { border-top: 1px solid var(--border); padding: 1rem 0; min-width: 0; }
.adm-section:first-of-type { border-top: none; padding-top: 0; }
.adm-section h3 { margin: 0 0 .75rem; font-size: 1rem; }
.adm-section h4 { margin: 1rem 0 .5rem; font-size: .875rem; color: var(--muted); font-weight: 600; }
.adm-body { min-width: 0; transition: opacity .2s; }
.adm-body.adm-stale { opacity: .5; }
.adm-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
@media (min-width: 761px) { .adm-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .adm-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.adm-tiles.adm-tiles-2, .adm-tiles.adm-tiles-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 761px) { .adm-tiles.adm-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.adm-tile { border: 1px solid var(--border); border-radius: 10px; padding: .75rem; min-width: 0; }
.adm-tile-label { font-size: .8rem; color: var(--muted); }
.adm-tile-value { font-size: 1.4rem; font-weight: 600; margin-top: .15rem; overflow-wrap: anywhere; }
.adm-tile-sub { font-size: .75rem; margin-top: .15rem; overflow-wrap: anywhere; }
.adm-chart { margin: .5rem 0 0; min-width: 0; }
.adm-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.adm-chart .adm-stack { height: 20px; }
.adm-grid { stroke: var(--adm-grid); stroke-width: 1; }
.adm-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.adm-cross { stroke: var(--border-strong); stroke-width: 1; }
.adm-dot { stroke: var(--panel); stroke-width: 2; }
.adm-empty { fill: var(--line-soft); }
.adm-bar:hover path, .adm-bar:focus path, .adm-bar:hover rect, .adm-bar:focus rect { opacity: .8; }
.adm-bar:focus { outline: none; }
.adm-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .8rem; margin-top: .5rem; color: var(--muted); }
.adm-legend b { color: var(--text); }
.adm-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.adm-key-line { height: 2px; width: 12px; border-radius: 1px; vertical-align: 3px; }
.adm-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; font-size: .8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.08); max-width: 18rem; }
.adm-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.adm-bars li { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) auto; align-items: center; gap: .6rem; font-size: .85rem; }
.adm-bars-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-bars-track { display: block; height: 10px; }
.adm-bars-fill { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.adm-bars-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 600px) {
  .adm-bars li { grid-template-columns: minmax(0, 1fr) auto; }
  .adm-bars-track { grid-column: 1 / -1; grid-row: 2; }
}
.adm-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.5rem; }
@media (min-width: 761px) { .adm-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.adm-facts { display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; font-size: .85rem; color: var(--muted); margin-top: .75rem; }
.adm-facts b { color: var(--text); }
.adm-table { margin-top: .4rem; font-size: .8rem; }
.adm-table summary { cursor: pointer; color: var(--muted); }
.adm-scroll { overflow-x: auto; max-width: 100%; }
.adm-table table, .adm-grid-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.adm-table th, .adm-table td, .adm-grid-table th, .adm-grid-table td { text-align: left; padding: .3rem .5rem;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.adm-grid-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.adm-grid-table code { font-family: var(--mono); font-size: .75rem; }
.adm-instance { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; margin-bottom: .5rem; }
.adm-instance-figs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; font-size: .85rem; margin-top: .35rem; }
.adm-spark { width: 120px; height: 32px; }
.adm-att ul { list-style: none; margin: 0; padding: 0; }
.adm-att li { padding: .4rem 0; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }
