/* AIGrant UI on the FlowDesk design system.
   Colors, radii, shadows and spacing come only from ds-tokens.css.
   Sections: 1 base · 2 layout shells · 3 components · 4 pages. */

/* ═══ 1. Base ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 24px;
  color: var(--ink); background: var(--surface); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
h1 { font-size: 32px; line-height: 40px; font-weight: 500; }
h2 { font-size: 20px; line-height: 28px; }
h3 { font-size: 16px; line-height: 24px; }
h4 { font-size: 14px; line-height: 20px; }
p, li, dd { text-wrap: pretty; }
p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-subtle); }
.small { font-size: 14px; line-height: 20px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.display-xl { font-size: clamp(40px, 6vw, 72px); line-height: 1.04; font-weight: 500; letter-spacing: -0.035em; }
.display { font-size: clamp(32px, 4vw, 48px); line-height: 1.1; font-weight: 500; letter-spacing: -0.03em; }
.lead { font-size: 18px; line-height: 28px; color: var(--ink-muted); }
/* The bracketed eyebrow: [ RÉSULTATS ] */
.eyebrow {
  font-family: var(--font-mono); font-size: 12px; line-height: 16px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--eyebrow);
}
.eyebrow::before { content: "[ "; }
.eyebrow::after { content: " ]"; }
.skip {
  position: absolute; left: var(--space-4); top: var(--space-4); z-index: 60; padding: var(--space-2) var(--space-3);
  background: var(--inverse); color: var(--on-inverse); border-radius: var(--radius-md); transform: translateY(-200%);
}
.skip:focus { transform: none; }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
[hidden] { display: none !important; }

/* ═══ 2. Layout shells ══════════════════════════════════════════════════ */
/* Public: a top nav, a centered page, the footer. */
.page { max-width: 1200px; margin: 0 auto; padding: var(--space-7) var(--space-5) var(--space-8); }
.page-narrow { max-width: 560px; }
.page-head { margin-bottom: var(--space-6); }
.page-head h1 { margin-top: var(--space-2); }
.page-head p { margin-top: var(--space-2); }

.site-nav {
  display: flex; align-items: center; gap: var(--space-5); max-width: 1200px; margin: 0 auto;
  padding: var(--space-4) var(--space-5);
}
.site-nav .nav-links { display: flex; align-items: center; gap: var(--space-1); flex-wrap: nowrap; flex-shrink: 0; }
.site-nav .nav-end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; flex-shrink: 0; }
/* When the links no longer fit on one line beside the logo and the actions, they drop out:
   the home page repeats them in its footer, other pages keep them on a row of their own. */
@media (max-width: 960px) {
  .home-hero .site-nav .nav-links { display: none; }
  .site-nav { flex-wrap: wrap; }
}
.nav-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill); text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink-muted);
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--ink); background: var(--surface-sunken); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 18px; text-decoration: none; letter-spacing: -0.02em; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--action); color: var(--on-action); font-size: 18px;
}
[data-theme="forest"] .brand-mark { background: var(--highlight); color: var(--on-highlight); }

/* App shells (owner and client workspace): side panel + content.
   On phones the panel stacks above the content. */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; align-items: stretch; }
.app-panel {
  flex: 1 1 240px; max-width: 100%; display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-5) var(--space-4); background: var(--surface-raised); border-right: 1px solid var(--border);
}
.app-main { flex: 999 1 560px; min-width: 0; padding: var(--space-6) var(--space-6) var(--space-8); }
@media (min-width: 900px) {
  .app-panel { flex: 0 0 240px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.app-panel .brand { padding: 0 var(--space-2) var(--space-4); }
.panel-label {
  margin: var(--space-4) var(--space-2) var(--space-1); font-size: 12px; line-height: 16px; font-weight: 500;
  color: var(--ink-subtle); text-transform: uppercase; letter-spacing: 0.06em;
}
.panel-foot { margin-top: auto; padding-top: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.app-head { display: flex; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.app-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.app-head h1 { margin-top: var(--space-1); }
.app-head p { margin-top: var(--space-1); }

/* Side nav item with an optional count badge. */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-nav button {
  display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3);
  border: 0; background: none; border-radius: var(--radius-md); text-decoration: none; text-align: left; width: 100%;
  font-size: 14px; font-weight: 500; color: var(--ink-muted); cursor: pointer;
}
.side-nav a:hover, .side-nav button:hover { background: var(--surface-sunken); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--surface-sunken); color: var(--ink); }
.side-nav i { font-size: 18px; }
.side-nav .label { flex: 1; min-width: 0; }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); color: var(--ink-muted); font-size: 12px; font-weight: 600; line-height: 1;
}
.count-todo { background: var(--warning-soft); color: var(--warning-ink); }
.side-nav a[aria-current="page"] .count:not(.count-todo) { background: var(--surface); }

/* Client pages: header with the 4-step stepper (Questions, Results, Documents, Follow-up). */
.client-top {
  display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; max-width: 1200px; margin: 0 auto;
  padding: var(--space-4) var(--space-5);
}
.client-top .nav-end { margin-left: auto; display: flex; gap: var(--space-1); align-items: center; }
.stepper { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; list-style: none; flex: 1 1 auto; justify-content: center; }
.stepper li { display: flex; align-items: center; gap: var(--space-2); }
.stepper li + li::before { content: ""; width: 24px; height: 1px; background: var(--border); }
.step-pill {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3);
  border-radius: var(--radius-pill); font-size: 14px; font-weight: 500; text-decoration: none; color: var(--ink-subtle);
}
.step-pill .n {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--border); font-size: 12px; font-weight: 600;
}
a.step-pill { color: var(--ink-muted); }
a.step-pill:hover { background: var(--surface-sunken); color: var(--ink); }
.step-pill.done .n { background: var(--success-soft); color: var(--success-ink); border-color: transparent; }
.step-pill[aria-current="step"] { color: var(--ink); }
.step-pill[aria-current="step"] .n { background: var(--action); color: var(--on-action); border-color: var(--action); }

