/* ===========================================================================
   Components — the vocabulary every view is assembled from.
   Cards declare container queries, so a widget decides its own density from the
   space it was given rather than from the viewport it happens to sit in.
   =========================================================================== */

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */
.stack { display: grid; gap: var(--grid-gap); }
.stack--tight { gap: var(--sp-2); }
.stack--loose { gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.spacer { flex: 1; }

/* The dashboard bento. Collapses to one column below 768px, by construction. */
.bento {
  display: grid;
  gap: var(--grid-gap);
  grid-template-columns: 1fr;
  /* Cards take their content's height. Stretching a short card to match a tall
     neighbour just fills the page with empty card. */
  align-items: start;
}
/* Tablet: two columns, where `span-2` means "take the full width".
   The range is bounded on purpose — at desktop the same class would also match
   the 12-column rule below and flatten the whole dashboard back into a single
   column, which is exactly the anti-pattern this layout exists to avoid. */
@media (min-width: 768px) and (max-width: 1199px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bento > .span-2 { grid-column: span 2; }
}
@media (min-width: 1200px) {
  .bento { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .bento > .col-3  { grid-column: span 3; }
  .bento > .col-4  { grid-column: span 4; }
  .bento > .col-5  { grid-column: span 5; }
  .bento > .col-6  { grid-column: span 6; }
  .bento > .col-7  { grid-column: span 7; }
  .bento > .col-8  { grid-column: span 8; }
  .bento > .col-9  { grid-column: span 9; }
  .bento > .col-12 { grid-column: span 12; }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.page-head__text { flex: 1; min-width: 12rem; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { color: var(--ink-2); font-size: var(--fs-sm); max-width: 62ch; }

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.card {
  container-type: inline-size;
  position: relative;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
  padding: clamp(0.9rem, 2.2vw, 1.35rem);
  min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card--sunken { background: var(--sunken); box-shadow: none; }
.card--accent { border-color: color-mix(in srgb, var(--brand) 36%, var(--line)); }
.card--accent::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 80% at 100% 0%, var(--brand-wash), transparent 62%);
}
.card__head {
  display: flex;
  align-items: center;
  /* A card head is a title plus however many actions the view needs. On a phone
     that is wider than the card, so it wraps rather than pushing the page into
     a horizontal scroll. */
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  min-height: 24px;
}
.card__head > .spacer { min-width: 0; }
.card__title { font-size: 0.93rem; font-weight: 640; letter-spacing: -0.01em; }
.card__sub { font-size: var(--fs-xs); color: var(--ink-3); }
.card__foot {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line-faint);
}

.section-label {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-micro); font-weight: 680;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-2);
}
.section-label::after {
  content: ""; flex: 1; height: 1px; background: var(--line-faint);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--s2);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 620;
  letter-spacing: -0.005em;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
  font-weight: 680;
}
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--outline { background: transparent; }
.btn--danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 42%, transparent); background: transparent; }
.btn--sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-xs); border-radius: var(--r-xs); }
.btn--lg { min-height: 48px; padding: 0 var(--sp-5); font-size: var(--fs-body); border-radius: var(--r-md); }
.btn--block { width: 100%; }
.btn--icon { width: 40px; min-height: 40px; padding: 0; border-radius: var(--r-sm); }
.btn--icon.btn--sm { width: 32px; min-height: 32px; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--s3); border-color: var(--line-strong); }
  .btn--primary:hover { background: color-mix(in srgb, var(--brand) 88%, white); }
  .btn--ghost:hover { background: var(--s2); color: var(--ink); }
  .btn--danger:hover { background: var(--critical-wash); }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn--sm { min-height: 40px; }
  .btn--icon { width: 44px; }
}

