/* Roote Shule components, work density.
   Used by every signed-in screen. Public pages add public.css on top. */

/* ============ Buttons ============ */
.btn {
  --_bg: var(--surface);
  --_fg: var(--ink);
  --_bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--ctl-h); padding: 0 var(--s-4);
  border-radius: var(--r-pill);
  background: var(--_bg); color: var(--_fg);
  border: 1px solid var(--_bd);
  font-size: var(--t-md); font-weight: 600; white-space: nowrap;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-quick) ease, border-color var(--t-quick) ease;
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { --_bg: var(--surface-2); --_bd: var(--ink-3); }
  .btn-primary:hover { --_bg: var(--brand-strong); --_bd: var(--brand-strong); }
  .btn-ghost:hover { --_bg: var(--ground-2); }
}
.btn-primary { --_bg: var(--brand); --_fg: var(--on-brand); --_bd: var(--brand); }
.btn-ghost { --_bg: transparent; --_bd: transparent; }
.btn-danger { --_fg: var(--neg); --_bd: var(--neg-line); }
.btn-sm { height: 1.875rem; padding: 0 var(--s-3); font-size: var(--t-sm); }
.btn-lg { height: 2.75rem; padding: 0 var(--s-5); font-size: var(--t-lg); }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
/* Button in a button: the primary action carries its arrow in its own circle. */
.btn-arrow { padding-right: 0.25rem; }
.btn-arrow .btn-dot {
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: color-mix(in oklab, var(--on-brand) 18%, transparent);
  transition: transform var(--t-quick) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .btn-arrow:hover .btn-dot { transform: translateX(2px); } }

/* ============ Fields ============ */
.field { display: grid; gap: var(--s-1); }
.field > label, .label { font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.help { font-size: var(--t-xs); color: var(--ink-3); }
.error-text { font-size: var(--t-xs); color: var(--neg); display: flex; gap: var(--s-1); align-items: center; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h);
  padding: 0 var(--s-3);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  font-size: var(--t-md);
  transition: border-color var(--t-quick) ease, box-shadow var(--t-quick) ease;
}
.textarea { height: auto; min-height: 5rem; padding: var(--s-2) var(--s-3); resize: vertical; }
.input::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-ink);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 22%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--neg); }
.input.input-bad { border-color: var(--neg); background: var(--neg-bg); color: var(--neg); font-weight: 600; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .i { position: absolute; left: var(--s-3); color: var(--ink-3); pointer-events: none; }
.input-affix .input { padding-left: 2.1rem; }
.input-money { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--ground-2); border-radius: var(--r-pill); border: 1px solid var(--line); }
.seg button, .seg a {
  height: 1.75rem; padding: 0 var(--s-3); border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: var(--s-1);
}
.seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ============ Status badges ============ */
.badge {
  --_c: var(--ink-2); --_b: var(--ground-2); --_l: var(--line);
  display: inline-flex; align-items: center; gap: 0.3em;
  height: 1.375rem; padding: 0 0.55rem;
  border-radius: var(--r-pill);
  font-size: var(--t-xs); font-weight: 650; line-height: 1;
  color: var(--_c); background: var(--_b); border: 1px solid var(--_l);
  white-space: nowrap;
}
.badge .i { width: 1em; height: 1em; }
.badge-pos  { --_c: var(--pos);  --_b: var(--pos-bg);  --_l: var(--pos-line); }
.badge-warn { --_c: var(--warn); --_b: var(--warn-bg); --_l: var(--warn-line); }
.badge-neg  { --_c: var(--neg);  --_b: var(--neg-bg);  --_l: var(--neg-line); }
.badge-info { --_c: var(--info); --_b: var(--info-bg); --_l: var(--info-line); }
.badge-brand { --_c: var(--brand-ink); --_b: var(--brand-tint); --_l: var(--brand-tint-2); }
/* Simulated (demo adapters): hatched, always labelled. */
.badge-sim {
  --_c: var(--sim); --_l: var(--sim-line);
  background: repeating-linear-gradient(-45deg, var(--sim-bg) 0 5px, color-mix(in oklab, var(--sim-bg) 55%, var(--surface)) 5px 9px);
  border-style: dashed;
}

