/*
 * Wise.design-inspired functional UI — admin + default frontend.
 * Layers: tokens → reset → base → components → utilities.
 */
@layer tokens, reset, base, components, utilities;

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin.woff2') format('woff2-variations'), url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2-variations'), url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@view-transition { navigation: auto; }

@layer tokens {
  :root {
    /* Wise.design High-Contrast Light Theme */
    --bg-canvas: #F8FAF9;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F1F5F2;
    --bg-forest: #163300;
    --bg-lime: #9FE870;
    --bg-lime-hover: #8CD95B;

    --text-primary: #0E0F0C;
    --text-secondary: #454745;
    --text-muted: #6A6C6A;
    --text-on-forest: #FFFFFF;
    --text-on-lime: #0E0F0C;

    --border-subtle: #E2E6E3;
    --border-strong: #C6CEC8;
    --border-focus: #163300;

    --status-success: #1B7F37;
    --status-warning: #B56B00;
    --status-danger: #D92D20;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Inter Display', 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 9999px;

    --shadow-card: 0 1px 3px rgba(14, 15, 12, 0.06);
    --transition-fast: 140ms cubic-bezier(0.22, 1, 0.36, 1);

    /* Derived (not part of the spec map) */
    --shadow-pop: 0 12px 32px rgba(14, 15, 12, 0.14), 0 2px 6px rgba(14, 15, 12, 0.06);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--bg-lime) 70%, transparent);
    --tint-success: color-mix(in srgb, var(--status-success) 12%, var(--bg-surface));
    --tint-warning: color-mix(in srgb, var(--status-warning) 14%, var(--bg-surface));
    --tint-danger: color-mix(in srgb, var(--status-danger) 10%, var(--bg-surface));
    --tint-lime: color-mix(in srgb, var(--bg-lime) 28%, var(--bg-surface));
    --container: 72rem;
    --sidebar-width: 15.5rem;
    color-scheme: light;
  }

  [data-theme="dark"] {
    --bg-canvas: #0E0F0C;
    --bg-surface: #161814;
    --bg-elevated: #20231D;
    --bg-forest: #9FE870;
    --bg-lime: #9FE870;
    --bg-lime-hover: #B2F089;

    --text-primary: #F2F5F3;
    --text-secondary: #B4B8B4;
    --text-muted: #7C807C;
    --text-on-forest: #0E0F0C;
    --text-on-lime: #0E0F0C;

    --border-subtle: #282C25;
    --border-strong: #3A3F36;
    --border-focus: #9FE870;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }

  /* Follow the OS unless a theme was chosen explicitly. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg-canvas: #0E0F0C;
      --bg-surface: #161814;
      --bg-elevated: #20231D;
      --bg-forest: #9FE870;
      --bg-lime: #9FE870;
      --bg-lime-hover: #B2F089;
      --text-primary: #F2F5F3;
      --text-secondary: #B4B8B4;
      --text-muted: #7C807C;
      --text-on-forest: #0E0F0C;
      --text-on-lime: #0E0F0C;
      --border-subtle: #282C25;
      --border-strong: #3A3F36;
      --border-focus: #9FE870;
      --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
      color-scheme: dark;
    }
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-height: 100vh; line-height: 1.55; -webkit-font-smoothing: antialiased; }
  img, picture, video, canvas, svg, iframe { display: block; max-width: 100%; }
  img, video { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }
  table { border-collapse: collapse; }
  [hidden] { display: none !important; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  }
}

@layer base {
  body {
    background: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-feature-settings: 'ss01', 'cv11';
  }
  h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -0.02em; font-weight: 700; }
  h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3.5rem); font-weight: 800; letter-spacing: -0.035em; }
  h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); }
  h3 { font-size: 1.25rem; }
  a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
  a:hover { text-decoration-thickness: 2px; }
  :focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
  ::selection { background: var(--bg-lime); color: var(--text-on-lime); }
  code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
  hr { border: 0; border-top: 1px solid var(--border-subtle); }
  mark { background: var(--tint-lime); color: inherit; padding: 0 0.15em; border-radius: 3px; }
  .tabular-nums { font-variant-numeric: tabular-nums; }
}

@layer components {
  /* ─── Primitives ─────────────────────────────────────────── */
  .wise-container { width: min(100% - 2rem, var(--container)); margin-inline: auto; }

  .wise-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 2.75rem; padding: 0.6rem 1.25rem;
    border: 1px solid transparent; border-radius: var(--radius-pill);
    font-weight: 600; font-size: 0.95rem; line-height: 1.2; text-decoration: none; white-space: nowrap;
    background: var(--bg-elevated); color: var(--text-primary);
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  }
  .wise-button:hover { background: color-mix(in srgb, var(--bg-elevated) 85%, var(--text-primary)); }
  .wise-button:active { transform: scale(0.98); }
  .wise-button:disabled, .wise-button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
  .wise-button--primary { background: var(--bg-lime); color: var(--text-on-lime); }
  .wise-button--primary:hover { background: var(--bg-lime-hover); }
  .wise-button--forest { background: var(--bg-forest); color: var(--text-on-forest); }
  .wise-button--secondary { background: transparent; border-color: var(--border-strong); }
  .wise-button--secondary:hover { border-color: var(--text-primary); background: transparent; }
  .wise-button--ghost { background: transparent; }
  .wise-button--ghost:hover { background: var(--bg-elevated); }
  .wise-button--danger { background: transparent; color: var(--status-danger); border-color: color-mix(in srgb, var(--status-danger) 40%, transparent); }
  .wise-button--danger:hover { background: var(--tint-danger); }
  .wise-button--sm { min-height: 2rem; padding: 0.3rem 0.85rem; font-size: 0.85rem; }
  .wise-button--icon { width: 2.5rem; min-height: 2.5rem; padding: 0; }
  .wise-button.htmx-request { opacity: 0.7; pointer-events: none; }

  .wise-input, .wise-select, .wise-textarea {
    width: 100%; min-height: 2.75rem; padding: 0.6rem 0.85rem;
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-strong); border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  }
  .wise-textarea { min-height: 6rem; resize: vertical; line-height: 1.5; }
  .wise-input:hover, .wise-select:hover, .wise-textarea:hover { border-color: var(--text-muted); }
  .wise-input:focus, .wise-select:focus, .wise-textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--focus-ring); }
  .wise-input[aria-invalid="true"], .wise-select[aria-invalid="true"], .wise-textarea[aria-invalid="true"] { border-color: var(--status-danger); }
  .wise-input--pill { border-radius: var(--radius-pill); min-height: 2.5rem; padding-inline: 1rem; }
  .wise-input[type="color"] { padding: 0.25rem; width: 4rem; }
  .wise-check { width: 1.15rem; height: 1.15rem; accent-color: var(--bg-forest); }

  .wise-form { display: grid; gap: 1.1rem; }
  .wise-field { display: grid; gap: 0.4rem; }
  .wise-field[data-translatable] { gap: 0.5rem; }
  .wise-field-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
  .wise-label { font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
  .wise-required { color: var(--status-danger); }
  .wise-locale-badge { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.1rem 0.45rem; border-radius: var(--radius-pill); background: var(--bg-elevated); color: var(--text-secondary); }
  .wise-field__help { font-size: 0.85rem; color: var(--text-muted); }
  .wise-field__error { font-size: 0.85rem; color: var(--status-danger); font-weight: 500; }
  .wise-fieldset { border: 0; padding: 0; display: grid; gap: 0.5rem; }
  .wise-choice { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; }
  .wise-form__actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
  .wise-hp { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
  .wise-media-field { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
  .wise-media-field img { width: 4rem; height: 4rem; object-fit: cover; border-radius: var(--radius-sm); }

  .wise-badge {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.65rem;
    font-size: 0.78rem; font-weight: 600; border-radius: var(--radius-pill);
    background: var(--bg-elevated); color: var(--text-secondary); text-decoration: none; white-space: nowrap;
  }
  .wise-badge--published, .wise-badge--success, .wise-badge--active, .wise-badge--approved { background: var(--tint-success); color: var(--status-success); }
  .wise-badge--draft, .wise-badge--pending, .wise-badge--hidden, .wise-badge--unread { background: var(--tint-warning); color: var(--status-warning); }
  .wise-badge--scheduled { background: var(--tint-lime); color: var(--text-primary); }
  .wise-badge--archived, .wise-badge--danger, .wise-badge--spam, .wise-badge--failed { background: var(--tint-danger); color: var(--status-danger); }

  .wise-alert { padding: 0.85rem 1rem; border-radius: var(--radius-md); border: 1px solid var(--border-subtle); background: var(--bg-elevated); }
  .wise-alert--success { background: var(--tint-success); border-color: color-mix(in srgb, var(--status-success) 30%, transparent); }
  .wise-alert--warning { background: var(--tint-warning); border-color: color-mix(in srgb, var(--status-warning) 30%, transparent); }
  .wise-alert--danger { background: var(--tint-danger); border-color: color-mix(in srgb, var(--status-danger) 30%, transparent); }

  .wise-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 1.25rem; }
  .wise-card > h2, .wise-card > h3, .wise-card__title { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.85rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
  .wise-card + .wise-card { margin-top: 1rem; }

  .wise-table-wrap { overflow-x: auto; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-surface); }
  .wise-table { width: 100%; font-size: 0.92rem; }
  .wise-table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-subtle); background: var(--bg-elevated); white-space: nowrap; }
  .wise-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
  .wise-table tr:last-child td { border-bottom: 0; }
  .wise-table tbody tr:hover { background: color-mix(in srgb, var(--bg-elevated) 55%, transparent); }
  .wise-table a { font-weight: 600; text-decoration: none; }
  .wise-table a:hover { text-decoration: underline; }
  .wise-table .num { text-align: right; font-variant-numeric: tabular-nums; }

  .wise-tabs { display: flex; gap: 0.25rem; padding: 0.25rem; background: var(--bg-elevated); border-radius: var(--radius-pill); width: fit-content; max-width: 100%; overflow-x: auto; }
  .wise-tabs button, .wise-tabs a { border: 0; background: transparent; padding: 0.4rem 0.9rem; border-radius: var(--radius-pill); font-weight: 600; font-size: 0.88rem; color: var(--text-secondary); text-decoration: none; white-space: nowrap; }
  .wise-tabs [aria-selected="true"], .wise-tabs [aria-current="page"] { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-card); }

  .empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
  .visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.6rem 1rem; background: var(--bg-lime); color: var(--text-on-lime); border-radius: var(--radius-pill); font-weight: 600; }
  .skip-link:focus { top: 1rem; }

  .pagination ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin-block: 2rem; }
  .pagination a, .pagination span { display: inline-flex; min-width: 2.5rem; height: 2.5rem; padding-inline: 0.75rem; align-items: center; justify-content: center; border-radius: var(--radius-pill); text-decoration: none; font-weight: 600; font-variant-numeric: tabular-nums; }
  .pagination a { border: 1px solid var(--border-subtle); background: var(--bg-surface); }
  .pagination a:hover { border-color: var(--text-primary); }
  .pagination [aria-current="page"] { background: var(--bg-forest); color: var(--text-on-forest); }
  .pagination .is-disabled { color: var(--text-muted); }

  /* ─── Frontend ───────────────────────────────────────────── */
  .site { display: flex; flex-direction: column; }
  .site-main { flex: 1; padding-block: 2rem 4rem; }
  .site-main:focus { outline: none; }
  .site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg-canvas) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border-subtle); view-transition-name: site-header; }
  .site-header__inner { display: flex; align-items: center; gap: 1.5rem; min-height: 4.25rem; flex-wrap: wrap; padding-block: 0.6rem; }
  .site-brand { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; text-decoration: none; }
  .site-nav { flex: 1; }
  .site-nav__list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .site-nav__item { position: relative; }
  .site-nav a { display: block; padding: 0.45rem 0.85rem; border-radius: var(--radius-pill); text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--text-secondary); }
  .site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text-primary); background: var(--bg-elevated); }
  .site-nav__list--sub { display: none; position: absolute; top: 100%; left: 0; min-width: 12rem; flex-direction: column; padding: 0.4rem; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-pop); }
  .site-nav__item:hover > .site-nav__list--sub, .site-nav__item:focus-within > .site-nav__list--sub { display: flex; }
  .site-header__tools { display: flex; align-items: center; gap: 0.75rem; }
  .site-search .wise-input { width: 11rem; }
  .lang-switcher ul { list-style: none; padding: 0.2rem; display: flex; gap: 0.15rem; background: var(--bg-elevated); border-radius: var(--radius-pill); }
  .lang-switcher a, .lang-switcher span { display: inline-block; padding: 0.3rem 0.65rem; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 700; text-decoration: none; color: var(--text-secondary); }
  .lang-switcher [aria-current="true"] { background: var(--bg-forest); color: var(--text-on-forest); }
  .lang-switcher .is-unavailable { opacity: 0.45; cursor: not-allowed; }
  .admin-bar { display: flex; gap: 1rem; align-items: center; padding: 0.35rem 1rem; background: var(--bg-forest); color: var(--text-on-forest); font-size: 0.85rem; font-weight: 600; }
  .admin-bar a { text-decoration: none; }
  .admin-bar__badge { background: var(--bg-lime); color: var(--text-on-lime); padding: 0.1rem 0.5rem; border-radius: var(--radius-pill); }

  .hero { padding-block: clamp(3rem, 8vw, 6.5rem) 2rem; }
  .hero__title { font-size: clamp(2.5rem, 1.5rem + 5vw, 5.5rem); max-width: 16ch; }
  .hero__lede, .entry__lede { font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem); color: var(--text-secondary); max-width: 52ch; margin-top: 1.25rem; }
  .page-header { padding-block: 1.5rem 2rem; display: grid; gap: 1rem; }
  .page-header__intro { color: var(--text-secondary); max-width: 60ch; }
  .search-form { display: flex; gap: 0.75rem; max-width: 36rem; }

  .entry { max-width: 46rem; }
  .entry__header { padding-block: 1.5rem 2rem; }
  .entry__meta { color: var(--text-muted); margin-top: 1rem; font-size: 0.95rem; }
  .entry__meta a { color: var(--text-secondary); }
  .entry__terms { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
  .subpages { margin-top: 3rem; padding: 1.25rem; background: var(--bg-elevated); border-radius: var(--radius-lg); }
  .subpages ul { padding-left: 1.2rem; display: grid; gap: 0.35rem; }

  .prose { font-size: 1.075rem; line-height: 1.7; display: grid; gap: 1.15em; }
  .prose > * { min-width: 0; }
  .prose h2 { margin-top: 1em; } .prose h3 { margin-top: 0.75em; }
  .prose ul, .prose ol { padding-left: 1.4em; display: grid; gap: 0.35em; }
  .prose li > ul, .prose li > ol { margin-top: 0.35em; }
  .prose a { color: var(--text-primary); text-decoration-color: var(--bg-lime); text-decoration-thickness: 2px; }
  .prose a:hover { background: var(--tint-lime); }
  .prose pre { background: var(--bg-elevated); border: 1px solid var(--border-subtle); padding: 1rem 1.15rem; border-radius: var(--radius-md); overflow-x: auto; font-size: 0.9rem; line-height: 1.55; }
  .prose :not(pre) > code { background: var(--bg-elevated); padding: 0.1em 0.35em; border-radius: 4px; }
  .prose figure { display: grid; gap: 0.6rem; }
  .prose figcaption { font-size: 0.9rem; color: var(--text-muted); }
  .prose img { border-radius: var(--radius-md); }
  .cms-image--border img { border: 1px solid var(--border-subtle); }
  .cms-image--background { background: var(--bg-elevated); padding: 1.5rem; border-radius: var(--radius-lg); }
  .cms-image--background img { margin-inline: auto; max-width: 60%; }
  .cms-image--stretched { width: min(100vw - 2rem, var(--container)); margin-inline: calc(50% - min(50vw - 1rem, var(--container) / 2)); }
  .cms-quote blockquote { border-left: 4px solid var(--bg-lime); padding-left: 1.25rem; font-size: 1.25rem; font-weight: 500; letter-spacing: -0.01em; }
  .cms-quote.cms-align-center { text-align: center; } .cms-quote.cms-align-center blockquote { border: 0; padding: 0; }
  .cms-callout { padding: 1rem 1.15rem; border-radius: var(--radius-md); background: var(--tint-warning); border-left: 4px solid var(--status-warning); }
  .cms-callout__title { margin-bottom: 0.35rem; }
  .cms-embed iframe { width: 100%; height: auto; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius-md); background: var(--bg-elevated); }
  .cms-embed--spotify iframe, .cms-embed--soundcloud iframe { aspect-ratio: auto; height: 352px; }
  .cms-table-wrap { overflow-x: auto; }
  .cms-table-wrap table { width: 100%; font-size: 0.95rem; }
  .cms-table-wrap th, .cms-table-wrap td { border-bottom: 1px solid var(--border-subtle); padding: 0.6rem 0.75rem; text-align: left; }
  .cms-table-wrap th { font-weight: 700; background: var(--bg-elevated); }
  .cms-checklist { list-style: none; padding-left: 0 !important; }
  .cms-checkbox { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--border-strong); border-radius: 4px; vertical-align: -0.12em; }
  .is-checked > .cms-checkbox { background: var(--bg-forest); border-color: var(--bg-forest); }
  .cms-align-center { text-align: center; } .cms-align-right { text-align: right; } .cms-align-justify { text-align: justify; }
  .cms-attachment a { display: flex; gap: 0.85rem; align-items: center; padding: 0.85rem 1rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); text-decoration: none; background: var(--bg-surface); }
  .cms-attachment__ext { font-size: 0.75rem; font-weight: 800; background: var(--bg-forest); color: var(--text-on-forest); padding: 0.3rem 0.5rem; border-radius: var(--radius-sm); }
  .cms-attachment__size { margin-left: auto; color: var(--text-muted); font-size: 0.85rem; }
  .cms-link-card { display: flex; gap: 1rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; text-decoration: none; background: var(--bg-surface); }
  .cms-link-card img { width: 8rem; object-fit: cover; }
  .cms-link-card__body { display: grid; gap: 0.25rem; padding: 0.85rem 1rem; }
  .cms-link-card small { color: var(--text-muted); }
  hr.cms-block--delimiter { border: 0; text-align: center; height: 1.5rem; }
  hr.cms-block--delimiter::before { content: '* * *'; letter-spacing: 0.75em; color: var(--text-muted); }

  .card-grid { container-type: inline-size; display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
  .card { display: flex; flex-direction: column; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; transition: transform var(--transition-fast), box-shadow var(--transition-fast); container-type: inline-size; }
  .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
  .card__media img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
  .card__body { padding: 1.15rem 1.25rem 1.35rem; display: grid; gap: 0.5rem; }
  .card__eyebrow { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--status-success); }
  .card__title { font-size: 1.25rem; }
  .card__title a { text-decoration: none; }
  .card__title a::after { content: ''; position: absolute; inset: 0; }
  .card { position: relative; }
  .card__excerpt { color: var(--text-secondary); }
  .card__meta { font-size: 0.85rem; color: var(--text-muted); }
  @container (min-width: 34rem) {
    .card:first-child { flex-direction: row; }
  }

  .comments { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border-subtle); display: grid; gap: 1.25rem; }
  .comment { padding: 1rem 1.15rem; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); display: grid; gap: 0.5rem; }
  .comment--reply { margin-left: 2rem; }
  .comment header { font-size: 0.9rem; color: var(--text-muted); }
  .comment header strong { color: var(--text-primary); }
  .comment-form { padding: 1.25rem; background: var(--bg-elevated); border-radius: var(--radius-lg); }

  .site-footer { border-top: 1px solid var(--border-subtle); padding-block: 2rem; color: var(--text-muted); font-size: 0.9rem; }
  .site-footer__inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
  .error-state { text-align: center; padding-block: 4rem; display: grid; gap: 1rem; justify-items: center; }
  .error-state__code { font-family: var(--font-display); font-size: clamp(5rem, 15vw, 9rem); font-weight: 900; line-height: 1; color: var(--bg-lime); -webkit-text-stroke: 2px var(--bg-forest); }
  .error-page main { padding-block: 4rem; display: grid; gap: 1rem; }
  .error-page pre { white-space: pre-wrap; background: var(--bg-elevated); padding: 1rem; border-radius: var(--radius-md); font-size: 0.8rem; }

  @media (max-width: 48rem) {
    .site-header__inner { gap: 0.75rem; }
    .site-nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .site-nav__list { flex-wrap: nowrap; }
    .site-search .wise-input { width: 8rem; }
  }

  /* ─── Admin shell ────────────────────────────────────────── */
  .admin { background: var(--bg-canvas); }
  .admin-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
  .admin-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg-surface); border-right: 1px solid var(--border-subtle); padding: 1.1rem 0.75rem; display: flex; flex-direction: column; gap: 1.25rem; }
  .admin-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.6rem; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
  .admin-brand__mark { width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--bg-lime); color: var(--text-on-lime); display: grid; place-items: center; font-size: 0.85rem; font-weight: 900; }
  .admin-nav { display: grid; gap: 0.1rem; }
  .admin-nav__heading { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 0.85rem 0.75rem 0.35rem; }
  .admin-nav a { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.75rem; border-radius: var(--radius-pill); text-decoration: none; font-weight: 600; font-size: 0.92rem; color: var(--text-secondary); }
  .admin-nav a:hover { background: var(--bg-elevated); color: var(--text-primary); }
  .admin-nav a[aria-current="page"] { background: var(--bg-forest); color: var(--text-on-forest); }
  .admin-nav__count { font-size: 0.72rem; padding: 0.05rem 0.45rem; border-radius: var(--radius-pill); background: var(--bg-lime); color: var(--text-on-lime); }
  .admin-sidebar__footer { margin-top: auto; display: grid; gap: 0.5rem; font-size: 0.85rem; color: var(--text-muted); padding: 0 0.6rem; }
  .admin-main { min-width: 0; display: flex; flex-direction: column; }
  .admin-topbar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1.5rem; background: color-mix(in srgb, var(--bg-canvas) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-subtle); }
  .admin-topbar__search { flex: 1; max-width: 28rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 1rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-pill); background: var(--bg-surface); color: var(--text-muted); text-align: left; }
  .admin-topbar__search kbd { font-size: 0.75rem; padding: 0.1rem 0.4rem; border: 1px solid var(--border-strong); border-radius: 4px; }
  .admin-topbar__spacer { flex: 1; }
  .admin-menu-toggle { display: none; }
  .admin-content { padding: 1.75rem 1.5rem 4rem; display: grid; gap: 1.5rem; align-content: start; }
  .admin-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
  .admin-page-header h1 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.2rem); }
  .admin-page-header p { color: var(--text-secondary); margin-top: 0.35rem; }
  .admin-page-header__actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
  .admin-toolbar { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
  .admin-toolbar .wise-input { max-width: 18rem; }
  .admin-toolbar .wise-select { width: auto; }
  .admin-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); align-items: start; }
  .admin-two-col { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; }
  .stat-tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
  .stat-tile { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.1rem 1.2rem; text-decoration: none; display: grid; gap: 0.25rem; }
  .stat-tile:hover { border-color: var(--border-strong); }
  .stat-tile__value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
  .stat-tile__label { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
  .stat-tile--accent { background: var(--bg-forest); color: var(--text-on-forest); border-color: transparent; }
  .stat-tile--accent .stat-tile__label { color: inherit; opacity: 0.8; }
  .list-plain { list-style: none; padding: 0; display: grid; gap: 0.1rem; }
  .list-plain li { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border-subtle); font-size: 0.92rem; align-items: center; }
  .list-plain li:last-child { border-bottom: 0; }
  .meta { color: var(--text-muted); font-size: 0.85rem; }
  .kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; font-size: 0.9rem; }
  .kv dt { color: var(--text-muted); }
  .codeblock { font-family: var(--font-mono); font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; background: var(--bg-elevated); padding: 0.85rem; border-radius: var(--radius-md); max-height: 22rem; overflow: auto; }
  .row-actions { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: wrap; }
  .inline-form { display: inline; }
  .stack { display: grid; gap: 0.75rem; }
  .cluster { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

  /* Entity editor (split screen) */
  .editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.5rem; align-items: start; }
  .editor-main { display: grid; gap: 1rem; min-width: 0; }
  .editor-side { position: sticky; top: 4.5rem; display: grid; gap: 1rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; padding-bottom: 1rem; }
  .editor-titlebar { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .locale-tabs { display: flex; gap: 0.25rem; padding: 0.25rem; background: var(--bg-elevated); border-radius: var(--radius-pill); }
  .locale-tabs button { border: 0; background: transparent; padding: 0.35rem 0.85rem; border-radius: var(--radius-pill); font-weight: 700; font-size: 0.85rem; color: var(--text-secondary); display: inline-flex; gap: 0.35rem; align-items: center; }
  .locale-tabs button[aria-pressed="true"] { background: var(--bg-forest); color: var(--text-on-forest); }
  .locale-tabs .dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--border-strong); }
  .locale-tabs .dot.is-filled { background: var(--bg-lime); }
  .editor-title-input { width: 100%; border: 0; background: transparent; font-family: var(--font-display); font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.75rem); font-weight: 800; letter-spacing: -0.03em; padding: 0.25rem 0; }
  .editor-title-input:focus { outline: none; box-shadow: none; }
  .editor-title-input::placeholder { color: var(--text-muted); }
  .editor-slug { display: flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.9rem; flex-wrap: wrap; }
  .editor-slug input { width: auto; flex: 1; min-width: 10rem; min-height: 2rem; padding: 0.25rem 0.6rem; }
  .editor-canvas { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 1.5rem clamp(1rem, 4vw, 3.5rem); min-height: 28rem; }
  .editor-split { display: grid; gap: 1rem; grid-template-columns: 1fr; }
  .editor-split.is-split { grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); }
  .editor-reference { background: var(--bg-elevated); border-radius: var(--radius-lg); padding: 1.25rem; font-size: 0.95rem; max-height: 70vh; overflow-y: auto; }
  .editor-reference .prose { font-size: 0.95rem; }
  .editor-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
  .editor-status .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--status-success); }
  .editor-status.is-dirty .dot { background: var(--status-warning); }
  .codex-editor__redactor { padding-bottom: 8rem !important; }
  .ce-block__content, .ce-toolbar__content { max-width: 44rem; }
  .ce-paragraph, .cdx-block { line-height: 1.65; }
  .ce-header { font-family: var(--font-display); letter-spacing: -0.02em; }
  .cms-pagebreak { display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.75rem 0; }
  .cms-pagebreak::before, .cms-pagebreak::after { content: ''; flex: 1; border-top: 2px dashed var(--border-strong); }
  [data-theme="dark"] .ce-toolbar__plus, [data-theme="dark"] .ce-toolbar__settings-btn { color: var(--text-primary); background: var(--bg-elevated); }
  [data-theme="dark"] .ce-popover, [data-theme="dark"] .ce-inline-toolbar, [data-theme="dark"] .ce-conversion-toolbar { --color-background: var(--bg-elevated); --color-text-primary: var(--text-primary); background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }

  /* Overlays */
  .wise-dialog { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-pop); width: min(100% - 2rem, 52rem); max-height: min(100% - 4rem, 46rem); }
  .wise-dialog::backdrop { background: rgba(14, 15, 12, 0.45); backdrop-filter: blur(2px); }
  .wise-dialog__header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-surface); z-index: 1; }
  .wise-dialog__body { padding: 1.25rem; display: grid; gap: 1rem; }
  .command-palette { width: min(100% - 2rem, 38rem); margin-top: 12vh; }
  .command-palette input { border: 0; border-bottom: 1px solid var(--border-subtle); border-radius: 0; min-height: 3.5rem; font-size: 1.05rem; padding-inline: 1.25rem; }
  .command-palette input:focus { box-shadow: none; }
  .command-palette ul { list-style: none; padding: 0.5rem; max-height: 22rem; overflow-y: auto; }
  .command-palette li a { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0.85rem; border-radius: var(--radius-md); text-decoration: none; font-weight: 600; }
  .command-palette li a small { color: var(--text-muted); font-weight: 500; }
  .command-palette li a[aria-selected="true"] { background: var(--bg-elevated); }
  .toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: grid; gap: 0.5rem; width: min(100% - 2rem, 22rem); }
  .toast { padding: 0.8rem 1rem; border-radius: var(--radius-md); background: var(--bg-forest); color: var(--text-on-forest); box-shadow: var(--shadow-pop); font-weight: 600; font-size: 0.92rem; display: flex; justify-content: space-between; gap: 0.75rem; }
  .toast--error { background: var(--status-danger); color: #fff; }
  .toast__close { background: none; border: 0; color: inherit; font: inherit; }
  .command-palette__empty { padding: 0.75rem 0.85rem; }

  /* Media library */
  .media-grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); }
  .media-tile { position: relative; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-surface); text-align: left; padding: 0; display: grid; }
  .media-tile:hover, .media-tile[aria-pressed="true"] { border-color: var(--border-focus); box-shadow: var(--focus-ring); }
  .media-tile__thumb { aspect-ratio: 1; background: var(--bg-elevated); display: grid; place-items: center; font-weight: 800; color: var(--text-muted); overflow: hidden; }
  .media-tile__thumb img { width: 100%; height: 100%; object-fit: cover; }
  .media-tile__name { font-size: 0.78rem; padding: 0.4rem 0.55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; color: var(--text-muted); transition: border-color var(--transition-fast), background var(--transition-fast); }
  .dropzone.is-over { border-color: var(--border-focus); background: var(--tint-lime); }
  .focal-picker { position: relative; cursor: crosshair; border-radius: var(--radius-md); overflow: hidden; }
  .focal-picker__dot { position: absolute; width: 1.25rem; height: 1.25rem; margin: -0.625rem; border-radius: 50%; border: 3px solid #fff; background: var(--bg-lime); box-shadow: 0 0 0 2px var(--bg-forest); pointer-events: none; }

  /* Tree builder (menus, taxonomies) */
  .tree { list-style: none; padding: 0; display: grid; gap: 0.4rem; }
  .tree .tree { margin-left: 1.5rem; margin-top: 0.4rem; }
  .tree-node { display: flex; gap: 0.5rem; align-items: center; padding: 0.5rem 0.65rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); flex-wrap: wrap; }
  .tree-node .wise-input { min-height: 2.1rem; padding: 0.3rem 0.6rem; width: auto; flex: 1; min-width: 8rem; }
  .tree-node__label { flex: 1; font-weight: 600; }
  .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem; padding: 0.85rem; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-surface); align-items: end; }
  .field-row + .field-row { margin-top: 0.6rem; }

  /* Auth */
  .auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 20% 10%, var(--tint-lime), transparent 40%), var(--bg-canvas); }
  .auth-card { width: min(100%, 26rem); }
  .auth-card h1 { font-size: 1.9rem; margin-bottom: 0.35rem; }

  @media (max-width: 70rem) {
    .editor-layout, .admin-two-col { grid-template-columns: 1fr; }
    .editor-side { position: static; max-height: none; }
    .editor-split.is-split { grid-template-columns: 1fr; }
  }
  @media (max-width: 52rem) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar { position: fixed; inset: 0 auto 0 0; width: min(85vw, 18rem); z-index: 40; transform: translateX(-100%); transition: transform var(--transition-fast); box-shadow: var(--shadow-pop); }
    .admin-sidebar.is-open { transform: none; }
    .admin-menu-toggle { display: inline-flex; }
    .admin-content { padding-inline: 1rem; }
    .admin-topbar { padding-inline: 1rem; }
  }
}

@layer utilities {
  .mt-0 { margin-top: 0 !important; }
  .w-full { width: 100%; }
  .text-muted { color: var(--text-muted); }
  .text-right { text-align: right; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mono { font-family: var(--font-mono); font-size: 0.85em; }
  [x-cloak] { display: none !important; }
}