.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: "";
  position: absolute; inset: 50% auto auto 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-radius: var(--r-pill);
  border-top-color: transparent;
  color: var(--ink);
  animation: spin 640ms linear infinite;
}
.btn--primary.is-busy::after { color: var(--on-brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Chips, pills, badges
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0 0.8rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--s2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
}
.chip[aria-pressed="true"], .chip.is-active {
  background: var(--brand-wash);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  color: var(--ink);
}
@media (pointer: coarse) { .chip { min-height: 40px; } }
@media (hover: hover) and (pointer: fine) { .chip:hover { color: var(--ink); border-color: var(--line-strong); } }

.tag {
  display: inline-flex;
  align-items: center;
  /* A tag sizes to its label. Without this it stretches to the full track when
     it happens to be a grid item. */
  justify-self: start;
  align-self: start;
  width: fit-content;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--r-xs);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  font-size: var(--fs-micro);
  font-weight: 640;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}
.tag--ok       { background: var(--ok-wash);       color: var(--ok);       border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.tag--warn     { background: var(--warn-wash);     color: var(--warn);     border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.tag--serious  { background: var(--serious-wash);  color: var(--serious);  border-color: color-mix(in srgb, var(--serious) 28%, transparent); }
.tag--critical { background: var(--critical-wash); color: var(--critical); border-color: color-mix(in srgb, var(--critical) 28%, transparent); }
.tag--brand    { background: var(--brand-wash);    color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 32%, transparent); }

/* Coach action badges — the "+ LEARNED / + PLANNED" pills under a reply. */
.badge-list { display: grid; gap: var(--sp-2); margin-top: var(--sp-3); }
.badge {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--s2);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.badge__kind {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-xs);
  font-size: 0.64rem; font-weight: 760; letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge__body { min-width: 0; }
.badge__text { font-size: var(--fs-sm); font-weight: 580; line-height: 1.35; }
.badge__meta { font-size: var(--fs-micro); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.badge__more { color: var(--ink-3); }
.badge[data-col="--ok"]   { border-left: 3px solid var(--ok); }
.badge[data-col="--ai"]   { border-left: 3px solid var(--s-1); }
.badge[data-col="--warn"] { border-left: 3px solid var(--warn); }
.badge[data-col="--err"]  { border-left: 3px solid var(--critical); }
.badge[data-col="--ok"]   .badge__kind { background: var(--ok-wash); color: var(--ok); }
.badge[data-col="--ai"]   .badge__kind { background: color-mix(in srgb, var(--s-1) 16%, transparent); color: var(--s-1); }
.badge[data-col="--warn"] .badge__kind { background: var(--warn-wash); color: var(--warn); }
.badge[data-col="--err"]  .badge__kind { background: var(--critical-wash); color: var(--critical); }
@media (hover: hover) and (pointer: fine) { .badge:hover { background: var(--s3); border-color: var(--line-strong); } }

/* --------------------------------------------------------------------------
   Stat tile & hero figure
   -------------------------------------------------------------------------- */
.stats {
  display: grid;
  gap: var(--sp-2);
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
}
.stat {
  padding: 0.7rem 0.8rem;
  border-radius: var(--r-md);
  background: var(--s2);
  border: 1px solid var(--line-faint);
  min-width: 0;
}
.stat__label {
  font-size: var(--fs-micro); font-weight: 640;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.stat__value {
  font-size: 1.32rem; font-weight: 660; line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat__value small { font-size: 0.6em; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.stat__note { font-size: var(--fs-micro); color: var(--ink-3); margin-top: 3px; }
.stat--null .stat__value { color: var(--ink-3); font-weight: 560; }

.hero-figure {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 680;
  line-height: 0.95;
  letter-spacing: -0.035em;
}
.hero-figure small { font-size: 0.3em; font-weight: 620; letter-spacing: 0; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Meter
   -------------------------------------------------------------------------- */
.meter {
  /* Explicitly block: a meter is often a <span> inside a flex row, and an inline
     box silently ignores height, so the bar renders as a hairline. */
  display: block;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--sunken);
  overflow: hidden;
  position: relative;
}
.meter__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width var(--t-slow) var(--ease-out);
}
.meter--ok       .meter__fill { background: var(--ok); }
.meter--warn     .meter__fill { background: var(--warn); }
.meter--critical .meter__fill { background: var(--critical); }
.meter__marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--ink-2); opacity: 0.6; border-radius: 1px;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: grid; gap: 0.35rem; min-width: 0; }
.field__label {
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-2);
}
.field__hint { font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.45; }
.field__error { font-size: var(--fs-micro); color: var(--critical); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--s2);
  color: var(--ink);
  font-size: max(16px, 0.9rem);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
  outline: none;
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--critical); }
.select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* Browsers draw a white native option list over a dark select without this. */
.select option { background-color: var(--s1); color: var(--ink); }

