/*
 * Component styles. Phase 1.2 v0 — only the brand lockup so far.
 * Phase 2 will populate this file with the full component library.
 */

/* ---------- Brand lockup (header + footer mark) ---------- */

.brand-lockup {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.625rem; /* lockup-specific — 10px gap is the tuned mark↔wordmark distance, not on the spacing scale */
  color: var(--color-brand-primary);
  text-decoration: none;
  line-height: 1;
}

.brand-lockup:hover {
  color: var(--color-brand-primary-hover);
}

.brand-lockup__mark {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

.brand-lockup__mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-lockup__wordmark {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  line-height: 0.85;
  color: inherit;
}

.brand-lockup--small .brand-lockup__mark { width: 1.5rem; height: 1.5rem; }
.brand-lockup--small .brand-lockup__wordmark { font-size: var(--text-base); }

.brand-lockup--large .brand-lockup__mark { width: 2.75rem; height: 2.75rem; }
.brand-lockup--large .brand-lockup__wordmark { font-size: var(--text-2xl); }

/* ---------- Ornament stage: sun-cursor drop shadow ---------- */
/*
 * Wraps an ornament <img>. Picks up --sun-shadow-* custom properties driven
 * by /static/js/sun-cursor.js. Falls back to a quiet baseline shadow when
 * the JS hasn't loaded or prefers-reduced-motion is set (the JS no-ops
 * under reduced-motion, and the fallback values stay neutral).
 */
/*
 * Apply the filter to each inline <svg> child rather than the wrapper. If
 * applied to the wrapper, any background/border on the wrapper would put the
 * filter onto a filled rectangle and produce a rectangular shadow instead of
 * one tracing the plant silhouettes.
 */
.ornament-stage svg {
  filter: drop-shadow(
    var(--sun-shadow-x, 0px)
    var(--sun-shadow-y, 0.75px)
    var(--sun-shadow-blur, 1px)
    rgba(var(--sun-shadow-rgb, 26, 24, 20), var(--sun-shadow-opacity, 0))
  );
}

/*
 * Reduced-motion does NOT strip the filter. A static drop-shadow doesn't
 * violate the preference; only the cursor-tracking is disabled (in the JS).
 */

/* Phase 2.3 replaces the v0 .site-header and .site-footer rules.
   See the Phase 2.3 block at the foot of this file. */

/* ============================================================ *
 * Phase 2.1 primitives — buttons, inputs, tags
 *
 * Foundation register, with three Systems grafts:
 *   1. Aligned control height (--control-height shared by .btn and inputs)
 *   2. Field focus also switches border-color so border + ring read as one
 *   3. Status badge uses muted tone (bg as both fill and border)
 *
 * No transform-based hover lift. Reduced-motion drops transitions on the
 * properties that move (none, currently — all transitions are color/border/
 * shadow which stay perceivable).
 * ============================================================ */

:root {
  --control-height:    2.5rem;   /* 40px — default button + input */
  --control-height-sm: 1.75rem;  /* 28px — small button (table rows) */
}

/* ---------- Button ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-5);
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-md);
  background: transparent;

  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-normal);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;

  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;

  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color     var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard),
    box-shadow       var(--duration-normal) var(--ease-standard);
}

.btn .icon {
  display: inline-flex;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}
.btn .icon svg { width: 100%; height: 100%; display: block; }

.btn--sm {
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  gap: var(--space-1);
}

.btn--block { display: flex; width: 100%; }

.btn--primary {
  background-color: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover, .btn--primary.is-hovered {
  background-color: var(--color-brand-primary-hover);
  border-color: var(--color-brand-primary-hover);
  box-shadow: var(--shadow-md);
}
.btn--primary:active, .btn--primary.is-active {
  background-color: var(--color-brand-primary-active);
  border-color: var(--color-brand-primary-active);
  box-shadow: var(--shadow-sm);
}

.btn--secondary {
  background-color: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.btn--secondary:hover, .btn--secondary.is-hovered {
  background-color: var(--surface-sunken);
}
.btn--secondary:active, .btn--secondary.is-active {
  background-color: var(--surface-inset);
  box-shadow: none;
}

.btn--ghost {
  background-color: transparent;
  border-color: transparent;
  color: var(--text-primary);
}
.btn--ghost:hover, .btn--ghost.is-hovered { background-color: var(--surface-sunken); }
.btn--ghost:active, .btn--ghost.is-active { background-color: var(--surface-inset); }

.btn--link {
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-link);
  text-decoration: underline;
  text-decoration-thickness: var(--border-thin);
  text-underline-offset: 2px;
  font-weight: var(--weight-regular);
  border-radius: var(--radius-sm);
}
.btn--link:hover, .btn--link.is-hovered,
.btn--link:active, .btn--link.is-active { color: var(--text-link-hover); }
.btn--link:focus-visible { outline-offset: 2px; }

.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  pointer-events: none;
}

/* ---------- Field (input + label + hint + error) ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-family: var(--font-body);
}

.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
}

.field__required {
  color: var(--color-accent);
  font-family: var(--font-mono);
  margin-left: var(--space-1);
}

.field__hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.input,
.textarea,
.field__control {
  display: block;
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-4);
  background-color: var(--surface-raised);
  border: var(--border-thin) solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-snug);
  color: var(--text-primary);
  transition:
    border-color     var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

.input::placeholder,
.textarea::placeholder { color: var(--text-placeholder); }

.input:hover,
.textarea:hover { border-color: var(--color-warm-500); }

/* Systems graft: focus border picks up brand-primary, so the 2px ring
   from base.css and the border read as one continuous event. */
.input:focus-visible,
.textarea:focus-visible,
.field__control:focus-visible { border-color: var(--color-brand-primary); }

.input:disabled,
.textarea:disabled {
  background-color: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

.textarea {
  resize: vertical;
  min-height: calc(var(--space-10) * 2);
  padding: var(--space-3) var(--space-4);
  line-height: var(--leading-normal);
}

.field--search { position: relative; }
.field--search .input { padding-left: var(--space-10); }

.field__icon {
  position: absolute;
  left: var(--space-3);
  bottom: 0;
  height: var(--control-height);
  width: var(--space-4);
  color: var(--text-placeholder);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.field__icon svg { width: 100%; height: auto; display: block; }

.field--error .input,
.field--error .textarea,
.field--error .field__control { border-color: var(--color-danger); }
.field--error .input:focus-visible,
.field--error .textarea:focus-visible,
.field--error .field__control:focus-visible {
  border-color: var(--color-danger);
  outline-color: var(--color-danger);
}

.field__error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  line-height: var(--leading-snug);
  margin-top: var(--space-1);
}

/* ---------- Tag / Pill ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  border: var(--border-thin) solid transparent;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.tag--citation {
  font-family: var(--font-mono);
  font-weight: var(--weight-regular);
  background-color: var(--color-kale-50);
  border-color: var(--color-kale-200);
  color: var(--color-kale-700);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color     var(--duration-fast) var(--ease-standard);
}
.tag--citation:hover, .tag--citation.is-hovered {
  background-color: var(--color-kale-100);
  border-color: var(--color-kale-300);
}
.tag--citation:active, .tag--citation.is-active {
  background-color: var(--color-kale-200);
}

/* Filter chip — citation family (Daniel's call: keep filter chips looking
   like citation pills, one visual family). Adds a dismiss ✕. */
.tag--filter {
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  background-color: var(--color-kale-50);
  border-color: var(--color-kale-200);
  color: var(--color-kale-700);
  padding-right: var(--space-1);
}

.tag--filter__dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--space-4);
  height: var(--space-4);
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-kale-700);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard);
}
.tag--filter__dismiss svg { width: 100%; height: 100%; display: block; }
.tag--filter__dismiss:hover, .tag--filter__dismiss.is-hovered {
  background-color: var(--color-kale-200);
  color: var(--color-kale-800);
}
.tag--filter__dismiss:active, .tag--filter__dismiss.is-active {
  background-color: var(--color-kale-300);
}