/* ============ Panels ============ */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  min-height: 3rem;
}
.panel-head.flush { border-bottom: 0; padding-bottom: 0; }
.panel-title { font-size: var(--t-lg); font-weight: 650; letter-spacing: -0.01em; }
.panel-sub { font-size: var(--t-sm); color: var(--ink-3); }
.panel-head .spacer, .spacer { flex: 1; }
.panel-body { padding: var(--s-4); }
.panel-foot { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); display: flex; align-items: center; gap: var(--s-3); }

/* The margin line: one short accent rule marking "here". */
.margin-mark { position: relative; }
.margin-mark::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--accent);
}

/* Drill-down link: from a figure to the records behind it. */
.drill { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--t-sm); font-weight: 600; color: var(--brand-ink); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .drill:hover { text-decoration: underline; text-underline-offset: 3px; } }

/* ============ Key-value lists ============ */
.kv { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: var(--s-2) var(--s-4); font-size: var(--t-md); }
.kv dt { color: var(--ink-3); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.table { font-size: var(--t-md); }
.table th {
  text-align: left; font-weight: 600; font-size: var(--t-sm); color: var(--ink-3);
  padding: 0 var(--s-3); height: 2.25rem; white-space: nowrap;
  border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 0 var(--s-3); height: var(--row); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--s-4); }