.form-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }

.switch {
  display: inline-flex; align-items: center; gap: 0.6rem;
  cursor: pointer; min-height: 44px;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  width: 42px; height: 24px; flex: none;
  border-radius: var(--r-pill);
  background: var(--sunken);
  border: 1px solid var(--line-strong);
  position: relative;
  transition: background var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.switch__track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: var(--r-pill);
  background: var(--ink-2);
  transition: transform var(--t-base) var(--ease), background var(--t-base) var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: var(--on-brand); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--brand-wash); }
.switch__label { font-size: var(--fs-sm); }

.color-field {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--s2);
}
.color-field input[type="color"] {
  width: 32px; height: 32px; flex: none; padding: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-xs);
  background: none; cursor: pointer;
}
.color-field__name { font-size: var(--fs-xs); font-weight: 600; flex: 1; }
.color-field__hex { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Segmented control / tabs
   -------------------------------------------------------------------------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-sm);
  background: var(--sunken);
  border: 1px solid var(--line-faint);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented__btn {
  padding: 0.4rem 0.85rem;
  border-radius: calc(var(--r-sm) - 3px);
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-3);
  white-space: nowrap;
  min-height: 34px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.segmented__btn[aria-selected="true"], .segmented__btn.is-active {
  background: var(--s1);
  color: var(--ink);
  box-shadow: var(--e-1);
}
@media (pointer: coarse) { .segmented__btn { min-height: 40px; } }

.tabs {
  display: flex;
  gap: var(--sp-4);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__btn {
  position: relative;
  padding: 0.7rem 0;
  font-size: var(--fs-sm);
  font-weight: 620;
  color: var(--ink-3);
  white-space: nowrap;
}
.tabs__btn[aria-selected="true"] { color: var(--ink); }
.tabs__btn[aria-selected="true"]::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--brand);
}

/* --------------------------------------------------------------------------
   Rows, lists and the table ⇄ card morph
   -------------------------------------------------------------------------- */
.list { display: grid; }
.list > * + * { border-top: 1px solid var(--line-faint); }

.row-tap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.15rem;
  text-align: left;
  transition: background var(--t-fast) var(--ease);
  border-radius: var(--r-sm);
}
.row-tap__lead {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--s2);
  font-size: var(--fs-sm);
}
.row-tap__lead svg { width: 18px; height: 18px; }
.row-tap__title { font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; }
.row-tap__meta { font-size: var(--fs-micro); color: var(--ink-3); }
.row-tap__value { font-variant-numeric: tabular-nums; font-weight: 640; font-size: var(--fs-sm); text-align: right; }
@media (hover: hover) and (pointer: fine) { .row-tap:hover { background: var(--s2); } }

/* A high-density ledger on desktop; the same records as cards on a phone. */
.ledger { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ledger th {
  text-align: left;
  font-size: var(--fs-micro);
  font-weight: 680;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ledger td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
}
.ledger td.num, .ledger th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { .ledger tbody tr:hover { background: var(--s2); } }

@media (max-width: 767px) {
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: 100%; }
  .ledger thead { display: none; }
  .ledger tr {
    padding: 0.65rem 0.1rem;
    border-bottom: 1px solid var(--line-faint);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 0.75rem;
  }
  .ledger td { padding: 0; border: 0; font-size: var(--fs-sm); }
  .ledger td[data-col="primary"] { grid-column: 1; font-weight: 600; }
  .ledger td[data-col="value"] { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-weight: 640; }
  .ledger td[data-col="meta"] { grid-column: 1; font-size: var(--fs-micro); color: var(--ink-3); }
  .ledger td[data-col="hide-sm"] { display: none; }
}