/* Forest band: hero, CTA band, catalog hero, footer. Grid lines every 48px. */
.forest {
  position: relative; background-color: var(--surface); color: var(--ink);
  background-image:
    linear-gradient(to right, var(--forest-700) 1px, transparent 1px),
    linear-gradient(to bottom, var(--forest-700) 1px, transparent 1px);
  background-size: 48px 48px; background-position: -1px -1px;
}
.forest-frame { border-radius: var(--radius-2xl); overflow: hidden; margin: var(--space-3); }
.footer-forest { background: var(--forest-900); background-image: none; }

/* ═══ 3. Components ═════════════════════════════════════════════════════ */
/* Buttons: app buttons radius-md, marketing buttons pill. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid transparent;
  font-size: 15px; font-weight: 500; line-height: 1; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--action-quiet); color: var(--on-action-quiet); transition: background-color .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-sunken); filter: none; }
.btn-light { background: var(--pill-light); color: var(--on-pill-light); box-shadow: var(--shadow-button-light); }
.btn-danger { background: var(--danger-soft); color: var(--danger-ink); }
.btn-pill { border-radius: var(--radius-pill); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 var(--space-5); font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; font-weight: 500; }
.link:hover { text-decoration-color: currentColor; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Chips and badges: pill, status text uses the -ink step on the -soft fill. */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap;
  background: var(--surface-sunken); color: var(--ink-muted);
}
.chip-ok { background: var(--success-soft); color: var(--success-ink); }
.chip-warn { background: var(--warning-soft); color: var(--warning-ink); }
.chip-bad { background: var(--danger-soft); color: var(--danger-ink); }
.chip-info { background: var(--info-soft); color: var(--info-ink); }
.chip-neutral { background: var(--surface-sunken); color: var(--ink-muted); }
.chip-live { background: var(--highlight); color: var(--on-highlight); }
.chip-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* Filter chips are links or buttons. */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filter {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-pill); text-decoration: none; font-size: 14px; font-weight: 500;
  color: var(--ink-muted); background: var(--surface-raised);
}
.filter:hover { color: var(--ink); }
.filter[aria-current="true"], .filter[aria-pressed="true"] { background: var(--inverse); color: var(--on-inverse); border-color: var(--inverse); }

/* Cards */
.card {
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: var(--space-5);
}
.card > h2, .card-head { margin-bottom: var(--space-4); }
.card-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.card-head h2 { flex: 1; margin: 0; }
.card-flat { box-shadow: none; }
.cards { display: grid; gap: var(--space-4); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.split { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: flex-start; }
.split > .split-main { flex: 999 1 560px; min-width: 0; display: grid; gap: var(--space-5); }
.split > .split-side { flex: 1 1 320px; min-width: 0; display: grid; gap: var(--space-4); }
/* A sticky side column never grows past the window: it scrolls on its own, so it is always in view. */
@media (min-width: 1000px) {
  .split-side.sticky {
    position: sticky; top: var(--space-5); max-height: calc(100vh - 2 * var(--space-5));
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; border-radius: var(--radius-lg);
  }
  /* The confirm button stays at the bottom of the panel while its lists scroll. */
  .split-side.sticky .board-confirm {
    position: sticky; bottom: calc(-1 * var(--space-5)); z-index: 1; margin: 0 calc(-1 * var(--space-5)) calc(-1 * var(--space-5));
    padding: var(--space-3) var(--space-5) var(--space-5); background: var(--surface-raised);
    border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}
.board .more { margin-top: var(--space-2); }
.board .more .timeline, .board .more .needs { margin-top: var(--space-3); }
.board details.disclose .dots { margin-top: var(--space-2); }

/* Stat card */
.stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); margin-bottom: var(--space-6); }
.stat { padding: var(--space-5); }
.stat-label { font-size: 14px; line-height: 20px; color: var(--ink-subtle); display: flex; gap: var(--space-2); align-items: center; }
.stat-value { font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -0.02em; margin-top: var(--space-2); }
.stat-note { font-size: 14px; line-height: 20px; color: var(--ink-subtle); margin-top: var(--space-1); }
.stat-note.is-warn { color: var(--warning-ink); }

/* Stage track: 5 segments filled in --action up to the current stage. */
.stage-track { display: grid; gap: var(--space-2); }
.stage-bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stage-bars span { height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); }
.stage-bars span.on { background: var(--action); }
.stage-labels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 12px; line-height: 16px; color: var(--ink-subtle); }
.stage-labels span.on { color: var(--ink); font-weight: 500; }

/* To-do row: icon well, text, actions. */
.todo-list { display: grid; gap: var(--space-2); list-style: none; }
.todo-row {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised);
}
.todo-row > .todo-text { flex: 1 1 260px; min-width: 0; }
.todo-row .todo-text p { font-size: 14px; line-height: 20px; color: var(--ink-subtle); }
.todo-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.well {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--ink-muted); font-size: 18px;
}
.well-ok { background: var(--success-soft); color: var(--success-ink); }
.well-warn { background: var(--warning-soft); color: var(--warning-ink); }
.well-bad { background: var(--danger-soft); color: var(--danger-ink); }
.well-info { background: var(--info-soft); color: var(--info-ink); }
.well-lg { width: 48px; height: 48px; font-size: 24px; border-radius: var(--radius-md); }