.table th:last-child, .table td:last-child { padding-right: var(--s-4); }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table .c { text-align: center; }
.table-compact td { height: var(--row-compact); }
@media (hover: hover) and (pointer: fine) { .table tbody tr:hover td { background: var(--surface-2); } }
.table tr[aria-selected="true"] td { background: var(--brand-tint); }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.cell-person { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.cell-person .name { font-weight: 600; }

/* ============ Figures (stats) ============ */
.figure-label { font-size: var(--t-sm); color: var(--ink-2); font-weight: 500; }
.figure {
  font-size: var(--t-num); font-weight: 650; letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.figure small { font-size: 0.45em; font-weight: 600; letter-spacing: 0; color: var(--ink-2); margin-right: 0.2em; }
.delta { display: inline-flex; align-items: center; gap: 0.2em; font-size: var(--t-sm); font-weight: 600; }
.delta.up { color: var(--pos); } .delta.down { color: var(--neg); }
.meter { height: 6px; border-radius: 6px; background: var(--ground-2); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--chart-1); border-radius: inherit; }

/* ============ Avatars ============ */
.avatar {
  --_size: 2rem;
  width: var(--_size); height: var(--_size); flex: none;
  border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: var(--brand-tint-2); color: var(--brand-ink);
  font-size: calc(var(--_size) * 0.38); font-weight: 700; letter-spacing: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { --_size: 4.5rem; }
.avatar-sm { --_size: 1.625rem; }
.avatar[data-tone="2"] { background: #e8e1f5; color: #4f3a85; }
.avatar[data-tone="3"] { background: #f7e6cf; color: #7a4d06; }
.avatar[data-tone="4"] { background: #dcebf6; color: #1f4f80; }
.avatar[data-tone="5"] { background: #f5dfe0; color: #8a2a2f; }
:root[data-theme="dark"] .avatar[data-tone="2"] { background: #2c2442; color: #cdbaf6; }
:root[data-theme="dark"] .avatar[data-tone="3"] { background: #3a2c14; color: #f0c98a; }
:root[data-theme="dark"] .avatar[data-tone="4"] { background: #172c42; color: #a9cdf2; }
:root[data-theme="dark"] .avatar[data-tone="5"] { background: #3a1d20; color: #f2b3b6; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button {
  position: relative; display: inline-flex; align-items: center; gap: var(--s-2);
  height: 2.75rem; padding: 0 var(--s-3);
  font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); }
.tabs [aria-selected="true"]::after, .tabs [aria-current="page"]::after {
  content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px;
}
.tabs .count { font-size: var(--t-xs); color: var(--ink-3); font-weight: 600; }

/* ============ Shell: office and ledger desk (sidebar) ============ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; padding: var(--s-4) var(--s-3);
}
.school-chip { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-2) var(--s-4); }
.crest {
  width: 2.25rem; height: 2.25rem; flex: none; border-radius: 0.6rem;
  display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand);
  font-family: var(--font-serif); font-weight: 700; font-size: 1rem; letter-spacing: -0.02em;
}
.school-chip .name { font-family: var(--font-serif); font-weight: 650; font-size: var(--t-lg); line-height: 1.15; letter-spacing: -0.01em; }
.school-chip .sub { font-size: var(--t-xs); color: var(--ink-3); }
.nav-group { margin-top: var(--s-4); }
.nav-group-label { font-size: var(--t-xs); color: var(--ink-3); font-weight: 600; padding: 0 var(--s-3) var(--s-1); }
.nav-link {
  position: relative; display: flex; align-items: center; gap: var(--s-3);
  height: 2.25rem; padding: 0 var(--s-3); border-radius: var(--r-ctl);
  color: var(--ink-2); font-weight: 550;
}
.nav-link .i { color: var(--ink-3); }
.nav-link .count { margin-left: auto; font-size: var(--t-xs); font-weight: 650; color: var(--ink-3); font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .nav-link:hover { background: var(--ground); color: var(--ink); } }
.nav-link[aria-current="page"] { background: var(--brand-tint); color: var(--brand-ink); font-weight: 650; }
.nav-link[aria-current="page"] .i { color: var(--brand-ink); }
.nav-link[aria-current="page"]::before {
  content: ""; position: absolute; left: -0.75rem; top: 0.5rem; bottom: 0.5rem; width: 3px; border-radius: 3px; background: var(--accent);
}
.sidebar-foot { margin-top: auto; padding-top: var(--s-4); display: grid; gap: var(--s-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-3);
  height: 3.5rem; padding: 0 var(--s-6);
  background: color-mix(in oklab, var(--ground) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--ink-3); min-width: 0; }
.crumbs a { color: var(--ink-2); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.page { padding: var(--s-6); width: 100%; max-width: var(--content-max); }
.page-head { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.page-title { font-size: var(--t-2xl); font-weight: 680; letter-spacing: -0.025em; line-height: 1.15; }
.page-sub { color: var(--ink-2); margin-top: var(--s-1); }
.menu-btn { display: none; }

@media (max-width: 64rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(18rem, 86vw); z-index: var(--z-drawer);
    transform: translateX(-102%); transition: transform var(--t-sheet) var(--ease-drawer);
    box-shadow: var(--shadow-3);
  }
  .sidebar[data-open="true"] { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 var(--s-4); }
  .page { padding: var(--s-4); }
}

/* ============ Shell: owner briefing (no sidebar) ============ */
.briefing-bar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-4);
  height: 3.75rem; padding: 0 max(var(--s-6), calc((100vw - var(--content-max)) / 2 + var(--s-6)));
  background: color-mix(in oklab, var(--ground) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.briefing-nav { display: flex; gap: var(--s-1); }
.briefing-nav a {
  position: relative; height: 2.25rem; padding: 0 var(--s-3); display: inline-flex; align-items: center;
  border-radius: var(--r-pill); font-weight: 600; color: var(--ink-2);
}
.briefing-nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
@media (hover: hover) and (pointer: fine) { .briefing-nav a:hover { color: var(--ink); } }

/* ============ Phone shell (teacher, parent web) ============ */
.phone-shell { max-width: 30rem; margin: 0 auto; min-height: 100dvh; background: var(--ground); display: flex; flex-direction: column; }
.app-bar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-3);
  padding: calc(env(safe-area-inset-top) + var(--s-3)) var(--s-4) var(--s-3);
  background: var(--ground);
}
.bottom-nav {
  position: sticky; bottom: 0; z-index: var(--z-nav);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: var(--s-1) var(--s-2) calc(env(safe-area-inset-bottom) + var(--s-1));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottom-nav a {
  display: grid; justify-items: center; gap: 2px; padding: var(--s-2) 0;
  font-size: 0.6875rem; font-weight: 600; color: var(--ink-3);
}
.bottom-nav a .i { width: 1.4rem; height: 1.4rem; }
.bottom-nav a[aria-current="page"] { color: var(--brand-ink); }

/* ============ Drawer, dialog, toast ============ */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-drawer) - 1); }
.scrim[hidden] { display: none; }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(28rem, 100vw); z-index: var(--z-drawer);
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform var(--t-sheet) var(--ease-drawer);
  overscroll-behavior: contain;
}
.drawer[data-open="true"] { transform: none; }
.drawer-static { position: static; transform: none; width: auto; box-shadow: none; border: 1px solid var(--line); border-radius: var(--r-panel); }
.drawer-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.drawer-body { padding: var(--s-5); overflow-y: auto; display: grid; gap: var(--s-4); align-content: start; flex: 1; }
.drawer-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line); display: flex; gap: var(--s-3); justify-content: flex-end; }

.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-panel);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-3);
  font-size: var(--t-md); max-width: 26rem;
}