/* --------------------------------------------------------------------------
   Overlays — bottom sheet (mobile) ⇄ right drawer / centred modal (desktop)
   -------------------------------------------------------------------------- */
.overlay-root { position: relative; z-index: var(--z-overlay); }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 9, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
}
.scrim.is-open { opacity: 1; }

.overlay {
  position: fixed;
  display: flex;
  flex-direction: column;
  background: var(--s3);
  color: var(--ink);
  box-shadow: var(--e-3);
  overscroll-behavior: contain;
}

/* Mobile default: a sheet from the bottom edge. */
.overlay--sheet {
  inset: auto 0 0 0;
  max-height: 92dvh;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-top: 1px solid var(--line-strong);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(100%);
  transition: transform var(--t-slow) var(--ease-out);
}
.overlay--sheet.is-open { transform: translateY(0); }

.overlay--modal {
  inset: 50% auto auto 50%;
  width: min(480px, calc(100vw - 2rem));
  max-height: 86dvh;
  transform: translate(-50%, -46%);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  opacity: 0;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease);
}
.overlay--modal.is-open { transform: translate(-50%, -50%); opacity: 1; }

.overlay__grab {
  width: 38px; height: 4px;
  margin: 0.55rem auto 0;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  flex: none;
}
.overlay__head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-faint);
  flex: none;
}
.overlay__title { font-size: 1rem; font-weight: 650; flex: 1; min-width: 0; }
.overlay__sub { font-size: var(--fs-micro); color: var(--ink-3); }
.overlay__body {
  padding: var(--sp-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.overlay__foot {
  display: flex; gap: var(--sp-2); justify-content: flex-end;
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-faint);
  background: var(--s3);
  flex: none;
}
.overlay__foot .btn { flex: 1; }

@media (min-width: 768px) {
  /* A complex form becomes a right slide-over so the page stays in view. */
  .overlay--sheet {
    inset: 0 0 0 auto;
    width: min(560px, 92vw);
    max-height: none;
    border-radius: var(--r-xl) 0 0 var(--r-xl);
    border-top: 0;
    border-left: 1px solid var(--line-strong);
    transform: translateX(100%);
  }
  .overlay--sheet.is-open { transform: translateX(0); }
  .overlay__grab { display: none; }
  .overlay__head { padding: var(--sp-4) var(--sp-5); }
  .overlay__body { padding: var(--sp-5); }
  .overlay__foot { padding: var(--sp-4) var(--sp-5); justify-content: flex-end; }
  .overlay__foot .btn { flex: none; }
}

body.is-locked { overflow: hidden; }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-root {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.75rem);
  transform: translateX(-50%);
  display: grid;
  gap: var(--sp-2);
  width: min(30rem, calc(100vw - 1.5rem));
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-root { left: auto; right: 1.25rem; bottom: 1.25rem; transform: none; }
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--r-md);
  background: var(--s3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--e-3);
  font-size: var(--fs-sm);
  animation: toast-in var(--t-base) var(--ease-out);
}
.toast.is-leaving { animation: toast-out var(--t-base) var(--ease) forwards; }
.toast__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast__icon svg { width: 100%; height: 100%; }
.toast__text { flex: 1; min-width: 0; line-height: 1.4; }
.toast--ok .toast__icon { color: var(--ok); }
.toast--err .toast__icon { color: var(--critical); }
.toast--warn .toast__icon { color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.98); } }