/* Forms */
.form { display: grid; gap: var(--space-4); }
.field { display: grid; gap: 6px; }
.field > label, .field legend { font-size: 14px; line-height: 20px; font-weight: 500; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px var(--space-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface-raised); color: var(--ink); font-size: 15px; line-height: 22px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[type=file] { font-size: 14px; max-width: 100%; }
input[type=checkbox], input[type=radio] { accent-color: var(--action); width: 18px; height: 18px; }
.check { display: flex; gap: var(--space-2); align-items: center; min-height: 36px; font-size: 15px; }
.field-error { display: flex; gap: 6px; align-items: center; color: var(--danger-ink); font-size: 14px; line-height: 20px; }
.has-error input { border-color: var(--danger); }
.form-actions { display: flex; gap: var(--space-3); justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* Notices */
.notice, .callout {
  display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); font-size: 15px; line-height: 22px;
}
.notice { background: var(--success-soft); color: var(--success-ink); }
.callout { background: var(--warning-soft); color: var(--warning-ink); }
.callout-info { background: var(--info-soft); color: var(--info-ink); }
.callout-bad { background: var(--danger-soft); color: var(--danger-ink); }
.notice i, .callout i { font-size: 20px; margin-top: 1px; }
.page-notices { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); }

/* Progress bar */
.progress { height: 6px; border-radius: var(--radius-pill); background: var(--surface-sunken); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; background: var(--action); border-radius: var(--radius-pill); }
.progress > span.review { background: var(--info-soft); border-radius: 0; }

/* Tables scroll inside their box on narrow screens. */
.table-wrap { position: relative; overflow-x: auto; margin: 0 calc(-1 * var(--space-5)); padding: 0 var(--space-5); }
table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
th { text-align: left; font-weight: 500; color: var(--ink-subtle); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }

/* Lists */
.ticks, .dots { list-style: none; display: grid; gap: 6px; font-size: 15px; line-height: 22px; }
.ticks li, .dots li { position: relative; padding-left: 24px; }
.ticks li::before { content: "✓"; position: absolute; left: 2px; color: var(--success-ink); font-weight: 600; }
.dots li::before { content: ""; position: absolute; left: 6px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-subtle); }
.numbered { padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }
.plain { list-style: none; display: grid; gap: var(--space-2); }
.kv { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: var(--space-2) var(--space-4); font-size: 14px; line-height: 20px; }
.kv dt { color: var(--ink-subtle); }
.kv dd { margin: 0; }
.empty-inline { display: flex; gap: var(--space-3); align-items: center; color: var(--ink-subtle); font-size: 15px; padding: var(--space-4) 0; }
.empty-inline i { font-size: 24px; }

/* Details used as disclosure */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.disclose > summary { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-muted); min-height: 32px; }
.disclose > summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.disclose[open] > summary::before { transform: rotate(90deg); }

/* Timeline: dates in mono */
.timeline { list-style: none; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: var(--space-3); position: relative; padding-bottom: var(--space-4); }
.timeline li::before { content: ""; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--action); box-shadow: 0 0 0 3px var(--surface-raised); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 4.5px; top: 14px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline time, .timeline .when { display: block; font-family: var(--font-mono); font-size: 12px; line-height: 18px; color: var(--ink-subtle); }
.timeline .what { font-size: 15px; line-height: 22px; }
.timeline .sub { font-size: 14px; line-height: 20px; color: var(--ink-subtle); }

/* Drawer (owner "New case") */
#drawer:empty { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 70; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 71; overflow-y: auto;
  background: var(--surface); box-shadow: var(--shadow-window); padding: var(--space-6);
}
.drawer-head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-5); }
.drawer-head > div { flex: 1; }

/* Popover form (send to client) */
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-close {
  position: absolute; top: var(--space-2); right: var(--space-2); width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink-subtle); cursor: pointer; font-size: 18px;
}
.pop-close:hover { background: var(--surface-sunken); color: var(--ink); }
.pop-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pop-text { padding-right: 36px; }
.pop[open] > .pop-body {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(360px, 90vw);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-window); padding: var(--space-4);
}

.working { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-subtle); font-size: 14px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 1.4s ease-in-out infinite; }
.dot-ok { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.dot-warn { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); flex: none; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ═══ 4. Pages ══════════════════════════════════════════════════════════ */
/* ── Home ─────────────────────────────────────────────────────────────── */
.shell-home { background: var(--surface); }
.home-hero { padding-bottom: var(--space-8); }
.home-hero .site-nav { max-width: 1240px; }
.hero {
  display: grid; gap: var(--space-7); align-items: center; max-width: 1240px; margin: 0 auto;
  padding: var(--space-7) var(--space-5) 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
}
.hero-copy { display: grid; gap: var(--space-5); justify-items: start; }
.hero-copy .lead { max-width: 560px; color: var(--ink-muted); }
.hero-ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.hero-note { color: var(--ink-subtle); }
.prompt { display: grid; gap: var(--space-4); width: 100%; max-width: 560px; }
.prompt-label { font-size: 15px; font-weight: 500; margin-bottom: var(--space-3); padding: 0; }
.prompt-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pick-chip { position: relative; display: inline-flex; }
.pick-chip input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.pick-chip span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: 14px; font-weight: 500; color: var(--ink-muted);
}
.pick-chip input:checked + span { background: var(--highlight); color: var(--on-highlight); border-color: var(--highlight); }
.pick-chip input:checked + span::before { content: "✓"; }
.pick-chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
[data-theme="forest"] .field-error { color: var(--highlight); }
[data-theme="forest"] .btn-ghost { color: var(--ink); border-color: var(--border); }
[data-theme="forest"] .btn-ghost:hover { background: var(--surface-sunken); }