/* ============ Callouts and states ============ */
.callout {
  --_c: var(--info); --_b: var(--info-bg); --_l: var(--info-line);
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-panel);
  background: var(--_b); border: 1px solid var(--_l); color: var(--ink);
  font-size: var(--t-md);
}
.callout > .i { color: var(--_c); margin-top: 0.1em; }
.callout-warn { --_c: var(--warn); --_b: var(--warn-bg); --_l: var(--warn-line); }
.callout-neg { --_c: var(--neg); --_b: var(--neg-bg); --_l: var(--neg-line); }
.callout-pos { --_c: var(--pos); --_b: var(--pos-bg); --_l: var(--pos-line); }
.callout-sim { --_c: var(--sim); --_b: var(--sim-bg); --_l: var(--sim-line); border-style: dashed; }

.empty { display: grid; justify-items: start; gap: var(--s-2); padding: var(--s-8) var(--s-6); }
.empty .i { width: 1.75rem; height: 1.75rem; color: var(--ink-3); }
.empty h3 { font-size: var(--t-lg); font-weight: 650; }
.empty p { color: var(--ink-2); max-width: 34ch; }

.skeleton {
  display: block; border-radius: 6px; height: 0.9em;
  background: linear-gradient(90deg, var(--ground-2) 0%, var(--surface-2) 50%, var(--ground-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Demo marker: a slim strip at the top of every demo school screen. */
.demo-strip {
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 1.75rem; padding: 0.2rem var(--s-4);
  font-size: var(--t-xs); font-weight: 600; color: var(--sim); text-align: center;
  background: repeating-linear-gradient(-45deg, var(--sim-bg) 0 6px, color-mix(in oklab, var(--sim-bg) 60%, var(--surface)) 6px 11px);
  border-bottom: 1px dashed var(--sim-line);
}

/* ============ Charts (server-rendered SVG) ============ */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-sans); font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .s1 { fill: var(--chart-1); }
.chart .s2 { fill: var(--chart-2); }
.chart .l1 { stroke: var(--chart-1); stroke-width: 2.25; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .l2 { stroke: var(--ink-3); stroke-width: 1.5; fill: none; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--surface); stroke: var(--chart-1); stroke-width: 2; }
.chart .area { fill: color-mix(in oklab, var(--chart-1) 14%, transparent); }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--t-sm); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: var(--s-2); }
.legend i { width: 0.75rem; height: 0.75rem; border-radius: 3px; display: inline-block; }

