@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/assets/fonts/bricolage-grotesque-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: Geist;
  src: url("/assets/fonts/geist-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

@layer arconite.tokens {
  /* ---------- Shared foundations ---------- */
  :where([data-arconite-spacing]),
  [data-brand][data-mode]:not(:where([data-brand][data-mode] *)) {
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  }

  [data-brand][data-mode]:not(:where([data-brand][data-mode] *)) {
    --r-xs: 6px; --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-xl: 32px; --r-pill: 999px;
    --h-sm: 32px; --h-md: 40px; --h-lg: 48px;
    --shadow-sm: none; --shadow-md: none;

    --t-press: 110ms; --t-control: 160ms; --t-panel: 250ms; --t-move: 280ms; --t-reveal: 350ms;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  }

  /* ---------- Brand × mode color roles ---------- */
  /* Arconite: Carbono, approved on 2026-12-03. */
  [data-brand="arconite"][data-mode="light"] { --bg: #f5f5f7; --surface: #ffffff; --sunken: #e9e9ed; --line: #dcdce1; --line-strong: #84848b; --ink: #111111; --ink-2: #5a5a61; --accent: #111111; --on-accent: #ffffff; --accent-ink: #2b2b2b; --accent-soft: #e7e7eb; --dot: #111111; --stage: #1c1c1f; --stage-deep: #0a0a0b; --on-stage: #ffffff; --glow: #ffffff; --fig-mid: #6b6b70; --fig-glow: #d9d9de; --fig-hot: #ffffff; }
  [data-brand="arconite"][data-mode="dark"] { --bg: #0a0a0b; --surface: #17171a; --sunken: #000000; --line: #2b2b30; --line-strong: #7b7b83; --ink: #ffffff; --ink-2: #a1a1a8; --accent: #ffffff; --on-accent: #0a0a0b; --accent-ink: #ffffff; --accent-soft: #26262b; --dot: #ffffff; --stage: #1c1c1f; --stage-deep: #0a0a0b; --on-stage: #ffffff; --glow: #ffffff; --fig-mid: #6b6b70; --fig-glow: #d9d9de; --fig-hot: #ffffff; }

  /* Type: Bricolage Grotesque for display and titles, Geist for interface and text. */
  [data-brand][data-mode]:not(:where([data-brand][data-mode] *)) { --font-display: "Bricolage Grotesque", system-ui, sans-serif; --font-title: "Bricolage Grotesque", system-ui, sans-serif; --font-ui: Geist, system-ui, sans-serif; --display-weight: 500; --display-track: -0.035em; }

  /* Status roles and elevation depend on mode only. */
  :where([data-brand])[data-mode="light"] {
    --ok: #17734f; --ok-soft: #dcf1e6; --warn: #8a5a00; --warn-soft: #f8ead0; --err: #b3261e; --err-soft: #f9dedb;
  }
  :where([data-brand])[data-mode="dark"] {
    --ok: #6fd3a5; --ok-soft: #12382a; --warn: #f0c36a; --warn-soft: #3a2c10; --err: #ff9f97; --err-soft: #40181a;
  }

  /* Tonal layers. Nothing has an outline: each layer is one step of tone above the one it sits on.
     page (--bg) < surface < raised. Only what floats over content gets one soft ambient shadow. */
  :where([data-brand])[data-mode="light"] {
    --raised: var(--sunken); --tray: var(--sunken); --pad: var(--surface);
    --float: 0 1px 2px rgb(20 26 30 / 0.04), 0 14px 44px rgb(20 26 30 / 0.10);
  }
  :where([data-brand])[data-mode="dark"] {
    --raised: color-mix(in srgb, var(--surface) 88%, var(--ink)); --tray: var(--surface);
    --pad: color-mix(in srgb, var(--surface) 90%, var(--ink));
    --float: 0 18px 50px rgb(0 0 0 / 0.45);
  }
}

/* Whole-document defaults for surfaces that opt in on html. */
:where(html[data-arconite-ui]) {
  /* ---------- Reset and page ---------- */
  &, * { box-sizing: border-box; }
  & body, & h1, & h2, & h3, & h4, & p, & ul, & ol, & dl, & dd, & figure { margin: 0; }
  & ul, & ol { padding: 0; list-style: none; }
  & button, & input, & select, & textarea { font: inherit; color: inherit; }
  & button { cursor: pointer; }
  & img, & svg, & canvas { display: block; max-width: 100%; }
  [hidden] { display: none !important; }

  &[data-brand], [data-brand] { color: var(--ink); }
  & body {
    font: 400 15px/1.55 var(--font-ui);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background var(--t-panel) var(--ease);
  }
  :focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: var(--r-xs); }
  &[data-mode="light"], [data-mode="light"] { color-scheme: light; }
  &[data-mode="dark"], [data-mode="dark"] { color-scheme: dark; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }
}

:where([data-arconite-ui]) {
  .stage :focus-visible { outline-color: var(--glow); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* ---------- Type roles ---------- */
  .display { font: var(--display-weight, 400) clamp(44px, 7vw, 104px)/0.98 var(--font-display); letter-spacing: var(--display-track, -0.02em); text-wrap: balance; }
  .headline { font: var(--display-weight, 400) clamp(32px, 4vw, 52px)/1.04 var(--font-display); letter-spacing: var(--display-track, -0.015em); text-wrap: balance; }
  .title { font: 600 clamp(22px, 2.4vw, 28px)/1.2 var(--font-title); letter-spacing: -0.03em; }
  .subtitle { font: 600 17px/1.3 var(--font-title); letter-spacing: -0.02em; }
  .lead { font-size: 18px; line-height: 1.5; color: var(--ink-2); max-width: 58ch; }
  .body { max-width: 68ch; }
  .small { font-size: 13px; color: var(--ink-2); }
  .caption { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-ink); }
  .stage .caption { color: var(--glow); }
  .equation { font: italic 400 20px/1.3 var(--font-display); }
  .wordmark { font: 600 22px/1 var(--font-title); letter-spacing: -0.04em; }
  .brandmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
  .brandmark svg { width: 28px; height: 28px; }
  .stage .brandmark { color: var(--on-stage); }

  .section-head { display: grid; gap: var(--s-2); }
  .grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .grid.narrow { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
  .stack { display: grid; gap: var(--s-3); align-content: start; }
  .panel { padding: var(--s-5); background: var(--surface); border: 0; border-radius: var(--r-lg); display: grid; gap: var(--s-4); align-content: start; min-width: 0; }
  .panel > h3 { font: 600 14px/1.3 var(--font-ui); color: var(--ink-2); }
  .rule-note { font-size: 13px; color: var(--ink-2); max-width: 70ch; }

  /* ---------- Stage: the dark field where a brand shows its figure ---------- */
  .stage { background: var(--stage-deep); color: var(--on-stage); border-radius: var(--r-xl); overflow: hidden; position: relative; }
  .stage.tinted { background: var(--stage); }
  .figure-canvas { width: 100%; height: 100%; }
  .fig-caption { display: grid; gap: 4px; justify-items: end; text-align: right; padding-top: 10px; border-top: 1px solid var(--glow); }
  .fig-caption .small { color: color-mix(in srgb, var(--on-stage) 78%, transparent); }

  .hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 560px; }
  .hero-copy { position: relative; z-index: 1; display: grid; gap: var(--s-5); align-content: space-between; padding: clamp(24px, 4vw, 56px); }
  .hero-copy .lead { color: color-mix(in srgb, var(--on-stage) 84%, transparent); }
  .hero-figure { position: relative; min-height: 380px; }
  .hero-figure canvas { position: absolute; inset: 0; }
  .hero-figure .fig-caption { position: absolute; right: clamp(20px, 3vw, 40px); bottom: clamp(20px, 3vw, 40px); }
  @media (max-width: 860px) { .hero { grid-template-columns: minmax(0, 1fr); } }

  /* ---------- Icons ---------- */
  .icon { width: 18px; height: 18px; flex: none; color: inherit; }
  /* ---------- Buttons ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2, 8px);
    height: var(--h-md); padding: 0 18px; border-radius: var(--r-pill);
    border: 0; background: transparent; color: var(--ink);
    font: 500 14px/1 var(--font-ui); text-decoration: none; white-space: nowrap;
    transition: background var(--t-press) var(--ease), transform var(--t-press) var(--ease), box-shadow var(--t-press) var(--ease), opacity var(--t-press) var(--ease);
  }
  .btn:active:not(:disabled) { transform: scale(0.98); }
  .btn.sm { height: var(--h-sm); padding: 0 12px; font-size: 13px; }
  .btn.lg { height: var(--h-lg); padding: 0 20px; font-size: 15px; }
  .btn.primary { background: var(--accent); color: var(--on-accent); }
  .btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
  .btn.secondary { background: var(--raised); }
  .btn.secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--raised) 86%, var(--ink)); }
  .btn.quiet { color: var(--accent-ink); }
  .btn.quiet:hover:not(:disabled) { background: var(--accent-soft); }
  .btn.danger { background: var(--err); color: var(--bg); }
  .btn.icon-only { width: var(--h-md); padding: 0; }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
  .btn[data-loading] { pointer-events: none; }
  .btn[data-loading]::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: arconite-spin 0.7s linear infinite; }
  .stage .btn.primary { background: var(--glow); color: var(--stage-deep); }
  .stage .btn.secondary { background: color-mix(in srgb, var(--on-stage) 14%, var(--stage-deep)); color: var(--on-stage); }
  .stage .btn.secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--on-stage) 24%, var(--stage-deep)); }
  .link { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
  .link:hover { text-decoration-thickness: 2px; }

  /* ---------- Fields ---------- */
  .field { display: grid; gap: 6px; }
  .field > span { font-size: 13px; font-weight: 600; }
  .field small { font-size: 12px; color: var(--ink-2); }
  .input, .select, .textarea {
    width: 100%; height: var(--h-md); padding: 0 12px; border-radius: var(--r-sm);
    background: var(--raised); border: 0; color: var(--ink);
    transition: background var(--t-control) var(--ease), box-shadow var(--t-control) var(--ease);
  }
  .textarea { border-radius: var(--r-md); height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
  .input::placeholder, .textarea::placeholder { color: var(--ink-2); opacity: 0.8; }
  .input:hover, .select:hover, .textarea:hover { background: color-mix(in srgb, var(--raised) 90%, var(--ink)); }
  .input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent-ink); }
  .field.invalid .input { box-shadow: 0 0 0 1.5px var(--err); }
  .field.invalid small { color: var(--err); }
  .input:disabled { opacity: 0.5; }
  .search { position: relative; }
  .search .icon { position: absolute; left: 14px; top: 11px; color: var(--ink-2); }
  .search .input { padding-left: 40px; border-radius: var(--r-pill); }

  /* ---------- Selection ---------- */
  .check { display: flex; align-items: center; gap: 10px; min-height: 28px; }
  .check input { appearance: none; width: 20px; height: 20px; margin: 0; flex: none; border: 2px solid var(--line-strong); border-radius: var(--r-xs); background: var(--surface); display: grid; place-items: center; transition: background var(--t-press) var(--ease), border-color var(--t-press) var(--ease); }
  .check input[type="radio"] { border-radius: 50%; }
  .check input:checked { background: var(--accent); border-color: var(--accent); }
  .check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 6px; margin-top: -2px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg); }
  .check input[type="radio"]:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-accent); }
  .switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 32px; }
  .switch input { appearance: none; position: relative; width: 44px; height: 26px; margin: 0; flex: none; border-radius: var(--r-pill); background: var(--line-strong); transition: background var(--t-control) var(--ease); }
  .switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--t-control) var(--ease-spring); }
  .switch input:checked { background: var(--accent); }
  .switch input:checked::after { transform: translateX(18px); background: var(--on-accent); }
  .segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--raised); }
  .segmented button { height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: 500 13px/1 var(--font-ui); transition: background var(--t-control) var(--ease), color var(--t-control) var(--ease); }
  .segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); }
  .range { width: 100%; accent-color: var(--accent); }
  .chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-pill); border: 0; background: var(--raised); font-size: 13px; font-weight: 500; }
  .chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
  .tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 12px; font-weight: 500; background: var(--accent-soft); color: var(--accent-ink); }
  .tag.ok { background: var(--ok-soft); color: var(--ok); }
  .tag.warn { background: var(--warn-soft); color: var(--warn); }
  .tag.err { background: var(--err-soft); color: var(--err); }

  /* ---------- Navigation ---------- */
  .tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--line); overflow-x: auto; }
  .tabs button { position: relative; height: 40px; padding: 0; border: 0; background: none; color: var(--ink-2); font: 500 14px/1 var(--font-ui); white-space: nowrap; }
  .tabs button[aria-selected="true"] { color: var(--ink); }
  .tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent-ink); border-radius: 2px; }
  .side-nav { display: grid; gap: 2px; }
  .side-nav a { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px; }
  .side-nav a:hover { background: var(--raised); color: var(--ink); }
  .side-nav a[aria-current="page"] { background: var(--raised); color: var(--ink); }
  .crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-2); }
  .crumbs a { color: inherit; text-decoration: none; }
  .crumbs a:hover { color: var(--ink); text-decoration: underline; }
  .crumbs li + li::before { content: "/"; margin-right: 6px; opacity: 0.6; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--surface); }
  .bottom-nav a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 10px; font-size: 11px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
  .bottom-nav a[aria-current="page"] { color: var(--accent-ink); }

  /* ---------- Surfaces ---------- */
  .card { background: var(--surface); border: 0; border-radius: var(--r-lg); overflow: hidden; display: grid; align-content: start; }
  .card.lift { box-shadow: var(--shadow-md); transition: box-shadow var(--t-control) var(--ease), transform var(--t-control) var(--ease), outline-color var(--t-control) var(--ease); outline: 2px solid transparent; outline-offset: 2px; }
  .card.lift:hover { transform: translateY(-2px); box-shadow: var(--float); }
  .card-body { padding: var(--s-4); display: grid; gap: var(--s-2); }
  .cover { aspect-ratio: 16 / 10; border-radius: 0; }
  .list { display: grid; }
  .list li { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line); }
  .list li:last-child { border-bottom: 0; }
  .thumb { width: 44px; height: 44px; border-radius: var(--r-sm); }
  .progress { height: 4px; border-radius: 2px; background: var(--raised); overflow: hidden; }
  .progress i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
  .stage .progress { background: color-mix(in srgb, var(--on-stage) 18%, transparent); }
  .stage .progress i { background: var(--glow); }
  .table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-2); padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .table td { padding: 12px; border-bottom: 1px solid var(--line); }
  .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .table-scroll { overflow-x: auto; }
  .avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font: 600 12px var(--font-ui); }

  /* ---------- Feedback ---------- */
  .alert { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s-3); padding: 12px var(--s-4); border-radius: var(--r-md); background: var(--accent-soft); color: var(--ink); font-size: 14px; }
  .alert .icon { color: var(--accent-ink); }
  .alert.ok { background: var(--ok-soft); } .alert.ok .icon { color: var(--ok); }
  .alert.warn { background: var(--warn-soft); } .alert.warn .icon { color: var(--warn); }
  .alert.err { background: var(--err-soft); } .alert.err .icon { color: var(--err); }
  .skeleton { border-radius: var(--r-sm); background: var(--raised); animation: arconite-pulse 1.2s var(--ease) infinite alternate; }
  .empty { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-4); text-align: center; background: var(--raised); border-radius: var(--r-lg); }
  .empty p { color: var(--ink-2); max-width: 36ch; }
  .toasts { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: grid; gap: var(--s-2); }
  .toast { display: flex; align-items: center; gap: var(--s-3); padding: 12px 16px; border-radius: var(--r-pill); background: var(--ink); color: var(--bg); box-shadow: var(--float); font-size: 14px; animation: arconite-rise var(--t-reveal) var(--ease-spring); }

  /* ---------- Overlays ---------- */
  .menu-wrap { position: relative; display: inline-block; }
  .menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; min-width: 200px; padding: 6px; border-radius: var(--r-md); background: var(--pad); border: 0; box-shadow: var(--float); transform-origin: top left; animation: arconite-pop var(--t-control) var(--ease); }
  .menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; font-size: 14px; text-align: left; }
  .menu button:hover { background: var(--raised); }
  .menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
  .menu .destructive { color: var(--err); }
  & dialog.dialog { width: min(440px, calc(100vw - 32px)); padding: var(--s-5); border: 0; border-radius: 28px; background: var(--pad); color: var(--ink); box-shadow: var(--float); }
  & dialog.dialog[open] { display: grid; gap: var(--s-4); animation: arconite-dialog-in var(--t-panel) var(--ease); }
  & dialog.dialog::backdrop { background: rgb(8 10 12 / 0.6); }
  .tip { position: relative; }
  .tip::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; translate: -50% 4px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--t-control) var(--ease), translate var(--t-control) var(--ease); }
  .tip:hover::after, .tip:focus-visible::after { opacity: 1; translate: -50% 0; }

  /* Canvases fill their framed parent regardless of the bitmap size set by the script. */
  .cover > canvas, .thumb > canvas { position: absolute; inset: 0; }
  /* Keep the hero figure clear of its caption. */
  .hero-figure canvas { inset: 0 0 auto 0; height: calc(100% - 104px); }
  .round { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); transition: background var(--t-control) var(--ease), color var(--t-control) var(--ease); }
  .round:hover { background: var(--raised); color: var(--ink); }
  .round[aria-current="page"], .round.on { background: var(--raised); color: var(--ink); }
  @media (prefers-reduced-motion: reduce) {
    .btn, .btn::before, .card.lift, .switch input::after, .chip, .skeleton, .toast,
    .menu, & dialog.dialog, .tip::after, .round {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }
}

@keyframes arconite-spin { to { transform: rotate(360deg); } }
@keyframes arconite-pulse { to { opacity: 0.45; } }
@keyframes arconite-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes arconite-pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes arconite-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