/* Status badge — Systems graft: bg as both fill and border (effectively
   borderless within the tone), saturated color reserved for the dot.
   This reads as "label" rather than "alert." */
.tag--status {
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  cursor: default;
}
.tag--status .tag__dot {
  display: inline-block;
  width: var(--space-2);
  height: var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.tag--status--success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-bg);
  color: var(--color-success);
}
.tag--status--success .tag__dot { background-color: var(--color-success); }

.tag--status--warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-bg);
  color: var(--color-warning);
}
.tag--status--warning .tag__dot { background-color: var(--color-warning); }

.tag--status--danger {
  background-color: var(--color-danger-bg);
  border-color: var(--color-danger-bg);
  color: var(--color-danger);
}
.tag--status--danger .tag__dot { background-color: var(--color-danger); }

.tag--status--info {
  background-color: var(--color-info-bg);
  border-color: var(--color-info-bg);
  color: var(--color-info);
}
.tag--status--info .tag__dot { background-color: var(--color-info); }

@media (prefers-reduced-motion: reduce) {
  .btn,
  .input, .textarea, .field__control,
  .tag--citation, .tag--filter__dismiss {
    transition:
      background-color var(--duration-fast) var(--ease-standard),
      border-color     var(--duration-fast) var(--ease-standard),
      color            var(--duration-fast) var(--ease-standard);
  }
}