/* ============ Theme switch ============ */
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ============ Menu categories and quick actions (Brief 09, B4) ============ */
.nav-cat { margin-top: var(--s-1); }
.nav-group + .nav-cat { margin-top: var(--s-3); }
.nav-cat-btn {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  min-height: 2.25rem; padding: 0.35rem var(--s-3); border-radius: var(--r-ctl);
  color: var(--ink); font-weight: 650; font-size: var(--t-sm); text-align: left; line-height: 1.25;
}
.nav-cat-btn .i { color: var(--ink-3); }
.nav-cat-btn .chev { margin-left: auto; transition: transform var(--t-quick) ease; }
.nav-cat-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
@media (hover: hover) and (pointer: fine) { .nav-cat-btn:hover { background: var(--ground); } }
.nav-cat-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nav-cat[data-current] > .nav-cat-btn { color: var(--brand-ink); }
.nav-cat[data-current] > .nav-cat-btn .i:first-child { color: var(--brand-ink); }
.nav-cat-items { padding: 2px 0 var(--s-2) var(--s-4); margin-left: var(--s-3); border-left: 1px solid var(--line); }
.nav-cat-items .nav-link { height: 2.1rem; font-size: var(--t-sm); }
.nav-cat-items .nav-link .i { width: 1rem; height: 1rem; }
.nav-cat-items .nav-link[aria-current="page"]::before { left: calc(-1 * var(--s-4) - 2px); }
.quick { position: relative; }
.quick > summary { list-style: none; cursor: pointer; }
.quick > summary::-webkit-details-marker { display: none; }
.quick-menu {
  position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: var(--z-nav);
  min-width: 15rem; padding: var(--s-2); display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-3);
}
.quick-menu a { display: flex; gap: var(--s-3); align-items: center; padding: 0.55rem var(--s-3); border-radius: var(--r-ctl); font-weight: 550; font-size: var(--t-sm); }
.quick-menu a .i { color: var(--brand-ink); }
@media (hover: hover) and (pointer: fine) { .quick-menu a:hover { background: var(--ground); } }
.quick-menu a:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (max-width: 40rem) { .hide-sm { display: none; } }

/* ============ Search box in the top bar (Brief 09, B5) ============ */
.tsearch { position: relative; display: flex; align-items: center; gap: var(--s-2); width: min(26rem, 40vw); height: 2.25rem; padding: 0 var(--s-2) 0 var(--s-3); border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
.tsearch:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 18%, transparent); }
.tsearch > .i { color: var(--ink-3); flex: none; }
.tsearch input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: inherit; font-size: var(--t-sm); color: var(--ink); }
.tsearch input::-webkit-search-cancel-button { display: none; }
.tsearch kbd { font-size: var(--t-xs); color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 0.35rem; }
.tsearch-pop { position: absolute; left: 0; right: 0; top: calc(100% + 0.35rem); z-index: var(--z-nav); max-height: min(70vh, 32rem); overflow-y: auto; padding: var(--s-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-3); }
.tsearch-pop a { display: grid; gap: 1px; padding: 0.45rem var(--s-3); border-radius: var(--r-ctl); }
.tsearch-pop a b { font-weight: 600; font-size: var(--t-sm); }
.tsearch-pop a small { font-size: var(--t-xs); color: var(--ink-3); }
.tsearch-pop a[aria-selected="true"], .tsearch-pop a:hover { background: var(--brand-tint); }
.tsearch-h { font-size: var(--t-xs); font-weight: 700; color: var(--ink-3); padding: var(--s-2) var(--s-3) 2px; }
.tsearch-none { padding: var(--s-3); color: var(--ink-3); font-size: var(--t-sm); }
.tsearch-all { margin-top: var(--s-1); border-top: 1px solid var(--line); font-weight: 600; font-size: var(--t-sm); color: var(--brand-ink); }
@media (max-width: 64rem) { .tsearch { width: auto; flex: 1; } .crumbs { display: none; } }