/* --------------------------------------------------------------------------
   Empty, error and loading states
   -------------------------------------------------------------------------- */
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: clamp(1.5rem, 5vw, 3rem) var(--sp-4);
  color: var(--ink-3);
}
.empty__icon {
  width: 42px; height: 42px;
  display: block;
  color: var(--ink-3);
  opacity: 0.7;
  margin-bottom: var(--sp-1);
}
.empty__icon svg { width: 100%; height: 100%; }
.empty__title { font-size: var(--fs-body); font-weight: 620; color: var(--ink-2); }
.empty__text { font-size: var(--fs-sm); max-width: 38ch; line-height: 1.5; }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(100deg, var(--s2) 30%, var(--s3) 50%, var(--s2) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 12px;
}
@keyframes shimmer { to { background-position: -120% 0; } }

.notice {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--s2);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.notice svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.notice--warn     { background: var(--warn-wash);     border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.notice--critical { background: var(--critical-wash); border-color: color-mix(in srgb, var(--critical) 32%, transparent); }
.notice--ok       { background: var(--ok-wash);       border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
.notice--brand    { background: var(--brand-wash);    border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.notice__title { font-weight: 640; }

/* --------------------------------------------------------------------------
   Disclosure
   -------------------------------------------------------------------------- */
.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--s2);
  overflow: hidden;
}
.disclosure > summary {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 620;
  color: var(--ink-2);
  list-style: none;
  min-height: 42px;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: "";
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--t-fast) var(--ease);
}
.disclosure[open] > summary::after { transform: rotate(225deg) translate(-2px, -2px); }
.disclosure__body {
  padding: 0 0.85rem 0.85rem;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Prose (coach messages, scouting reports)
   -------------------------------------------------------------------------- */
.prose { font-size: var(--fs-body); line-height: 1.62; }
.prose > * + * { margin-top: 0.7em; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.2em; font-weight: 650; }
.prose h1 { font-size: 1.16rem; }
.prose h2 { font-size: 1.06rem; }
.prose h3 { font-size: 0.98rem; }
.prose strong { font-weight: 680; color: var(--ink); }
.prose em { font-style: italic; }
.prose code {
  font-family: var(--mono); font-size: 0.86em;
  padding: 0.1em 0.35em; border-radius: var(--r-xs);
  background: var(--s2); border: 1px solid var(--line-faint);
}
.prose pre {
  padding: 0.8rem; border-radius: var(--r-sm);
  background: var(--sunken); border: 1px solid var(--line-faint);
  overflow-x: auto; font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.5;
}
.prose pre code { background: none; border: 0; padding: 0; }
.prose ul, .prose ol { padding-left: 1.15rem; display: grid; gap: 0.3em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li::marker { color: var(--ink-3); }
.prose a { color: var(--brand-ink); text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote {
  padding-left: 0.8rem;
  border-left: 2px solid var(--line-strong);
  color: var(--ink-2);
}
.prose hr { border: 0; border-top: 1px solid var(--line-faint); margin: 1.1em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.prose th, .prose td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line-faint); text-align: left; }

/* --------------------------------------------------------------------------
   Quota meter (AI capacity)
   -------------------------------------------------------------------------- */
.quota { display: grid; gap: 0.45rem; }
.quota__row { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.6rem; align-items: center; }
.quota__name { font-size: var(--fs-micro); color: var(--ink-2); font-weight: 600; }
.quota__count { font-size: var(--fs-micro); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.quota__bar { grid-column: 1 / -1; height: 4px; border-radius: var(--r-pill); background: var(--sunken); overflow: hidden; }
.quota__fill { height: 100%; background: var(--s-1); border-radius: inherit; }
.quota__fill[data-state="warn"] { background: var(--warn); }
.quota__fill[data-state="full"] { background: var(--critical); }

/* --------------------------------------------------------------------------
   Copy/paste console (manual model path)
   -------------------------------------------------------------------------- */
.console {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--sunken);
  border: 1px dashed var(--line-strong);
}
.console__text {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  min-height: 130px;
  background: var(--s1);
}