/* ============================================================ *
 * Phase 2.2 primitives — card + table
 *
 * Foundation chassis with three Systems grafts (per critic):
 *   1. Default table row padding 8/12px — .table--tight opts to 4/12
 *   2. Unsorted column header at faint opacity, lifts on hover
 *   3. card__head, card__foot, card__meta use --surface-page (cream)
 *      so the body reads as printed onto a quieter substrate
 *
 * Three card variants only: basic, head+foot, strip-on-top. No
 * .card--linked, --flat, --inset, or --muted in v1 — defer until
 * a real surface asks. Empty state hides the table head.
 * ============================================================ */

/* ---------- Card ---------- */

.card {
  background-color: var(--surface-raised);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

.card__head {
  padding: var(--space-4) var(--space-5);
  background-color: var(--surface-page);
  border-bottom: var(--border-thin) solid var(--border-divider);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0;
}

.card__eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-1) 0;
}

.card__head-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.card__body {
  padding: var(--space-5);
}
.card__body > :last-child { margin-bottom: 0; }

/* Flush body — for cards whose body is a table that should butt
   the card's inner edge (no double padding). */
.card__body--flush { padding: 0; }
.card__body--flush .table { border: 0; }

.card__foot {
  padding: var(--space-3) var(--space-5);
  background-color: var(--surface-page);
  border-top: var(--border-thin) solid var(--border-divider);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}
.card__foot--split { justify-content: space-between; }

/* Metadata strip — top placement only.
   Identity-before-content: the run ID and status badges read first,
   the body answers second. */
.card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-5);
  background-color: var(--surface-page);
  border-bottom: var(--border-thin) solid var(--border-divider);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.card__meta-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-primary);
}
.card__meta-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- Table ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.table thead th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: var(--border-thin) solid var(--border-divider);
  white-space: nowrap;
  vertical-align: bottom;
}

.table tbody tr { border-bottom: var(--border-thin) solid var(--border-divider); }
.table tbody tr:last-child { border-bottom: 0; }

/* Default density: 8/12 px — comfortable for the dashboard's summary
   tables. .table--tight tightens to 4/12 for catalog density. */
.table th,
.table td {
  padding: var(--space-2) var(--space-3);
  vertical-align: middle;
}
.table--tight th,
.table--tight td { padding: var(--space-1) var(--space-3); }

.table--roomy th,
.table--roomy td { padding: var(--space-3) var(--space-4); }

/* Cell helpers */
.table .cell--num    { text-align: right; font-variant-numeric: tabular-nums; }
.table .cell--mono   { font-family: var(--font-mono); font-size: var(--text-xs); }
.table .cell--id     { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-primary); }
.table .cell--actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.table .cell--status { width: 1%; white-space: nowrap; }

/* Sortable column header. CSS-only state — JS sort wiring lands in
   Phase 4. The button is keyboard-focusable; pressing it does nothing
   yet. aria-sort drives which chevron is visible. */
.table thead th.is-sortable { padding: 0; }

.table .th-sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard);
}
.table--tight .th-sort { padding: var(--space-1) var(--space-3); }
.table--roomy .th-sort { padding: var(--space-3) var(--space-4); }

.table .th-sort:hover  { background-color: var(--surface-sunken); color: var(--text-primary); }
.table .th-sort:active { background-color: var(--surface-inset); }

.table .th-sort__icon {
  display: inline-flex;
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  color: var(--text-muted);
}
.table .th-sort__icon svg { width: 100%; height: 100%; display: block; }

/* Unsorted indicator: faint chevron-pair at rest, lifts to full
   strength on hover so the "this is sortable" affordance fires
   the moment a cursor approaches. */