/* ============ The assistant (Brief 09, B6) ============ */
.ast-fab { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: var(--z-nav); display: inline-flex; align-items: center; gap: var(--s-2); height: 3rem; padding: 0 1.1rem; border-radius: var(--r-pill); background: var(--brand); color: var(--on-brand); font-weight: 650; box-shadow: var(--shadow-3); }
.ast-fab .i { width: 1.25rem; height: 1.25rem; }
.ast-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ast-panel { position: fixed; right: var(--s-5); bottom: calc(var(--s-5) + 3.6rem); z-index: var(--z-drawer); width: min(27rem, calc(100vw - 2rem)); height: min(40rem, calc(100dvh - 7rem)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-3); overflow: hidden; }
.ast-panel[hidden] { display: none; }
.ast-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.ast-head h2 { font-size: var(--t-md, 1rem); font-weight: 700; margin-right: auto; }
.ast-head > .i { color: var(--brand-ink); }
.ast-log { flex: 1; overflow-y: auto; padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.ast-inline .ast-log { min-height: 22rem; max-height: 62vh; }
.ast-msg { max-width: 92%; font-size: var(--t-sm); line-height: 1.5; }
.ast-msg > p { margin: 0; }
.ast-me { align-self: flex-end; background: var(--brand); color: var(--on-brand); padding: var(--s-2) var(--s-3); border-radius: 1rem 1rem 0.3rem 1rem; }
.ast-bot { align-self: flex-start; display: grid; gap: var(--s-2); }
.ast-bot > p:first-child { background: var(--ground); padding: var(--s-2) var(--s-3); border-radius: 1rem 1rem 1rem 0.3rem; }
.ast-card { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: var(--s-3); display: grid; gap: var(--s-2); }
.ast-card dl { display: grid; gap: 4px; }
.ast-card dl div { display: grid; grid-template-columns: 9rem 1fr; gap: var(--s-2); }
.ast-card dt { color: var(--ink-3); }
.ast-card dd { margin: 0; }
.ast-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-ctl); }
.ast-table .table { font-size: var(--t-xs); }
.ast-list { display: grid; gap: 2px; }
.ast-list li { display: grid; padding: 0.35rem var(--s-2); border-bottom: 1px solid var(--line); }
.ast-list li:last-child { border-bottom: 0; }
.ast-list small { color: var(--ink-3); font-size: var(--t-xs); }
.ast-links { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.ast-links a { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--brand-ink); }
.ast-choices { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.ast-choices .chip { border: 1px solid var(--line-strong); border-radius: var(--r-pill); padding: 0.3rem 0.75rem; font-size: var(--t-xs); background: var(--surface); text-align: left; }
.ast-choices .chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.ast-action { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; padding: var(--s-2); border: 1px dashed var(--brand); border-radius: var(--r-ctl); }
.ast-action .faint { font-size: var(--t-xs); }
.ast-src { display: flex; gap: 4px; align-items: center; color: var(--ink-3); font-size: var(--t-xs); }
.ast-form { display: flex; gap: var(--s-2); padding: var(--s-3); border-top: 1px solid var(--line); }
.ast-form .input { flex: 1; min-width: 0; }
.ast-wait { flex-direction: row; display: flex; gap: 4px; padding: var(--s-3); }
.ast-wait span:not(.sr-only) { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--ink-3); animation: ast-dot 1s infinite ease-in-out; }
.ast-wait span:nth-child(2) { animation-delay: .15s; } .ast-wait span:nth-child(3) { animation-delay: .3s; }
@keyframes ast-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ast-wait span { animation: none; } }
@media (max-width: 40rem) { .ast-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 88dvh; border-radius: var(--r-panel) var(--r-panel) 0 0; } .ast-fab { right: var(--s-3); bottom: var(--s-3); padding: 0; width: 3rem; justify-content: center; } }
@media print { .ast-fab, .ast-panel { display: none !important; } }

/* Badge names used by Brief 09 screens (same colours as pos / neg). */
.badge-ok { --_c: var(--pos); --_b: var(--pos-bg); --_l: var(--pos-line); }
.badge-danger { --_c: var(--neg); --_b: var(--neg-bg); --_l: var(--neg-line); }
.badge-muted { --_c: var(--ink-3); --_b: var(--ground); --_l: var(--line); }