.window {
  margin: 0; background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-window); overflow: hidden; border: 1px solid var(--border);
}
.window-bar { display: flex; align-items: center; gap: 6px; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface-sunken); }
.window-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.window-bar span { margin-left: var(--space-3); font-size: 13px; color: var(--ink-subtle); }
.window-body { display: grid; gap: var(--space-5); padding: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.window-body .eyebrow { margin-bottom: var(--space-3); }
.window-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.window-row:last-child { border-bottom: 0; }
.window-row > span:nth-child(2) { flex: 1; min-width: 0; display: grid; }

.home-body { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-5); }
.proof-line { text-align: center; color: var(--ink-subtle); font-size: 14px; padding: var(--space-6) 0 0; }
.home-section { padding: var(--space-8) 0 0; display: grid; gap: var(--space-3); }
.home-section > .lead { max-width: 640px; }
.how-frame {
  list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; margin-top: var(--space-5);
  background: var(--surface-raised);
}
.how-frame li { padding: var(--space-6) var(--space-5); display: grid; gap: var(--space-2); align-content: start; border-right: 1px solid var(--border); }
.how-frame li:last-child { border-right: 0; }
.how-n { font-family: var(--font-mono); font-size: 13px; color: var(--eyebrow); }
.how-frame h3 { font-size: 18px; }
.how-frame p { color: var(--ink-muted); }
.benefits { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); margin-top: var(--space-5); }
.benefits .card { display: grid; gap: var(--space-3); align-content: start; }
.benefits p { color: var(--ink-muted); }
.tagline-band { background: var(--surface-sunken); margin-top: var(--space-8); padding: var(--space-8) var(--space-5); text-align: center; }
.faq { display: grid; gap: var(--space-2); margin-top: var(--space-4); max-width: 820px; }
.faq details { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-md); }
.faq summary { padding: var(--space-4) var(--space-5); font-weight: 500; display: flex; justify-content: space-between; gap: var(--space-4); min-height: 44px; }
.faq summary::after { content: "+"; color: var(--ink-subtle); font-size: 20px; }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 var(--space-5) var(--space-4); color: var(--ink-muted); }
.cta-band { margin-top: var(--space-8); padding: var(--space-9) var(--space-5); display: grid; gap: var(--space-4); justify-items: center; text-align: center; }
.cta-band .display { max-width: 720px; }
.home-foot { padding: var(--space-7) var(--space-5) var(--space-5); color: var(--ink); }
.home-foot-grid { max-width: 1200px; margin: 0 auto; display: grid; gap: var(--space-6); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.home-foot-grid > div { display: grid; gap: var(--space-3); align-content: start; }
.home-foot nav { display: grid; gap: var(--space-2); align-content: start; }
.home-foot nav a { color: var(--ink-muted); text-decoration: none; min-height: 28px; }
.home-foot nav a:hover { color: var(--ink); }
.home-foot h3 { font-size: 14px; color: var(--ink-subtle); font-weight: 500; }
.home-foot-copy { max-width: 1200px; margin: var(--space-6) auto 0; padding-top: var(--space-4); border-top: 1px solid var(--border); }
.site-foot { border-top: 1px solid var(--border); }
.site-foot-inner { max-width: 1200px; margin: 0 auto; padding: var(--space-5); display: flex; gap: var(--space-4); flex-wrap: wrap; justify-content: space-between; }
@media (max-width: 640px) {
  .forest-frame { margin: var(--space-2); border-radius: var(--radius-xl); }
  .home-hero .site-nav .nav-links { display: none; }
  .how-frame li { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* ── Questionnaire and gate ───────────────────────────────────────────── */
.q-layout { display: flex; flex-wrap: wrap; gap: var(--space-5); align-items: flex-start; }
.q-sheet { flex: 999 1 520px; min-width: 0; display: grid; gap: var(--space-4); padding: var(--space-6); }
.q-sheet .progress { margin-bottom: var(--space-2); }
.q-title { font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: -0.02em; }
.q-title:focus { outline: none; }
.q-form { display: grid; gap: var(--space-5); }
.options { display: grid; gap: var(--space-2); }
.option {
  position: relative; display: flex; align-items: center; gap: var(--space-4); min-height: 56px; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); cursor: pointer;
}
.option:hover { border-color: var(--ink-subtle); }
.option input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.option-body { flex: 1; display: grid; gap: 2px; }
.option-label { font-weight: 500; }
.option-hint { font-size: 14px; line-height: 20px; color: var(--ink-subtle); }
.option-check {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%;
  border: 1px solid var(--border); color: transparent; font-size: 14px;
}
.option:has(input:checked) { border-color: var(--action); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--action); }
.option:has(input:checked) .option-check { background: var(--action); border-color: var(--action); color: var(--on-action); }
.option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.q-profile { flex: 1 1 280px; min-width: 0; display: grid; gap: var(--space-4); }
.q-profile h2 { margin-bottom: var(--space-3); }
.profile-list { display: grid; gap: var(--space-3); }
.profile-list dt { font-size: 13px; line-height: 18px; color: var(--ink-subtle); }
.profile-list dd { font-size: 15px; line-height: 22px; font-weight: 500; }
.gate { justify-items: start; }

/* ── Results ──────────────────────────────────────────────────────────── */
.group { display: grid; gap: var(--space-4); }
.group-head h2 { display: flex; align-items: center; gap: var(--space-2); }
.program { display: grid; gap: var(--space-3); transition: border-color .15s, box-shadow .15s; }
.program:has(.pick input:checked) { border-color: var(--action); box-shadow: 0 0 0 1px var(--action), var(--shadow-card); }
.program-head { display: flex; gap: var(--space-3); align-items: flex-start; justify-content: space-between; }
.program-head h3 { font-size: 18px; line-height: 26px; }
.amount { font-size: 20px; line-height: 28px; font-weight: 500; letter-spacing: -0.01em; }
.program-desc { color: var(--ink-muted); }
.program-cols { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.program-cols h4 { margin-bottom: var(--space-2); }
.program-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.pick { position: relative; display: inline-flex; }
.pick input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.pick span {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-4);
  border-radius: var(--radius-md); font-size: 15px; font-weight: 500; background: var(--action-quiet); color: var(--on-action-quiet);
}
.pick .pick-on { display: none; background: var(--action); color: var(--on-action); }
.pick input:checked ~ .pick-off { display: none; }
.pick input:checked ~ .pick-on { display: inline-flex; }
.pick input:focus-visible ~ span { outline: 2px solid var(--focus); outline-offset: 2px; }
.board { display: grid; gap: var(--space-5); }
.board-h { font-size: 14px; line-height: 20px; font-weight: 600; margin-bottom: var(--space-2); }
.metric { font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: -0.02em; }
.needs { list-style: none; display: grid; gap: var(--space-2); font-size: 14px; line-height: 20px; }
.needs li { display: flex; gap: var(--space-2); align-items: flex-start; }
.needs li i { font-size: 18px; color: var(--ink-subtle); flex: none; }
.needs li.done { color: var(--ink-subtle); }
.needs li.done i { color: var(--success-ink); }
.file-list { list-style: none; display: grid; gap: var(--space-2); font-size: 14px; line-height: 20px; }
.file-list li { display: flex; gap: var(--space-2); align-items: center; }
.file-list li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.drop-form { display: grid; justify-items: center; }
.drop-file { font-size: 14px; }
.hit-list { list-style: none; display: grid; gap: var(--space-4); }
.hit-list li { display: grid; gap: 2px; padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.hit-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.nofit summary { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; min-height: 44px; }
.nofit ul { margin-top: var(--space-3); }

/* ── Sign in, account, catalog, legal ─────────────────────────────────── */
.auth { max-width: 440px; margin: 0 auto; }
.auth-foot { margin-top: var(--space-4); text-align: center; }
.account { display: grid; gap: var(--space-6); }
.account-files { display: grid; gap: var(--space-3); }
.file-card { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.file-card.current { border-color: var(--action); }
.file-card-text { flex: 1 1 280px; min-width: 0; display: grid; gap: 4px; }
.file-card h3 { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.shell-public .page:has(.catalog-hero) { max-width: none; padding: 0 0 var(--space-8); }
.catalog-hero { padding: var(--space-8) var(--space-5); display: grid; gap: var(--space-4); justify-items: center; text-align: center; }
.catalog-hero .lead { max-width: 680px; }
.search-pill {
  display: flex; align-items: center; gap: var(--space-2); width: min(640px, 100%); padding: 6px 6px 6px var(--space-4);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-pill);
}
.search-pill input[type=search] { border: 0 !important; background: transparent !important; min-height: 44px; padding: 0 !important; }
.search-pill input[type=search]:focus-visible { outline: none; }
.search-pill:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.catalog-body { max-width: 960px; margin: 0 auto; padding: var(--space-6) var(--space-5) 0; display: grid; gap: var(--space-5); }
.app-main .catalog-hero { margin: 0 0 var(--space-5); }
.app-main .catalog-body { padding: 0; }
.cta-card { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.cta-card > div { flex: 1 1 280px; }
.prose { max-width: 720px; margin: 0 auto; display: grid; gap: var(--space-4); }
.prose p { color: var(--ink-muted); }
.empty { display: grid; justify-items: center; gap: var(--space-4); text-align: center; padding: var(--space-8) 0; }

/* ── Client workspace ─────────────────────────────────────────────────── */
.switcher { display: grid; gap: 4px; padding: 0 var(--space-2) var(--space-4); }
.switcher select { min-height: 36px; padding: 6px var(--space-2); font-size: 14px; flex: 1; min-width: 0; }
.switcher .row { flex-wrap: nowrap; gap: var(--space-2); }
.panel-case { padding: 0 var(--space-2) var(--space-3); font-size: 14px; line-height: 20px; }
.advisor { display: grid; gap: 4px; padding: var(--space-3); margin-bottom: var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); }
.stat-text { font-size: 22px; line-height: 30px; }
.progress-list { list-style: none; display: grid; gap: var(--space-5); }
.progress-list li { display: grid; gap: var(--space-2); }
.card-foot { margin-top: var(--space-4); }
.grant-card { display: grid; gap: var(--space-4); }
.answer-list { display: grid; gap: 0; }
.answer-list > div { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.answer-list > div:last-child { border-bottom: 0; }
.answer-list dt { color: var(--ink-subtle); font-size: 14px; line-height: 20px; }
.answer-list dd { display: grid; gap: 2px; font-weight: 500; }
@media (max-width: 560px) { .answer-list > div { grid-template-columns: 1fr; gap: 2px; } }
.feed { list-style: none; display: grid; gap: 0; }
.feed li { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed li > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.feed time { font-size: 12px; white-space: nowrap; }
.prev { display: grid; gap: 2px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.upload-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.todo-row.in-file { border-color: var(--action); }
.questions .question { padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.shell-workspace .todo-row input[type=file] { max-width: 220px; }

/* ── Owner app ────────────────────────────────────────────────────────── */
.section-gap { margin-bottom: var(--space-5); }
.section-top { margin-top: var(--space-5); }
.filters-gap { margin-bottom: var(--space-4); }
.agent-status { padding: 0 var(--space-3) var(--space-3); color: var(--ink-muted); flex-wrap: nowrap; }
.case-link { text-decoration: none; }
.case-link:hover strong { text-decoration: underline; }
.row-actions { display: flex; gap: var(--space-2); align-items: center; justify-content: flex-end; white-space: nowrap; }
.todo-row time { margin-left: auto; }
.case-head h1 { gap: var(--space-3); }
.case-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-2); }
.case-meta span { display: inline-flex; gap: 6px; align-items: center; }
.your-turn { border-color: var(--warning); }
.your-turn h2 { margin-bottom: var(--space-4); }
details.todo-row { display: block; }
details.todo-row > summary { display: flex; align-items: center; gap: var(--space-4); min-height: 44px; }
details.todo-row[open] > summary { margin-bottom: var(--space-4); }
.held-form { padding-top: var(--space-4); border-top: 1px solid var(--border); }
.grant-rows { list-style: none; display: grid; gap: var(--space-3); }
.grant-rows li { display: grid; gap: var(--space-2); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.grant-rows li:last-child { border-bottom: 0; padding-bottom: 0; }
.grant-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.report { white-space: pre-wrap; color: var(--ink-muted); }
.chat-card { display: grid; gap: var(--space-4); }
.chat-card h2 { margin: 0; }
.chat { list-style: none; display: grid; gap: var(--space-3); max-height: 480px; overflow-y: auto; }
.chat li { display: grid; gap: 4px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-sunken); max-width: 88%; }
.chat li.chat-owner { justify-self: end; background: var(--action); color: var(--on-action); }
.chat li.chat-owner time, .chat li.chat-owner .who { color: inherit; opacity: .8; }
.chat li p { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat .who { font-weight: 600; color: var(--ink-subtle); }
.chat-form { display: flex; gap: var(--space-2); align-items: flex-end; }
.chat-form textarea { flex: 1; }
.thread { list-style: none; display: grid; gap: var(--space-2); }
.thread li { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.thread summary { display: flex; gap: var(--space-3); align-items: center; min-height: 44px; flex-wrap: wrap; }
.mail-body { white-space: pre-wrap; padding: var(--space-3) 0 var(--space-2) 48px; color: var(--ink-muted); overflow-wrap: anywhere; }
.check-list { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); }
.del .pop-body { text-align: left; white-space: normal; }

/* Package */
.pkg-screens .side-nav a { min-height: 36px; font-size: 13px; }
.pkg-screens .count { min-width: 20px; height: 20px; font-size: 11px; }
.pkg-screens .short { display: none; }
.ok-ink { color: var(--success-ink); }
.pkg-top { display: grid; gap: var(--space-4); }
.pkg-counts { display: flex; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; justify-content: space-between; }
.doc-list { list-style: none; display: grid; gap: var(--space-3); }
.doc-list li { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border-bottom: 0; }
.doc-list details { flex-basis: 100%; }
.screen { scroll-margin-top: var(--space-5); }
.sheet { list-style: none; display: grid; gap: var(--space-3); }
.sheet-field { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); }
.sheet-field.status-missing { background: var(--danger-soft); border-color: transparent; }
.sheet-label { display: flex; justify-content: space-between; gap: var(--space-3); align-items: flex-start; font-weight: 500; }
.req { color: var(--danger-ink); }
.sheet-answer { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-sunken); }
.sheet-ticks { list-style: none; margin: 0; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--surface-sunken); display: grid; gap: var(--space-1); font-size: 15px; }
.sheet-ticks li { color: var(--ink-subtle); }
.ticks-more { margin-top: var(--space-2); }
.owner-answer { margin-top: var(--space-2); }
.owner-answer .form { margin-top: var(--space-2); }
.owner-answer fieldset { display: grid; gap: var(--space-1); border: 0; padding: 0; }
.add-instance { align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.add-instance input[type=text] { flex: 1 1 220px; min-width: 0; }
.app-tabs { margin-bottom: var(--space-5); display: grid; gap: var(--space-3); }
.ticks-more summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.ticks-more .sheet-ticks { margin-top: var(--space-1); }
.sheet-ticks + .sheet-answer { margin-top: var(--space-2); }
/* Narrow windows: the screens of the form stay at the top as one row of links while the sheet scrolls. */
@media (max-width: 999px) {
  .pkg-screens { position: sticky; top: 0; z-index: 5; flex-basis: 100%; }
  .pkg-screens .card { padding: var(--space-2); border-radius: 0 0 var(--radius-md) var(--radius-md); box-shadow: var(--shadow-card); }
  .pkg-screens .board-h { display: none; }
  .pkg-screens .side-nav { flex-direction: row; gap: var(--space-1); overflow-x: auto; scrollbar-width: thin; list-style: none; margin: 0; padding: 0; }
  .pkg-screens .side-nav li { flex: 0 0 auto; }
  .pkg-screens .long { display: none; }
  .pkg-screens .short { display: inline; }
  .pkg-screens .side-nav a { white-space: nowrap; gap: var(--space-2); padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface); }
  .screen { scroll-margin-top: 72px; }
}
.sheet-ticks li.on { color: var(--ink); font-weight: 600; }
.sheet-answer p { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
@media print {
  .no-print, .app-panel { display: none !important; }
  .app-main { padding: 0; }
  .card { box-shadow: none; }
}

/* ══ Upload dropzone ═════════════════════════════════════
   Bencho reads these and does not define them. They are set
   on .upl so they stay inside the block.

   --ink is already this page's ink (#14241C), so it is not
   set again. --card and --fill-slab are the white surface a
   card sits on. --fill-on is the ink drawn on that surface.
   --font-ui is Geist. --pane-edge is the hairline already
   used for borders. --signal and --ok are the accent: this
   page has no separate blue for a bar, and no separate green
   for a tick. */
.upl {
  --card: var(--surface-raised);
  --fill-on: var(--ink);
  --fill-slab: var(--surface-raised);
  --font-ui: var(--font-sans);
  --ok: var(--action);
  --pane-edge: var(--border);
  --signal: var(--action);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  font-family: var(--font-ui);
  color: var(--fill-on, var(--ink));
  user-select: none;
  -webkit-user-select: none;}

/* a slot of fixed size, so the box can close in round an upload
   without moving anything below it */
.upl-zone-wrap {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 176px;}

.upl-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  /* 176, up from 128: the drop target is the block, and a short
     one read as a banner rather than a place to put something */
  height: 176px;
  padding: 0 16px;
  overflow: hidden;
  border-radius: var(--upl-r);
  background: var(--fill-slab, var(--card));
  /* a file over it and it grows, with a bounce; an upload and it
     closes in round it */
  transition:
    scale 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
    width 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
    height 420ms cubic-bezier(0.24, 1.34, 0.38, 1),
    background-color 220ms ease;}

.upl-zone[data-over] { scale: 1.02; }

/* the gulp: in a little as the file goes down, out past its size,
   and settle */
.upl-zone[data-gulp] { animation: upl-gulp 460ms cubic-bezier(0.3, 1.2, 0.4, 1); }

.upl-zone[data-gulp] .upl-icon { animation: upl-open 460ms cubic-bezier(0.3, 1.4, 0.4, 1); }

[data-stroke="on"] .upl-zone { box-shadow: 0 0 0 1px var(--pane-edge); }

.upl-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  /* a light grey tile, no edge — the fill's own ink walked most
     of the way to its slab, so it is a pale grey on the light fill
     and a lifted grey on the dark one */
  background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));
  color: color-mix(in srgb, var(--fill-on, #17181a) 72%, var(--fill-slab, #ffffff));
  transition: translate 420ms cubic-bezier(0.24, 1.34, 0.38, 1), background-color 220ms ease, color 220ms ease;}

/* over the box the tile only lifts, and its arrow goes to full
   ink — no colour of its own */
.upl-zone[data-over] .upl-icon {
  translate: 0 -4px;
  color: var(--fill-on, var(--ink));}

.upl-say {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0em;}

.upl-say b { font-weight: 500; }

.upl-say span {
  font-size: 12px;
  color: color-mix(in srgb, var(--fill-on, #17181a) 52%, var(--fill-slab, #ffffff));
  letter-spacing: 0em;}

.upl-zone[data-refuse] .upl-say b { color: #e5484d; }

/* the file, arrived in the box */
.upl-now {
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  flex: none;
  animation: upl-land 420ms var(--upl-spring) both;}

.upl-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 150px;}

.upl-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
  letter-spacing: 0em;}

.upl-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 14px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--fill-on, #17181a) 52%, var(--fill-slab, #ffffff));
  letter-spacing: 0em;}

.upl-track {
  position: relative;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: color-mix(in srgb, var(--fill-on, #17181a) 6%, var(--fill-slab, #ffffff));}

.upl-bar {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--signal, #2231dd);
  transform-origin: left center;}

.upl-roll { display: inline-flex; line-height: 1em; height: 1em; overflow: hidden; }

.upl-roll-col { display: inline-block; height: 1em; overflow: hidden; }

.upl-roll-strip {
  display: flex;
  flex-direction: column;
  transition: transform 220ms cubic-bezier(0.24, 1.34, 0.38, 1);}

.upl-roll-strip > span { height: 1em; }

.upl-end {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;}

.upl-tick {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok, #15803d);
  color: #fff;
  animation: upl-pop 380ms cubic-bezier(0.3, 1.6, 0.4, 1) both;}

/* the tray: three files lying under the box */
.upl-tray {
  display: flex;
  justify-content: center;
  gap: 20px;}

.upl-slot {
  position: relative;
  width: 76px;
  height: 75px;}

.upl-file {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  cursor: grab;
  touch-action: none;
  outline: none;
  /* home is a spring; the Bounce knob sets its overshoot */
  transition: transform 420ms var(--upl-spring), opacity 220ms ease;}

.upl-file[data-held] {
  z-index: 5;
  cursor: grabbing;
  transition: none;}

.upl-file[data-gone] { opacity: 0; pointer-events: none; transition: none; }

.upl-file:not([data-gone]) { animation: upl-back 360ms var(--upl-spring) both; }

.upl-file:focus-visible .upl-page { outline: 2px solid var(--signal, #2231dd); outline-offset: 3px; border-radius: 6px; }

.upl-page { overflow: visible; }

.upl-page-line {
  stroke: color-mix(in srgb, var(--fill-on, #17181a) 32%, var(--fill-slab, #ffffff));
  stroke-width: 1.5;
  /* outline only: the page is drawn, not filled */
  fill: none;}

.upl-page-ext {
  fill: #fff;
  font-family: var(--font-ui);
  /* size is the <text>'s own fontSize, in the icon's units */
  font-weight: 500;
  letter-spacing: 0em;}

.upl-label {
  max-width: 76px;
  overflow: hidden;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: color-mix(in srgb, var(--fill-on, #17181a) 72%, var(--fill-slab, #ffffff));
  letter-spacing: 0em;}

/* the tray sits on the STAGE, not on the block, so when Fill
   takes the block the other way from the page its names would be
   coloured for the wrong ground — light grey on a light stage.
   Across that split they take the page's own ink instead. */
/* the page's outline goes with its name, the same colour */
:root:not([data-theme="dark"]) [data-fill="dark"] .upl-label { color: color-mix(in srgb, var(--fill-on, var(--ink)) 70%, #ffffff); }

:root:not([data-theme="dark"]) [data-fill="dark"] .upl-page-line { stroke: color-mix(in srgb, var(--fill-on, var(--ink)) 70%, #ffffff); }

:root[data-theme="dark"] [data-fill="light"] .upl-label { color: color-mix(in srgb, #f4f3f1 70%, var(--fill-on, var(--ink))); }

:root[data-theme="dark"] [data-fill="light"] .upl-page-line { stroke: color-mix(in srgb, #f4f3f1 70%, var(--fill-on, var(--ink))); }

@keyframes upl-gulp {
  0% { scale: 1.02; }
  35% { scale: 0.985; }
  70% { scale: 1.006; }
  100% { scale: 1; }}

@keyframes upl-open { 40% { scale: 1.08; } }

@keyframes upl-land { from { opacity: 0; scale: 0.85; translate: 0 10px; } }

@keyframes upl-pop { from { scale: 0; } }

@keyframes upl-back { from { scale: 0.7; opacity: 0; } }

.upl.upl-live {
  width: 100%;
  /* the card under this box is already white, so the slab takes the
     second surface or the box has no edge to see */
  --card: var(--surface-sunken);
  --fill-slab: var(--surface-sunken);
}
.upl.upl-live .upl-zone-wrap { height: auto; min-height: 164px; }
.upl.upl-live .upl-zone { height: auto; min-height: 164px; padding: 16px; cursor: pointer; }
.drop-form:has(#doc-drop:not(:empty)) .drop-file {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.board:has(.htmx-request) { opacity: 0.72; }

/* Phones: the stacked side panel stays short, its nav scrolls sideways. */
@media (max-width: 899px) {
  .app-panel { flex-basis: 100%; gap: var(--space-2); padding: var(--space-3) var(--space-3) var(--space-2); border-right: 0; border-bottom: 1px solid var(--border); }
  .app-panel .brand { padding-bottom: var(--space-2); }
  .app-panel .side-nav { flex-direction: row; overflow-x: auto; gap: var(--space-1); scrollbar-width: none; }
  .app-panel .side-nav a, .app-panel .side-nav button { width: auto; flex: none; white-space: nowrap; }
  .app-panel .panel-label, .app-panel .panel-case, .advisor, .agent-status { display: none; }
  .panel-foot { margin-top: 0; padding-top: 0; }
  .app-main { padding: var(--space-5) var(--space-4) var(--space-7); }
  .pkg-screens { display: none; }
}
.card > p + .form, .card > h2 + .form { margin-top: var(--space-4); }
.nav-link { white-space: nowrap; }
@media (max-width: 640px) {
  .site-nav, .client-top { flex-wrap: wrap; gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-4); }
  .site-nav .nav-end .btn { display: none; }
  .site-nav .nav-end, .client-top .nav-end { margin-left: auto; }
  .client-top > nav { order: 3; flex-basis: 100%; }
  .stepper { justify-content: flex-start; gap: 0 var(--space-1); }
  .stepper li + li::before { display: none; }
  .step-pill { padding: 0 var(--space-2); font-size: 13px; }
  .page { padding: var(--space-5) var(--space-4) var(--space-7); }
  .q-sheet { padding: var(--space-5) var(--space-4); }
}
.program-head { flex-wrap: wrap; }
.program-head .chip { white-space: normal; }
/* Grid tracks never grow past their column: long words and chips wrap instead. */
.split > .split-main, .split > .split-side, .cards, .board, .group, .program, .stack-grid { grid-template-columns: minmax(0, 1fr); }
.table-wrap time { white-space: nowrap; }

/* Agents page */
.ag-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); align-items: end; }
.ag-filters .field { gap: 4px; }
.ag-filters .field > span { font-size: 12px; color: var(--ink-subtle); }
.ag-filters select { min-height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); font: inherit; font-size: 14px; color: var(--ink); max-width: 240px; }
.ag-day { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-subtle); margin: var(--space-5) 0 var(--space-2); }
.ag-day:first-of-type { margin-top: 0; }
.ag-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; font-size: 13px; color: var(--ink-subtle); margin-top: 4px; }
.ag-meta span, .ag-meta a { display: inline-flex; gap: 4px; align-items: center; }
.ag-run > .todo-text > p:not(.ag-meta) { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ag-error { color: var(--danger-ink); font-size: 14px; overflow-wrap: anywhere; }
.ag-live { border-color: var(--success); }
.ag-live .working { display: block; overflow-wrap: anywhere; }
.ag-live .working .pulse { display: inline-block; margin-right: 6px; vertical-align: middle; }
.ag-steps { margin-top: var(--space-2); }
.ag-step .what { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ag-step .report { margin-top: 4px; overflow-wrap: anywhere; }
.ag-thought .report { color: var(--ink-subtle); font-style: italic; }
.ag-answer .report { color: var(--ink); }
.ag-args { margin-top: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunken); }
.ag-args dd { color: var(--ink); overflow-wrap: anywhere; }
.ag-class-email .ag-args { border-left: 3px solid var(--info-ink); }
.ag-pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 12px; line-height: 18px; max-height: 360px; overflow: auto;
  padding: var(--space-3); margin-top: var(--space-2); border-radius: var(--radius-md); background: var(--surface-sunken); color: var(--ink-muted); }
.ag-sub { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.ag-sub h3 { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; font-size: 16px; }
.ag-final { border-color: var(--action); }