.table .th-sort__icon--unsorted { opacity: 0.45; }
.table .th-sort:hover .th-sort__icon--unsorted { opacity: 1; }

.table .th-sort[aria-sort="ascending"],
.table .th-sort[aria-sort="descending"] { color: var(--text-primary); }
.table .th-sort[aria-sort="ascending"]  .th-sort__icon,
.table .th-sort[aria-sort="descending"] .th-sort__icon { color: var(--color-brand-primary); opacity: 1; }

/* Default state: show only --unsorted. Active states swap to one. */
.table .th-sort .th-sort__icon--unsorted { display: inline-flex; }
.table .th-sort .th-sort__icon--asc,
.table .th-sort .th-sort__icon--desc { display: none; }

.table .th-sort[aria-sort="ascending"]  .th-sort__icon--unsorted,
.table .th-sort[aria-sort="descending"] .th-sort__icon--unsorted { display: none; }
.table .th-sort[aria-sort="ascending"]  .th-sort__icon--asc  { display: inline-flex; }
.table .th-sort[aria-sort="descending"] .th-sort__icon--desc { display: inline-flex; }

/* Row-action button (more-vertical icon). */
.table .row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  background: transparent;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard);
}
.table .row-action svg { width: var(--space-4); height: var(--space-4); display: block; }
.table .row-action:hover  { background-color: var(--surface-sunken); color: var(--text-primary); }
.table .row-action:active { background-color: var(--surface-inset); }

/* ---------- Filter chips above table ---------- */

.table-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-3) 0;
  border-bottom: var(--border-thin) solid var(--border-divider);
  margin-bottom: var(--space-3);
}
.table-filters__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: var(--space-2);
}
.table-filters__clear { margin-left: auto; font-size: var(--text-xs); }

/* ---------- Empty / Error / Loading states ---------- */

.table-empty,
.table-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--text-muted);
  background-color: var(--surface-raised);
  border-top: var(--border-thin) solid var(--border-divider);
}
.table-empty__title,
.table-error__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin: 0;
}
.table-empty__body,
.table-error__body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 32rem;
  margin: 0;
}
.table-error__title { color: var(--color-danger); }
.table-error__body  { color: var(--color-danger); }

/* Loading skeleton — text-cap height, three width modifiers, staggered
   pulse gated on no-preference, stripped under reduce. */
.table-skeleton .skeleton-bar {
  display: block;
  height: 0.75rem;
  background-color: var(--surface-inset);
  border-radius: var(--radius-sm);
}
.table-skeleton .skeleton-bar--narrow { width: 40%; }
.table-skeleton .skeleton-bar--medium { width: 65%; }
.table-skeleton .skeleton-bar--wide   { width: 90%; }

@media (prefers-reduced-motion: no-preference) {
  .table-skeleton .skeleton-bar {
    animation: dg-skeleton-pulse 1.4s var(--ease-standard) infinite;
  }
  .table-skeleton tr:nth-child(2) .skeleton-bar { animation-delay: 80ms; }
  .table-skeleton tr:nth-child(3) .skeleton-bar { animation-delay: 160ms; }
  .table-skeleton tr:nth-child(4) .skeleton-bar { animation-delay: 240ms; }
  .table-skeleton tr:nth-child(5) .skeleton-bar { animation-delay: 320ms; }
}
@keyframes dg-skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .table-skeleton .skeleton-bar { animation: none; }
}

/* ============================================================ *
 * Phase 2.3 — modal, nav (top bar + breadcrumb + footer),
 *             page-level states, layout shells
 *
 * Merge rationale (see design/concepts/phase-2-3-modal-nav-layouts/critique.md):
 *   - Systems chassis: modal sizes/motion, top bar, breadcrumb, shells
 *   - Foundation grafts: .btn--danger, modal title tint, page-state
 *     namespace, contained-shell prose loosen, sticky sidebar, :has()
 *     empty-sidebar fallback
 *   - Daniel's calls: topbar 4rem, .btn--danger, sidebar left,
 *     reading shell narrows header, reading shell width 80rem
 * ============================================================ */

/* ---------- Site header (top bar) ---------- */

.site-header {
  display: block;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  border-bottom: var(--border-thin) solid var(--border-divider);
  background-color: var(--surface-page);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  height: var(--topbar-height);
  padding: 0 var(--space-6);
  max-width: var(--shell-max-app);
  margin: 0 auto;
  width: 100%;
  position: relative;
}
.shell--read .site-header__inner { max-width: var(--shell-max-read); }

/* Primary nav links list */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: var(--text-sm);
}

.site-nav__link,
.site-nav a {
  display: inline-flex;
  align-items: center;
  height: var(--control-height);
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: var(--weight-medium);
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard);
}
.site-nav__link:hover,
.site-nav a:hover {
  color: var(--text-primary);
  background-color: var(--surface-sunken);
}
.site-nav__link[aria-current="page"],
.site-nav a[aria-current="page"] {
  color: var(--text-primary);
  box-shadow: inset 0 -2px 0 var(--color-brand-primary);
  border-radius: 0;
}
.site-nav__sep {
  color: var(--text-muted);
  opacity: 0.4;
  padding: 0 var(--space-2);
  user-select: none;
}

/* ---------- Site-nav dropdown menus (About + Workspace) ----------
   The trigger renders as a button styled to match .site-nav__link.
   Submenu pops below the trigger; opens on hover, focus-within, or
   explicit aria-expanded="true" (managed by site-nav-menus.js for
   keyboard + touch). Click outside / Escape closes it.            */
.site-nav__item { display: inline-flex; }
.site-nav__has-menu { position: relative; }
.site-nav__menu-trigger {
  /* Reset button defaults so the trigger inherits .site-nav__link styles */
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.site-nav__caret {
  font-size: 0.7em;
  line-height: 1;
  opacity: 0.7;
  transition: transform var(--duration-fast) var(--ease-standard);
}
.site-nav__has-menu:hover .site-nav__caret,
.site-nav__has-menu:focus-within .site-nav__caret,
.site-nav__menu-trigger[aria-expanded="true"] .site-nav__caret {
  transform: rotate(180deg);
}

.site-nav__submenu {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  min-width: 13.5rem;
  margin: 0;
  padding: var(--space-2) 0;
  list-style: none;
  background: var(--surface-raised);
  border: var(--border-thin) solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 20;

  /* Default hidden — opens via :hover, :focus-within, or
     aria-expanded="true" on the trigger inside this menu. */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    opacity     var(--duration-fast) var(--ease-standard),
    visibility  var(--duration-fast) var(--ease-standard),
    transform   var(--duration-fast) var(--ease-standard);
}
.site-nav__has-menu:hover .site-nav__submenu,
.site-nav__has-menu:focus-within .site-nav__submenu,
.site-nav__menu-trigger[aria-expanded="true"] + .site-nav__submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.site-nav__submenu a,
.site-nav__submenu a:visited {
  display: block;
  padding: 0.45rem var(--space-4);
  border-radius: 0;
  height: auto;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  background: transparent;
}
.site-nav__submenu a:hover,
.site-nav__submenu a:focus {
  background: var(--surface-sunken);
  color: var(--color-brand-primary);
  text-decoration: none;
}

/* Identity slot */
.site-identity {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.site-identity__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-height-sm);
  padding: 0 var(--space-3) 0 var(--space-1);
  border-radius: var(--radius-full);
  background-color: var(--surface-raised);
  border: var(--border-thin) solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color     var(--duration-fast) var(--ease-standard);
}
.site-identity__chip:hover {
  background-color: var(--surface-sunken);
  border-color: var(--border-strong);
}

.site-identity__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background-color: var(--color-kale-100);
  color: var(--color-kale-700);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  flex-shrink: 0;
}

/* Mobile menu toggle */
.site-header__toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  background: transparent;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
}
.site-header__toggle svg { width: var(--space-5); height: var(--space-5); display: block; }
.site-header__toggle:hover { background-color: var(--surface-sunken); }

@media (max-width: 48rem) {
  .site-header__toggle { display: inline-flex; }
  .site-header__nav-wrap {
    display: none;
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background-color: var(--surface-raised);
    border-bottom: var(--border-thin) solid var(--border-divider);
    box-shadow: var(--shadow-md);
    padding: var(--space-3) var(--space-6);
    z-index: var(--z-overlay);
  }
  .site-header__nav-wrap[data-open="true"] { display: block; }
  .site-nav { flex-direction: column; align-items: stretch; gap: var(--space-1); }
  .site-nav__link,
  .site-nav a {
    height: var(--control-height);
    padding: 0 var(--space-3);
  }
  .site-nav__link[aria-current="page"],
  .site-nav a[aria-current="page"] {
    box-shadow: inset 2px 0 0 var(--color-brand-primary);
    border-radius: 0;
  }
  .site-identity { display: none; }
  .site-header__inner .site-identity--mobile { display: inline-flex; }
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0 0 var(--space-4) 0;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.breadcrumb__link {
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) var(--ease-standard);
}
.breadcrumb__link:hover { color: var(--text-primary); }

.breadcrumb__current {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

.breadcrumb__sep {
  display: inline-flex;
  width: 0.75rem;
  height: 0.75rem;
  color: var(--color-warm-400);
  flex-shrink: 0;
}
.breadcrumb__sep svg { width: 100%; height: 100%; display: block; }

/* ---------- Site footer (richer) ---------- */

.site-footer {
  display: block;
  border-top: var(--border-thin) solid var(--border-divider);
  background-color: var(--surface-page);
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  max-width: var(--shell-max-app);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-8);
  width: 100%;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
  align-items: start;
}
.shell--read .site-footer__inner { max-width: var(--shell-max-read); }

.site-footer__brand-col { display: flex; flex-direction: column; gap: var(--space-3); }

.site-footer__tagline {
  max-width: 32ch;
  color: var(--text-muted);
  margin: 0;
}

.site-footer__col-title {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0 0 var(--space-3) 0;
}

.site-footer__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer__list a {
  color: var(--text-muted);
  text-decoration: none;
}
.site-footer__list a:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer__meta {
  border-top: var(--border-thin) solid var(--border-divider);
  padding: var(--space-4) var(--space-6);
  max-width: var(--shell-max-app);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}
.shell--read .site-footer__meta { max-width: var(--shell-max-read); }

.site-footer__version {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

@media (max-width: 48rem) {
  .site-footer__inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    padding: var(--space-8) var(--space-6);
  }
  .site-footer__brand-col { grid-column: 1 / -1; }
  .site-footer__meta { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
}
@media (max-width: 30rem) {
  .site-footer__inner { grid-template-columns: 1fr; }
}

/* ---------- Danger button ---------- */

.btn--danger {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}
.btn--danger:hover, .btn--danger.is-hovered {
  background-color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  box-shadow: var(--shadow-md);
}
.btn--danger:active, .btn--danger.is-active {
  background-color: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
  box-shadow: var(--shadow-sm);
}

/* ---------- Modal / dialog ---------- */

.modal {
  padding: 0;
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-lg);
  background-color: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  width: min(calc(100vw - var(--space-8)), var(--modal-width-md));
  max-height: calc(100dvh - var(--space-12));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal--sm { width: min(calc(100vw - var(--space-8)), var(--modal-width-sm)); }
.modal--md { width: min(calc(100vw - var(--space-8)), var(--modal-width-md)); }
.modal--lg { width: min(calc(100vw - var(--space-8)), var(--modal-width-lg)); }

.modal::backdrop { background-color: var(--surface-overlay); }

.modal__head {
  padding: var(--space-5) var(--space-6) var(--space-3);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: var(--border-thin) solid var(--border-divider);
}

.modal__title-block { min-width: 0; }

.modal__eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-1) 0;
}
.modal--danger .modal__eyebrow { color: var(--color-danger); }

.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0;
}
.modal--danger .modal__title { color: var(--color-danger); }

.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0;
  background: transparent;
  border: var(--border-thin) solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color            var(--duration-fast) var(--ease-standard);
}
.modal__close svg { width: var(--space-4); height: var(--space-4); display: block; }
.modal__close:hover  { background-color: var(--surface-sunken); color: var(--text-primary); }
.modal__close:active { background-color: var(--surface-inset); }

.modal__body {
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
  flex: 1 1 auto;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
}
.modal__body > :first-child { margin-top: 0; }
.modal__body > :last-child  { margin-bottom: 0; }

.modal__foot {
  padding: var(--space-3) var(--space-6);
  background-color: var(--surface-page);
  border-top: var(--border-thin) solid var(--border-divider);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}
.modal__foot--split { justify-content: space-between; }

/* Modal motion — entry/exit. Reduced-motion strips transform/opacity. */
@media (prefers-reduced-motion: no-preference) {
  .modal {
    opacity: 0;
    transform: translateY(6px);
    transition:
      opacity   var(--duration-normal) var(--ease-decelerate),
      transform var(--duration-normal) var(--ease-decelerate),
      overlay   var(--duration-normal) allow-discrete,
      display   var(--duration-normal) allow-discrete;
  }
  .modal[open] { opacity: 1; transform: translateY(0); }
  @starting-style {
    .modal[open] { opacity: 0; transform: translateY(6px); }
  }
  .modal::backdrop {
    opacity: 0;
    transition:
      opacity var(--duration-normal) var(--ease-standard),
      overlay var(--duration-normal) allow-discrete,
      display var(--duration-normal) allow-discrete;
  }
  .modal[open]::backdrop { opacity: 1; }
  @starting-style {
    .modal[open]::backdrop { opacity: 0; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .modal           { opacity: 1; transform: none; transition: none; }
  .modal::backdrop { transition: none; }
}

/* ---------- Page-level states (empty / loading / error / 404) ---------- */

.page-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-6);
  color: var(--text-primary);
  min-height: 24rem;
}

.page-state__ornament {
  display: inline-flex;
  width: 12rem;
  height: 3rem;
  color: var(--color-ornament);
  margin-bottom: var(--space-2);
  opacity: 0.75;
}
.page-state__ornament svg { width: 100%; height: 100%; display: block; }

.page-state__eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.page-state__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  margin: 0;
}

.page-state__body {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: var(--leading-normal);
  max-width: 36rem;
  margin: 0;
}

.page-state__actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
}

.page-state__detail {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background-color: var(--surface-sunken);
  border: var(--border-thin) solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
  max-width: 36rem;
  word-break: break-all;
}

.page-state--error    .page-state__title   { color: var(--color-danger); }
.page-state--notfound .page-state__eyebrow { color: var(--color-warning); }

.page-state--loading .page-state__skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  max-width: 32rem;
}
.page-state--loading .skeleton-bar {
  display: block;
  height: 0.875rem;
  background-color: var(--surface-inset);
  border-radius: var(--radius-sm);
  width: 80%;
}
.page-state--loading .skeleton-bar--narrow { width: 40%; }
.page-state--loading .skeleton-bar--medium { width: 65%; }
.page-state--loading .skeleton-bar--wide   { width: 90%; }

@media (prefers-reduced-motion: no-preference) {
  .page-state--loading .skeleton-bar {
    animation: dg-skeleton-pulse 1.4s var(--ease-standard) infinite;
  }
  .page-state--loading .skeleton-bar:nth-child(2) { animation-delay: 100ms; }
  .page-state--loading .skeleton-bar:nth-child(3) { animation-delay: 200ms; }
}
@media (prefers-reduced-motion: reduce) {
  .page-state--loading .skeleton-bar { animation: none; }
}

/* ---------- Layout shells ----------
 * Selector strategy: shell class lives on <body>. The .page__main child
 * carries the existing max-width contract from base.css; the shell overrides.
 * `.shell--app` is the default; `.shell--read` narrows for long-form;
 * `.shell--with-sidebar` overlays a left sidebar.
 */

.shell--app  .page__main { max-width: var(--shell-max-app); }
.shell--read .page__main { max-width: var(--shell-max-read); }

/* Foundation graft: long-form prose gets a touch more line-height inside
   the reading shell so publications read clean. Scoped tight so dashboard
   density is not affected. */
.shell--read .page__main p,
.shell--read .page__main li { line-height: var(--leading-relaxed); }

/* Two-column shell — sidebar on the left, sticky. Falls back to one column
   if no sidebar is rendered (via :has). */
.shell--with-sidebar .page__main {
  display: grid;
  grid-template-columns: var(--shell-sidebar-w) minmax(0, 1fr);
  gap: var(--space-10);
  align-items: start;
}
.shell--with-sidebar .page__main > .page__sidebar {
  position: sticky;
  top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
  border-right: var(--border-thin) solid var(--border-divider);
  padding-right: var(--space-6);
}
.shell--with-sidebar .page__main > .page__content { min-width: 0; }

/* Empty-sidebar fallback (Foundation graft) — if no .page__sidebar exists,
   collapse back to one column. Requires :has() support; static fallback
   above ensures the page still renders. */
.shell--with-sidebar .page__main:not(:has(.page__sidebar)) {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 64rem) {
  .shell--with-sidebar .page__main {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  .shell--with-sidebar .page__main > .page__sidebar {
    position: static;
    border-right: 0;
    border-bottom: var(--border-thin) solid var(--border-divider);
    padding-right: 0;
    padding-bottom: var(--space-4);
  }
}
