Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

254 KB
Raw Blame
@import "tailwindcss";
@import "tw-animate-css";
@import "shadcn/tailwind.css";
@import "./cmd-f.css";
/* IDE color-theme palettes (Dracula, Nord, …). Generated from
   src/lib/color-themes.ts — `html[data-color-theme="…"]` rules out-specify the
   base :root/.dark blocks below. See color-themes.ts for the generator. */
@import "./color-themes.generated.css";
@plugin "tailwind-scrollbar";

/* react-medium-image-zoom hardcodes rgba(255,255,255,1) for the visible
   overlay — the lightbox flashes white in dark mode without this override.
   The unprefixed library rule remains correct for light mode (white ≈ the
   light-mode --background by construction). */
.dark [data-rmiz-modal-overlay="visible"] {
  background-color: var(--background);
}

[data-editor-hidden] [data-rmiz-content] {
  /* biome-ignore lint/complexity/noImportantStyles: react-medium-image-zoom writes visibility: visible as an inline style, which no selector specificity can outrank. */
  visibility: hidden !important;
}

/*
 * Explicit source root for Tailwind v4 content scanning.
 *
 * packages/app's own `bun run dev` runs with CWD=packages/app, and Tailwind
 * v4 auto-detects sources via a package.json walk from there — that default
 * works for the web distribution. The `@source` below is load-bearing for
 * the desktop case only:
 *
 * When packages/desktop's `electron-vite dev` serves this CSS with
 * `root: packages/app` (electron-vite resolves its own config from the desktop
 * package and does not use the app's vite.config.ts), Vite runs with
 * CWD=packages/desktop so Tailwind's auto-detection scans packages/desktop/**
 * — which has no .tsx
 * files, so zero utility classes get emitted. The @source directive below
 * anchors the scan to packages/app/src/** (relative to this CSS file) and is
 * inert for packages/app's own dev because the same paths are already
 * auto-covered. (Pre-US-004 a second Tailwind-source directive pointed at
 * the fumadocs dist tree; removed alongside the per-component CSS-variable
 * token bridge in D-MF2 / FR-14.)
 */
@source "./**/*.{tsx,ts,jsx,js}";

/*
 * Streamdown (ACP thread markdown) ships its utility classes inside its
 * prebuilt dist chunks, which no auto-detected source root covers — without
 * these lines its blocks render unstyled. Globs (not index.js) because the
 * class strings live in the hashed chunk files, not the entry. The paths are
 * pnpm-isolated (the packages/app/node_modules symlinks), NOT root-hoisted:
 * a root-relative ../../../node_modules glob matches nothing under pnpm and
 * silently drops every streamdown-only utility — e.g. the -mt-10 that
 * overlays the copy button on the code-block header, and the
 * text-[var(--sdm-c,…)] token colors that syntax highlighting paints with.
 */
@source "../node_modules/streamdown/dist/*.js";

/*
 * The HTML entries are the only place the `antialiased` body class is used,
 * and they sit outside the src glob above. Under packages/app's own
 * `bun run dev` / `vite build` they're covered by the Vite HTML entries, but
 * electron-vite dev (CWD=packages/desktop; the app's vite.config.ts is not
 * used) relies solely on these @source
 * directives — without these lines `.antialiased` is never emitted there and
 * desktop-dev text renders heavier than production. Keep in sync with the
 * classes in index.html / uninstall.html.
 */
@source "../index.html";
@source "../uninstall.html";

@custom-variant dark (&:is(.dark *));

/* Opt a single utility into the reduced-transparency fallback. The @media
   block further down strips `backdrop-filter` from every slot that opts into a
   blur, but stripping the blur alone is not enough for a translucent overlay:
   without it, the alpha that the blur was hiding behind turns into sharp text
   showing through a wash — the exact effect the setting exists to remove. A
   slot that pairs a blur with an alpha-suffixed background utility uses this
   variant to restore an opaque background at the same breakpoint. */
@custom-variant reduced-transparency (@media (prefers-reduced-transparency: reduce));

@theme {
  /* Agent terracotta */
  --color-agent: #d97757;
  --color-agent-foreground: #ffffff;

  /* Font tokens */
  --font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", ui-monospace, monospace;

  /* Strong custom easing curves (Emil / easing.dev) — punchier than default ease-out */
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-strong: cubic-bezier(0.77, 0, 0.175, 1);

  --text-2xs: 0.688rem; /* 11px */
  --text-1sm: 0.813rem; /* 13px */
  --color-gray-50: oklch(0.985 0.001 106.423);
  --color-gray-100: oklch(0.97 0.001 106.424);
  --color-gray-200: oklch(0.923 0.003 48.717);
  --color-gray-300: oklch(0.869 0.005 56.366);
  --color-gray-400: oklch(0.709 0.01 56.259);
  --color-gray-500: oklch(0.553 0.013 58.071);
  --color-gray-600: oklch(0.444 0.011 73.639);
  --color-gray-700: oklch(0.374 0.01 67.558);
  --color-gray-800: oklch(0.268 0.007 34.298);
  --color-gray-900: oklch(0.216 0.006 56.043);
  --color-gray-950: oklch(0.147 0.004 49.25);

  /* File-tree muted foreground (disclosure carets, indent guides). Pierre
     declares `--trees-fg-muted` on `:host` inside its shadow root, so that var
     is unreachable from sidebar chrome rendered outside the tree. This token is
     the shared source: `createFileTreeStyle` feeds it into the tree, and
     out-of-tree rows use the generated `text-tree-muted` utility to match. */
  --color-tree-muted: light-dark(var(--color-gray-400), var(--color-gray-500));

  /* brand colors */
  --color-azure-blue: #3784ff;
  --color-sky-blue: #69a3ff;
  --color-crystal-blue: #d5e5ff;
  --color-morning-mist: #fbf9f4;
  --color-night-sky: #231f20;
  --color-blue-dark: #29325c;
  --color-cream: #f7f4ed;
  --color-white-cream: #fff5e1;
  --color-orange-light: #fbe1bc;
  --color-gray-light: #5f5c62;

  /* based on azure blue (#3784ff) */
  --color-azure-50: oklch(0.9697 0.0148 251.16);
  --color-azure-100: oklch(0.9308 0.0339 253.71);
  --color-azure-200: oklch(0.8807 0.0599 252.33);
  --color-azure-300: oklch(0.8092 0.0999 249.58);
  --color-azure-400: oklch(0.7135 0.1524 254.03);
  --color-azure-500: oklch(0.6321 0.1983 259.59);
  --color-azure-600: oklch(0.5468 0.2329 262.71);
  --color-azure-700: oklch(0.4895 0.233 263.93);
  --color-azure-800: oklch(0.4234 0.195 264.97);
  --color-azure-900: oklch(0.3773 0.1488 264.94);
  --color-azure-950: oklch(0.2785 0.0961 267.56);

  /* Agent flash keyframes — refined version with accent slide + subtle background pulse.
     Combines three effects in a single animation:
     1. Inset box-shadow left accent bar slides in then out
     2. Subtle background tint pulses once
     3. Slight scale nudge (barely perceptible, adds "alive" quality)

     Easing rationale: uses --ease-out-strong (cubic-bezier custom curve) —
     strong custom curves outpunch built-in CSS easing keywords on UI work.
     Duration 2s is deliberately above the typical UI ceiling (~300ms) because
     this is a one-shot state-indication flash (rare event), not a frequently-
     triggered interaction. */
  @keyframes agent-flash {
    0% {
      box-shadow: inset 3px 0 0 transparent;
      background: transparent;
      transform: translateX(0);
    }
    8% {
      box-shadow: inset 3px 0 0 var(--color-agent);
      background: rgba(217, 119, 87, 0.09);
      transform: translateX(1px);
    }
    35% {
      box-shadow: inset 3px 0 0 var(--color-agent);
      background: rgba(217, 119, 87, 0.06);
      transform: translateX(0);
    }
    100% {
      box-shadow: inset 3px 0 0 transparent;
      background: transparent;
      transform: translateX(0);
    }
  }

  /* Agent insert flash — position-accurate highlight on the exact ranges an
     agent write changed (.ok-agent-insert-flash inline decorations from the
     agent-insert-flash PM plugin). Background/box-shadow only — no layout,
     so it stays cheap on large writes. */
  @keyframes agent-insert-flash {
    0% {
      background: rgba(217, 119, 87, 0.3);
      box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.12);
    }
    55% {
      background: rgba(217, 119, 87, 0.14);
      box-shadow: 0 0 0 0 transparent;
    }
    100% {
      background: transparent;
      box-shadow: 0 0 0 0 transparent;
    }
  }

  /* Agent badge breathing — subtle pulse when agent is editing */
  @keyframes agent-breathing {
    0%,
    100% {
      background: rgba(217, 119, 87, 0.04);
    }
    50% {
      background: rgba(217, 119, 87, 0.14);
    }
  }

  /* Undo button nudge — scale + glow when transitioning to enabled */
  @keyframes undo-ready {
    0% {
      transform: scale(0.95);
      box-shadow: 0 0 0 0 rgba(217, 119, 87, 0);
    }
    40% {
      transform: scale(1.02);
      box-shadow: 0 0 0 4px rgba(217, 119, 87, 0.15);
    }
    100% {
      transform: scale(1);
      box-shadow: 0 0 0 0 rgba(217, 119, 87, 0);
    }
  }

  --animate-agent-flash: agent-flash 2s var(--ease-out-strong) forwards;
  --animate-agent-insert-flash: agent-insert-flash 1.4s var(--ease-out-strong) forwards;
  --animate-agent-breathing: agent-breathing 2.4s ease-in-out infinite;
  --animate-undo-ready: undo-ready 600ms var(--ease-out-strong) forwards;

  @keyframes agent-ready-settle {
    from {
      opacity: 0;
      transform: translateY(3px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  --animate-agent-ready-settle: agent-ready-settle 240ms var(--ease-out-strong) both;

  @keyframes agent-mark-breathe {
    0%,
    100% {
      opacity: 0.25;
    }
    50% {
      opacity: 0.12;
    }
  }

  --animate-agent-mark-breathe: agent-mark-breathe 2.4s ease-in-out infinite;

  @keyframes sidebar-push-pulse {
    0% {
      box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 0%, transparent);
    }
    25% {
      box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 40%, transparent);
    }
    100% {
      box-shadow: inset 4px 0 0 0 color-mix(in oklab, var(--primary) 0%, transparent);
    }
  }

  --animate-sidebar-push-pulse: sidebar-push-pulse 700ms ease-out;

  /* Settings field flash — red briefly to signal a non-pane writer
     (CLI/MCP/hand-edit) caused L3 validation rejection.
     Outline-only so the field input itself is untouched. */
  @keyframes settings-flash {
    0% {
      outline: 2px solid color-mix(in oklab, var(--destructive) 0%, transparent);
      outline-offset: 2px;
    }
    20% {
      outline: 2px solid color-mix(in oklab, var(--destructive) 70%, transparent);
      outline-offset: 2px;
    }
    100% {
      outline: 2px solid color-mix(in oklab, var(--destructive) 0%, transparent);
      outline-offset: 2px;
    }
  }

  --animate-settings-flash: settings-flash 600ms ease-out;

  /* Navigation highlight — played once when the settings search jumps to a
     field. Neutral primary outline (not the destructive red of settings-flash,
     which signals a validation error). A dedicated one-shot class so the
     imperative classList toggle can't collide with a field's own React
     className. */
  @keyframes settings-nav-flash {
    0% {
      outline: 2px solid color-mix(in oklab, var(--primary) 0%, transparent);
      outline-offset: 2px;
    }
    25% {
      outline: 2px solid color-mix(in oklab, var(--primary) 70%, transparent);
      outline-offset: 2px;
    }
    100% {
      outline: 2px solid color-mix(in oklab, var(--primary) 0%, transparent);
      outline-offset: 2px;
    }
  }

  --animate-settings-nav-flash: settings-nav-flash 700ms ease-out;
}

/* Push-mode pulse hint — plays once when an in-sidebar action (file pick,
   wiki-link follow) lands while the sidebar is open at small width.
   Honors prefers-reduced-motion. The selector targets the SidebarInset's
   data-push-pulse attribute set by SidebarProvider. */
[data-slot="sidebar-inset"][data-push-pulse] {
  animation: var(--animate-sidebar-push-pulse);
}
@media (prefers-reduced-motion: reduce) {
  [data-slot="sidebar-inset"][data-push-pulse] {
    animation: none;
  }
  .animate-settings-flash {
    animation: none;
  }
  .animate-settings-nav-flash {
    animation: none;
  }
}

/* Dialog/Sheet overlays carry a viewport-sized `backdrop-filter: blur` over
   the live editor. The blur is engine-acknowledged expensive (WebKit warns;
   Chromium + Firefox have documented compositor jank) and, more importantly,
   is exactly the visual effect prefers-reduced-transparency exists to
   suppress. Stripping it at the primitive level means every Dialog/Sheet
   consumer inherits the compliant behavior with no per-call-site opt-in.

   This is a sibling of — not a modification to — the electron outer-canvas
   reduced-transparency block lower in this file, which intentionally excludes
   dialog/tooltip surfaces (those are opaque-always there). Unlayered, so it
   wins over the layered `supports-backdrop-filter:*` utility without
   `!important` (same cascade discipline as the reduced-motion block above). */
@media (prefers-reduced-transparency: reduce) {
  [data-slot="dialog-overlay"],
  [data-slot="sheet-overlay"],
  [data-slot="alert-dialog-overlay"],
  [data-slot="pack-card-reveal"] {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* Radix Collapsible content height + opacity. Height drives the reflow of
   surrounding content; opacity hides children early so the eye never lingers
   on partially-laid-out widgets. Closing easing front-loaded (ease-in) so the
   fade leads the height collapse — content reads as "gone" before the gap
   finishes closing. */
@keyframes collapsible-down {
  from {
    height: 0;
    opacity: 0;
  }
  to {
    height: var(--radix-collapsible-content-height);
    opacity: 1;
  }
}
@keyframes collapsible-up {
  from {
    height: var(--radix-collapsible-content-height);
    opacity: 1;
  }
  to {
    height: 0;
    opacity: 0;
  }
}

/* Text shimmer: a light band sweeps through the text via a clipped gradient,
   used on the agent-thread "starting/installing/connecting" status line so the
   wait reads as working. Text-only (relies on `background-clip: text`), so it
   has no effect on non-text (SVG/icon) elements. Registered as a real Tailwind
   utility (not a plain class) so state variants can also drive it. */
@utility shimmer {
  background: linear-gradient(
    90deg,
    var(--muted-foreground) 25%,
    var(--foreground) 50%,
    var(--muted-foreground) 75%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* Pin the shimmer static for reduced-motion users. Stopping the animation
   alone leaves `background-clip: text` + transparent fill, which freezes a
   gradient band across the text; reset both so it renders as plain
   muted-foreground. */
@media (prefers-reduced-motion: reduce) {
  .shimmer {
    animation: none;
    background: none;
    -webkit-text-fill-color: var(--muted-foreground);
    color: var(--muted-foreground);
  }
}

/* A quieter shimmer for the agent-thread starting state, whose status line sits
   alone in an otherwise empty pane. The sweep runs from `--muted-foreground` to
   a 35% mix toward `--foreground`, so its floor is the contrast the text would
   have had unswept and its peak stays far below the default utility's full
   `--foreground`. Mixing toward `--background` instead would drop the trough
   under WCAG AA on the default light theme. */
@utility shimmer-subtle {
  background: linear-gradient(
    90deg,
    var(--muted-foreground) 25%,
    color-mix(in oklab, var(--foreground) 35%, var(--muted-foreground)) 50%,
    var(--muted-foreground) 75%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 1.5s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .shimmer-subtle {
    animation: none;
    background: none;
    -webkit-text-fill-color: var(--muted-foreground);
    color: var(--muted-foreground);
  }
}

@utility floating-card-surface {
  @apply rounded-lg border border-border bg-card shadow-[0_2px_8px_0_rgb(0_0_0/0.08),0_1px_2px_-1px_rgb(0_0_0/0.1)];
}

@utility corner-card-column {
  & .floating-card-surface {
    pointer-events: auto;
  }
}

/* UPSTREAM([email protected]): a modal Radix menu or dialog locks the page by writing pointer-events none inline on body, and the cards must honor that lock. */
body[style*="pointer-events: none"] .corner-card-column .floating-card-surface {
  pointer-events: none;
}

/* Reduced-motion override — keep the opacity crossfade as a comprehension
   aid (the panel still appears/disappears) but pin the height so the
   layout-triggering animation doesn't fire. Matches the rest of this
   file's reduced-motion discipline. */
@media (prefers-reduced-motion: reduce) {
  @keyframes collapsible-down {
    from {
      height: var(--radix-collapsible-content-height);
      opacity: 0;
    }
    to {
      height: var(--radix-collapsible-content-height);
      opacity: 1;
    }
  }
  @keyframes collapsible-up {
    from {
      height: var(--radix-collapsible-content-height);
      opacity: 1;
    }
    to {
      height: var(--radix-collapsible-content-height);
      opacity: 0;
    }
  }
}

/* Base styles */
@layer base {
  *,
  *::before,
  *::after {
    border-color: var(--color-border);
  }

  body {
    @apply font-sans bg-sidebar text-foreground;
  }
  * {
    @apply border-border outline-ring/50;
  }
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
  html {
    @apply font-sans;
  }
}

/* Agent flash — surgical, survives ProseMirror reconciliation.
   The data-agent-flash-state attribute lives on the React wrapper (stable across PM updates).
   Targets only the last 3 blocks (append) or first 3 blocks (prepend) — covers most agent writes.
   Uses :nth-last-child / :nth-child to scope the flash without touching PM-managed DOM.
   The append half counts `of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)` because
   both are widget decorations that render as a direct .ProseMirror child at the document end.
   Counting either would shift the append flash one block up while it is showing. CSS cannot
   import OK_TRAILING_AFFORDANCE_CLASS from editor/extensions/trailing-affordance.ts, so this
   list is the one place carrying the names literally; globals.test.ts pins them together.

   The append and prepend halves are separate rules on purpose rather than one comma-joined
   prelude. A selector list is invalidated as a whole, so on a UA that cannot parse `of S` the
   prepend half would lose its flash too, though it uses no Selectors L4 syntax of its own.

   Staggered entry (30ms per block) via animation-delay for a cascading feel on multi-block writes. */

/* Position-accurate agent-insert flash — inline decoration class applied by
   the agent-insert-flash PM plugin to the exact ranges a remote agent write
   changed. `box-decoration-break: clone` keeps wrapped lines individually
   rounded; duration matches AGENT_INSERT_FLASH_MS in agent-insert-flash.ts. */
.ok-agent-insert-flash {
  animation: agent-insert-flash 1.4s var(--ease-out-strong) forwards;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

@media (prefers-reduced-motion: reduce) {
  .ok-agent-insert-flash {
    animation-duration: 1ms;
  }
}

/* The agent-ready settle keeps its fade for reduced-motion viewers — it is what
   marks the agent becoming usable — and drops only the spatial part. */
@media (prefers-reduced-motion: reduce) {
  .animate-agent-ready-settle {
    animation-name: agent-ready-fade;
  }
}

@keyframes agent-ready-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Landing flash — transient highlight on the range a mode-switch jump lands on
   (landing-flash-source.ts / landing-flash-wysiwyg.ts). A dedicated class, not
   the agent-write flash, so its treatment can diverge from the agent wash later
   without touching attribution; it reuses the shared agent-flash keyframe today.
   Inline decoration in both editors, so one rule covers CodeMirror and
   ProseMirror. box-decoration-break keeps a wrapped multi-line range
   individually accented; duration matches FLASH_DURATION_MS. */
.ok-landing-flash {
  animation: agent-flash 2s var(--ease-out-strong) forwards;
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  position: relative;
}

/* Reduced motion — static terracotta accent bar, no movement or background sweep. */
@media (prefers-reduced-motion: reduce) {
  .ok-landing-flash {
    animation: none;
    box-shadow: inset 3px 0 0 var(--color-agent);
    transition: box-shadow 2s ease;
  }
}

[data-agent-flash-state="editing"][data-agent-flash-position="append"]
  .ProseMirror
  > *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {
  animation: agent-flash 2s var(--ease-out-strong) forwards;
  position: relative;
}
[data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
  .ProseMirror
  > *:nth-child(-n + 3) {
  animation: agent-flash 2s var(--ease-out-strong) forwards;
  position: relative;
}

/* Stagger — second affected block fires 30ms after first, third at 60ms */
[data-agent-flash-state="editing"][data-agent-flash-position="append"]
  .ProseMirror
  > *:nth-last-child(2 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {
  animation-delay: 30ms;
}
[data-agent-flash-state="editing"][data-agent-flash-position="append"]
  .ProseMirror
  > *:nth-last-child(1 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {
  animation-delay: 0ms;
}
[data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
  .ProseMirror
  > *:nth-child(1) {
  animation-delay: 0ms;
}
[data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
  .ProseMirror
  > *:nth-child(2) {
  animation-delay: 30ms;
}
[data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
  .ProseMirror
  > *:nth-child(3) {
  animation-delay: 60ms;
}

/* Reduced motion — keep a color fade for comprehension, remove movement.
   Static terracotta left accent bar fades in, no transform, no background tint.
   The fade is an animation, not a transition: these blocks keep `transition`
   for the `.ok-chunk-wrapper` content-visibility deferral, and a `transition`
   here would replace it while the flash lasts. */
@keyframes ok-agent-flash-bar {
  from {
    box-shadow: none;
  }
  to {
    box-shadow: inset 3px 0 0 var(--color-agent);
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-agent-flash-state="editing"][data-agent-flash-position="append"]
    .ProseMirror
    > *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {
    animation: ok-agent-flash-bar 2s ease forwards;
    box-shadow: inset 3px 0 0 var(--color-agent);
  }
  [data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
    .ProseMirror
    > *:nth-child(-n + 3) {
    animation: ok-agent-flash-bar 2s ease forwards;
    box-shadow: inset 3px 0 0 var(--color-agent);
  }
}

/* OK Blob mascot */

/* 3D wrapper — hosts perspective + cursor-following rotateX/rotateY so the
   head can tilt independently of the click-bounce transform on .ok-blob-group.
   Inline-flex avoids inline-block whitespace gaps. */
.ok-blob-3d-wrapper {
  display: inline-flex;
  perspective: 400px;
  transform-style: preserve-3d;
  will-change: transform;
  /* Rapid-click on the mascot would otherwise trigger the browser's
     double-click/triple-click selection gesture and select surrounding text. */
  user-select: none;
  -webkit-user-select: none;
}

/* Group wrapper — the click bounce animates the group so body + eyes squish together. */
.ok-blob-group {
  transform-box: fill-box;
  transform-origin: center bottom;
}

.ok-blob-body {
  fill: var(--color-azure-blue);
  animation: ok-blob-squish 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center bottom;
}
.dark .ok-blob-body {
  fill: var(--color-sky-blue);
}

.ok-blob-eye {
  fill: var(--color-azure-blue);
  animation: ok-blob-blink 6s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.dark .ok-blob-eye {
  fill: var(--color-sky-blue);
}
.ok-blob-eye-right {
  animation-delay: 0.04s;
}

/* Single blink then long pause */
@keyframes ok-blob-blink {
  0%,
  28%,
  34%,
  100% {
    transform: scaleY(1);
  }
  30%,
  32% {
    transform: scaleY(0.05);
  }
}

/* Body squish synced to the blink */
@keyframes ok-blob-squish {
  0%,
  28%,
  38%,
  100% {
    transform: scaleY(1) scaleX(1);
  }
  30% {
    transform: scaleY(0.97) scaleX(1.02);
  }
  33% {
    transform: scaleY(1.02) scaleX(0.99);
  }
  36% {
    transform: scaleY(1) scaleX(1);
  }
}

/* Click — happy ^^ eyes + bounce */
.ok-blob-eye-hidden {
  opacity: 0;
}

.ok-blob-happy-eye {
  stroke: var(--color-azure-blue);
  transition: opacity 100ms ease;
}
.dark .ok-blob-happy-eye {
  stroke: var(--color-sky-blue);
}

@keyframes ok-blob-click-bounce {
  0% {
    transform: scaleY(1) scaleX(1);
  }
  20% {
    transform: scaleY(0.9) scaleX(1.08);
  }
  45% {
    transform: scaleY(1.06) scaleX(0.96);
  }
  70% {
    transform: scaleY(0.98) scaleX(1.01);
  }
  100% {
    transform: scaleY(1) scaleX(1);
  }
}

/* Level 2 — rapid click, bouncier + snappier */
@keyframes ok-blob-click-bounce-2 {
  0% {
    transform: scaleY(1) scaleX(1);
  }
  20% {
    transform: scaleY(0.84) scaleX(1.13);
  }
  45% {
    transform: scaleY(1.1) scaleX(0.93);
  }
  70% {
    transform: scaleY(0.97) scaleX(1.02);
  }
  100% {
    transform: scaleY(1) scaleX(1);
  }
}

/* Level 3 — rage click, max squish + max stretch */
@keyframes ok-blob-click-bounce-3 {
  0% {
    transform: scaleY(1) scaleX(1);
  }
  18% {
    transform: scaleY(0.76) scaleX(1.2);
  }
  42% {
    transform: scaleY(1.16) scaleX(0.88);
  }
  65% {
    transform: scaleY(0.96) scaleX(1.03);
  }
  85% {
    transform: scaleY(1.02) scaleX(0.99);
  }
  100% {
    transform: scaleY(1) scaleX(1);
  }
}

.ok-blob-clicked-1 {
  animation: ok-blob-click-bounce 500ms var(--ease-out-strong) forwards;
}
.ok-blob-clicked-2 {
  animation: ok-blob-click-bounce-2 550ms var(--ease-out-strong) forwards;
}
.ok-blob-clicked-3 {
  animation: ok-blob-click-bounce-3 650ms var(--ease-out-strong) forwards;
}

/* Firework burst — radial particles launch from the blob center, translate
   outward with varied distance/size/delay/duration, then fade. Per-particle
   variation is pumped in via CSS custom properties (--fx-tx, --fx-ty,
   --fx-delay, --fx-duration) set inline by the React component so one keyframe
   serves every spark. */
.ok-blob-firework {
  transform-box: fill-box;
  transform-origin: center;
  animation: ok-blob-firework-pop var(--fx-duration, 700ms) var(--ease-out-strong)
    var(--fx-delay, 0ms) forwards;
}

@keyframes ok-blob-firework-pop {
  0% {
    transform: translate(0, 0) scale(0.2);
    opacity: 0;
  }
  12% {
    transform: translate(calc(var(--fx-tx, 0px) * 0.22), calc(var(--fx-ty, 0px) * 0.22)) scale(1.35);
    opacity: 1;
  }
  70% {
    transform: translate(var(--fx-tx, 0px), var(--fx-ty, 0px)) scale(0.7);
    opacity: 0.7;
  }
  100% {
    transform: translate(var(--fx-tx, 0px), var(--fx-ty, 0px)) scale(0.1);
    opacity: 0;
  }
}

/* Sleeping state — closed eyelids + gentler body motion + floating "z"s.
   The sleeping class lives on the group, so descendant selectors pause the
   blink/squish animations without removing them entirely (a very slow rest
   cycle reads as breathing). */
.ok-blob-sleeping .ok-blob-body {
  animation: ok-blob-sleeping-breathe 4.8s ease-in-out infinite;
}
.ok-blob-sleeping .ok-blob-eye {
  animation: none;
}

.ok-blob-sleeping-eye {
  stroke: var(--color-azure-blue);
  opacity: 0.9;
}
.dark .ok-blob-sleeping-eye {
  stroke: var(--color-sky-blue);
}

@keyframes ok-blob-sleeping-breathe {
  0%,
  100% {
    transform: scaleY(1) scaleX(1);
  }
  50% {
    transform: scaleY(0.985) scaleX(1.01);
  }
}

/* Floating z letters — drift up + fade. Two instances with staggered delay
   and different travel so the rhythm doesn't look mechanical. */
.ok-blob-z {
  font-family: var(--font-geist-sans, ui-sans-serif, system-ui, sans-serif);
  font-size: 6px;
  font-style: italic;
  font-weight: 600;
  fill: var(--color-azure-blue);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.dark .ok-blob-z {
  fill: var(--color-sky-blue);
}
.ok-blob-z-1 {
  animation: ok-blob-z-float 2.4s ease-out 0s infinite;
}
.ok-blob-z-2 {
  animation: ok-blob-z-float 2.4s ease-out 1.2s infinite;
}

@keyframes ok-blob-z-float {
  0% {
    transform: translate(0, 0) scale(0.7);
    opacity: 0;
  }
  20% {
    opacity: 0.85;
  }
  100% {
    transform: translate(3px, -6px) scale(1.1);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ok-blob-eye {
    animation: none;
  }
  .ok-blob-body {
    animation: none;
  }
  .ok-blob-clicked-1,
  .ok-blob-clicked-2,
  .ok-blob-clicked-3 {
    animation: none;
  }
  .ok-blob-firework {
    display: none;
  }
  .ok-blob-sleeping .ok-blob-body,
  .ok-blob-z-1,
  .ok-blob-z-2 {
    animation: none;
  }
  .ok-blob-z {
    opacity: 0.7;
  }
}

/* Working avatar (agent-thread "working" row) — the personality layer on top of
   the JS-driven shape morph in WorkingAvatar.tsx. The morph itself sets `d`
   every frame; everything here is squash, blink and squint applied on top.
   `transform-box: fill-box` is required — SVG children default to the
   viewport's coordinate box, so a percentage transform-origin would otherwise
   resolve against the wrong rect. */
/* The row arrives when a turn opens. Short enough to stay under the
   interactive-UI ceiling — this is a state change you see on every turn, not a
   scroll reveal you see once. Compositor-only (opacity + transform). */
.ok-working-enter {
  animation: ok-working-enter 180ms var(--ease-out-strong) both;
}

@keyframes ok-working-enter {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
}

/* The status line rewrites itself several times a turn as the agent moves
   between tools, and a hard text swap reads as a glitch rather than a change.
   A short fade with a touch of blur bridges the two states — the blur is what
   makes an un-crossfadeable swap (the outgoing text is already gone) still
   read as one transformation. Kept well under the 20px where blur gets
   expensive. */
.ok-working-status {
  animation: ok-working-status-in 200ms var(--ease-out-strong) both;
}

@keyframes ok-working-status-in {
  from {
    opacity: 0;
    filter: blur(2px);
  }
}

.ok-working-group {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* Needed by the squint below — SVG children resolve a percentage
   transform-origin against the viewport box, not their own. */
.ok-working-eye {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* Four squash beats per cycle — the "still going" tell on long tasks. The
   strong in-out curve is what makes each beat land as a squash; the built-in
   `ease-in-out` is too weak and reads as a slow pulse instead. */
.ok-working-pop .ok-working-group {
  animation: ok-working-pop 4.8s var(--ease-in-out-strong) infinite;
}

@keyframes ok-working-pop {
  0%,
  25%,
  50%,
  75%,
  100% {
    transform: scale(1);
  }
  12%,
  37%,
  62%,
  87% {
    transform: scale(1.1, 0.9);
  }
}

/* Effort tell. Replaces the ambient blink by specificity — the mascot is
   squinting at the work, not idly blinking at you. */
.ok-working-squint .ok-working-eye {
  animation: ok-working-squint 1.8s ease-in-out infinite;
}

@keyframes ok-working-squint {
  0%,
  44%,
  100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.35);
  }
  56% {
    transform: scaleY(1);
  }
}

/* Reduced motion pins the avatar to its resting pose. The shape morph is
   suppressed in JS (the rAF loop never subscribes), so only the CSS layer
   needs stopping here. The entrance keeps its opacity fade and loses only the
   spatial travel — the fade is what tells you a new row appeared, and dropping
   it would make the working state blink into existence with no warning. */
@media (prefers-reduced-motion: reduce) {
  .ok-working-group,
  .ok-working-eye,
  .ok-working-pop .ok-working-group,
  .ok-working-squint .ok-working-eye {
    animation: none;
  }
  .ok-working-enter {
    animation-name: ok-working-enter-fade;
  }
  /* The status swap keeps its fade but drops the blur — blur is a spatial
     effect, and the fade alone still marks the line as having changed. */
  .ok-working-status {
    animation-name: ok-working-enter-fade;
  }
}

@keyframes ok-working-enter-fade {
  from {
    opacity: 0;
  }
}

/* Collaboration cursor styles (WYSIWYG — TipTap) */
.collaboration-cursor__caret {
  position: relative;
  margin-left: -1px;
  margin-right: -1px;
  border-left: 2px solid;
  border-right: 0;
  word-break: normal;
  pointer-events: none;
}

.collaboration-cursor__label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.collaboration-cursor__label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 1.5px 6px;
  border-radius: 5px 5px 5px 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

/* CodeMirror cursor styles (Source mode) */
.cm-ySelectionCaret {
  position: relative;
  border-left: 2px solid;
  margin-left: -1px;
  margin-right: -1px;
  pointer-events: none;
  word-break: normal;
}

.cm-ySelectionInfo {
  position: absolute;
  top: -1.4em;
  left: -1px;
  padding: 1px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  color: #fff;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  z-index: 10;
}

.cm-ySelection {
  opacity: 0.3;
}

section[data-editor-pane-id] {
  container-type: inline-size;
  container-name: editor-document;
}

/* Editor layout — grid on wrapper; content column max 1024px (lg), side rails minmax(gutter, 1fr) */
.tiptap-editor {
  --content-max-width: 1024px;
  --margin-width: 4rem;
  display: grid;
  width: 100%;
  grid-template-columns:
    [full-start] minmax(var(--margin-left-width, var(--margin-width)), 1fr)
    [content-start] minmax(0, min(var(--content-max-width), 100%))
    [content-end] minmax(var(--margin-right-width, var(--margin-width)), 1fr)
    [full-end];
}

/* Same content-column grid as .tiptap-editor — applied to siblings (e.g., the
   property panel) so they horizontally align with the editor body. Variables
   redeclared here so this class doesn't depend on living inside .tiptap-editor. */
.editor-content-aligned {
  --content-max-width: 1024px;
  --margin-width: 4rem;
  display: grid;
  width: 100%;
  grid-template-columns:
    [full-start] minmax(var(--margin-left-width, var(--margin-width)), 1fr)
    [content-start] minmax(0, min(var(--content-max-width), 100%))
    [content-end] minmax(var(--margin-right-width, var(--margin-width)), 1fr)
    [full-end];
}

.editor-content-aligned > * {
  grid-column: content;
}

@property --ask-composer-height {
  syntax: "<length>";
  initial-value: 0px;
  inherits: false;
}

/* The floating Ask AI composer reserves scroll room at the bottom of the doc by
   padding the editor CONTENT (.ProseMirror / .cm-content) — padding the scroll
   container alone creates no overflow because the content's own min-height fills
   it. The inset tracks the live composer via `--ask-composer-height` (card height
   + gap, published by BottomComposer); the var resolves to 0px when the composer is
   collapsed or hidden, so the space is reclaimed — no class to fall out of sync. Scoped inside
   `.editor-doc-scroll` so the floating composer's own ProseMirror (a sibling of
   the scroll container) is never padded. */
.editor-doc-scroll {
  scroll-padding-bottom: var(--ask-composer-height, 0px);
}
.editor-doc-scroll :is(.ProseMirror, .cm-content) {
  /* Composer inset ADDS to the trailing dead zone rather than replacing it —
     this selector outranks the base `.ProseMirror` rule, so a bare
     `var(--ask-composer-height)` here would zero the zone out from under the
     affordance for every document in the scroller. `--ok-trailing-zone` is
     declared on `.ProseMirror` only, so `.cm-content` takes the 0px fallback
     and source mode is unchanged. */
  padding-bottom: calc(var(--ask-composer-height, 0px) + var(--ok-trailing-zone, 0px));
}

/* Standalone Mermaid docs render inside `.editor-doc-scroll` like every other
   pool branch, but the host itself is a diagram + source pane rather than a
   `.ProseMirror` / `.cm-content` element, so the inset above never selects it.
   Reserve the composer height on the whole editor so a full-page
   panzoom diagram (which does not scroll) and the source pane's last lines clear
   the floating card. The var is 0 when the composer is collapsed/hidden, so the
   space is reclaimed with no class to fall out of sync. */
[data-mermaid-doc-editor] {
  padding-bottom: var(--ask-composer-height, 0px);
}

/* Conflict surface scroller: same composer inset so the last hunks (and
   their inline Accept/Reject controls) can scroll clear of the floating
   composer. The conflict footer itself needs no inset — the composer anchors
   above it via `--conflict-footer-height` (see use-conflict-footer-height.ts). */
.conflict-view {
  scroll-padding-bottom: var(--ask-composer-height, 0px);
}

/* `scroll-padding-bottom` above only moves the scroll ANCHOR; it adds no
   scrollable space, so the last rows still sit under the floating composer with
   no way to reach them. The room has to come from padding the CONTENT, which is
   what the editor does via `.cm-content` / `.ProseMirror`. Pierre's equivalent
   is the `<diffs-container>` host it renders into — the CodeMirror rule this
   replaces (`.diff-view .cm-content`) went away with the merge view and had no
   successor until now. The var is 0 when the composer is collapsed or hidden,
   so the space is reclaimed on its own.

   Scoped to `.conflict-view` deliberately: the inset exists for surfaces that
   sit under the floating ask composer. A Pierre diff inside a dialog has no
   composer to clear. */
/* Pierre renders into a `<diffs-container>` custom element. Undefined/custom
   elements get no UA display styling and default to `display: inline`, and
   @pierre/[email protected] never sets `display` on `:host` (its `:host` block is
   custom properties only; every `display: block` in its shadow stylesheet
   targets inner nodes -- `pre, code, [data-error-wrapper]`,
   `[data-unmodified-lines]`, `&:before`). An inline host ignores width,
   padding and block layout, which is what the `padding-bottom` rule below
   depends on.

   Both selectors are needed because the class lands in different places.
   `MultiFileDiff` forwards `className` ONTO the host, so for the panel and
   dialog surfaces `.pierre-diff` IS the `<diffs-container>`. `ConflictView`
   and `ConflictFilePreview` instead put `conflict-view` on a wrapper and
   render the host inside it, so there it is a descendant. A single
   `.pierre-diff diffs-container` descendant rule matches NEITHER group's
   host for the first three surfaces and was silently dead. */
.pierre-diff,
.conflict-view diffs-container {
  display: block;
}

.conflict-view diffs-container {
  padding-bottom: var(--ask-composer-height, 0px);
}

/* Ease the inset + composer entrance so collapsing/expanding glides instead of a
   hard jump cut. Only the `.editor-doc-scroll` content inset is eased. The host-route
   inset (`[data-mermaid-doc-editor]`) steps in one frame because it pads a border box
   that also carries the non-scrolling diagram pane, so easing it would animate the
   diagram's viewport rather than a text inset. The conflict surface's
   `.conflict-view diffs-container` is a content inset of the same shape as the eased
   rule, so easing it would be structurally sound. It is left unanimated because that
   surface has no measured geometry coverage, and an easing change there cannot be
   verified against the re-clamp.
   The per-frame scroll re-clamp in BottomComposer keeps the bottom pinned either
   way. `bottom` is
   included because the composer's anchor tracks `--conflict-footer-height`, which
   flips between 0 and the conflict footer's height when conflict mode
   mounts/unmounts. Reduced-motion users get the instant change. */
@media (prefers-reduced-motion: no-preference) {
  .editor-doc-scroll :is(.ProseMirror, .cm-content) {
    transition: padding-bottom 240ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  [data-testid="bottom-composer"] {
    transition:
      opacity 200ms ease,
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
      bottom 240ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  @starting-style {
    [data-testid="bottom-composer"] {
      opacity: 0;
      transform: translateY(8px);
    }
  }
}

/* Content-column children. The `.tiptap-editor` wrapper is a 3-column named
 * grid ([full-start] margin [content-start] content [content-end] margin
 * [full-end]). Direct children default to `grid-column: content` so editor
 * chrome — EditorContent, future <nav>/<header>/<footer>
 * — lands in the content column. An earlier version of this rule targeted
 * `> div` specifically, which worked while every child was a <div> but
 * silently broke semantic elements: a direct <nav> child auto-placed into
 * the right-margin track (width = --margin-width = 4rem), truncating its
 * content into a ~64px vertical sliver. Widened to `> *` so the rule's
 * intent ("content-column children") matches the CSS. Edge-to-edge
 * elements that want a different track can explicit-override with
 * `grid-column: full`.
 */
.tiptap-editor > * {
  grid-column: content;
  position: relative;
}

/* H6 cross-doc-bleed structural fix: `<EditorContent>`'s refDiv is rendered
 * via `React.createPortal` into a per-Activity `data-ok-editor-portal` div,
 * which itself is appended into a JSX `portalSlot` placeholder (`display:
 * contents`) inside `.tiptap-editor`. Both wrappers use `display: contents`
 * so the refDiv remains the effective grid item of `.tiptap-editor` — same
 * grid placement, scroll geometry, and box model as the pre-portal inline
 * `<EditorContent>` mount.
 *
 * The `.tiptap-editor > *` rule above selects DOM DIRECT children only.
 * Two layers of `display: contents` (portalSlot + portalTarget) make the
 * refDiv a DOM great-grandchild of `.tiptap-editor` even though, for grid
 * layout purposes, it acts as a direct grid item. The descendant selector
 * `.tiptap-editor .tiptap-editor-portal-content` matches it explicitly and
 * applies the same `grid-column: content; position: relative` that the
 * inline refDiv used to inherit via `.tiptap-editor > *`. Without this
 * rule, the refDiv falls into the first grid track (the left margin) at
 * intrinsic-min width and collapses ProseMirror to a ~104px column —
 * surfaced via the slash-menu's `onMouseEnter` racing the cursor's now-
 * overlapping popup.
 */
.tiptap-editor .tiptap-editor-portal-content {
  grid-column: content;
  /* Explicit row: `.ok-table-cell-handle-layer` is pinned to row 1 to share
     this row (see that rule for why); without an explicit row here,
     auto-placement would skip the occupied content-column cell and bump the
     editor body to row 2 whenever the cursor is in a table. */
  grid-row: 1;
  position: relative;
}

/* Editor polish */
.ProseMirror {
  outline: none;
  min-height: 200px;
  line-height: 1.7;
  /* Trailing dead zone — the click target `TrailingAffordance` engages in, and
     the reason it is a token rather than incidental slack. The extension reads
     the band between the last block's bottom and this element's bottom, and a
     block's own `margin-bottom` collapses THROUGH a parent with no bottom
     padding: with `padding-bottom: 0` those two edges are the same pixel and
     the band is exactly 0px tall. That is the state a document is in whenever
     the Ask composer is unmounted. With the composer
     mounted the scroller rule above does supply padding, but the composer
     floats over precisely that band, so the only room ever left to click was
     whatever `margin-bottom` the final block happened to carry. The old
     `trailingNode` paragraph supplied this height as content; 2rem reproduces
     it as layout. Anything that zeroes this silently un-ships the affordance,
     so an e2e pins it by asserting this element's resolved `padding-bottom`
     equals the composer inset plus this token, and a second assertion measures
     the band directly. That direct reading pins the token only because
     `measureZoneHeight` subtracts the other two terms sharing this edge: the
     composer's reserved inset, and the final block's own `margin-bottom`, which
     does not collapse through a padded parent and on this fixture already
     exceeds the floor on its own. A naive band measurement would stay plausible
     with the token gone, and that subtraction is what lets this one go red.

     The base is 0px and the height is granted by the opt-in rule below, so the
     CSS predicate matches the plugin's own bail (`view.editable`) instead of
     approximating it. A read-only view and every non-editor ProseMirror get no
     dead zone rather than an unreachable one. */
  --ok-trailing-zone: 0px;
  padding-bottom: var(--ok-trailing-zone);
  /* Extend hit area into left margin so the gap between text and the drag handle
     does not prematurely hide it. padding-left compensates so text is unchanged. */
  margin-left: -2.5rem;
  padding-left: 2.5rem;
  /* Mirror the same negative-margin/padding trick on the right. Without it, the
     content box's right edge sits flush with the editor element's border-box
     right edge (content-end), so a `w-full` bordered block (e.g. the empty-Mermaid
     placeholder card) paints its right border with ZERO in-element slack — the
     left border has 2.5rem of it. Any right-side clip (an overflow ancestor's edge
     or a scrollbar gutter at wide widths) then shaves that flush 1px right border
     while the slack-protected left/top/bottom survive. Extending the border-box
     2.5rem into the right gutter (padding-right compensates, so text and every
     block stay put) gives the right border the same slack the left already has. */
  margin-right: -2.5rem;
  padding-right: 2.5rem;
  @apply text-gray-800 dark:text-white/80;
}

/* The dead zone, granted only where the affordance can actually engage. The
   selector is the CSS half of `trailingAffordancePlugin`'s `view.editable`
   bail; the composer opts out because its editor is a slim one-line prompt
   whose own rule zeroes `min-height`, and 2rem of unclickable padding under it
   reads as a broken text box. This wins on specificity, not position: the
   attribute selector and the class inside `:not()` each add a class-level
   point, so (0,3,0) against the base rule's (0,1,0). Raising the base rule's
   specificity is what would break it, not moving this block. */
.ProseMirror[contenteditable="true"]:not(.composer-prosemirror) {
  --ok-trailing-zone: 2rem;
}

@container editor-document (width < 40rem) {
  .tiptap-editor,
  .property-panel {
    --margin-left-width: 3.75rem;
    --margin-right-width: 1rem;
  }

  .tiptap-editor:where(:dir(rtl)),
  .property-panel:where(:dir(rtl)) {
    --margin-left-width: 1rem;
    --margin-right-width: 3.75rem;
  }

  .editor-content-aligned:where(:not(.property-panel)) {
    --margin-left-width: 1rem;
    --margin-right-width: 1rem;
  }

  .ProseMirror:not(.composer-prosemirror) {
    margin-right: -1rem;
    padding-right: 1rem;
  }
}

@media (width < 40rem) and (pointer: coarse) {
  .tiptap-editor,
  .editor-content-aligned {
    --margin-width: 1rem;
    --margin-left-width: 1rem;
    --margin-right-width: 1rem;
  }

  .ProseMirror {
    margin-left: -1rem;
    padding-left: 1rem;
    margin-right: -1rem;
    padding-right: 1rem;
  }
}

.ProseMirror p {
  margin-bottom: 0.5em;
}

/* Document text takes its writing direction from what the user wrote, never
   from the interface language. `<html dir>` carries the chrome's direction and
   `direction` inherits, so without this an Arabic interface would lay out an
   English paragraph right-to-left, and an English interface would flatten
   Arabic prose to left-to-right. `plaintext` resolves each block's base
   direction from its own first strong character — the CSS form of `dir="auto"`,
   and the only form available here because ProseMirror and CodeMirror own this
   DOM and emit no attributes we could set.

   Scoped to block-level nodes on purpose. `unicode-bidi` does not inherit, so
   the editor root alone would only cover text directly inside it; applying it
   to every descendant instead would isolate each inline mark as its own run and
   reorder mixed-direction text WITHIN a sentence, which is the opposite of what
   this is for.

   WYSIWYG only. Source mode's direction comes from CodeMirror's
   `perLineTextDirection` facet, not from here — CodeMirror keeps its own model
   of the bidi order to place the caret, so a CSS-only override would move the
   glyphs out from under the cursor. */
.ProseMirror,
.ProseMirror :is(p, h1, h2, h3, h4, h5, h6, li, blockquote, pre, td, th, dt, dd, figcaption) {
  unicode-bidi: plaintext;
}

/* The bottom "Ask AI" composer reuses a ProseMirror view but is a slim prompt
   field, not a document body: drop the 200px min-height and the drag-handle
   left margin/padding so it rests at one line and its text origin aligns with
   the placeholder overlay. Higher specificity (.ProseMirror.composer-prosemirror)
   beats the unlayered base rule above; a Tailwind `min-h-0` utility would not. */
.ProseMirror.composer-prosemirror {
  min-height: 0;
  line-height: 1.5;
  margin-left: 0;
  padding-left: 0;
  /* STOP: 0.25rem mirrors this element's own `py-1` top; 0 un-centres the composer row. */
  padding-bottom: 0.25rem;
  /* Drop the right gutter mirror too — the slim composer is a single-line prompt,
     not a document body, so it needs neither the drag-handle hit area nor the
     full-width-block border slack. */
  margin-right: 0;
  padding-right: 0;
}

.ProseMirror.composer-prosemirror p {
  margin-bottom: 0;
}

/* Inline `@`-mention chip in the composer — VISUALLY INDISTINGUISHABLE from the
   host-level ComposerContextChips top-row chip (`FileChip`): a user can't tell an
   inline chip from a top-row chip by looking, only by where it sits. Each rule
   below maps token-for-token to a Tailwind class on the top-row chip so the two
   stay in lockstep. The top-row container is:
     inline-flex max-w-[14rem] items-center gap-1 rounded-md border bg-muted/40
     py-0.5 pr-1.5 pl-1 text-muted-foreground text-xs
   and its leading icon-button is `size-3.5 rounded-sm` holding a `size-3` glyph
   that cross-fades file-icon → X.

   Like the top-row chip, the LEADING icon doubles as the remove control (Cursor
   pattern): NO trailing × and no reserved trailing slot — at rest the chip is
   fully tight (leading `@` marker + label). The reveal is LAYOUT-NEUTRAL: the
   leading cell is fixed-size and holds two stacked glyphs (`@` and `×`); on
   hover/`:focus-within` they cross-fade via `opacity` ONLY (the `@` fades to 0,
   the `×` fades to 1) in the same cell, so the chip's box is identical hovered vs
   not and the inline prompt text never reflows (a width/margin-changing reveal
   here flickered: reflow shifted the chip out from under the cursor, toggling
   :hover off → shrink → reflow back → infinite). Single-line ONLY: `inline-flex`
   + bounded `max-width` + the label ellipsizes, so a long label truncates with
   `…` instead of wrapping. `vertical-align: middle` (inline-context-only — the
   top-row chip is a standalone flex row and doesn't need it) keeps the pill
   aligned with the surrounding prompt text. */
.composer-mention-chip {
  display: inline-flex; /* inline-flex */
  align-items: center; /* items-center */
  gap: 0.25rem; /* gap-1 */
  max-width: 14rem; /* max-w-[14rem] */
  border-radius: var(--radius-md); /* rounded-md */
  border: 1px solid var(--border); /* border */
  background-color: color-mix(in oklab, var(--muted) 40%, transparent); /* bg-muted/40 */
  padding: 0.125rem 0.375rem 0.125rem 0.25rem; /* py-0.5 pr-1.5 pl-1 */
  font-size: var(--text-xs); /* text-xs */
  line-height: 1rem; /* text-xs line-height — matches the top-row chip's pill height */
  color: var(--muted-foreground); /* text-muted-foreground */
  vertical-align: middle;
  white-space: nowrap;
  user-select: none;
}
/* The leading icon-button — the top-row chip's `size-3.5 rounded-sm` ghost
   icon-button: a fixed-size cell that overlays its two glyphs (so the cell never
   resizes during the cross-fade). It IS the remove control — focusable real
   `<button>` (Enter/Space activate natively), clickable cursor, accessible name
   set in the node view. The `text-muted-foreground/80 → hover:text-foreground`
   mirrors the top-row icon-button's color treatment. */
.composer-mention-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 0.875rem; /* size-3.5 */
  height: 0.875rem; /* size-3.5 */
  border-radius: var(--radius-sm); /* rounded-sm */
  line-height: 1;
  color: color-mix(in oklab, var(--muted-foreground) 80%, transparent);
  cursor: pointer;
}
.composer-mention-icon:hover {
  color: var(--foreground);
}
.composer-mention-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ring);
}
/* Both glyphs share the SAME `size-3`-equivalent cell (stacked + centered). Only
   `opacity` toggles — never layout — so the swap is reflow-free. Each glyph holds
   an inline lucide `<svg>` (injected by the node view), sized to the top-row
   chip's `size-3` (0.75rem) footprint and inheriting `currentColor` so the cell's
   `color` (muted-foreground → foreground on hover) drives the glyph — identical
   to the React-rendered top-row icon. The base rule is the static reduced-motion
   state (instant swap, no transition); the transition is added only under
   `prefers-reduced-motion: no-preference` below. */
.composer-mention-glyph {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.composer-mention-glyph svg {
  width: 0.75rem; /* size-3 — matches the top-row leading icon */
  height: 0.75rem;
}
.composer-mention-glyph-icon {
  opacity: 1;
}
.composer-mention-glyph-x {
  opacity: 0;
}
.composer-mention-chip:hover .composer-mention-glyph-icon,
.composer-mention-chip:focus-within .composer-mention-glyph-icon {
  opacity: 0;
}
.composer-mention-chip:hover .composer-mention-glyph-x,
.composer-mention-chip:focus-within .composer-mention-glyph-x {
  opacity: 1;
}
@media (prefers-reduced-motion: no-preference) {
  .composer-mention-glyph {
    transition: opacity 140ms ease;
  }
}
.composer-mention-label {
  min-width: 0; /* min-w-0 */
  overflow: hidden; /* truncate */
  white-space: nowrap; /* truncate */
  text-overflow: ellipsis; /* truncate */
}

/* The composer's leading `/command` token (decoration-styled text, not a chip
   node — see composer-slash-command.ts). Both states pair a SHAPE cue with the
   color so recognized vs unrecognized never rides color alone: recognized is a
   filled pill (like a chip), unrecognized a dashed underline (the "unresolved
   reference" idiom); the hint line under the field carries the textual
   explanation. */
.composer-slash-token {
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.composer-slash-token-known {
  background-color: color-mix(in oklab, var(--primary) 14%, transparent);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 28%, transparent);
  color: var(--foreground);
  padding: 0.0625rem 0.125rem;
}
.composer-slash-token-unknown {
  color: var(--muted-foreground);
  text-decoration: underline dashed;
  text-underline-offset: 3px;
}
/* In-field argument-hint ghost after a bare recognized /command (the
   terminal-CLI idiom): inert, dimmed, never a pointer target, gone the moment
   an argument is typed (the decoration recomputes per transaction). */
.composer-slash-ghost {
  margin-left: 0.5ch;
  color: color-mix(in oklab, var(--muted-foreground) 75%, transparent);
  pointer-events: none;
  user-select: none;
  white-space: pre-wrap;
}

.ProseMirror [data-mark-view-content] {
  @apply truncate;
}

.ProseMirror mark {
  color: inherit;
  background: color-mix(in oklab, var(--syntax-type) 28%, var(--background));
  @apply py-0.5 px-1 rounded-sm;
}

/* Authoring annotations (`%%…%%`, `<!-- … -->`). The editing surface shows
 * them dimmed rather than hiding them: the comment promoter claims literal
 * comment syntax wherever it appears in the bytes, including prose a user
 * typed without meaning it as a comment, so `display: none` here would
 * delete typed text from the surface it was typed into. Reading surfaces
 * still hide them — the mdast→hast renderer emits a literal HTML comment.
 *
 * No delimiter glyphs are drawn. Every other construct in this editor keeps
 * its syntax out of the page — `**`, backticks and `[](…)` all live in
 * attributes and render nothing — and a comment painting `%%` into the middle
 * of a sentence was the one that didn't. Source mode shows the raw
 * `%%…%%` / `<!-- … -->` bytes, which is where the delimiters are edited.
 *
 * Nothing names the construct to assistive technology: the mark renders a bare
 * `span`, and no `role`, `aria-label` or `title` is attached anywhere.
 *
 * The dimming is paired with a SHAPE cue, per the house rule stated with the
 * slash-token rules earlier in this file: a signal must never ride colour
 * alone. Without one, an inline comment differed from `*emphasis*` by colour
 * only — `em` gets no rule anywhere here, so it renders UA italic at
 * `--foreground`, which means italic is on both and discriminates nothing.
 * That matters more than it looks: a claimed run is emitted as a real HTML
 * comment on reading surfaces, so "can I see the difference" is really "will
 * readers see this text", and a reader who cannot resolve the step can publish
 * away something they meant to hide.
 *
 * `underline dashed` specifically, for three reasons. It is the only line
 * style still free inside `.ProseMirror` (`solid` is links, `dotted` is
 * missing skill refs and the loading state, `wavy` is lint and unresolved
 * refs; the other `dashed` belongs to the composer, a separate surface).
 * Forced-colors mode forces `text-decoration-color` but preserves
 * `-line` and `-style`, so the cue survives there with no media arm — unlike
 * a background or box-shadow, which are suppressed. And it is the idiom this
 * stylesheet already ships twice for the same "not ordinary prose" semantic.
 *
 * The delimiters themselves stay unpainted: the point was to stop printing a
 * construct's syntax into the middle of a sentence, not to leave the construct
 * unmarked. */
.comment-mark {
  color: var(--muted-foreground);
  font-style: italic;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
}

.comment-block {
  color: var(--muted-foreground);
  font-style: italic;
  /* Dashed, where blockquote's rail a few rules below is solid: dashed reads as
   * "not part of the prose", solid as "quoted prose". That contrast plus the
   * dimming is the whole signal — the construct carries no gutter label, so the
   * rail is what has to distinguish it. */
  border-left: 2px dashed color-mix(in oklab, var(--muted-foreground) 45%, transparent);
  padding-left: 0.75rem;
  margin: 0.6rem 0;
}

.ProseMirror .ok-find-match {
  border-radius: 0.15rem;
  background-color: color-mix(in oklab, var(--color-agent) 28%, transparent);
  color: inherit;
}

.ProseMirror .ok-find-match-active {
  background-color: color-mix(in oklab, var(--primary) 34%, transparent);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--primary) 55%, transparent);
}

.ProseMirror h1,
.ProseMirror h2,
.ProseMirror h3 {
  font-weight: 600;
  margin-top: 1em;
  margin-bottom: 0.4em;
}

.ProseMirror > h1:first-child,
.ProseMirror > h2:first-child,
.ProseMirror > h3:first-child {
  margin-top: 0;
}

.ProseMirror h1 {
  font-size: 1.5em;
  @apply tracking-tighter;
}
.ProseMirror h2 {
  font-size: 1.25em;
  @apply tracking-tight;
}
.ProseMirror h3 {
  font-size: 1.1em;
  @apply tracking-tight;
}

/* Lists */
.ProseMirror ul {
  list-style-type: disc;
  padding-left: 1.5em;
  margin-bottom: 0.5em;
}

.ProseMirror ol {
  list-style-type: decimal;
  /* Wide enough for 3-digit markers (`100.`). The previous 1.5em fits
     single-digit items only; 2-digit markers (`20.`/`21.`/`22.`) overflow
     into the negative inline-start area where the surrounding canvas
     container's clip horizon truncates the leading digit (PRD-7113). */
  padding-left: 2.5em;
  margin-bottom: 0.5em;
}

.ProseMirror li {
  margin-bottom: 0.15em;
}

.ProseMirror li > p {
  margin-bottom: 0.15em;
}

/* Nested lists */
.ProseMirror ul ul {
  list-style-type: circle;
  margin-bottom: 0;
}

.ProseMirror ul ul ul {
  list-style-type: square;
}

/* Task lists — unified List extension emits <li data-type="taskItem"> */
.ProseMirror ul:has(> li[data-type="taskItem"]):not(:has(> li:not([data-type="taskItem"]))) {
  list-style: none;
  padding-left: 0;
}

.ProseMirror li[data-type="taskItem"] {
  list-style-type: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  margin-bottom: 0.1em;
}

.ProseMirror li[data-type="taskItem"] > label {
  flex-shrink: 0;
  margin-top: 0.3em;
}

.ProseMirror li[data-type="taskItem"] > label input[type="checkbox"] {
  appearance: none;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--border);
  border-radius: calc(var(--radius) * 0.4);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  margin: 0;
  transition:
    background-color 150ms,
    border-color 150ms;
}

.ProseMirror li[data-type="taskItem"] > label input[type="checkbox"]:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.ProseMirror li[data-type="taskItem"] > label input[type="checkbox"]:checked::after {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  background-color: var(--color-primary-foreground);
}

.ProseMirror li[data-type="taskItem"] > label input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.ProseMirror li[data-type="taskItem"] > div {
  flex: 1;
}

.ProseMirror li[data-type="taskItem"] > div p {
  margin-bottom: 0;
}

.ProseMirror li[data-type="taskItem"][data-checked="true"] > div {
  text-decoration: line-through;
  color: var(--muted-foreground);
}

/* Blockquote */
.ProseMirror blockquote {
  border-left: 3px solid var(--callout-quote-color);
  padding-left: 1em;
  margin-left: 0;
  margin-bottom: 0.5em;
  color: var(--muted-foreground);
}

/* Code blocks — fallback for any <pre> not wrapped by the .ok-codeblock NodeView */
.ProseMirror pre {
  background: var(--syntax-bg);
  padding: 0.75em 1em;
  margin-bottom: 0.5em;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875em;
  line-height: 1.6;
  @apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50 rounded-lg;
}

/* .ok-codeblock — zero permanent chrome (precedent #30). Single rounded
   container, generous padding, no border. Hover/selection reveals a chrome
   bar floating above the block edge. Dark theme inverts the surface so
   the block reads as a code surface in either color mode. */
.ProseMirror .ok-codeblock {
  position: relative;
}

.ProseMirror .ok-codeblock-pre {
  background: var(--syntax-bg);
  color: var(--foreground);
  border: 0;
  @apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;
}

/* Strip the outer-pre fallback chrome — the NodeView's own .ok-codeblock-pre
   carries the box. */
.ProseMirror .ok-codeblock pre.ok-codeblock-pre {
  margin: 0;
  border-radius: 0.5rem;
}

/* Title strip above the code body when the fence carries `title="…"`
   (PRD-6819). Display-only — the editable surface is the title input
   inside the chrome's settings popover. The strip and the `<pre>` below
   it form one visual card by squaring the pre's top corners (rule below). */
.ok-codeblock-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  background: oklch(0.94 0 0);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 0.5rem 0.5rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted-foreground);
  user-select: none;
}

.dark .ok-codeblock-title {
  background: oklch(0.22 0.005 285);
  color: oklch(0.78 0 0);
}

.ok-codeblock-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Square the pre's top corners when a title strip is rendered above it
   so the two surfaces share a single visual edge. */
.ProseMirror .ok-codeblock:has(> .ok-codeblock-title) pre.ok-codeblock-pre {
  border-radius: 0 0 0.5rem 0.5rem;
}

/* Hover-revealed chrome bar hosting the language picker, edit-source,
   preview toggle, settings, Ask AI, copy, and delete affordances. Floats
   above the block edge (opacity-toggled) so the surface stays clean and
   the chrome does not overlap a preview iframe's content. */
.ok-codeblock-chrome {
  position: absolute;
  /* Float above the block edge (same visual pattern as the text-selection
     bubble menu) rather than inside the top-right corner, where the chrome
     was intrusive over an html preview iframe's content. Flush with the
     block edge (no gap) so the wrapper's mouseleave doesn't fire while the
     user's pointer travels from the block up into the chrome buttons. */
  bottom: 100%;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.1875rem;
  /* Preserve the visual gap between block and chrome via padding-bottom on
     the chrome itself, which stays inside the hover-tracked box. Must sit
     AFTER the `padding` shorthand or biome flags a shorthand-override. */
  padding-bottom: calc(0.1875rem + 0.375rem);
  border-radius: 0.375rem;
  background: var(--popover);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.ProseMirror .ok-codeblock:hover > .ok-codeblock-chrome,
.ProseMirror .ok-codeblock:focus-within > .ok-codeblock-chrome,
.ProseMirror .ok-codeblock[data-cursor-inside="true"] > .ok-codeblock-chrome,
.ProseMirror .ok-codeblock[data-selected="true"] > .ok-codeblock-chrome {
  opacity: 1;
  pointer-events: auto;
}

/* HTML preview blocks: the iframe fills the block area with its own
   pointer-events, so the native `:hover` selector never fires on the
   wrapper. `CodeBlockView` mirrors hover state onto `data-hovered="true"`
   via native mouseenter/mouseleave listeners so the chrome still reveals
   on interaction. */
.ProseMirror .ok-codeblock[data-hovered="true"] > .ok-codeblock-chrome {
  opacity: 1;
  pointer-events: auto;
}

.ok-codeblock-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  height: 1.5rem;
  min-width: 1.5rem;
  padding: 0 0.375rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition:
    background-color 0.1s,
    color 0.1s;
}

.ok-codeblock-chrome-btn:hover:not(:disabled),
.ok-codeblock-chrome-btn[data-state="open"] {
  background: var(--accent);
  color: var(--accent-foreground);
}

/* Persistent pressed indicator for toggle buttons: preview-shown
   (`Eye`/`EyeOff`) and settings-carrying-title (`Settings2`) both emit
   `data-active="true"` when their underlying state is on. Mirrors the
   sibling `.jsx-chrome-btn[data-active="true"]` treatment so the two
   chrome surfaces read the same to a user. */
.ok-codeblock-chrome-btn[data-active="true"] {
  background: var(--accent);
  color: var(--accent-foreground);
}

.ok-codeblock-chrome-btn:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.ok-codeblock-chrome-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.ok-codeblock-chrome-lang {
  color: var(--foreground);
  font-weight: 500;
}

.ok-codeblock-chrome-btn--delete:hover {
  background: transparent;
  color: var(--destructive, #ef4444);
}

/* HTML preview pane — primary surface when language=html + meta has `preview`.
   Iframe is `sandbox="allow-scripts"` only (null origin) so embedded JS can't
   reach the parent doc / cookies / auth-bearing fetch surface. The code body
   is hidden by default in preview mode (see [data-code-visible] selectors
   below) and toggled visible via the code-icon chrome button. Resize is
   driven by the shared `ok-resize-overlay` handles (8 corners + edges), not
   native CSS `resize` — replaces the bottom-only grip with full-axis control
   and unifies the affordance with `.ok-embed`. */
.ProseMirror .ok-codeblock > .ok-codeblock-preview {
  position: relative;
  /* Track the editor theme so a dark-mode preview does not flash white
     before / while the iframe document paints (the iframe's own srcDoc sets
     a themed `body` background once loaded). */
  background: var(--background);
  height: 26rem;
  min-height: 8rem;
  max-height: 80vh;
  max-width: 100%;
  overflow: hidden;
  @apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;
}

.ok-codeblock-preview--solo {
  border-radius: 0.5rem;
}

.ok-codeblock-preview--with-code {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.ok-codeblock-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  /* Themed so the pre-load iframe surface matches light/dark (see the
     .ok-codeblock-preview rule above). */
  background: var(--background);
}

/* Collapse the code body (PM contentDOM) when preview is active and the
   user hasn't opted to view source. We keep the <pre> mounted (precedent
   #30 — never literally `display:none` PM content) and instead clip it
   to zero height; PM still owns the contentDOM, undo history is stable,
   caret can re-enter when toggled back on. */
.ProseMirror .ok-codeblock[data-preview="true"][data-code-visible="false"] > .ok-codeblock-pre {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  border: 0;
  pointer-events: none;
}

/* Inline code */
.ProseMirror code {
  background: var(--syntax-bg);
  border-radius: 0.25em;
  padding: 0.15em 0.35em;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.ProseMirror pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* ----------------------------------------------------------------------
 * Syntax highlighting tokens — highlight.js class names emitted by lowlight
 * via ProseMirror Decoration.inline. Light & dark palettes mirror the
 * `github` / `github-dark` hljs themes, tuned to our color tokens.
 * ---------------------------------------------------------------------- */
.ProseMirror .ok-codeblock code .hljs-comment,
.ProseMirror .ok-codeblock code .hljs-quote {
  color: var(--syntax-comment);
  font-style: italic;
}

.ProseMirror .ok-codeblock code .hljs-keyword,
.ProseMirror .ok-codeblock code .hljs-selector-tag,
.ProseMirror .ok-codeblock code .hljs-doctag,
.ProseMirror .ok-codeblock code .hljs-formula {
  color: var(--syntax-keyword);
}

.ProseMirror .ok-codeblock code .hljs-name,
.ProseMirror .ok-codeblock code .hljs-section,
.ProseMirror .ok-codeblock code .hljs-tag,
.ProseMirror .ok-codeblock code .hljs-template-variable,
.ProseMirror .ok-codeblock code .hljs-variable {
  color: var(--syntax-var);
}

.ProseMirror .ok-codeblock code .hljs-attr {
  color: var(--syntax-attr);
}

.ProseMirror .ok-codeblock code .hljs-string,
.ProseMirror .ok-codeblock code .hljs-regexp,
.ProseMirror .ok-codeblock code .hljs-literal,
.ProseMirror .ok-codeblock code .hljs-meta-string,
.ProseMirror .ok-codeblock code .hljs-symbol,
.ProseMirror .ok-codeblock code .hljs-bullet,
.ProseMirror .ok-codeblock code .hljs-addition {
  color: var(--syntax-string);
}

.ProseMirror .ok-codeblock code .hljs-number,
.ProseMirror .ok-codeblock code .hljs-built_in,
.ProseMirror .ok-codeblock code .hljs-link {
  color: var(--syntax-number);
}

.ProseMirror .ok-codeblock code .hljs-type {
  color: var(--syntax-type);
}

.ProseMirror .ok-codeblock code .hljs-title,
.ProseMirror .ok-codeblock code .hljs-attribute,
.ProseMirror .ok-codeblock code .hljs-meta {
  color: var(--syntax-func);
}

/* Descendant-combinator selectors come AFTER the simple-class rules so
   document order matches specificity order (biome's noDescendingSpecificity).
   `.hljs-class .hljs-title` paints class names as types; `.hljs-function
   .hljs-title` keeps function names in the function slot. */
.ProseMirror .ok-codeblock code .hljs-class .hljs-title {
  color: var(--syntax-type);
}

.ProseMirror .ok-codeblock code .hljs-function .hljs-title {
  color: var(--syntax-func);
}

.ProseMirror .ok-codeblock code .hljs-deletion {
  color: var(--diff-removed);
  background: color-mix(in oklab, var(--diff-removed) 15%, transparent);
}

.ProseMirror .ok-codeblock code .hljs-emphasis {
  font-style: italic;
}

.ProseMirror .ok-codeblock code .hljs-strong {
  font-weight: 600;
}

/* Links */
.ProseMirror a {
  color: var(--link-color);
  cursor: pointer;
  @apply font-medium hover:underline hover:underline-offset-2;
}
/* Chrome-bar anchor items (Embed, Mirror) must NOT inherit the prose-link
 * blue color or hover underline — they're icon buttons in the
 * `.jsx-component-chrome` bubble, not body links. Specificity 0,1,1,1
 * beats `.ProseMirror a` (0,0,1,1) and the Tailwind `@apply` rules above. */
.ProseMirror a.jsx-chrome-btn,
.ProseMirror a.jsx-chrome-btn:hover {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}

/* -------------------------------------------------------------------------
 * V2 InteractionLayer chips — InternalLink + WikiLink (precedent #27(h))
 *
 * Pre-V2: per-instance React MarkViews rendered styled chrome around each
 * link mark. V2 moves to plain-DOM `<span data-link>` / `<span data-wiki-link>`
 * with `data-mark-id` / `data-node-id` for event delegation AND a
 * `data-resolution-state` decoration attribute ('resolved' | 'folder' |
 * 'unresolved' | 'loading' | 'external' | 'anchor' | 'asset') written by the
 * `linkResolutionDecorationPlugin`. The styling below is the user-visible
 * half of that contract (review Pass-2 Major #8).
 * --------------------------------------------------------------------- */

.ProseMirror [data-link],
.ProseMirror [data-wiki-link] {
  display: inline;
  cursor: pointer;
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-style: solid;
  text-underline-offset: 2px;
  border-radius: 2px;
  @apply font-medium;
}

.ProseMirror [data-link]:hover,
.ProseMirror [data-wiki-link]:hover {
  text-decoration-thickness: 2px;
}

.ProseMirror [data-link]:focus-visible,
.ProseMirror [data-wiki-link]:focus-visible {
  outline: 2px solid var(--color-ring);
  /* Pulled inset (was `2px`, which painted the ring OUTSIDE the chip's
   * text bounds). On a wrap boundary the offset cropped against the
   * line below; on chips near a scroll-container edge the 2px halo got
   * clipped by the surrounding `overflow: hidden` ancestor. `1px`
   * stays visible without crossing into adjacent text or beyond the
   * column edge. Border-radius rounds the ring corners so the rect
   * matches the link's perceived shape (especially visible on wiki
   * chips which have a subtle background). */
  outline-offset: 1px;
  border-radius: 2px;
}

/* Wiki-link chip icon prefix — emoji or `<img>` inside the chip, before
   the visible label. The slot is always rendered (so DOM shape stays
   stable across icon changes) but `:empty` collapses it to zero width
   when no icon is set — most docs have no `icon:` frontmatter so the
   common case carries no layout cost. `text-decoration: none` opts the
   icon out of the chip's underline; `vertical-align: -2px` nudges the
   inline-block down so emoji glyphs and small images sit on the text
   baseline rather than floating above it. */
.ProseMirror [data-wiki-link-icon]:empty {
  display: none;
}

.ProseMirror [data-wiki-link-icon] {
  display: inline-block;
  margin-right: 0.25rem;
  text-decoration: none;
  vertical-align: -2px;
  line-height: 1;
  font-size: 0.95em;
}

/* `/skill-name` references in skill-doc prose: installed reads as a link;
   missing reads as the broken-link treatment with an install path on click. */
.ProseMirror .ok-skill-ref,
.cm-skill-ref {
  cursor: pointer;
  color: var(--color-azure-blue);
  @apply dark:text-sky-blue;
}
.ProseMirror .ok-skill-ref:hover,
.cm-skill-ref:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ProseMirror .ok-skill-ref-missing,
.cm-skill-ref-missing {
  color: var(--muted-foreground);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* In-viewer find (§8.4): CSS Custom Highlight API paint — DOM untouched. */
::highlight(ok-find) {
  background-color: color-mix(in srgb, var(--color-azure-blue) 30%, transparent);
}
::highlight(ok-find-active) {
  background-color: color-mix(in srgb, var(--color-azure-blue) 60%, transparent);
}

/* Skill-doc bundle-path affordance — code spans shaped like `references/…` /
   `scripts/…` get a link cursor; the visible affordance is hover-only (link
   tint + solid underline). Dotted-at-rest was tried and read as the
   unresolved/spellcheck error style, and wrapped chips in tables stacked
   rows of dots. Decoration-only; bytes and chip styling untouched. */
.ProseMirror .ok-skill-path-link,
.cm-skill-path-link {
  cursor: pointer;
}
.ProseMirror .ok-skill-path-link:hover,
.cm-skill-path-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--color-azure-blue);
  @apply dark:text-sky-blue;
}

/* Resolution states — the decoration plugin writes `data-resolution-state`
   at PM render time. Selectors are specific enough to override the base
   chip color when present. */

.ProseMirror [data-resolution-state="resolved"] {
  color: var(--link-color);
}

/* Folder chip — doc-reference to a directory rather than a page. Italicize
   to differentiate from a resolved page link. */
.ProseMirror [data-resolution-state="folder"] {
  font-style: italic;
}

/* Unresolved / broken — squiggly underline + muted color to make the
   broken state visible in WYSIWYG (source mode has its own squiggly via
   `source-polish`). */
.ProseMirror [data-resolution-state="unresolved"] {
  color: var(--color-red-600, #dc2626);
  text-decoration-style: wavy;
  text-decoration-color: var(--color-red-600, #dc2626);
}

.dark .ProseMirror [data-resolution-state="unresolved"] {
  color: #f87171; /* red-400 */
  text-decoration-color: #f87171;
}

/* Loading — awaiting page-list-cache population. Dotted underline
   communicates "indeterminate" without alarming. */
.ProseMirror [data-resolution-state="loading"] {
  opacity: 0.7;
  text-decoration-style: dotted;
}

/* External — leaves-the-workspace visual. Find decorations and remote caret
   widgets split a single link into sibling fragments inside its `[data-link]`
   wrapper; only the final fragment gets the cue. Wiki-link chips are
   paragraph-level siblings of each other, so they stay out of this rule. */
.ProseMirror
  [data-link]
  [data-resolution-state="external"]:has(~ [data-resolution-state="external"])::after {
  content: none;
}

.ProseMirror [data-resolution-state="external"]::after {
  content: " ↗";
  font-size: 0.85em;
  opacity: 0.6;
}

/* In-doc anchor — no external navigation. Keep base link color; just drop
   the ↗ glyph. Selector intentionally LAST so it overrides `external`'s
   ::after if both flags ever coexist. */
.ProseMirror [data-resolution-state="anchor"]::after {
  content: none;
}

/* Horizontal rule */
.ProseMirror hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1em 0;
}

/* Images */
.ProseMirror img {
  max-width: 100%;
  height: auto;
  margin: 0.5em 0;
  @apply rounded-lg;
}

.ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* `<div align>` compat wrapper (HtmlAlignBlock / div-align-promoter):
   images inside the aligned block flow inline like GitHub renders them —
   the OK default `display: block` image would ignore the wrapper's
   text-align and pin badges/heroes to the left edge. */
.ProseMirror [data-component-type="align-block"] img {
  display: inline-block;
}

/* Wiki-link chip icon — the `<img>` inside `[data-wiki-link-icon]`. Lives
   AFTER `.ProseMirror img` so source order matches the descending-
   specificity ratchet (biome's noDescendingSpecificity). Overrides
   the chip-image defaults (`max-width: 100%; height: auto; margin:
   0.5em 0; rounded-lg`) with the tight inline glyph sizing the chip
   needs. */
.ProseMirror [data-wiki-link-icon] img {
  display: inline-block;
  width: 1em;
  height: 1em;
  max-width: none;
  margin: 0;
  border-radius: 2px;
  object-fit: cover;
  vertical-align: baseline;
}

/* Tables */
.ProseMirror .tableWrapper {
  overflow-x: auto;
  /* Extra bottom room so the TableInsertControls "add row" bar (≈20px below
     the table: EDGE_GAP + bar thickness) clears the following block. */
  margin: 0.5em 0 1.75em;
  @apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;
}

.ProseMirror table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  /* `clip`, not `hidden`: overflow:hidden makes the table itself a scroll
     container, which would capture the first-column `position: sticky` cells
     below (sticky constrains to the nearest scrollport — the cells must reach
     .tableWrapper's). clip clips identically without creating a scrollport. */
  overflow: clip;
}

.ProseMirror th,
.ProseMirror td {
  border: 1px solid var(--border);
  padding: 0.4em 0.6em;
  vertical-align: top;
  position: relative;
  min-width: 80px;
  box-sizing: border-box;
}

.ProseMirror th {
  background: var(--muted);
  font-weight: 600;
  text-align: left;
}

.ProseMirror td > p,
.ProseMirror th > p {
  margin-bottom: 0;
}

.ProseMirror .selectedCell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-azure-100);
  opacity: 0.4;
  pointer-events: none;
  z-index: 2;
}

.ProseMirror .column-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: -2px;
  width: 4px;
  background-color: var(--color-azure-400);
  pointer-events: none;
  z-index: 20;
}

.ProseMirror.resize-cursor {
  cursor: col-resize;
}

/* First-column sticky freeze (horizontal scroll). Works because .tableWrapper
   is the CSS scroll container for the x-axis. */
.ProseMirror .tableWrapper > table > tbody > tr > td:first-child,
.ProseMirror .tableWrapper > table > tbody > tr > th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.ProseMirror .tableWrapper > table > tbody > tr > td:first-child {
  background-color: var(--background);
}

/* A first row holding any th is the row the freeze translates, every cell of
   it, so it stacks above body rows at every scroll position. The freeze moves
   it with a compositor-driven animation; a stacking flip at the freeze boundary
   would land on the main thread, frames behind the transform, leaving body rows
   painted over the moving row during a fast scroll. */
.ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > :is(th, td) {
  z-index: 2;
}

.ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > td {
  background-color: var(--background);
}

/* First-column header cells in body rows (header-column tables) sit above the
   sticky body column. */
.ProseMirror .tableWrapper > table > tbody > tr > th:first-child {
  background-color: var(--muted);
  z-index: 3;
}

/* A frozen-row cell's resize handle overhangs its right border; raise the cell
   holding it so the next cell in that row does not cover the overhang. */
.ProseMirror
  .tableWrapper
  > table
  > tbody
  > tr:first-child:has(> th)
  > :is(th, td):not(:first-child):has(> .column-resize-handle) {
  z-index: 3;
}

/* Corner cell (first column + frozen row) clears the frozen row, a raised
   resize-handle cell and the sticky column, frozen or not. */
.ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > :is(th, td):first-child {
  z-index: 4;
}

/* Occluder above the frozen header (frozen-table-headers.ts): scrolled-past
   rows must not show in the translucent toolbar-fade slot above the pinned
   header. An opaque block riding each header cell's composited layer tracks
   the frozen header's transform pixel-for-pixel — unlike a scroll-driven
   clip-path on the wrapper, which updates on the main thread and trails the
   compositor during scroll. Hidden until the extension's scroll-driven
   opacity flip reveals it while frozen. The wrapper's own overflow clips the
   block at the table's top edge, so it never covers content above the table.
   ±1px horizontal overlap closes the seams over collapsed cell borders.
   height must stay >= TOOLBAR_HEIGHT (56px, frozen-table-headers.ts) so the
   block spans the whole toolbar-fade slot; 80px adds margin. */
.ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > :is(th, td)::before {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: 100%;
  height: 80px;
  background: var(--background);
  opacity: 0;
  pointer-events: none;
}

/* Print: neutralize the freeze. The WAAPI fill animations hold transform /
   occluder opacity at the on-screen scroll position, which would print the
   header mid-table; !important author declarations override animation
   effects in the cascade, so these win over the fills. */
@media print {
  .ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > :is(th, td) {
    /* biome-ignore lint/complexity/noImportantStyles: the freeze holds transform in a WAAPI fill, which outranks every normal author declaration. */
    transform: none !important;
    /* biome-ignore lint/complexity/noImportantStyles: same WAAPI fill override as `transform` above. */
    box-shadow: none !important;
  }
  .ProseMirror .tableWrapper > table > tbody > tr:first-child:has(> th) > :is(th, td)::before {
    /* biome-ignore lint/complexity/noImportantStyles: the occluder's opacity is held in a WAAPI fill on ::before. */
    opacity: 0 !important;
  }
}

.ProseMirror p.is-empty::before,
.ProseMirror[data-empty-placeholder]:empty::before {
  pointer-events: none;
  float: left;
  height: 0;
  @apply text-muted-foreground/60;
}

.ProseMirror p.is-empty::before {
  content: attr(data-placeholder);
}

.ProseMirror[data-empty-placeholder]:empty::before {
  content: attr(data-empty-placeholder);
}

/* When any JSX prop panel is open in this editor, suppress the slash-command
 * placeholder on empty paragraphs — the placeholder competes for attention
 * with the focused panel. Scope is narrow on purpose: the trigger must live
 * inside `.jsx-component-chrome` so other open popovers (BubbleMenu, color
 * picker, future link panels routed through InteractionLayerStore) keep the
 * placeholder visible. `:has()` is supported on Chrome 105+, Safari 15.4+,
 * Firefox 121+; older Firefox sees the pre-fix behavior (placeholder still
 * visible behind the panel) as graceful degradation. */
.tiptap-editor:has(.jsx-component-chrome button[data-slot="popover-trigger"][data-state="open"])
  .ProseMirror
  p.is-empty::before {
  content: none;
}

/* DragHandlePlugin container — absolutely positioned flex row of grip + "+"
   created imperatively by `BlockDragHandle` (see
   `packages/app/src/editor/extensions/drag-handle.ts`). Per FR-15 / FR-16. */
.ok-block-controls {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 1;
  transition: opacity 100ms var(--ease-out-strong);
  user-select: none;
}

/* Gutter "+" chrome, shared by the block handle's button (`ok-add-block-btn`, a
   real <button> parked beside a block by DragHandlePlugin) and the
   TrailingAffordance hint (`ok-trailing-affordance-plus`, a <span> inside a
   widget decoration below the last block). The two are deliberately the same
   glyph at the same gutter offset, so hovering the dead zone reads as "a block
   goes here" exactly the way hovering a block does. One rule rather than two
   copies, so they cannot drift into a near-miss that reads as a rendering bug.

   `color` clears the 3:1 WCAG 2.2 §1.4.11 floor for a non-text UI component,
   here and on the drag grip that matches it: 3.64:1 against `--background`.
   It is one value for the whole gutter vocabulary rather than a per-call-site
   choice, so both glyphs move together when it changes.

   Hover is a second surface, not a free ride, because the hover background is
   translucent and composites toward the glyph. Light hover (6% black over
   white) lands 3.19:1 and stays put. Dark hover (8% white over the dark canvas)
   lifts the ground far enough that the resting dark glyph drops to 2.79:1, so
   the dark block below lifts the glyph on hover rather than the background
   alone. Every figure is `Y = L³` for these chroma-0 colors, then the standard
   `(Y1 + 0.05) / (Y2 + 0.05)`, with the translucent layer composited in sRGB
   before linearizing. */
.ok-add-block-btn,
.ok-trailing-affordance-plus {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  cursor: pointer;
  color: oklch(0.62 0 0);
  border-radius: 3px;
  border: none;
  background: transparent;
  padding: 0;
  transition: background-color 100ms var(--ease-out-strong);
}
.ok-add-block-btn:hover,
.ok-trailing-affordance-plus:hover {
  background-color: oklch(0 0 0 / 6%);
}

/* Drag grip — rendered as a <button> for a11y (click handler binds to a
   semantic interactive element discoverable by screen readers). Default
   <button> chrome (border, padding, system background) is reset so the
   visual is unchanged from when this was a <div>. */
.ok-drag-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  cursor: grab;
  color: oklch(0.62 0 0);
  border-radius: 3px;
  border: none;
  background: transparent;
  padding: 0;
}
.ok-drag-grip:hover {
  background-color: oklch(0 0 0 / 6%);
}
.ok-drag-grip:active {
  cursor: grabbing;
}

body[data-editor-tab-dragging],
body[data-editor-tab-dragging] * {
  cursor: grabbing;
}

/* Keyboard focus indicator — mirrors the editor-wide pattern used by
   .tag, [data-link], a.ok-file-attachment, and task-list checkboxes.
   The grip carries tabindex="-1" today, so the indicator only fires on
   explicit `.focus()` calls; the add button is reachable via Tab while
   its hover-only chrome is visible. */
.ok-add-block-btn:focus-visible,
.ok-drag-grip:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

/* Visibility fade — DragHandlePlugin sets inline visibility: hidden.
   The hidden handle stays in layout and keeps whatever inline top/left
   floating-ui last wrote for it, so a handle parked against a deep block goes
   on stretching the scroller's scrollHeight after the content beneath it
   shrinks (a rebuilt content DOM re-estimates every content-visibility chunk
   much shorter). That surplus is scrollable but holds nothing, which is how a
   restored offset can park the viewport on blank space. Pinning the hidden
   handle to the container origin keeps chrome inside the content by
   construction; `!important` because the plugin writes those offsets inline.
   `visibility` must stay the hiding mechanism — the plugin's reveal path
   measures the handle's box via floating-ui (the position write lands a
   microtask after the reveal), and `display: none` would zero the dimensions
   that measurement needs. */
.ok-block-controls[style*="visibility: hidden"],
.ok-block-controls[style*="visibility:hidden"] {
  opacity: 0;
  /* biome-ignore lint/complexity/noImportantStyles: the plugin writes top/left as inline styles, which no selector specificity can outrank. */
  top: 0 !important;
  /* biome-ignore lint/complexity/noImportantStyles: same inline-style override as `top` above. */
  left: 0 !important;
}

/* Dark mode */
.dark :is(.ok-add-block-btn, .ok-trailing-affordance-plus) {
  color: oklch(0.5 0 0);
}
.dark :is(.ok-add-block-btn, .ok-trailing-affordance-plus):hover {
  background-color: oklch(1 0 0 / 8%);
  /* 0.5 against the hover-lifted ground is 2.79:1, under the 3:1 floor; 0.62
     restores 4.60:1. Derivation on the shared rule above. */
  color: oklch(0.62 0 0);
}
.dark .ok-drag-grip {
  color: oklch(0.5 0 0);
}
.dark .ok-drag-grip:hover {
  background-color: oklch(1 0 0 / 8%);
  /* Same ground, same floor, same lift — the grip is part of the gutter
     vocabulary and moves with it. */
  color: oklch(0.62 0 0);
}

/* TrailingAffordance hint — the "+" shown while hovering the empty region below
   a non-paragraph final block (`editor/extensions/trailing-affordance.ts`). It
   is a widget decoration, so it is chrome and never document content.

   Zero height with an absolutely positioned child: the hint appears and
   disappears under the pointer, and an in-flow box would reflow the document
   every time it did. `left: -52px` is not arbitrary — it is where
   `BlockDragHandle` parks its own "+" (floating-ui `left-start`, `mainAxis: 10`
   against the 42px controls row), so the two read as one affordance. The dead
   zone reaches the plugin because `handleDOMEvents` binds on `view.dom` and
   `inTrailingZone` classifies by coordinate, not because of anything here — a
   zero-height row has no hit region to claim it either way. What the
   `pointer-events` pair declares is that the hint is inert chrome with one
   exception: the glyph opts back in, and it has to, because `left: -52px` puts
   it partly left of `view.dom`'s border box and so outside that coordinate
   test, which is why `inTrailingZone` recognizes it by target instead. */
.ok-trailing-affordance {
  position: relative;
  height: 0;
  pointer-events: none;
  user-select: none;
}

/* Only the placement is this glyph's own — everything else comes from the
   shared gutter-"+" rule above. `left` lands it in the same column the block
   handle uses: the row is a child of `.ProseMirror`, whose content box starts
   2.5rem (40px) inside its border box, and the handle sits 12px further out
   still. `top` centers the 20px box on the line a click would create. */
.ok-trailing-affordance-plus {
  position: absolute;
  top: 4px;
  left: -52px;
  pointer-events: auto;
}

/* Same narrow-rail gate as the `.ProseMirror` escape far above. At a 1rem rail
   the -52px gutter does not exist, so the 20px glyph lands at [-36px, -16px],
   outside `.ProseMirror`'s border box and clipped away by the scroller, and the
   affordance the plugin pins on for coarse pointers is invisible. Park it at
   the text origin instead: nothing follows the last block, so it overlaps
   nothing. Must stay AFTER the rule above — a media query adds no specificity,
   so an earlier block loses to it on source order. */
@media (width < 40rem) and (pointer: coarse) {
  .ok-trailing-affordance-plus {
    left: 0;
  }
}

/* The block handle's "+" fades in; this one is a widget decoration that enters
   the DOM already hovered, so without an entry transition it pops at full
   opacity and the two gutter glyphs read as different components. There is no
   exit half: the decoration is removed, not hidden. */
@media (prefers-reduced-motion: no-preference) {
  .ok-trailing-affordance-plus {
    transition:
      background-color 100ms var(--ease-out-strong),
      opacity 100ms var(--ease-out-strong);
  }

  @starting-style {
    .ok-trailing-affordance-plus {
      opacity: 0;
    }
  }
}

/* Gapcursor — the caret ProseMirror places where no textblock can sit (after a
   final table, between two fences). It is drawn as `border-top: 1px solid
   black`, which is all but invisible on the dark theme. Bind it to the same
   token the text caret uses.

   The descendant selector is load-bearing. prosemirror-gapcursor itself injects
   nothing (it ships `style/gapcursor.css` and tells you to include it), but
   `@tiptap/core` carries a copy of that CSS as a string and appends it to a
   `style[data-tiptap-style]` tag at runtime. Its rule has equal specificity to
   a bare `.ProseMirror-gapcursor::after` and can land after this stylesheet, so
   the extra `.ProseMirror` ancestor is what keeps this declaration winning. */
.ProseMirror .ProseMirror-gapcursor::after {
  border-top-color: var(--foreground);
}

/* Positioned host for the per-column / per-row cell-handle dropdowns
   (`TableCellHandles`). The handles are `position: absolute` + floating-ui
   placed, so they need a positioned offsetParent. This host is a React-rendered
   direct child of `.tiptap-editor`, so it inherits `grid-column: content;
   position: relative` from `.tiptap-editor > *` — content-aligned, inside the
   scroll container (handles track scroll), and crucially NOT
   `view.dom.parentElement`, which TipTap vacuums on `<Activity>` recycle. A
   portal into that node desyncs React and throws `removeChild` on navigation
   (see TableCellHandles.tsx). The host is pinned into the content's grid row
   (`grid-row: 1` here + on `.tiptap-editor-portal-content`) instead of
   generating its own: `.tiptap-editor` is taller than short documents, and the
   default `align-content: stretch` hands every in-flow auto row an equal share
   of the leftover height — an own row for this host would balloon into a blank
   band ABOVE the document the moment the cursor enters a table. `align-self:
   start` keeps the host zero-height inside the shared row, so the absolute
   handles position exactly as they would from an own top row.

   Visibility is gated here, not in JS: the layer is rendered whenever the
   cursor is in a cell (TableCellHandles owns that), but the pills only paint
   when the user is actively touching the table — editor focused (covers
   typing, click-to-place-caret, and the post-dismiss pill-focused state, all
   under `.tiptap-editor:focus-within`), or a handle's Radix dropdown is open
   (the trigger inside the layer carries `data-state="open"` while focus has
   moved to the body-portaled menu content). `visibility: hidden` (not
   `display: none`) keeps floating-ui's positioning math live and drops the
   pills out of tab order. */
.ok-table-cell-handle-layer {
  position: relative;
  grid-row: 1;
  align-self: start;
  visibility: hidden;
  /* Delay the falling edge (visible -> hidden) so Radix's focus-restoration on
     Escape / dismiss lands on the (still-focusable) pill BEFORE the layer goes
     visibility:hidden. The rising edge stays immediate because the visible
     selectors below override transition-delay to 0s. */
  transition: visibility 0s 150ms;
}
.tiptap-editor:focus-within .ok-table-cell-handle-layer,
.ok-table-cell-handle-layer:has([data-state="open"]) {
  visibility: visible;
  transition-delay: 0s;
}

/* Table edge "+" bars — Notion-style append-column / append-row affordance.
   The TableInsertControls extension mounts one container per table on
   `editor.view.dom.parentElement`. Each bar is a persistent but
   transparent hit zone at the table edge; hovering it (the mouse landing inside
   the bar) reveals the "+", so reveal is pure CSS — no JS hover tracking. */
.ok-table-insert-controls {
  position: absolute;
  top: 0;
  left: 0;
  /* The container is just a positioning anchor — only the bars take pointer
     events, so the overlay never shadows editor content. */
  pointer-events: none;
  z-index: 5;
}

.ok-table-insert-bar {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
  border: none;
  border-radius: 4px;
  /* Invisible until hovered: transparent background + `currentColor`-stroked
     icon hidden via a transparent text color. The element still occupies its
     strip, so it's hoverable. */
  color: transparent;
  background: transparent;
  /* The bar sits flush against the table edge. The
     gutter toward the table is transparent padding — `content-box` keeps the
     visible highlight off it, preserving the visual gap while making the gutter
     itself part of the (hoverable) button, so there's no dead zone between the
     table and the bar. One shared var so the column/row gutters can't drift. */
  --ok-table-bar-gap: 6px;
  --ok-table-bar-thickness: 16px;
  background-clip: content-box;
  transition:
    background-color 100ms var(--ease-out-strong),
    color 100ms var(--ease-out-strong);
}
/* width/height = transparent gutter (toward the table) + visible strip. */
.ok-table-insert-column {
  width: calc(var(--ok-table-bar-thickness) + var(--ok-table-bar-gap));
  padding-left: var(--ok-table-bar-gap);
}
.ok-table-insert-row {
  height: calc(var(--ok-table-bar-thickness) + var(--ok-table-bar-gap));
  padding-top: var(--ok-table-bar-gap);
}
/* Revealed when hovered directly, focused, or when the pointer is in the
   table's last column / last row (`.is-active`, toggled by TableInsertControls). */
.ok-table-insert-bar:hover,
.ok-table-insert-bar:focus-visible,
.ok-table-insert-bar.is-active {
  background-color: oklch(0 0 0 / 6%);
  /* ~3:1 against the page (WCAG 1.4.11 non-text contrast); 0.72 was too faint. */
  color: oklch(0.55 0 0);
}
.dark .ok-table-insert-bar:hover,
.dark .ok-table-insert-bar:focus-visible,
.dark .ok-table-insert-bar.is-active {
  background-color: oklch(1 0 0 / 8%);
  color: oklch(0.5 0 0);
}
.ok-table-insert-bar:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

/* CodeMirror polish */
.cm-editor {
  font-size: 14px;
  font-family: var(--font-mono);
}

/* SourceEditor (full-page source mode) reserves a usable baseline height;
   nested CM instances inside PM NodeViews size to their content. */
.source-editor .cm-editor {
  min-height: 200px;
}

.cm-editor .cm-content {
  padding: 0;
}

/* Restore the floating Ask AI composer's bottom inset for two full-page
   CodeMirror surfaces: markdown source mode (`.source-editor`) and editable text
   docs (`[data-text-doc-editor]`, the `.ts` / `.json` / `.txt` editor).
   The `padding: 0` reset above ties on specificity with the shared
   `.editor-doc-scroll :is(.ProseMirror, .cm-content)` inset rule and, being
   later, zeroes it, so those surfaces' last lines would sit under the composer
   while WYSIWYG clears. `[data-text-doc-editor]` scrolls inside CodeMirror's own
   `.cm-scroller`; `.source-editor` sits in a content-sized ancestor chain, so its
   `height: 100%` resolves to auto and the outer `.editor-doc-scroll` is what
   scrolls. Either way the room has to come from padding the CONTENT, for a
   different reason per host: padding the text-doc host would shrink its own scroll
   box, cutting the gutter and the scrollbar off above the composer instead of
   running them behind it, and padding the source host would reserve the height a
   second time on top of this rule (the EITHER/OR below), while still ending its
   gutter above the card (that host paints no scrollbar of its own, since it is
   not the scroll parent).
   `[data-mermaid-doc-editor]` takes the host route because the same wrapper also
   hosts its non-scrolling diagram pane. Its source mode knowingly ends the
   gutter and scrollbar above the composer, preserving one inset across that
   diagram-first surface's mode switch. Scoped to these two hosts (not
   `.cm-editor`) so nested code-block CM inside the WYSIWYG body is never padded,
   and declared after the reset so it wins the tie. A full-page CM surface needs
   EITHER this content restore OR a host-level `padding-bottom` like
   `[data-mermaid-doc-editor]` above, never both, or it reserves two composer
   heights and the last line floats a card above the composer. */
.source-editor .cm-content,
[data-text-doc-editor] .cm-content {
  padding-bottom: var(--ask-composer-height, 0px);
}

.cm-editor.cm-focused {
  outline: none;
}

.cm-scroller {
  @apply font-mono! scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;
}

.cm-gutters.cm-gutters-before {
  @apply border-none!;
}

:where(html[data-color-theme]) .cm-gutters {
  @apply text-muted-foreground/80!;
}

.cm-lineNumbers .cm-gutterElement {
  @apply pr-1! pl-4!;
}

.cm-line {
  /* Per-line padding contract: pl-4 baseline + two per-line variables set inline
     by source-polish view-plugin for the lines it decorates:
       --list-hang  (set on .cm-list-item lines:  prefix width 2..8ch)
       --line-indent (set on .cm-fenced-code-line lines: source-indent count)
     Both fall back to 0 when unset, so non-decorated .cm-line elements render
     identically to plain pl-4. The Tailwind ! modifier compiles to !important
     and defeats CodeMirror 6's bundled .cm-line stylesheet; the additive calc
     form incorporates the variables directly so the !important declaration
     varies per-line rather than locking every line to a flat 1rem.
     See .cm-list-item (hanging-indent) and .cm-fenced-code-line (wrap-preserve-
     indent) rules later in this file for the original author comments. */
  @apply ps-[calc(1rem+var(--list-hang,0ch)+var(--line-indent,0)*1ch)]!;
  text-indent: calc(-1 * var(--list-hang, 0ch));
}

/* ─────────────────────────────────────────────────────────────
   Presence polish — agent badge, undo button, presence bar
   ───────────────────────────────────────────────────────────── */

/* Agent badge breathes subtly when editing — signals "alive, currently writing".
   Also respects reduced-motion: opacity-only pulse instead of background. */
[data-presence-badge="agent"][data-presence-mode="editing"] {
  animation: agent-breathing 2.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  [data-presence-badge="agent"][data-presence-mode="editing"] {
    animation: none;
    background: rgba(217, 119, 87, 0.08);
  }
}

/* All presence badges fade in on mount — uses @starting-style where supported.
   Fallback: no animation, just instant appearance (graceful degradation). */
[data-presence-badge] {
  transition: opacity 220ms var(--ease-out-strong);
}

@supports (transition-behavior: allow-discrete) {
  [data-presence-badge] {
    @starting-style {
      opacity: 0;
      transform: translateY(-2px);
    }
  }
}

/* Undo button — scale nudge + glow ring when transitioning to enabled.
   The `data-undo-state` attribute is set by AgentUndoButton based on canUndo polling.
   The animation only fires when state transitions from 'disabled' to 'ready' — not on every render. */
[data-undo-state="ready"][data-undo-just-enabled="true"] {
  animation: undo-ready 600ms var(--ease-out-strong) forwards;
}

/* Button press feedback — every interactive button gets scale(0.97) on :active.
   Emil principle: "Buttons must feel responsive to press." */
button {
  transition: transform 160ms var(--ease-out-strong);
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
[data-agent-thread-root] button:active:not(:disabled) {
  transform: none;
}

.subtle-scrollbar {
  @apply scrollbar-thin scrollbar-track-transparent scrollbar-thumb-muted-foreground/30 dark:scrollbar-thumb-muted-foreground/50;
}

/* Subtle top + bottom fade for scrollable regions — masks the first and last
   ~1rem of content so it fades into the surrounding bg as a "more above/below"
   affordance. Used by DialogBody and any other scrollable surface that wants
   the same polish.

   Modern browsers (Chrome 115+, Safari 18+) get a position-aware fade via
   two scroll-driven animations:
   - The TOP fade transitions IN over the first 1rem of scroll, then holds
     full strength until the bottom (so scrolling past the start reveals it,
     scrolling back to the start hides it).
   - The BOTTOM fade transitions OUT over the last 1rem of scroll (so it's
     full when there's content below, gone when you've reached the end).
   - When the body isn't scrollable at all, both timelines are inactive,
     both vars fall back to their @property initial-value of 1 (opaque
     edges → no fade).

   Browsers without scroll-driven animation support (Firefox today) fall
   through the @supports block and get the always-on fade — same as the
   original implementation, no regression. */

@property --scroll-fade-top {
  syntax: "<number>";
  initial-value: 1;
  inherits: false;
}

@property --scroll-fade-bottom {
  syntax: "<number>";
  initial-value: 1;
  inherits: false;
}

@property --scroll-fade-left {
  syntax: "<number>";
  initial-value: 1;
  inherits: false;
}

@property --scroll-fade-right {
  syntax: "<number>";
  initial-value: 1;
  inherits: false;
}

@keyframes scroll-fade-top-in {
  from {
    --scroll-fade-top: 1;
  }
  to {
    --scroll-fade-top: 0;
  }
}

@keyframes scroll-fade-bottom-out {
  from {
    --scroll-fade-bottom: 0;
  }
  to {
    --scroll-fade-bottom: 1;
  }
}

@keyframes scroll-fade-left-in {
  from {
    --scroll-fade-left: 1;
  }
  to {
    --scroll-fade-left: 0;
  }
}

@keyframes scroll-fade-right-out {
  from {
    --scroll-fade-right: 0;
  }
  to {
    --scroll-fade-right: 1;
  }
}

.scroll-fade-mask {
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
}

.scroll-fade-mask-bottom {
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 1.5rem), transparent 100%);
  mask-image: linear-gradient(to bottom, black calc(100% - 1.5rem), transparent 100%);
}

.scroll-fade-mask-x {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
}

/* shadcn Attachment component utilities (src/components/ui/attachment.tsx).
   The registry item references these but ships none of them, and the repo's own
   scroll-fade masks use different class names, so they're defined here.

   `.scroll-fade-x` mirrors `.scroll-fade-mask-x`: this static rule is the
   Firefox fallback (always-on edge fade); the @supports block below makes the
   fade scroll-driven in Chromium/Electron, so an edge only fades when there's
   content to scroll past it — without it the first card's left edge is always
   masked and appears clipped. */
.scroll-fade-x {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    black 1rem,
    black calc(100% - 1rem),
    transparent 100%
  );
}

@supports (animation-timeline: scroll(self)) {
  .scroll-fade-x {
    -webkit-mask-image: linear-gradient(
      to right,
      rgba(0, 0, 0, var(--scroll-fade-left)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-right)) 100%
    );
    mask-image: linear-gradient(
      to right,
      rgba(0, 0, 0, var(--scroll-fade-left)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-right)) 100%
    );
    animation-name: scroll-fade-left-in, scroll-fade-right-out;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: scroll(self inline);
    animation-range:
      0 1rem,
      calc(100% - 1rem) 100%;
  }
}

.scrollbar-none {
  scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
  display: none;
}

/* `shimmer` is applied through a `group-data-[state=…]/attachment:shimmer`
   variant, so it must be a real Tailwind utility (not a plain class) for the
   variant to resolve. Only the uploading/processing attachment states trigger
   it — the feedback picker's attachments are always `done`. */
@utility shimmer {
  background: linear-gradient(
    90deg,
    var(--muted-foreground) 25%,
    var(--foreground) 50%,
    var(--muted-foreground) 75%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@supports (animation-timeline: scroll(self)) {
  .scroll-fade-mask {
    -webkit-mask-image: linear-gradient(
      to bottom,
      rgba(0, 0, 0, var(--scroll-fade-top)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-bottom)) 100%
    );
    mask-image: linear-gradient(
      to bottom,
      rgba(0, 0, 0, var(--scroll-fade-top)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-bottom)) 100%
    );
    animation-name: scroll-fade-top-in, scroll-fade-bottom-out;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: scroll(self);
    animation-range:
      0 1rem,
      calc(100% - 1rem) 100%;
  }

  .scroll-fade-mask-bottom {
    -webkit-mask-image: linear-gradient(
      to bottom,
      black calc(100% - 1.5rem),
      rgba(0, 0, 0, var(--scroll-fade-bottom)) 100%
    );
    mask-image: linear-gradient(
      to bottom,
      black calc(100% - 1.5rem),
      rgba(0, 0, 0, var(--scroll-fade-bottom)) 100%
    );
    animation-name: scroll-fade-bottom-out;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: scroll(self);
    animation-range: calc(100% - 1.5rem) 100%;
  }

  .scroll-fade-mask-x {
    -webkit-mask-image: linear-gradient(
      to right,
      rgba(0, 0, 0, var(--scroll-fade-left)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-right)) 100%
    );
    mask-image: linear-gradient(
      to right,
      rgba(0, 0, 0, var(--scroll-fade-left)) 0,
      black 1rem,
      black calc(100% - 1rem),
      rgba(0, 0, 0, var(--scroll-fade-right)) 100%
    );
    animation-name: scroll-fade-left-in, scroll-fade-right-out;
    animation-duration: auto;
    animation-timing-function: linear;
    animation-fill-mode: both;
    animation-timeline: scroll(self inline);
    animation-range:
      0 1rem,
      calc(100% - 1rem) 100%;
  }
}

/* Horizontal scroll fade scoped to the mobile (< Tailwind `sm`) breakpoint.
   `.scroll-fade-mask-x` can't be reused directly here because the element it
   sits on (SettingsDialogShell's section nav) is a horizontal scroller only
   below `sm` — above it the same element is a vertical sidebar, where a
   left/right inline mask would fade the first/last 1rem of the labels. */
@media (width < 40rem) {
  .scroll-fade-mask-x-max-sm {
    -webkit-mask-image: linear-gradient(
      to right,
      transparent 0,
      black 1rem,
      black calc(100% - 1rem),
      transparent 100%
    );
    mask-image: linear-gradient(
      to right,
      transparent 0,
      black 1rem,
      black calc(100% - 1rem),
      transparent 100%
    );
  }
}

@supports (animation-timeline: scroll(self)) {
  @media (width < 40rem) {
    .scroll-fade-mask-x-max-sm {
      -webkit-mask-image: linear-gradient(
        to right,
        rgba(0, 0, 0, var(--scroll-fade-left)) 0,
        black 1rem,
        black calc(100% - 1rem),
        rgba(0, 0, 0, var(--scroll-fade-right)) 100%
      );
      mask-image: linear-gradient(
        to right,
        rgba(0, 0, 0, var(--scroll-fade-left)) 0,
        black 1rem,
        black calc(100% - 1rem),
        rgba(0, 0, 0, var(--scroll-fade-right)) 100%
      );
      animation-name: scroll-fade-left-in, scroll-fade-right-out;
      animation-duration: auto;
      animation-timing-function: linear;
      animation-fill-mode: both;
      animation-timeline: scroll(self inline);
      animation-range:
        0 1rem,
        calc(100% - 1rem) 100%;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-undo-state="ready"][data-undo-just-enabled="true"] {
    animation: none;
  }
  button:active:not(:disabled) {
    transform: none;
  }
}

@theme inline {
  --font-heading: var(--font-sans);
  --font-sans: "Inter Variable", sans-serif;
  --font-mono: "JetBrains Mono Variable", monospace;
  --color-sidebar-ring: var(--sidebar-ring);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-hover: var(--sidebar-hover);
  --color-sidebar-hover-foreground: var(--sidebar-hover-foreground);
  --color-sidebar-hover-muted-foreground: var(--sidebar-hover-muted-foreground);
  --color-sidebar-selected: var(--sidebar-selected);
  --color-sidebar-selected-foreground: var(--sidebar-selected-foreground);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-desk: var(--desk);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-success: var(--success);
  --color-warning: var(--warning);
  --color-info: var(--info);
  --color-identity-1: var(--identity-1);
  --color-identity-2: var(--identity-2);
  --color-identity-3: var(--identity-3);
  --color-identity-4: var(--identity-4);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
  --color-foreground: var(--foreground);
  --color-background: var(--background);
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --radius-3xl: calc(var(--radius) * 2.2);
  --radius-4xl: calc(var(--radius) * 2.6);
}

:root {
  color-scheme: light;

  /* Sidebar inset variant applies m-2 (8px top + 8px bottom) to SidebarInset — offset its height accordingly */
  --layout-inset-offset: 16px;

  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  /* Lightness is pinned by the WCAG 2 AA floor, not by taste: this token is
     both a fill under --primary-foreground (Button variant="default") and a
     text color on --background (Button variant="link"). At L 0.6321 it read
     3.41:1 against the fill's foreground and 3.56:1 as link text, so both
     surfaces failed the 4.5:1 requirement for normal-weight body text. L
     0.5621 is the first step that clears it on both (4.56:1 and 4.76:1) while
     holding chroma and hue, so the blue is the same blue, just deeper. Do not
     lighten without re-measuring both pairs. */
  --primary: oklch(0.5621 0.1983 259.59);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --destructive: oklch(0.49 0.21 27.518);
  --success: oklch(0.47 0.118 165.612);
  --warning: oklch(0.473 0.137 46.201);
  --info: oklch(0.488 0.243 264.376);
  --identity-1: oklch(0.702 0.183 293.541);
  --identity-2: oklch(0.789 0.154 211.53);
  --identity-3: oklch(0.75 0.183 55.934);
  --identity-4: oklch(0.718 0.202 349.761);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  /* Soft "this block is in your range" halo for JSX wrappers that the
   * browser's native text-selection paint can't reach (their chrome is
   * contentEditable=false). Top-level color token consumed by the soft-
   * halo paint rule; distinct from the instance-scoped `--selection-halo-*`
   * family (precedent #33) that lives on `.jsx-component-wrapper` and
   * gets overridden per `[data-component-type]`. Hue tracks --primary
   * (~259) so the in-range halo reads as brand-coherent; alpha is
   * intentionally lower than the focused `--ring` halo so range-encompass
   * is visibly subordinate to NodeSelection. A future global `::selection`
   * override would introduce a sibling `--selection` token at higher alpha
   * for body prose. */
  --selection-soft: oklch(0.66 0.18 259 / 0.18);
  /* Comment-highlight hue, as a color for interpolation by the anchor
     decorations (`comments/anchor-layers.ts`) and the property-value
     `::selection` twin. It lives here rather than in TS because it is the one
     part of the mark that must differ per theme: the decoration paints the same
     alpha ladder on both canvases, so a single hue cannot clear the 3:1 non-text
     floor at both ends — blue-600 does it on white, and washes out to 2.4:1 on
     the dark canvas. Dark takes blue-400. Gated by comment-hue-contrast.test.ts;
     the Tailwind mirrors on the rail marker and thread card are hand-kept. */
  --ok-comment-hue: rgb(37 99 235);
  /* Categorical chart palette for `html preview` embeds — five
     perceptually-distinct hues aligned with the callout color system
     (--chart-1 anchors to the brand azure, the rest track the
     note/tip/warning/important/caution hues). Light + dark values are
     contrast-gated against the respective --background. These tokens are
     injected into every preview iframe via the generated PREVIEW_THEME_TOKENS
     constant; the .dark block below MUST stay in sync — drift between these
     blocks and the constant is caught by preview-theme-tokens.uncached.test.ts. */
  --chart-1: oklch(0.62 0.19 259);
  --chart-2: oklch(0.58 0.14 145);
  --chart-3: oklch(0.62 0.15 70);
  --chart-4: oklch(0.55 0.18 290);
  --chart-5: oklch(0.58 0.21 25);
  --radius: 0.625rem;
  --desk: oklch(from var(--sidebar) calc(l - 0.015) c h);
  --desk-hover: oklch(from var(--sidebar-hover) calc(l - 0.015) c h);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(
    0.3773 0.1488 264.94 /
    4%
  ); /* based off of azure-900 with lower opacity */
  --sidebar-accent-foreground: var(--color-azure-600);
  --sidebar-hover: oklch(0.97 0 0);
  --sidebar-hover-foreground: oklch(0.145 0 0);
  --sidebar-hover-muted-foreground: #707070;
  --sidebar-hover-destructive-foreground: var(--destructive);
  --sidebar-selected: color-mix(in oklab, var(--sidebar-hover), #000 2%);
  --sidebar-selected-foreground: #000;
  --sidebar-selected-muted-foreground: #6c6c6c;
  --sidebar-selected-destructive-foreground: var(--destructive);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);

  --syntax-keyword: var(--color-purple-700, #6f42c1);
  --syntax-tag: var(--color-red-700, #b31d28);
  --syntax-attr: var(--color-blue-700, #005cc5);
  --syntax-string: var(--color-green-900, oklch(0.393 0.095 152.535));
  --syntax-number: var(--color-blue-800, #005cc5);
  --syntax-atom: var(--color-orange-800, oklch(0.47 0.157 37.304));
  /*
    The remaining syntax roles. A selected color theme overrides all of these
    from its base16 slots; the values here are the `default` theme's own, so
    the same rules paint correctly with no palette applied.
  */
  --syntax-comment: var(--color-gray-600, oklch(0.444 0.011 73.639));
  --syntax-func: var(--color-purple-700, #6f42c1);
  --syntax-var: var(--color-red-700, #b31d28);
  --syntax-type: var(--color-yellow-700, #8b6500);
  --syntax-operator: var(--foreground);
  --syntax-meta: var(--color-gray-600, oklch(0.444 0.011 73.639));
  /* Code-block canvas — a hair off `--background` so a fence reads as a slab. */
  --syntax-bg: oklch(0.97 0 0);

  /* Editor affordances a theme repaints. */
  /* Every document link paints this token, so it is normal-weight body text
     and owes the WCAG 2 AA 4.5:1 floor. `--color-azure-blue` (#3784ff) reads
     3.56:1 on --background and cannot be used here. It stays the palette
     entry for SVG fills, strokes and selection color-mix, where no text
     contrast requirement applies, so the fix is this declaration rather than
     the palette entry. `--color-azure-600` is the next step up the same ramp
     at 5.2:1. Do not point this back at --color-azure-blue. */
  --link-color: var(--color-azure-600);
  --broken-link-color: oklch(55% 0.15 25);
  --lint-warning-color: oklch(70% 0.15 75);
  --lint-error-color: oklch(55% 0.15 25);
  --diff-added: var(--color-green-800, #22863a);
  --diff-removed: var(--color-red-700, #b31d28);
  --diff-modified: var(--color-blue-700, #005cc5);

  /*
    Terminal ANSI slots. The docked terminal reads these live, so a base16
    theme repaints program output, not just the terminal's chrome. The
    `default` theme has no palette to derive from, so it keeps the curated
    VS Code values these were before — tuned for legibility.
  */
  --ansi-black: #000000;
  --ansi-red: #cd3131;
  --ansi-green: #00bc00;
  --ansi-yellow: #949800;
  --ansi-blue: #0451a5;
  --ansi-magenta: #bc05bc;
  --ansi-cyan: #0598bc;
  --ansi-white: #555555;
  --ansi-bright-black: #666666;
  --ansi-bright-red: #cd3131;
  --ansi-bright-green: #14ce14;
  --ansi-bright-yellow: #b5ba00;
  --ansi-bright-blue: #0451a5;
  --ansi-bright-magenta: #bc05bc;
  --ansi-bright-cyan: #0598bc;
  --ansi-bright-white: #a5a5a5;
}

.dark {
  color-scheme: dark;

  --background: oklch(0.21 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.245 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.225 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: var(--color-sky-blue);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.778 0.191 22.216);
  --success: oklch(0.765 0.177 163.223);
  --warning: oklch(0.879 0.169 91.605);
  --info: oklch(0.729 0.165 254.624);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  /* Dark-mode soft range halo — slightly brighter + higher alpha so the
   * 18%-on-white equivalent reads cleanly on dark backgrounds. */
  --selection-soft: oklch(0.72 0.16 259 / 0.32);
  /* Dark-canvas comment hue — blue-400. See the :root declaration for why this
     is the one token in the mark that has to move with the theme. */
  --ok-comment-hue: rgb(96 165 250);
  /* Dark-mode chart palette — same hue family as the :root block above,
     lightness lifted for legibility on the dark --background. Keep in sync
     with :root --chart-* and PREVIEW_THEME_TOKENS (preview-theme-tokens.uncached.test.ts). */
  --chart-1: oklch(0.72 0.14 259);
  --chart-2: oklch(0.73 0.13 145);
  --chart-3: oklch(0.77 0.14 70);
  --chart-4: oklch(0.72 0.16 290);
  --chart-5: oklch(0.72 0.2 25);
  --sidebar: oklch(0.185 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: var(--color-sky-blue);
  --sidebar-hover: oklch(0.269 0 0 / 50%);
  --desk-hover: var(--sidebar-hover);
  --sidebar-hover-foreground: oklch(0.985 0 0);
  --sidebar-hover-muted-foreground: var(--muted-foreground);
  --sidebar-hover-destructive-foreground: var(--destructive);
  --sidebar-selected: color-mix(in oklab, var(--sidebar-hover), #fff 4%);
  --sidebar-selected-foreground: #fff;
  --sidebar-selected-muted-foreground: var(--muted-foreground);
  --sidebar-selected-destructive-foreground: var(--destructive);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-ring: oklch(0.556 0 0);

  --syntax-keyword: var(--color-purple-300, #d2a8ff);
  --syntax-tag: var(--color-red-300, #ffa198);
  --syntax-attr: var(--color-blue-300, #79c0ff);
  --syntax-string: oklch(0.9 0.15 154.449);
  --syntax-number: var(--color-blue-300, #79c0ff);
  --syntax-atom: var(--color-orange-300, #ffa657);
  --syntax-comment: oklch(0.78 0.01 56.259);
  --syntax-func: var(--color-purple-300, #d2a8ff);
  --syntax-var: var(--color-red-300, #ffa198);
  --syntax-type: var(--color-yellow-300, #e3b341);
  --syntax-operator: var(--foreground);
  --syntax-meta: oklch(0.78 0.01 56.259);
  --syntax-bg: oklch(0.18 0.005 285);

  --link-color: var(--color-sky-blue);
  --broken-link-color: oklch(72% 0.18 25);
  --lint-warning-color: oklch(80% 0.13 80);
  --lint-error-color: oklch(72% 0.18 25);
  --diff-added: var(--color-green-300, #7ee787);
  --diff-removed: var(--color-red-300, #ffa198);
  --diff-modified: var(--color-blue-300, #79c0ff);

  --ansi-black: #000000;
  --ansi-red: #cd3131;
  --ansi-green: #0dbc79;
  --ansi-yellow: #e5e510;
  --ansi-blue: #2472c8;
  --ansi-magenta: #bc3fbc;
  --ansi-cyan: #11a8cd;
  --ansi-white: #e5e5e5;
  --ansi-bright-black: #666666;
  --ansi-bright-red: #f14c4c;
  --ansi-bright-green: #23d18b;
  --ansi-bright-yellow: #f5f543;
  --ansi-bright-blue: #3b8eea;
  --ansi-bright-magenta: #d670d6;
  --ansi-bright-cyan: #29b8db;
  --ansi-bright-white: #ffffff;
}

html.dark:not([data-color-theme]) {
  --desk: oklch(0.15 0 0);
  --file-tree-foreground: color-mix(in oklab, var(--sidebar-foreground) 75%, var(--sidebar));
}

html.dark:not([data-color-theme]) [data-app-header-leading] [data-variant="secondary"] {
  background-color: color-mix(in oklab, var(--desk) 96%, var(--sidebar-foreground));
  color: var(--muted-foreground);
}

html.dark [data-app-header] button[data-variant="ghost"]:is(:hover, [data-state="open"]) {
  background-color: oklch(from var(--desk) calc(l + 0.04) c h);
}

@media (hover: hover) {
  [data-app-header]
    [data-pane-switcher]
    button[data-variant="ghost"]:not([aria-pressed="true"]):hover {
    background-color: oklch(from var(--foreground) l c h / 0.1);
  }
}

html.dark
  [data-app-header]
  [data-pane-switcher]
  button[data-variant="ghost"][aria-pressed="true"]:is(:hover, [data-state="open"]) {
  background-color: oklch(from var(--foreground) l c h / 0.15);
}

/*
  Electron-mode outer-canvas alpha-aware retrofit.

  Triggered by the `electron-mode` class added to <html> by the FOUC inline
  script in index.html when `window.okDesktop` is present (preload bridge
  runs before any inline page script). Web mode (no class) leaves the
  outer canvas solid — visually unchanged from baseline.

  Scope is narrow: ONLY the outer canvas surfaces become alpha-aware
  so the BrowserWindow's `vibrancy: 'sidebar'` material shows through.
  Inner editor surfaces (sidebar-inset, card, popover, dialog, tooltip-card,
  --background) STAY OPAQUE — the visual depth cue. Vibrancy is exposed only
  through the outer canvas; the inner main island floats opaquely above it.

  The relative-color syntax `oklch(from var(--sidebar) l c h / <alpha>)`
  reads --sidebar's cascaded value (set in :root for light, .dark for dark)
  and produces the alpha-aware tint without duplicating OKLCH literals.
  Single source of truth — when --sidebar moves, the alpha-aware tint moves
  with it. No drift, no cycle (we override background-color, NOT --sidebar).

  Browser support: relative-color syntax is Chromium 119+ / WebKit 16.4+ /
  Firefox 128+. Electron 44 ships Chromium 152+ — fully supported.

  prefers-reduced-transparency has its own dedicated fallback path below
  (the @media (prefers-reduced-transparency: reduce) block) and is
  intentionally NOT handled here.
*/
html.electron-mode {
  background-color: transparent;
  /*
    macOS traffic-light safe-area reserve. The Electron main process places
    the OS-drawn close/min/zoom buttons in the renderer's top-left: at
    x=16, y=15 inside a project window's 44px AppHeader (lined up with the
    file list's content edge), x=22, y=17 in note windows and x=22, y=24 in
    every other window (see
    `packages/desktop/src/main/window-chrome.ts` and `note-window.ts`). Any
    top-row chrome or full-viewport overlay must reserve enough left padding
    to clear that footprint. 78px = trafficLightPosition.x (22) + 3 buttons
    × ~18px + margin. This token is the single source for that reserve:
    AppHeader, the note and single-file windows' EditorHeader, GraphPanel,
    and the connection and branch banners all consume it rather than
    re-declaring the literal. The AppHeader adds 10px to it, so on darwin
    back and forward start 12px after the window buttons at x=16, and on
    the web the first button's icon lines up with the file list, 16px from
    the edge. Windows and Linux re-declare it as 0px inside the AppHeader for
    the same alignment (see the rule after the reduced-transparency block).
    Web hosts (no `window.okDesktop`) never gain the `electron-mode` class,
    so the variable is undefined there. Consumers MUST always supply a
    fallback, and its value is the padding that consumer wants on the web:
    `pl-[var(--ok-titlebar-reserve-left,1rem)]` for the ones whose base is
    `px-4`, and `,0px` for the AppHeader, which supplies its own 10px on top
    and so wants nothing added underneath. A bare no-fallback
    `pl-[var(--ok-titlebar-reserve-left)]` is invalid-at-computed-value-time
    on web and collapses `padding-left` to `0`, discarding the consumer's
    base padding — a regression, not intended behavior. See precedent #49.
  */
  --ok-titlebar-reserve-left: 78px;
}

/*
  Windows/Linux chrome (electron-platform-* classes come from the FOUC
  script alongside electron-mode, read off `window.okDesktop.platform`).
  No traffic lights on these platforms — collapse the left reserve back to
  the 1rem base padding. The OS window controls instead float via Electron's
  titleBarOverlay (Window Controls Overlay), so reserve the chrome row's edge
  for them. Windows always places them top-right; Linux follows the desktop
  environment's own title-bar layout, so a DE configured to put them on the
  left gets only the 1rem base reserve and can crowd whatever sits leftmost
  in the row. Verify on a packaged build before assuming the left edge is
  clear there. The `titlebar-area-*` env() vars are live
  exactly when WCO is enabled; the fallbacks make the reserve 0 on darwin,
  web, and any WCO-less window. Consumers use the precedent-#49 fallback
  form `mr-[var(--ok-titlebar-reserve-right,0px)]`.
*/
html.electron-mode.electron-platform-win32,
html.electron-mode.electron-platform-linux {
  --ok-titlebar-reserve-left: 1rem;
  --ok-titlebar-reserve-right: calc(
    100vw -
    env(titlebar-area-x, 0px) -
    env(titlebar-area-width, 100vw)
  );
}

@media (hover: hover) {
  [data-app-header]
    :is([data-variant^="ghost"], [data-slot="menubar-trigger"]):not([aria-pressed="true"]):hover {
    background-color: var(--desk-hover);
  }
}

[data-app-header]
  :is([data-variant^="ghost"], [data-slot="menubar-trigger"]):not([aria-pressed="true"]):is(
    [data-state="open"],
    [aria-expanded="true"]
  ) {
  background-color: var(--desk-hover);
}

html.electron-mode body {
  background-color: oklch(from var(--desk) l c h / 0.85);
}

html.electron-mode [data-slot="sidebar-wrapper"] {
  background-color: oklch(from var(--desk) l c h / 0.85);
}

html.electron-mode [data-app-header] {
  background-color: oklch(from var(--desk) l c h / 0.85);
}

html.electron-mode [data-slot="sidebar-inner"] {
  background-color: oklch(from var(--sidebar) l c h / 0.85);
}

/*
  prefers-reduced-transparency revert.

  When the user has enabled macOS System Settings → Accessibility → Display →
  Reduce transparency, the alpha-aware outer canvas above is rolled back to
  solid `var(--sidebar)`. Pairs with the main-side runtime path
  (reduced-transparency-handler.ts) which calls `setVibrancy(null)` on every
  BrowserWindow — both sides converge on solid surfaces, so the user sees
  neither vibrancy material nor alpha-aware tints. Accessibility compliance
  with no degraded readability.

  Inner editor surfaces (sidebar-inset, card, popover, dialog, tooltip-card,
  --background) are opaque always — the @media block has no business
  redeclaring them. The cascade only touches what the cascade above touched.

  Specificity: the un-mediaed alpha-aware rules above and these solid
  reverts have identical (0,1,2) specificity; @media-takes-precedence is
  what ranks them when the user-agent supports the media query. Browsers
  without prefers-reduced-transparency (older WebKit / Gecko) ignore the
  @media block entirely and fall through to the alpha-aware rules — same
  result as a user who hasn't toggled the OS preference.
*/
@media (prefers-reduced-transparency: reduce) {
  html.electron-mode {
    background-color: var(--desk);
  }

  html.electron-mode body {
    background-color: var(--desk);
  }

  html.electron-mode [data-slot="sidebar-wrapper"] {
    background-color: var(--desk);
  }

  html.electron-mode [data-app-header] {
    background-color: var(--desk);
  }

  html.electron-mode [data-slot="sidebar-inner"] {
    background-color: var(--sidebar);
  }
}

html.electron-mode.electron-platform-win32 [data-app-header],
html.electron-mode.electron-platform-linux [data-app-header] {
  --ok-titlebar-reserve-left: 0px;
}

html [data-editor-file-list-slot] [data-slot="sidebar-inner"] {
  background-color: var(--sidebar);
}

/* prose-no-margin — margin reset for first/last children inside wrappers.
   Applied to the jsx-component-wrapper's nested editable region so block
   children don't carry their natural top/bottom prose margins into the
   component chrome. Surviving consumer: the wildcard UnregisteredBadgeRender
   in componentMap.tsx wraps children in <div className="prose-no-margin">,
   and this file's rawMdxFallback chrome + future DIY Callout/Accordion chrome
   rely on the same selector shape. Pre-US-004 the fumadocs cherry-pick section
   (Steps utility classes + Accordion/Collapsible animation keyframes) sat above
   this block; removed alongside the per-component CSS-variable token bridge
   in D-MF2. */
.prose-no-margin > :first-child {
  margin-top: 0;
}
.prose-no-margin > :last-child {
  margin-bottom: 0;
}

/* 7. Component block chrome — all overlays, zero permanent layout shift.
 * Principle: components render exactly like production. Editor affordances
 * are hover-revealed overlays (badge+gear, add-child pill, subtle hover tint). */

.ProseMirror .jsx-component-wrapper {
  position: relative;
  border-radius: 0.375rem;
  /* Reserve vertical space above each component wrapper for the chrome
   * bar (`.jsx-component-chrome` floats at `top: -11px`, ~28px tall, so
   * it extends ~11-39px above the wrapper). Without this gap, the bar
   * visually overlaps the previous block's bottom AND gets clipped at
   * the editor's scroll-top edge when the wrapper is the first block.
   * The Tailwind class on the element (`my-2` = 0.5rem each side) is
   * insufficient for the bar's 11px above-wrapper extension; this rule
   * overrides via descendant-selector specificity (0,2,0 vs 0,1,0).
   * Symmetric block spacing — both top and bottom — keeps the visual
   * weight consistent block-to-block. */
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
  /* Establishes a stacking context for the behind-content halo (§7a).
   * `position: relative` alone is NOT sufficient: with `z-index: auto`
   * the wrapper doesn't open its own stacking context, so the `::after`
   * at `z-index: -1` escapes to the viewport root and paints BEHIND
   * `body { background-color: ... }` — the halo becomes invisible.
   * `isolation: isolate` creates a stacking context without affecting
   * z-index cascade for siblings, trapping the halo at -1 behind the
   * wrapper's own content but above the body background. SPEC §3.3
   * T10 evidence assumed `position: relative` was enough; it's not. */
  isolation: isolate;
}
/* Child component drag prevention is handled via onDragStart={preventDefault}
   on the NodeViewWrapper in JsxComponentView.tsx. CSS-level -webkit-user-drag
   was removed due to Biome lint incompatibility. */
/* Invisible hover zone above the component — allows reaching the parent's
   chrome bar even when children fill the entire block. Does NOT affect
   layout (position:absolute + negative top, zero height in flow). */
.ProseMirror .jsx-component-wrapper::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
  z-index: 9;
}

/* 7a. Selection halo — per-block-type tokens, behind-content (T10),
 * transparent-outline placeholder (T3), forced-colors compliant,
 * reduced-motion gated, compositor-safe opacity transition.
 *
 * Consumes data-* attrs emitted by JsxComponentView from SelectionStatePlugin
 * (see selection-state-plugin.ts). The pseudo-element is `::after` because
 * `::before` is already used above as an invisible hover hit-zone; the
 * T10 (behind-content) + T3 (transparent-outline) architecture is identical
 * either way — only the name differs from the reference SPEC.
 *
 * Per-type tuning is opt-in via --selection-halo-* custom properties scoped
 * under [data-component-type="..."]. Pre-US-004 this pattern was described
 * as "extends the fumadocs token bridge"; the bridge itself was removed
 * alongside the fumadocs-ui React deps in D-MF2 / FR-13, leaving only the
 * per-type custom-property overlay shape. */
.ProseMirror .jsx-component-wrapper {
  /* Default halo tokens (overridden per component type below). */
  --selection-halo-inset: -4px;
  --selection-halo-radius: calc(0.375rem + 4px);
  --selection-halo-color: var(--ring);
  --selection-halo-opacity: 0;
  --selection-halo-width: 2px;
}

.ProseMirror .jsx-component-wrapper::after {
  content: "";
  position: absolute;
  inset: var(--selection-halo-inset);
  /* T3: transparent-outline placeholder — forced-colors mode forces
     border-color, making the element visible in Windows High Contrast
     even when the browser strips box-shadow. */
  border: var(--selection-halo-width) solid transparent;
  border-radius: var(--selection-halo-radius);
  opacity: var(--selection-halo-opacity);
  pointer-events: none;
  /* T10: behind-content — halo paints below the wrapper's chrome and its
     own content, so Card/Accordion/Callout borders don't stack a second
     ring. Requires position:relative on the wrapper (set above) + the
     wrapper having a transparent default background (it does). */
  z-index: -1;
  box-sizing: border-box;
}

/* Compositor-safe fade — only animate when motion is welcome. */
@media (prefers-reduced-motion: no-preference) {
  .ProseMirror .jsx-component-wrapper::after {
    /* Use the repo's custom easing token (defined ~L32) — matches the
       Emil Kowalski "strong ease-out" used by every other interactive
       transition in this file (7 usages incl. Popover, Callout). */
    transition: opacity 180ms var(--ease-out-strong);
  }
}

/* Paint the halo for the innermost selected wrapper. */
.ProseMirror .jsx-component-wrapper[data-selected="true"]::after {
  --selection-halo-opacity: 1;
  border-color: var(--selection-halo-color);
}

/* Innermost-wins defense-in-depth: the plugin never sets both attrs on the
 * same wrapper (store-enforced), but if a future refactor were to regress
 * that invariant, this rule keeps only the innermost halo visible. */
.ProseMirror .jsx-component-wrapper[data-has-child-selected="true"][data-selected="true"]::after {
  --selection-halo-opacity: 0;
}

/* Drag suppresses the halo + transition (Vaul pattern — halo re-appears
 * cleanly on drop rather than fading during the gesture). */
.ProseMirror .jsx-component-wrapper[data-dragging="true"]::after {
  --selection-halo-opacity: 0;
  transition: none;
}

/* Forced-colors (Windows High Contrast): CanvasText is the current system
 * foreground color, guaranteed visible regardless of WHCM theme. */
@media (forced-colors: active) {
  .ProseMirror .jsx-component-wrapper[data-selected="true"]::after {
    border-color: CanvasText;
  }
}

/* Soft "in your range" halo for JSX wrappers covered by a TextSelection /
 * AllSelection. The wrapper's chrome is contentEditable=false, so the
 * browser-native text highlight never reaches it; this rule paints a
 * subtle filled treatment so range-encompass is visually legible.
 *
 * Painted via `background` on the ::after pseudo-element (not the wrapper)
 * so it composes with the existing inset / radius / z-index:-1 tokens —
 * the soft tone tucks behind the wrapper content the same way the full
 * halo does. Specificity-wise, when both attributes happen to be set the
 * full halo wins (selectedness > range-encompass); the `:not()` guard
 * makes the intent explicit at the CSS layer in case a future code path
 * sets both attrs simultaneously. */
.ProseMirror .jsx-component-wrapper[data-range-selected="true"]:not([data-selected="true"])::after {
  background: var(--selection-soft);
  opacity: 1;
}

/* Forced-colors (Windows High Contrast): use the system Highlight color so
 * the in-range halo remains visible when the user's OS forces a high-
 * contrast palette. The `:not()` guard mirrors the standard rule above:
 * keeps the soft in-range tint from compositing with the full-halo
 * selection paint if a future code path were to set both attributes. */
@media (forced-colors: active) {
  .ProseMirror
    .jsx-component-wrapper[data-range-selected="true"]:not([data-selected="true"])::after {
    background: Highlight;
    opacity: 0.5;
  }
}

/* Per-block-type tuning. Media blocks (Image, Video) keep a tighter
 * border-radius that matches their inner element's corner geometry; the
 * halo inset itself is uniform across all substrates (set on the wrapper
 * default at the top of this block). Callouts read --callout-type-color
 * (set inline by the DIY Callout renderer) so the halo matches the
 * callout's chroma; the fallback to var(--ring) covers unregistered /
 * wildcard paths. Other substrates fall through to the wildpath defaults. */
.ProseMirror .jsx-component-wrapper[data-component-type="img"] {
  --selection-halo-radius: calc(0.625rem + 2px);
}

.ProseMirror .jsx-component-wrapper[data-component-type="video"] {
  --selection-halo-radius: calc(0.625rem + 2px);
}

/* Math block — KaTeX's default `.math-display` has zero vertical
 * padding, so a block formula sits flush against the surrounding
 * prose (the parent `.jsx-component-wrapper`'s `my-2` covers the
 * outer gap, but the formula's *content box* still touches the
 * wrapper's top + bottom edges, reading as cramped — especially when
 * two `$$…$$` blocks land back-to-back). 0.75rem of vertical padding
 * gives the formula breathing room without changing the block's
 * horizontal centering or the wrapper's selection-halo radius. */
.ProseMirror [data-component-type="math"].math-display {
  padding: 0.75rem 0;
}

/* Audio shrinks the wrapper to the rendered media's actual width so
   the selection halo and chrome bar (positioned at right: 0) hug the
   audio element instead of the full editor column. Text-heavy types
   (Callout, Accordion, etc.) intentionally fill the column and are
   not listed here.

   Image and video are excluded from fit-content for two different
   reasons:
   - Image: arbitrarily small (down to 1px decorative PNGs); a
     fit-content wrapper collapses to those dimensions, causing the
     right-anchored chrome bar (~120px wide) to overlap the image's
     click area.
   - Video: PropPanel anchors to the wrapper; a fit-content wrapper
     shrinks/grows as the author edits the video's `width` prop,
     causing the floating PropPanel to jump on every keystroke
     (PRD-6822). Column-width wrapper keeps the panel anchor stable.

   Both img and video use the text-align-on-wrapper alignment shape
   (see the `[data-align]` rules below) so the chrome bar sits at the
   column's right edge while the media moves left / center / right
   within the column. */
.ProseMirror .jsx-component-wrapper[data-component-type="audio"] {
  width: fit-content;
  max-width: 100%;
}

/* Image alignment within the column. Driven by `data-align` on the
 * `JsxComponentView` wrapper, which is set from the descriptor's `align`
 * prop (`htmlImgProps`, default `center`). Both descriptors that render
 * as an image — the `img` canonical AND the `CommonMarkImage` compat
 * (`![alt](src)` form) — get the alignment surface; the chrome-bar click
 * handler upgrades a CommonMarkImage to `img` on first non-default
 * alignment so the value persists through serialization.
 *
 * Implemented via `text-align` on the wrapper (the inline `<img>` inside
 * is centered/left/right via inline-content alignment). This is
 * deliberately DIFFERENT from the `width: fit-content + margin: auto`
 * approach — that would shrink the wrapper to the image's natural
 * dimensions, causing the right-anchored chrome bar (~120px wide,
 * `top: -11px`) to overlap the image's click region for small images.
 * The decorative-PNG comment on the `data-component-type="video|audio"`
 * fit-content rule above was written to protect against exactly this
 * overlap; `text-align` keeps the wrapper at its natural column width
 * so the chrome bar stays at the column's right edge while the image
 * sits left/center/right inside. */
.ProseMirror .jsx-component-wrapper[data-component-type="img"][data-align="left"],
.ProseMirror .jsx-component-wrapper[data-component-type="commonmarkimage"][data-align="left"] {
  text-align: left;
}
.ProseMirror .jsx-component-wrapper[data-component-type="img"][data-align="center"],
.ProseMirror .jsx-component-wrapper[data-component-type="commonmarkimage"][data-align="center"] {
  text-align: center;
}
.ProseMirror .jsx-component-wrapper[data-component-type="img"][data-align="right"],
.ProseMirror .jsx-component-wrapper[data-component-type="commonmarkimage"][data-align="right"] {
  text-align: right;
}
/* Tailwind v4 preflight sets `img { display: block }` (to fix the
 * baseline-descender gap when img sits next to text). Block elements
 * ignore the parent's `text-align`, which silently breaks the three
 * alignment rules above. Override to `inline-block` ONLY inside an
 * alignment-bearing image wrapper so the `text-align` can center /
 * left / right the img — Tailwind's block default stays in place for
 * every other img on the page. */
.ProseMirror .jsx-component-wrapper[data-component-type="img"][data-align] img,
.ProseMirror .jsx-component-wrapper[data-component-type="commonmarkimage"][data-align] img {
  display: inline-block;
}

/* Embed alignment — text-align on the wrapper centers/lefts/rights the
   inline-block embed pane inside the column. Mirrors the img/CommonMarkImage
   rules above. */
.ProseMirror .jsx-component-wrapper[data-component-type="embed"][data-align="left"] {
  text-align: left;
}
.ProseMirror .jsx-component-wrapper[data-component-type="embed"][data-align="center"] {
  text-align: center;
}
.ProseMirror .jsx-component-wrapper[data-component-type="embed"][data-align="right"] {
  text-align: right;
}

/* Video alignment — parity with img + embed (PRD-6822). `text-align` on the
   wrapper centers / lefts / rights the inline-block `.ok-video` child inside
   the column. The wrapper stays at column width (no fit-content) so the
   right-anchored chrome bar and the floating PropPanel stay column-stable
   while the author tweaks the video's `width` prop. */
.ProseMirror .jsx-component-wrapper[data-component-type="video"][data-align="left"] {
  text-align: left;
}
.ProseMirror .jsx-component-wrapper[data-component-type="video"][data-align="center"] {
  text-align: center;
}
.ProseMirror .jsx-component-wrapper[data-component-type="video"][data-align="right"] {
  text-align: right;
}

/* Embed pane — `display: inline-block` so the `text-align` alignment rules
   above can center / left / right the pane within the column. Resize is
   driven by the `ok-resize-overlay` handles (see below), not native CSS
   `resize` — the handles work on all 4 sides + 4 corners and don't
   require the user to find the bottom-right grip. */
.ProseMirror .ok-embed {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
  min-width: 12rem;
  min-height: 8rem;
  max-height: 80vh;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.ProseMirror .ok-embed-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  /* Match the wrapper background while the cross-origin page loads —
     hardcoded `white` flashes a light rectangle in dark mode. The
     embedded page renders its own background on load and covers this. */
  background: var(--background);
}

/* Placeholder shown for a fresh `<Embed />` with no src yet. Kept in a
   single matched-color box so the slash-insert UX is recognisable. */
.ProseMirror .ok-embed--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 8rem;
  color: var(--muted-foreground);
  font-style: italic;
}

/* -----------------------------------------------------------------------
 * Resize handles — shared 8-grip overlay for rich blocks (Embed, codeblock
 * preview, …). Inactive until the host wrapper is hovered / cursor-inside /
 * NodeSelected; the handles fade in via opacity so resting state stays
 * uncluttered. Each handle is a small absolutely-positioned hit target.
 *
 * Corners render as L-shaped brackets (matching the visual mock); edges
 * render as thin lines centred on each side. All 8 share the same hover
 * tint so the affordance reads consistently.
 * --------------------------------------------------------------------- */
.ok-resize-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.ok-resize-handle {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--border);
  opacity: 0;
  transition:
    opacity 0.15s,
    color 0.1s;
  pointer-events: none;
}

/* Honor the user's reduced-motion preference. Matches the codebase
   pattern applied to every other transition in this file. */
@media (prefers-reduced-motion: reduce) {
  .ok-resize-handle {
    transition: none;
  }
}

/* Edge handles — thin centred lines spanning ~40% of the side. Larger
   invisible hit-target padding makes them grabbable without precision. */
.ok-resize-handle--t,
.ok-resize-handle--b {
  left: 30%;
  right: 30%;
  height: 8px;
  background: currentColor;
  border-radius: 4px;
}
.ok-resize-handle--t {
  top: -4px;
}
.ok-resize-handle--b {
  bottom: -4px;
}

.ok-resize-handle--l,
.ok-resize-handle--r {
  top: 30%;
  bottom: 30%;
  width: 8px;
  background: currentColor;
  border-radius: 4px;
}
.ok-resize-handle--l {
  left: -4px;
}
.ok-resize-handle--r {
  right: -4px;
}

/* Corner handles — L-shaped brackets. Drawn with a 14×14 box whose two
   visible borders form the bracket; the inside is transparent. */
.ok-resize-handle--tl,
.ok-resize-handle--tr,
.ok-resize-handle--bl,
.ok-resize-handle--br {
  width: 14px;
  height: 14px;
  background: transparent;
  border: 0;
}

.ok-resize-handle--tl {
  top: -1px;
  left: -1px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-top-left-radius: 4px;
}
.ok-resize-handle--tr {
  top: -1px;
  right: -1px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-top-right-radius: 4px;
}
.ok-resize-handle--bl {
  bottom: -1px;
  left: -1px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-bottom-left-radius: 4px;
}
.ok-resize-handle--br {
  bottom: -1px;
  right: -1px;
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  border-bottom-right-radius: 4px;
}

/* Hover-on-host reveal. Host is the resizable component's wrapper
   (`.ok-embed`, `.ok-codeblock-preview`, etc.). The handle pointer-events
   only enable while visible so the wrapper's normal interactions
   (iframe clicks, text selection) work in resting state. */
.ProseMirror .ok-embed:hover .ok-resize-handle,
.ProseMirror .ok-embed:focus-within .ok-resize-handle,
.ProseMirror .ok-codeblock-preview:hover .ok-resize-handle,
.ProseMirror .ok-codeblock[data-cursor-inside="true"] .ok-codeblock-preview .ok-resize-handle,
.ProseMirror .jsx-component-wrapper[data-selected="true"] .ok-resize-handle {
  opacity: 1;
  pointer-events: auto;
  color: var(--ring, oklch(0.55 0.18 250));
}

.ok-resize-handle:hover {
  color: var(--ring, oklch(0.55 0.18 250));
}

.ProseMirror .jsx-component-wrapper[data-component-type="callout"],
.ProseMirror .jsx-component-wrapper[data-component-type="gfmcallout"] {
  --selection-halo-color: var(--callout-type-color, var(--ring));
  --selection-halo-radius: calc(0.625rem + 4px);
}

.ProseMirror .jsx-component-wrapper[data-component-type="accordion"] {
  --selection-halo-radius: calc(0.625rem + 4px);
}

/* 7b. Callout (5-pack DIY renderer, US-005) — per-type accent tokens.
 *
 * Per-type accent color drives: left-border tint, icon color, collapsible
 * chevron, and the wrapper's selection halo (via --callout-type-color which
 * the §7a rule above reads). Author's `color` prop sets --callout-type-color
 * inline on the root element, overriding the per-type default below. The
 * 5 values match the GFM alert set (D-MF11); parser alias map (US-010)
 * folds broader Obsidian / Mintlify types into this subset.
 *
 * All five accent tokens are oklch() for consistent chroma across light/dark.
 * Mapping rationale: `note` → sky-blue (OK primary family, informational);
 * `tip` → green (positive / supportive); `important` → violet (emphasis /
 * attention); `warning` → amber (heads-up, non-destructive); `caution` →
 * red (destructive / hazard).
 */
:root {
  /* GFM 5 — pre-2026-05 colors, kept identical so existing renders are
   * unchanged. */
  --callout-note-color: oklch(0.62 0.15 240); /* blue */
  --callout-tip-color: oklch(0.58 0.14 145); /* green */
  --callout-important-color: oklch(0.55 0.18 290); /* violet */
  --callout-warning-color: oklch(0.65 0.16 70); /* amber */
  --callout-caution-color: oklch(0.58 0.21 25); /* red */
  /* Obsidian-parity 10 — distinct hues so the visual identity per type
   * is recognizable at a glance. Tokens are referenced once in the
   * `[data-callout-type="…"]` rules below; chroma values match the GFM
   * 5's intensity for visual coherence. */
  --callout-abstract-color: oklch(0.65 0.13 220); /* sky / teal */
  --callout-info-color: oklch(0.62 0.15 240); /* blue — note's hue */
  --callout-todo-color: oklch(0.62 0.15 260); /* indigo */
  --callout-success-color: oklch(0.6 0.16 150); /* emerald — slightly hotter than tip's green */
  --callout-question-color: oklch(0.6 0.18 310); /* magenta-violet */
  --callout-failure-color: oklch(0.58 0.21 15); /* red — matches caution */
  --callout-danger-color: oklch(0.6 0.21 35); /* red-orange */
  --callout-bug-color: oklch(0.58 0.18 5); /* deep red */
  --callout-example-color: oklch(0.6 0.15 280); /* violet, distinct from important */
  --callout-quote-color: oklch(0.55 0.04 270); /* near-gray with cool tint */
}

.dark {
  /* Lifted lightness for dark-mode legibility — same hue family per type. */
  --callout-note-color: oklch(0.75 0.12 240);
  --callout-tip-color: oklch(0.73 0.13 145);
  --callout-important-color: oklch(0.72 0.16 290);
  --callout-warning-color: oklch(0.77 0.14 70);
  --callout-caution-color: oklch(0.72 0.2 25);
  --callout-abstract-color: oklch(0.78 0.11 220);
  --callout-info-color: oklch(0.75 0.12 240);
  --callout-todo-color: oklch(0.75 0.13 260);
  --callout-success-color: oklch(0.75 0.14 150);
  --callout-question-color: oklch(0.75 0.16 310);
  --callout-failure-color: oklch(0.72 0.2 15);
  --callout-danger-color: oklch(0.74 0.19 35);
  --callout-bug-color: oklch(0.72 0.17 5);
  --callout-example-color: oklch(0.75 0.13 280);
  --callout-quote-color: oklch(0.72 0.04 270);
}

/* ── Footnotes ───────────────────────────────────────────────────────────────
 *
 * `footnoteReference` PM atom + `footnoteDefinition` PM block.
 * Reference: superscript link to the matching definition. Definition:
 * numbered list at the foot of the document with a back-reference arrow
 * — Obsidian-parity rendering. Both keyed on the `identifier` attr; the
 * `<sup><a href="#fn-{id}">` link points to `<aside id="fn-{id}">`, and
 * the `<a class="footnote-backref" href="#fnref-{id}">` arrow on the
 * definition points back to the reference's `<sup id="fnref-{id}">`.
 */
.footnote-ref {
  font-size: 0.75em;
  /* `position: relative; top` instead of `vertical-align: super` keeps
   * the inline box on baseline (so the parent's line-height isn't
   * forced to grow), while rendering visually as a superscript. The
   * previous `vertical-align: super` + `line-height: 0` pair raised
   * the inline box ~0.5em and then collapsed its line-box
   * contribution, so the bracket glyph's top extended above the
   * parent line's ascender — visible clipping in headings (tighter
   * intrinsic ascender) and on the first line of a block. The
   * relative-position technique is the standard cross-browser fix
   * (used by MDN's reset, Wikipedia's mobile skin, etc.). */
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
  margin: 0 0.05em;
}
.footnote-ref-link {
  color: var(--primary);
  text-decoration: none;
}
.footnote-ref-link:hover {
  text-decoration: underline;
}

/* Counter resets at the editor root so all `.footnote-def` blocks in the
 * document share one auto-numbering sequence (1., 2., 3., …) regardless
 * of their identifier strings. */
.ProseMirror {
  counter-reset: footnote 0;
}

.footnote-def {
  counter-increment: footnote;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Auto-numbered marker: `1.`, `2.`, `3.` — generated from the counter
 * rather than the identifier string, matching how Obsidian / GFM
 * renderers display footnotes regardless of the underlying label. */
.footnote-def::before {
  content: counter(footnote) ".";
  flex-shrink: 0;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  min-width: 1.5em;
}

/* Visual divider above the first footnote in the document — separates
 * the footnote list from the prose body. CSS has no native "first-of-
 * class" selector, so we apply the divider to ALL `.footnote-def` and
 * then UN-apply it on any `.footnote-def` that has a prior
 * `.footnote-def` SIBLING anywhere earlier in the parent. The general-
 * sibling combinator (`~`) matches across intervening non-footnote
 * elements — PM inserts `<p class="ok-chunk-wrapper">` chunks between
 * every block-level node, so the adjacent-sibling combinator (`+`)
 * would never see a `.footnote-def + .footnote-def` match in practice.
 *
 * Class-keyed rather than `:first-of-type` because `commentBlock` also
 * renders as `<aside>` (see `core/src/extensions/comment-block.ts`) —
 * a comment block before the first footnote would otherwise hide the
 * divider. */
.footnote-def {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.footnote-def ~ .footnote-def {
  margin-top: 0.25rem;
  padding-top: 0;
  border-top: none;
}

.footnote-def .footnote-body {
  flex: 1;
}
.footnote-def .footnote-body > :first-child {
  margin-top: 0;
}
.footnote-def .footnote-body > :last-child {
  margin-bottom: 0;
}

.footnote-backref {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.85em;
  margin-left: 0.25rem;
  flex-shrink: 0;
}
.footnote-backref:hover {
  color: var(--primary);
}

/* Per-type default accent. An inline `--callout-type-color` from the
 * Callout.tsx `color` prop wins over these defaults (inline style has
 * higher specificity than an attribute selector rule). */
.callout[data-callout-type="note"] {
  --callout-type-color: var(--callout-note-color);
}
.callout[data-callout-type="tip"] {
  --callout-type-color: var(--callout-tip-color);
}
.callout[data-callout-type="important"] {
  --callout-type-color: var(--callout-important-color);
}
.callout[data-callout-type="warning"] {
  --callout-type-color: var(--callout-warning-color);
}
.callout[data-callout-type="caution"] {
  --callout-type-color: var(--callout-caution-color);
}
.callout[data-callout-type="abstract"] {
  --callout-type-color: var(--callout-abstract-color);
}
.callout[data-callout-type="info"] {
  --callout-type-color: var(--callout-info-color);
}
.callout[data-callout-type="todo"] {
  --callout-type-color: var(--callout-todo-color);
}
.callout[data-callout-type="success"] {
  --callout-type-color: var(--callout-success-color);
}
.callout[data-callout-type="question"] {
  --callout-type-color: var(--callout-question-color);
}
.callout[data-callout-type="failure"] {
  --callout-type-color: var(--callout-failure-color);
}
.callout[data-callout-type="danger"] {
  --callout-type-color: var(--callout-danger-color);
}
.callout[data-callout-type="bug"] {
  --callout-type-color: var(--callout-bug-color);
}
.callout[data-callout-type="example"] {
  --callout-type-color: var(--callout-example-color);
}
.callout[data-callout-type="quote"] {
  --callout-type-color: var(--callout-quote-color);
}

.callout {
  background: color-mix(in oklab, var(--callout-type-color) 6%, transparent);
  margin: 0.5rem 0;
  @apply rounded-lg py-3 px-4 pl-5 relative;
}

/* Accent line as a pseudo-element so it survives <details> collapse —
   non-summary children of a closed <details> are hidden by the browser,
   but ::before is not a child. */
.callout::before {
  content: "";
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 0.5rem;
  width: 2px;
  border-radius: 9999px;
  background: var(--callout-type-color);
  pointer-events: none;
}

.callout .callout-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--callout-type-color);
  font-weight: 500;
  line-height: 1.4;
}

.callout .callout-icon {
  flex: none;
  color: var(--callout-type-color);
}

.callout .callout-title {
  font-size: 0.9rem;
}

.callout-summary {
  @apply flex items-center gap-2 justify-between;
}

.callout-body {
  color: inherit;
  margin-top: 0.5rem;
}

.callout-body > :first-child {
  margin-top: 0;
}
.callout-body > :last-child {
  margin-bottom: 0;
}

/* Strip the trailing <p>'s margin-bottom so it doesn't stack on top of the
   callout's own padding-bottom. ProseMirror wraps content in two NodeView
   layers (.component-children → [data-node-view-wrapper]) before the <p>,
   so :last-child is chained down to the deepest-last paragraph and only
   that one. Fallbacks cover 0/1 wrapper depths. */
.callout-body > p:last-child,
.callout-body > :last-child > p:last-child,
.callout-body > :last-child > :last-child > p:last-child {
  margin-bottom: 0;
}

/* Collapsible variant — native <details>/<summary> with a real <svg> chevron.
 * The chevron is a lucide ChevronDown rendered as an actual DOM child of
 * <summary>, so cloneNode(true) (used by the clipboard live-DOM walker) can
 * carry it across to the pasted-HTML output in destination apps. CSS rotates
 * it on the `[open]` attribute, honoring prefers-reduced-motion. */
.callout-collapsible > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.callout-collapsible > summary::-webkit-details-marker {
  display: none;
}

.callout-chevron {
  flex: none;
  color: var(--callout-type-color);
  transform: rotate(0deg);
  transform-origin: 50% 50%;
}

.callout-collapsible[open] > summary > .callout-chevron {
  transform: rotate(-180deg);
}

@media (prefers-reduced-motion: no-preference) {
  .callout-chevron {
    transition: transform 180ms var(--ease-out-strong);
  }
}

/* 7c. Video (5-pack DIY renderer, US-007 — pure HTML5 `<video>` wrapper).
 *
 * Minimal styling per D-MF12 "HTML5 native chrome is the UX" — we only own
 * layout (block-level, max-width, rounded corners) so the video snaps to a
 * sensible authored size inside the editor without inheriting any
 * text-editor line-box weirdness. Native controls, poster-frame rendering,
 * fullscreen button, keyboard shortcuts, and reduced-motion all remain the
 * browser's responsibility.
 */
.ok-video {
  display: block;
  max-width: 100%;
  @apply rounded-lg;
  margin: 0.5rem 0;
}

/* YouTube dispatch: wrap a `<div>` containing react-lite-youtube-embed's
   `.yt-lite` (which uses `aspect-ratio: 16/9` to derive height from width).
   Native `<video>` is a replaced element with intrinsic dimensions from
   the file — the JsxComponentView wrapper's `width: fit-content` rule
   sizes that correctly. The lite-embed's `<div>` has no intrinsic width
   (the play button is `position: absolute`), so giving it an explicit
   default lets the same `fit-content` wrapper hug it without needing a
   `:has()` override that would otherwise expand the chrome bar / halo
   to the full column. `max-width: 100%` keeps the embed contained when
   the column is narrower than 720px. Author-supplied `width` (via
   inline style from the Video descriptor) overrides this default. */
.ok-video-youtube {
  width: 720px;
  max-width: 100%;
  /* Clip the inner `.yt-lite`'s rectangular thumbnail (and the
     post-activation iframe) to the wrapper's rounded corners — without
     this, the lib's background-image bleeds past the `.ok-video`'s
     border-radius and the video looks like it's leaking on the right.
     Native `<video>` doesn't need this because the element renders its
     pixels inside its own box; for a `<div>` wrapper with rounded
     corners the clip is on us. */
  overflow: hidden;
}

/* Vimeo dispatch: parallel to `.ok-video-youtube`. `@u-wave/react-vimeo`
   in `responsive` mode renders an iframe wrapped in a div that resizes
   to its parent — give the parent the same 720px default so authors who
   don't supply explicit width get the same UX as the YouTube path. The
   iframe itself is rectangular; rounded-corner clipping is on us. */
.ok-video-vimeo {
  width: 720px;
  max-width: 100%;
  overflow: hidden;
}

/* Loom dispatch: parallel to YouTube + Vimeo. The wrapper supplies the
   720px default + max-width and clips the iframe to the rounded corner.
   The Loom iframe itself defaults to no width/height (Loom's embed sizes
   itself via CSS internals), so we set sensible defaults on the iframe
   to match the wrapper. Author-supplied width/height override. */
.ok-video-loom {
  width: 720px;
  max-width: 100%;
  overflow: hidden;
}

/* Video alignment (PRD-6822) — `.ok-video` is `display: block` by default
   (HTML5 `<video>` is block, and the YouTube / Vimeo / Loom wrapper `<div>`
   is too). Block elements ignore the parent's `text-align`, breaking the
   three `[data-component-type="video"][data-align="…"]` rules above (which
   live with the rest of the wrapper-alignment rules). Override to
   `inline-block` for every JSX-form video wrapper so the `text-align` can
   position the media — `JsxComponentView` always emits `data-align` on
   video wrappers (defaulting to `center` via the `ALIGNABLE_DESCRIPTOR_NAMES`
   clamp), so the wrapper-component-type selector is the precise scope. The
   global `display: block` default stays everywhere outside the JSX
   wrapper. Placed after the `.ok-video-*` width rules so selector
   specificity stays ascending in document order. */
.ProseMirror .jsx-component-wrapper[data-component-type="video"] .ok-video {
  display: inline-block;
}
.ok-video-loom-iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

/* 7c-bis. PDF (Obsidian-parity `![[doc.pdf]]` — Pdf.tsx renders pages
 * to canvas via pdfjs-dist, no iframe). Three regions: toolbar (title +
 * page-nav controls), pages container (scrollable canvas list), and the
 * canvas pages themselves. Container height is set inline by Pdf.tsx
 * from the `height=N` anchor parameter (default 600px); per-page width
 * is computed at render time so the viewer fits the prose column.
 */
.ok-pdf {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin: 0.5rem 0;
  background-color: var(--muted);
  overflow: hidden;
}

.ok-pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background-color: var(--background);
  font-size: 0.8rem;
  user-select: none;
}

.ok-pdf-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--foreground);
  font-weight: 500;
}

.ok-pdf-controls {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.ok-pdf-divider {
  display: inline-block;
  width: 1px;
  height: 1.1rem;
  background: var(--border);
  margin: 0 0.2rem;
}

.ok-pdf-page-form {
  display: inline-flex;
}

.ok-pdf-page-input {
  width: 2.4rem;
  height: 1.5rem;
  padding: 0 0.25rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--background);
  color: var(--foreground);
}
.ok-pdf-page-input:focus {
  outline: 2px solid var(--ring, var(--border));
  outline-offset: -1px;
}

.ok-pdf-page-of {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin-right: 0.15rem;
}

.ok-pdf-zoom-display {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted-foreground);
  min-width: 2.6rem;
  text-align: center;
}

.ok-pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 0;
}
.ok-pdf-btn:hover:not(:disabled) {
  background-color: var(--muted);
  border-color: var(--border);
}
.ok-pdf-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.ok-pdf-btn[aria-pressed="true"] {
  background-color: var(--muted);
  border-color: var(--border);
}

/* Layout-dropdown menu — anchored to the chevron button.
 * Width is determined by content; max set so long labels don't push
 * the embed sideways. The wrapping `<div>` is the positioning context. */
.ok-pdf-layout-menu {
  position: relative;
}

.ok-pdf-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 10;
  min-width: 11rem;
  display: flex;
  flex-direction: column;
  padding: 0.25rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.ok-pdf-menu-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  color: var(--foreground);
  cursor: pointer;
}
.ok-pdf-menu-item:hover {
  background-color: var(--muted);
}
.ok-pdf-menu-check {
  display: inline-flex;
  width: 0.9rem;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
}
.ok-pdf-menu-divider {
  margin: 0.25rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

/* Body — flex row that hosts the optional thumbnail sidebar and the
 * main page-stack viewport. Sidebar is a fixed-width column; pages
 * take the remaining space. */
.ok-pdf-body {
  flex: 1;
  display: flex;
  min-height: 0; /* allow children to shrink below their content size */
}

.ok-pdf-sidebar {
  flex: 0 0 auto;
  width: 9rem;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-right: 1px solid var(--border);
  background: var(--background);
}

.ok-pdf-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.3rem;
  cursor: pointer;
}
.ok-pdf-thumb:hover {
  background-color: var(--muted);
}
.ok-pdf-thumb[data-active] {
  border-color: var(--ring, var(--foreground));
  background-color: var(--muted);
}
.ok-pdf-thumb-canvas {
  display: block;
  max-width: 100%;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-radius: 1px;
}
.ok-pdf-thumb-num {
  font-size: 0.7rem;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

/* Pages container — default vertical column. Two-page modes flip the
 * layout to a 2-column grid via the `data-layout` selector below. */
.ok-pdf-pages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  /* `align-items: safe center` keeps narrow canvases centered horizontally
   * but falls back to `start` once a page (post-zoom) is wider than the
   * container — without `safe`, an oversized item gets centered by the
   * flex layout, which prevents the user from scrolling all the way to
   * its left edge. */
  align-items: safe center;
  gap: 0.5rem;
  padding: 0.75rem;
  background-color: color-mix(in oklab, var(--muted) 70%, transparent);
}

.ok-pdf-pages[data-layout="two-odd"],
.ok-pdf-pages[data-layout="two-even"] {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
  column-gap: 0.75rem;
  row-gap: 0.5rem;
  align-items: start;
}

/* Two-page (even) — page 1 is a "cover" alone on the right, then pairs
 * (2,3) (4,5) … Achieved by shifting the first canvas to grid column 2;
 * subsequent pages flow normally starting at column 1. */
.ok-pdf-pages[data-layout="two-even"] > .ok-pdf-page:first-child {
  grid-column-start: 2;
}

.ok-pdf-page {
  display: block;
  /* No `max-width: 100%` — the inline `style.width` set by `Pdf.tsx` is
   * authoritative. At zoom > 1× the canvas is intentionally wider than
   * its parent and the container's `overflow: auto` (above) handles the
   * horizontal scroll. Clamping to 100% would silently re-floor zoom
   * to whichever fit-* base scale the parent's width can hold. */
  flex-shrink: 0;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
}

.ok-pdf-loading,
.ok-pdf-error {
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.ok-pdf-error {
  color: var(--destructive, #c33);
}

/* 7e. File (DIY renderer for the `File` canonical, 2026-05).
 *
 * Notion-style inline row — small file-up icon + bold name + dim size,
 * stacked vertically when consecutive (each File is its own block from
 * the JsxComponentView wrapper). No card background / border / padded
 * box: the row reads as part of doc flow rather than as a callout-
 * shaped block competing with prose for visual weight. Hover paints a
 * subtle muted background and underlines the name to signal
 * clickability.
 *
 * Why this differs from the Pdf card: Pdf renders a full pdfjs viewer
 * (toolbar + canvas list — necessarily card-shaped). File never
 * previews — it's the catch-all for types we deliberately don't try to
 * render inline (.zip / .docx / .xlsx / unknown extensions). Stacks of
 * Files read as a "files attached" list rather than a series of cards.
 */
/* Descendant base rules — declared before the anchor's hover/focus rules
 * so the cascade reads in ascending-specificity order (Biome
 * `noDescendingSpecificity` rule). The anchor selector uses
 * `.ProseMirror a.ok-file-attachment` (1 class + 1 element + 1 class) so
 * it beats Tailwind v4 typography's `.prose a` rule (1 class + 1
 * element) on specificity — without `.ProseMirror`, the blue prose-link
 * color + underline defaults bleed through and the row reads as a
 * generic markdown link rather than a file attachment row.
 *
 * No negative margin / padding overhang: the hover background must NOT
 * extend past the parent column's edge (which would clip in the
 * `.ProseMirror` overflow box and make the row look truncated on the
 * left). Internal padding gives the hover background breathing room
 * around the content without poking outside the column. */
.ok-file-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  /* Baseline alignment hack — lucide icons render with their bounding
   * box centered, but a paperclip glyph optically sits high relative
   * to the text x-height. Nudge down 0.18em so the icon's visual
   * center aligns with the lowercase letters of the name. */
  position: relative;
  top: 0.18em;
  color: var(--foreground);
}

.ok-file-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60ch;
}

.ok-file-size {
  font-size: 0.85em;
  color: var(--muted-foreground);
}

/* File wrapper takes the full column width (chrome bar sits at the
 * column's right edge, away from the row content). The wrapper-level
 * selection halo (`.jsx-component-wrapper[data-selected="true"]::after`,
 * `inset: -4px`) is hidden for File-type wrappers because painting a
 * 4px border around the full prose column when only the row is the
 * "selected thing" reads as a wide rectangle outline floating in
 * empty space. The selection feedback paints on the inner row instead
 * (a rule further below scoped to `[data-selected="true"] a.ok-file-attachment`)
 * so the highlight tracks the visible content.
 *
 * Both source-form variants — canonical `[data-component-type="file"]`
 * (hand-authored `<File>` JSX) and compat
 * `[data-component-type="wikiembedfile"]` (drop / `![[]]` form) — get
 * the same treatment so selection looks identical regardless of how
 * the row was authored.
 *
 * Rule ordering: the base `.ProseMirror a.ok-file-attachment` rule is
 * declared FIRST so that the more-specific selection-state rules below
 * cascade over it in source order (Biome `noDescendingSpecificity`). */
.ProseMirror a.ok-file-attachment {
  /* Full-width row (block-level flex) so the hover/selection background
   * spans the whole prose column — matches Notion's "file attached"
   * row visual where the row reads as a structural element of the
   * doc, not a content-width pill. */
  display: flex;
  width: 100%;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--foreground);
  font-size: inherit;
  line-height: 1.5;
  transition: background-color 120ms ease;
}

.ProseMirror a.ok-file-attachment:hover {
  background-color: var(--muted);
}

.ProseMirror a.ok-file-attachment:focus-visible {
  outline: 2px solid var(--ring, currentColor);
  outline-offset: 2px;
}

.ProseMirror a.ok-file-attachment:hover .ok-file-name {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.ProseMirror a.ok-file-attachment:hover .ok-file-size {
  /* Override the prose typography hover-underline that would otherwise
   * cascade through the `<a>` and paint a single underline beneath the
   * size span too — only the name should pick up the hover-underline,
   * the size stays muted gray. */
  text-decoration: none;
}

/* Suppress wrapper-level selection halo for File rows — see the comment
 * block above. The inner-row outline below is the selection feedback. */
.ProseMirror .jsx-component-wrapper[data-component-type="file"][data-selected="true"]::after,
.ProseMirror
  .jsx-component-wrapper[data-component-type="wikiembedfile"][data-selected="true"]::after {
  --selection-halo-opacity: 0;
}

.ProseMirror
  .jsx-component-wrapper[data-component-type="file"][data-selected="true"]
  a.ok-file-attachment,
.ProseMirror
  .jsx-component-wrapper[data-component-type="wikiembedfile"][data-selected="true"]
  a.ok-file-attachment {
  /* Selection feedback is the muted background only — no outline ring.
   * The full-width row + bg tint reads clearly as "this row is the
   * thing you've selected" without painting a hard rectangle. The
   * chrome bar's appearance + bubble-menu mode-swap (download button)
   * provide the additional UI signals. */
  background-color: var(--muted);
}

/* 7f. CodeMirror prop input (PropPanel string-prop control with `language` set,
 * 2026-05).
 *
 * Replaces the plain `<input type="text">` for code-shaped props (Math
 * formula → LaTeX, Mermaid chart, JSON / HTML / YAML payloads). Sized
 * to fit the PropPanel popover comfortably — min-height ≈ 5 lines so a
 * one-line formula doesn't render in a sliver, max-height with overflow
 * so a 50-line Mermaid diagram doesn't blow out the popover.
 *
 * Padding-free wrapper — the inner `.cm-editor` has its own padding from
 * CM6 defaults. Matches shadcn `<Input>` border + radius tokens so the
 * editor sits visually consistent with sibling string inputs in the
 * same panel. */
/* PRD-6821 — Code preview "Edit source" modal's CodeMirror surface.
 * Sibling of `.ok-prop-codemirror` below but sized to fill its modal pane
 * instead of capping at 18rem. The inner editor expands to the host
 * div's full height (the modal's pane uses `flex-1 min-h-[260px]`), the
 * scroller takes the remainder via `flex: 1 1 0`, and color tokens flow
 * from app CSS variables so light / dark tracks the active theme without
 * a CodeMirror Compartment. The first iteration of this modal tried to
 * use `nested-cm-extensions`'s `darkTheme`/`lightTheme` exports — those
 * expect a Compartment + transparent background, which lost the cascade
 * battle against the dialog's solid surfaces and left the source pane
 * blank against the dark background. The all-CSS approach below
 * sidesteps that whole class of bug. */
.ok-codepreview-cm {
  background-color: var(--background);
  color: var(--foreground);
  font-size: 0.8125rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ok-codepreview-cm .cm-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  outline: none;
}

.ok-codepreview-cm .cm-editor.cm-focused {
  outline: none;
}

.ok-codepreview-cm .cm-scroller {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  font-family: inherit;
  font-size: inherit;
  line-height: 1.5;
  overscroll-behavior: contain;
}

.ok-codepreview-cm .cm-content {
  padding: 0.5rem 0;
  color: var(--foreground);
  caret-color: var(--foreground);
}

.ok-codepreview-cm .cm-gutters {
  background-color: var(--background);
  border-right: 1px solid var(--border);
  color: var(--muted-foreground);
}

.ok-codepreview-cm .cm-activeLineGutter,
.ok-codepreview-cm .cm-activeLine {
  background-color: var(--muted);
}

.ok-codepreview-cm .cm-selectionBackground,
/* `.cm-focused` lands on `.cm-editor` (CM6's wrapper), not on this
 * outer host div — so the focused-selection rule must nest through it.
 * Sibling `.ok-prop-codemirror` uses the same nesting at line 3790. */
  .ok-codepreview-cm
  .cm-editor.cm-focused
  .cm-selectionBackground,
.ok-codepreview-cm ::selection {
  background-color: var(--accent);
}

.ok-prop-codemirror {
  width: 100%;
  /* Tightened from 6.5rem / 18rem — the PropPanel popover is narrow, so
   * a tall code surface dominated the visible area (Mermaid's `chart`
   * prop was the worst offender at ~188px on default content). The
   * fullscreen "Edit source" pen-icon modal remains the right tool for
   * heavy editing; the inline panel is for quick tweaks. */
  min-height: 4rem;
  max-height: 12rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background-color: var(--background);
  overflow: hidden;
  /* Stepped down from 0.8125rem (13px) to 0.75rem (12px) so the
   * source-string region reads as one of the panel's compact controls
   * instead of a centerpiece. Still inside the WCAG-2.1 SC 1.4.4
   * resize-text margin (browser zoom and OS-level font scaling apply
   * normally to monospace text). */
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: border-color 120ms ease;
}

.ok-prop-codemirror:focus-within {
  border-color: var(--ring, var(--border));
  outline: 2px solid var(--ring, currentColor);
  outline-offset: -1px;
}

.ok-prop-codemirror .cm-editor {
  height: 100%;
  /* Matches the host's compacted max-height (was 18rem). */
  max-height: 12rem;
  outline: none;
}

.ok-prop-codemirror .cm-editor.cm-focused {
  outline: none;
}

.ok-prop-codemirror .cm-scroller {
  font-family: inherit;
  font-size: inherit;
  line-height: 1.45;
  /*
    Stop scroll-chaining inside the PropPanel popover — without this,
    scrolling past the editor's content boundary (e.g. on a long
    Mermaid diagram) chains to the page behind the popover. `contain`
    keeps the gesture local to the editor's scrollable region.
  */
  overscroll-behavior: contain;
}

.ok-prop-codemirror .cm-content {
  padding: 0.4rem 0;
  caret-color: var(--foreground);
}

.ok-prop-codemirror .cm-gutters {
  background-color: var(--muted);
  border-right: 1px solid var(--border);
  color: var(--muted-foreground);
}

.ok-prop-codemirror .cm-activeLineGutter,
.ok-prop-codemirror .cm-activeLine {
  background-color: var(--accent);
}

/* 7d. Accordion (5-pack DIY renderer, US-009 — standalone HTML5 <details>).
 *
 * Standalone <details>/<summary> styled with OK shadcn tokens per D-MF14 +
 * D-MF16 — no parent wrapper required, no Radix animation state machine.
 * Chevron rotation keyed on the [open] attribute; summary is
 * contentEditable=false so PM doesn't mount inside. Exclusive-accordion
 * grouping uses HTML5 `<details name="group">` natively (Chrome 120+,
 * Safari 17.2+, Firefox 130+) — no wrapper component needed.
 *
 * Shadcn tokens: --border / --muted for the container; --foreground /
 * --muted-foreground for text; --ring inherits through the selection halo.
 */
.accordion {
  border: 1px solid var(--border);
  background: var(--background);
  margin: 0.5rem 0;
  overflow: clip;
  @apply rounded-lg;
}

.accordion > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.accordion > summary::-webkit-details-marker {
  display: none;
}

.accordion-chevron {
  flex: none;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
  transform: rotate(0deg);
  transform-origin: 50% 50%;
}

.accordion[open] > summary > .accordion-chevron {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: no-preference) {
  .accordion-chevron {
    transition: transform 180ms var(--ease-out-strong);
  }
}

.accordion .accordion-icon {
  flex: none;
  margin-top: 0.125rem;
  color: var(--muted-foreground);
}

.accordion .accordion-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  flex: 1;
}

.accordion .accordion-title {
  color: var(--foreground);
  font-size: 0.95rem;
  font-weight: 500;
}

.accordion .accordion-description {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
}

.accordion .accordion-body {
  padding: 0.5rem 0.875rem 0.75rem;
  border-top: 1px solid var(--border);
}

.accordion .accordion-body > :first-child {
  margin-top: 0;
}
.accordion .accordion-body > :last-child {
  margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Tabs
 *
 * Notion-style horizontal pill strip above an active panel. Component in
 * `editor/components/Tabs.tsx`; descriptor pair (Tabs + Tab) in
 * `core/registry/built-ins.ts`.
 *
 * Active visibility is purely CSS: `Tabs.tsx` writes `data-active-index="N"`
 * on `.tabs-content`; the rules below hide every `.react-renderer` sibling
 * (each PM-rendered child NodeView is wrapped in one) and re-show the
 * N+1-th. PM children stay live (Precedent #30) — they're just `display:
 * none` when not the active tab.
 *
 * Capacity: nth-of-type rules cover indices 0–19. Beyond that, Tabs.tsx
 * clamps `safeActive` to `labels.length - 1` so the last-rule slot
 * (index 19) stays visible; a 21st+ panel would silently fall back to
 * hidden until the rule list widens. Twenty tabs in a single `<Tabs>` is
 * already well outside realistic authoring.
 *
 * Chrome mirrors Accordion's shadcn-token shape (1px --border, --background
 * fill, rounded-lg) so the two canonical containers read as siblings.
 * ─────────────────────────────────────────────────────────────────────────── */

/* Bordered container — single chrome shell, no muted header band. The pill
   strip sits inline at the top of the same surface; the active panel paints
   directly below it on the same background. Matches Accordion's
   shadcn-token shape (border + rounded-lg) so the two canonical containers
   read as siblings.

   NO `overflow: hidden` — selection halos and focus outlines on inner blocks
   bleed slightly outside their box and would otherwise clip at the rounded
   container edge (visible on first-line / last-line of a Tab body). */
.tabs {
  border: 1px solid var(--border);
  background: var(--background);
  margin: 0.5rem 0;
  @apply rounded-lg;
}

.tabs-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem 0;
}

/* The `role="tablist"` element wraps only the `[role="tab"]` pills (WAI-
 * ARIA's required-owned-elements rule). `display: contents` makes it
 * transparent to layout so the pills participate directly in the outer
 * `.tabs-strip` flex row, alongside the auxiliary `+ Add tab` button
 * which lives as a sibling of the tablist. Visual row is unchanged from
 * the pre-restructure layout. */
.tabs-tablist {
  display: contents;
}

.tabs-strip-pill {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  cursor: pointer;
  line-height: 1.3;
  transition:
    background-color 100ms var(--ease-out-strong),
    color 100ms var(--ease-out-strong),
    transform 160ms var(--ease-out-strong);
}

.tabs-strip-pill:hover {
  color: var(--foreground);
  background: color-mix(in oklab, var(--muted) 50%, transparent);
}

.tabs-strip-pill:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.tabs-strip-pill[data-active="true"] {
  color: var(--foreground);
  background: color-mix(in oklab, var(--muted) 70%, transparent);
}

/* Inline "+ Add tab" button — sits at the end of the strip's flex row,
 * styled as a muted square that brightens on hover so it reads as a
 * "background" affordance until the author actively needs it. Visible
 * only when the Tabs descriptor's host context provides `addChild()`
 * (i.e. inside the editor, not in standalone preview surfaces). */
.tabs-strip-add {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 0.3125rem;
  cursor: pointer;
  margin-left: 0.125rem;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.tabs-strip-add:hover {
  color: var(--foreground);
  background: color-mix(in oklab, var(--muted) 50%, transparent);
}

.tabs-strip-add:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.tabs-content {
  padding: 0.125rem 0.875rem 0.375rem;
}

/* Hide every Tab inside the active Tabs's content area, then re-show the
   matching nth-of-type for each active-index value. PM/Tiptap's render
   stack between the JSX `<NodeViewContent>` and the user-visible Tab
   wrapper adds TWO intermediate divs:

     .tabs-content                              ← Tabs's own panel container
     > .component-children                      ← React's <NodeViewContent>
     > [data-node-view-content-react]           ← PM's contentDOMElement
                                                  (ReactNodeViewRenderer
                                                   constructor appends this
                                                   INSIDE the React node)
     > .react-renderer.node-jsxComponent        ← per-child ReactRenderer
                                                  element (one per Tab)
     > .jsx-component-wrapper[data-component-type="tab"]   ← our NodeViewWrapper

   We hide at the `.react-renderer` level (the actual sibling row PM
   manipulates). Schema is `block*` not `tab+`, so technically a non-Tab
   block could land here — but the user-facing contract is "Tabs only
   contains Tab children" (no slash entry for Tab outside Tabs; pasted
   non-Tab blocks would have no matching strip pill anyway). `:nth-of-type`
   over `.react-renderer` siblings drives the active selection. */
.tabs-content > .component-children > [data-node-view-content-react] > .react-renderer {
  display: none;
}

.tabs-content[data-active-index="0"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(1) {
  display: block;
}
.tabs-content[data-active-index="1"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(2) {
  display: block;
}
.tabs-content[data-active-index="2"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(3) {
  display: block;
}
.tabs-content[data-active-index="3"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(4) {
  display: block;
}
.tabs-content[data-active-index="4"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(5) {
  display: block;
}
.tabs-content[data-active-index="5"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(6) {
  display: block;
}
.tabs-content[data-active-index="6"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(7) {
  display: block;
}
.tabs-content[data-active-index="7"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(8) {
  display: block;
}
.tabs-content[data-active-index="8"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(9) {
  display: block;
}
.tabs-content[data-active-index="9"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(10) {
  display: block;
}
.tabs-content[data-active-index="10"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(11) {
  display: block;
}
.tabs-content[data-active-index="11"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(12) {
  display: block;
}
.tabs-content[data-active-index="12"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(13) {
  display: block;
}
.tabs-content[data-active-index="13"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(14) {
  display: block;
}
.tabs-content[data-active-index="14"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(15) {
  display: block;
}
.tabs-content[data-active-index="15"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(16) {
  display: block;
}
.tabs-content[data-active-index="16"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(17) {
  display: block;
}
.tabs-content[data-active-index="17"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(18) {
  display: block;
}
.tabs-content[data-active-index="18"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(19) {
  display: block;
}
.tabs-content[data-active-index="19"]
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer:nth-of-type(20) {
  display: block;
}

.tab-panel > .component-children > :first-child {
  margin-top: 0;
}
.tab-panel > .component-children > :last-child {
  margin-bottom: 0;
}

/* Hover-revealed chrome bar (component name + gear icon) — top-right overlay.
   z-index 50 sits high enough to paint above any intra-component sticky/z-40
   layers (pre-US-004 this was tuned against fumadocs Banner's sticky header)
   but still below shadcn Popover/Dialog portals (typically z-50+ on a detached
   layer), so the chrome isn't occluded by in-component stickies. */
.jsx-component-chrome {
  position: absolute;
  top: -11px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  background: var(--popover);
  border: 1px solid var(--border);
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
  white-space: nowrap;
}
/* Only show chrome for the INNERMOST hovered component — prevents
   parent and child chrome bars from overlapping at the top-right.
   When hovering a Card inside Cards, only the Card's icons show.
   When hovering the Cards container gap, only Cards' icons show. */
.jsx-component-wrapper:hover:not(:has(.component-children .jsx-component-wrapper:hover))
> .jsx-component-chrome {
  opacity: 1;
  pointer-events: auto;
}

/* Keyboard-selected parity with hover. Keyboard-only users who arrow-key
   to a component (block-ux/keyboard-nav.ts NodeSelection) get the halo
   via [data-selected]; this rule mirrors it so the chrome bar's Move /
   Delete / Settings buttons are reachable without a mouse (WCAG 2.1.1
   Keyboard). Innermost-wins uses [data-has-child-selected] written by
   SelectionStatePlugin (precedent #34) — a plain attribute-presence
   negation, so a parent whose descendant is the selected block doesn't
   paint chrome on both the parent AND the child. */
.jsx-component-wrapper[data-selected="true"]:not([data-has-child-selected="true"])
> .jsx-component-chrome {
  opacity: 1;
  pointer-events: auto;
}

/* Unconfigured hint — when the component has settable props AND at least one
   is empty/unset, surface the full-styled chrome pill with ONLY the gear
   button visible (arrows + destructive delete stay hidden until hover).
   The pill itself looks identical to its hovered state (full background,
   border, padding, opacity) — the hint is conveyed by *presence*, not by
   styling the gear differently. Hover upgrades the pill to show every
   button via the hover rule above. */
.jsx-component-wrapper[data-needs-config="true"]:not(
  :has(.component-children .jsx-component-wrapper:hover)
) > .jsx-component-chrome {
  opacity: 1;
  pointer-events: auto;
}
/* In hint mode (not hovering the wrapper itself), hide every chrome button
   except the properties trigger so the gear is the only affordance shown. */
.jsx-component-wrapper[data-needs-config="true"]:not(:hover):not(
    :has(.component-children .jsx-component-wrapper:hover)
  )
  > .jsx-component-chrome
  > button:not([aria-label*="properties"]) {
  display: none;
}

/* Chrome bar icon buttons — shared base style. Applies to both `<button>`
 * and `<a>` siblings; anchor chrome items (Embed's "open in new tab",
 * Mirror's "Open source" deep-link) need this so they match the button
 * siblings instead of inheriting the page's link styling. */
.jsx-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem;
  border: none;
  border-radius: 0.1875rem;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.1s,
    color 0.1s;
}
.jsx-chrome-btn:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
/* Active-state for toggle buttons (image alignment left/center/right —
 * only one is "pressed" at a time, reflecting the current `props.align`).
 * Keyed off `data-active="true"` rather than `aria-pressed` so the
 * selector composes cleanly with the hover rule above without specificity
 * tricks. */
.jsx-chrome-btn[data-active="true"] {
  background: var(--accent);
  color: var(--accent-foreground);
}
/* Keyboard focus indicator — mirrors the editor-wide pattern used by
   .tag, [data-link], file-attachment links, and the drag-handle controls.
   Chrome buttons are tab-reachable when the wrapper has roving tabIndex=0,
   so the focus ring is load-bearing for keyboard-only operation. */
.jsx-chrome-btn:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}
/* Delete icon — subtle red tint on hover, not a full red background */
.jsx-chrome-btn--delete:hover {
  background: transparent;
  color: var(--destructive, #ef4444);
}

/* 8. Container child insertion — overlay pill + empty placeholder */

/* "Add child" pill — centered at bottom edge of container, absolute overlay */
.jsx-add-child-pill {
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0.125rem 0;
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.jsx-add-child-pill > span {
  display: inline-block;
  padding: 0.125rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--popover);
  white-space: nowrap;
}
/* Add-child pill shows on ANY hover of the container — not restricted to
   innermost-only like the chrome bar. The pill sits at bottom:-10px (outside
   children) so it doesn't compete with child chrome. This makes it accessible
   even when children fill the entire container (e.g., Steps full of Steps). */
.jsx-component-wrapper:hover > .jsx-add-child-pill {
  opacity: 1;
  pointer-events: auto;
}
.jsx-add-child-pill:hover > span {
  background: var(--accent);
  color: var(--accent-foreground);
  border-color: var(--accent);
}

/* Empty container placeholder — in-flow (it IS the content for empty containers) */
.jsx-empty-child-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem;
  margin-top: 0.25rem;
  border: 1px dashed var(--border);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.jsx-empty-child-placeholder:hover {
  border-color: var(--ring);
  color: var(--accent-foreground);
}

/* Sidebar: separate hover (neutral gray) from active (blue accent) */

/* Dark overrides — ProseMirror content surfaces */
.dark .ProseMirror pre code {
  background: none;
}

/* Dark overrides — agent flash keyframes with boosted alpha for dark canvas */
@keyframes agent-flash-dark {
  0% {
    box-shadow: inset 3px 0 0 transparent;
    background: transparent;
    transform: translateX(0);
  }
  8% {
    box-shadow: inset 3px 0 0 var(--color-agent);
    background: rgba(217, 119, 87, 0.22);
    transform: translateX(1px);
  }
  35% {
    box-shadow: inset 3px 0 0 var(--color-agent);
    background: rgba(217, 119, 87, 0.14);
    transform: translateX(0);
  }
  100% {
    box-shadow: inset 3px 0 0 transparent;
    background: transparent;
    transform: translateX(0);
  }
}

@keyframes agent-breathing-dark {
  0%,
  100% {
    background: rgba(217, 119, 87, 0.1);
  }
  50% {
    background: rgba(217, 119, 87, 0.28);
  }
}

@keyframes undo-ready-dark {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(217, 119, 87, 0);
  }
  40% {
    transform: scale(1.02);
    box-shadow: 0 0 0 4px rgba(217, 119, 87, 0.3);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(217, 119, 87, 0);
  }
}

/* Full motion only: under reduced motion the agent flash is the accent-bar
   fade in both themes. */
@media (prefers-reduced-motion: no-preference) {
  .dark
    [data-agent-flash-state="editing"][data-agent-flash-position="append"]
    .ProseMirror
    > *:nth-last-child(-n + 3 of :not(.ok-trailing-affordance, .ProseMirror-gapcursor)) {
    animation-name: agent-flash-dark;
  }
  .dark
    [data-agent-flash-state="editing"][data-agent-flash-position="prepend"]
    .ProseMirror
    > *:nth-child(-n + 3) {
    animation-name: agent-flash-dark;
  }
}

.dark [data-presence-badge="agent"][data-presence-mode="editing"] {
  animation-name: agent-breathing-dark;
}

/* Boosted-alpha landing flash on the dark canvas (reduced motion already
   neutralizes the animation via a 0s duration, so the accent-bar fallback
   still stands). */
.dark .ok-landing-flash {
  animation-name: agent-flash-dark;
}

.dark [data-undo-state="ready"][data-undo-just-enabled="true"] {
  animation-name: undo-ready-dark;
}

/* Dark overrides — MEDIUM-severity items */
.dark .ProseMirror .selectedCell::after {
  background: var(--color-azure-900);
  opacity: 0.4;
}

/* ========================================================================
   Source-view minimal polish
   ======================================================================== */

/* Strikethrough — line-through, no color change. */
.cm-del {
  text-decoration: line-through;
}

/* List hanging-indent: wrapped continuation aligns under item text.
   padding-inline-start pushes ALL visual lines right; text-indent pulls
   only the FIRST visual line back - so the marker stays at its natural x
   and wrapped continuations start under the item's text.
   Redundant while .cm-line carries !important on padding-inline-start and
   the view-plugin always sets --list-hang inline alongside .cm-list-item;
   retained for documentation. Note the fallback path is not fully self-
   consistent on its own: .cm-line's text-indent falls back to 0ch while
   this rule's falls back to 2ch, so if the view-plugin ever stopped setting
   --list-hang the two declarations would resolve to different values. In
   practice the view-plugin sets the class and the variable atomically in
   the same Decoration.line call, so they can't decouple. */
.cm-list-item {
  padding-inline-start: var(--list-hang, 2ch);
  text-indent: calc(-1 * var(--list-hang, 2ch));
}

/* Fenced code - wrap-preserve-indent via padding-inline-start only (no text-indent).
   The ViewPlugin sets --line-indent per-line to the leading-whitespace count.
   NO tint, NO border - the code block visually blends with paragraph text
   except for monospace font and syntax-highlight colors (already applied by CM).
   Like .cm-list-item, redundant while .cm-line carries !important on padding-
   inline-start and incorporates --line-indent in its additive calc; retained as
   documentation. */
.cm-fenced-code-line {
  padding-inline-start: calc(var(--line-indent, 0) * 1ch);
}

/* Broken link affordance — wavy red underline (LSP convention).
   Single canonical definition for both broken link-refs and broken
   wikilinks — the "broken" concept has one visual form. The light-theme
   red (55% L) loses contrast against the dark canvas (14.5% L background,
   muted-fg at 70.8% L), so .dark lightens it to 72% L. */
.cm-link-ref-broken,
.cm-editor .cm-md-internal-link.cm-md-link-broken,
.cm-editor .cm-wiki-link.cm-wiki-link-broken {
  color: var(--broken-link-color);
  text-decoration: underline wavy;
  text-decoration-color: var(--broken-link-color);
}

/* Markdown linter (@codemirror/lint) — re-theme the default diagnostic surfaces
   onto OK's tokens so warnings/errors read consistently in light and dark. The
   wavy underline uses text-decoration (the same visual language as broken
   refs above) rather than the library's SVG background, which doesn't track
   our oklch palette. Severity colors: amber for warning, red for error. */
.cm-editor .cm-lintRange-warning {
  background: none;
  text-decoration: underline wavy var(--lint-warning-color);
  text-underline-offset: 0.2em;
}
.cm-editor .cm-lintRange-error {
  background: none;
  text-decoration: underline wavy var(--lint-error-color);
  text-underline-offset: 0.2em;
}
/* File-tree problem-indicator tokens (file-tree-problem-indicators.ts). The
   tree renders inside a shadow root, and its CSS names this tree-owned pair
   rather than the editor's --lint-*-color directly. Aliasing them here at
   :root is what carries the active theme's lint colors across the shadow
   boundary — custom properties inherit through it, so both light and dark
   follow whichever theme resolved --lint-*-color. The var() fallback literals
   in the shadow CSS only apply if this block is missing. */
:root {
  --ok-tree-problem-warning: var(--lint-warning-color);
  --ok-tree-problem-error: var(--lint-error-color);
}
/* Diagnostic tooltip + lint panel onto OK popover tokens. */
.cm-tooltip.cm-tooltip-lint,
.cm-panel.cm-panel-lint {
  background-color: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 0.25rem);
}
.cm-diagnostic {
  border-left-width: 3px;
}
.cm-diagnostic-warning {
  border-left-color: var(--lint-warning-color);
}
.cm-diagnostic-error {
  border-left-color: var(--lint-error-color);
}
.cm-diagnosticAction {
  background-color: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm, 0.25rem);
}

/* WYSIWYG markdown-lint decorations (markdown-lint-decorations.ts). Source mode
   underlines the exact error range; WYSIWYG has no source columns, so we flag
   the top-level block a diagnostic falls in with the SAME wavy underline visual
   language — applied to the block's text via a node decoration. No background
   fill or accent bar (those read as a heavy full-width highlight); just the
   recognizable squiggle, reusing the --lint-*-color tokens so the two surfaces
   match in light and dark. The native `title` tooltip the plugin sets on the
   block lists the rule + message on hover. */
.ProseMirror .ok-lint-block {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--lint-warning-color);
  text-decoration-skip-ink: none;
  text-underline-offset: 0.2em;
}
.ProseMirror .ok-lint-block.ok-lint-block-error {
  text-decoration-color: var(--lint-error-color);
}
/* Textless blocks (thematic break, block image) carry no inline text, so the
   wavy text-decoration above paints nothing. Swap it for an outline that reads
   the same warning/error color. The base .ok-lint-block class stays applied for
   the hover-tooltip lookup; here we cancel its (invisible) underline. */
.ProseMirror .ok-lint-block-atom {
  text-decoration: none;
  outline: 2px dashed var(--lint-warning-color);
  outline-offset: 3px;
  border-radius: 3px;
}
.ProseMirror .ok-lint-block-atom.ok-lint-block-error {
  outline-color: var(--lint-error-color);
}

/* Image failures use the same warning/error language as link audit and source
   diagnostics. A present target that the browser cannot decode is a warning;
   a target proven absent by the project inventory is an error. The labeled
   placeholder and ImageOff icon remain the non-color channels, while the
   authored target gets the familiar audit squiggle. */
.ok-image-error-placeholder {
  --ok-image-error-accent: color-mix(in oklch, var(--lint-warning-color) 82%, var(--foreground));

  border-color: var(--ok-image-error-accent);
  background: color-mix(in oklch, var(--lint-warning-color) 9%, transparent);
}
[data-image-error-kind="not-found"] > .ok-image-error-placeholder {
  --ok-image-error-accent: color-mix(in oklch, var(--lint-error-color) 82%, var(--foreground));

  border-color: var(--ok-image-error-accent);
  background: color-mix(in oklch, var(--lint-error-color) 8%, transparent);
}
.ok-image-error-placeholder > svg {
  color: var(--ok-image-error-accent);
}
.ok-image-error-target {
  text-decoration: underline wavy var(--ok-image-error-accent);
  text-underline-offset: 0.2em;
}

/* Percentage max-width is indefinite for shrink-to-fit inline content inside
   an auto-layout table cell. Give the error slot a definite cell-relative
   width there, then let the target grid item shrink and truncate within it. */
.ProseMirror td [data-image-error="true"],
.ProseMirror td .ok-image-error-placeholder {
  width: 100%;
  min-width: 0;
}
.ProseMirror td [data-image-error="true"] {
  display: block;
}
/* Hover tooltip for a decorated lint block (markdown-lint-decorations.ts). A
   styled, instant alternative to the native `title` — OK popover tokens,
   one diagnostic per line. It DOES take pointer events: the Fix button has to
   be clickable and the enter/leave handlers keep the box alive while the
   pointer travels to it, so it also swallows clicks on the region it covers
   (the line above the hovered one). Any keypress retires it. */
.ok-lint-tooltip {
  position: absolute;
  z-index: 50;
  max-width: 22rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 0.25rem);
  background-color: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md, 0 2px 8px oklch(0% 0 0 / 0.15));
  font-size: 0.75rem;
  line-height: 1.1rem;
  white-space: pre-line;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
}
.ok-lint-tooltip-message {
  white-space: pre-line;
}
/* Fix button styling comes from the shadcn buttonVariants recipe applied in
   markdown-lint-decorations.ts; this guard keeps the recipe's inline-flex from
   overriding the `hidden` attribute on the imperative DOM element. */
.ok-lint-tooltip-fix[hidden] {
  display: none;
}
.ok-lint-tooltip[hidden] {
  display: none;
}

/* Shrink-propagation for pane-clipped suggestion pickers.

   The pane cap is an inline `max-width` on the portaled wrapper, and a
   `max-width` does not shrink a block child carrying its own fixed `width`:
   a `w-80` menu root sat inside a 284px wrapper and still painted 320px,
   straight over the dock. Making the popup's CONTENT yield lives here, once,
   rather than as a `max-w-full` every menu component has to remember — the
   wrapper is the only place that knows it is clipped at all.

   Stated over the whole subtree rather than the direct children because the
   menu root's depth is not ours to know: tiptap interposes a `.react-renderer`
   between the wrapper and the component, so a `> *` rule caps that wrapper and
   leaves the root beneath it painting past the pane. The narrow-pane cases in
   `selection-surface-pane-clip.e2e.ts` are what hold that.

   LAYERED ON PURPOSE, and specificity is not what does it. The cascade sorts
   by layer BEFORE it looks at specificity, and unlayered author declarations
   form an implicit final layer that outranks every named one — so this rule
   sitting outside a layer beat every `max-w-*` a descendant carries no matter
   how weak the selector was, which made it a FLOOR. Tailwind emits its
   utilities into `@layer utilities`, and `components` sorts before that, so a
   descendant stating its own cap as a UTILITY wins and one stating nothing is
   still capped. The scoping is real: `.tag` a few blocks down is unlayered and
   renders inside the slash-command Tag preview, so it outranks this rule by
   the same law — invisibly today, since it also says `100%`.

   That is a ceiling, but it is NOT the `min()` the sibling producer composes.
   `deriveEditorSizeOptions` writes `min(authorMaxWidth, regionWidth)`, where
   the narrower wins in both directions. A cascade override REPLACES this
   declaration outright, wider included: a root carrying `max-w-96` beside a
   fixed `width` inside a 284px wrapper resolves to 384px, which constrains
   nothing and paints straight past the pane — the exact failure the first
   paragraph describes. A picker that wants its own ceiling AND the clip has
   to compose it, `max-w-[min(28rem,100%)]`, one character from the classes
   this rule replaced.

   The token the height axis uses (`--suggestion-menu-max-width`, consumed as
   an inline `min(...)` at each root) is the one option that composes natively
   and outranks every layer, which is why the producer chose it there. Kept a
   rule here because it needs no per-component consumption; recorded so the
   next reader does not re-derive the trade.

   Unlike the reduced-transparency and composer-prosemirror blocks, which stay
   unlayered so they always win, this one must be OVERRIDABLE — hence the
   layer. Both policies are right for their surface.

   Layering costs the fix nothing: `max-width` constrains `width` at the
   used-value step whichever declaration won the cascade, so a `w-80` root in a
   284px wrapper shrinks either way. `globals.suggestion-clip-cascade.test.ts`
   holds the layer, because no LAYOUT-FREE tier can observe it; a Playwright
   probe injecting a capped descendant would pin it harder and is the rung not
   bought yet. */
@layer components {
  [data-suggestion-popup][data-suggestion-clipped] * {
    max-width: 100%;
  }
}

/* One-column suggestion picker.

   `suggestion-floating-ui.ts` sets `data-suggestion-narrow` on the popup when
   the editor's visible region cannot hold the list AND the preview beside it.
   Squeezing both columns into a pane that fits neither reads worse than the
   list alone, and the preview is `aria-hidden` decoration, so it is the column
   that gives way. */
[data-suggestion-popup][data-suggestion-narrow] .ok-suggestion-preview {
  display: none;
}

/* Tables — hanging indent only, composed through .cm-line's additive-calc
   via --list-hang (set inline by the source-polish view-plugin on
   table-row/header lines — same mechanism lists use). Wrapped row
   continuation aligns under the first cell's content, not under `|`. No
   background, no border, no accent bar, no cell bands, NO font-size change —
   table lines read as the same size as surrounding paragraph text. Like
   .cm-list-item, redundant while .cm-line carries !important on
   padding-inline-start and incorporates --list-hang; retained as
   documentation. The prior standalone calc(8px + 2ch) was overridden by the
   base !important while the negative text-indent leaked, pulling tables ~2ch
   left of prose. */
.cm-table-row,
.cm-table-header {
  padding-inline-start: var(--list-hang, 2ch);
  text-indent: calc(-1 * var(--list-hang, 2ch));
}

/* V2 mode-toggle visibility (FR9, V2 SPEC §8b) — replaces Tailwind's
   `hidden` (`display: none`) on the non-active editor's container during
   Visual ↔ Source mode flips. `content-visibility: hidden` skips browser
   style + layout recalc on the 39K-PM-DOM-node tree of large docs:
   CV:hidden probe AC22 MET at 204 ms first / 115 ms repeat in dev,
   target G4 < 200 ms prod (cold-mount-profile §S3). `contain-intrinsic-size`
   reserves layout space so the scrollbar doesn't collapse during the
   toggle (no jarring scrollbar disappearance). The reserved height (8000px)
   is generous enough to cover most docs without forcing a layout shift
   on toggle-back; for ultra-tall docs CV:hidden's auto-resume on visibility
   handles the diff cheaply.

   Difference vs `display: none`:
     - `display: none` removes the element from layout entirely. Browser
       still has the DOM in memory but no layout/paint cost.
     - `content-visibility: hidden` keeps the element in layout but skips
       descendant layout/paint. The container reserves intrinsic size.
       Switching back to visible is faster on large trees (no full reflow).

   Out-of-flow stacking: `position: absolute; inset: 0` takes the hidden
   editor out of normal flow so its 8000px reserved intrinsic size does
   not size the wrapper (or any grid row) — earlier grid-based stacking
   sized rows to MAX intrinsic across children, stretching the visible
   sibling to 8000px and producing bottom whitespace on short docs. The
   consuming dual-editor wrapper must be `position: relative` so this
   absolute positioning resolves against it (see `EditorActivityPool.tsx`).
   Paint-lock scheduling (renderer-survival contract): Blink hard-CHECKs —
   killing the whole renderer process — when a mouse press's hit-tested
   node gains a paint-locked ancestor within one input dispatch
   (`hit_test_result.cc`, `DisplayLockUtilities::LockedAncestorPreventingPaint`;
   the CHECK is present at Chromium HEAD). React discrete updates flush
   inside event dispatch, so the className swap that applies this class can
   land exactly there. `transition: content-visibility 0s 32ms allow-discrete`
   defers the lock to a rendering update: discrete transitions flip TO
   `hidden` at 100% of the transition (MDN transition-behavior), and the
   document timeline's currentTime is fixed for the duration of a script
   execution block (Web Animations), so a style recalc forced mid-dispatch
   always computes the before-change value (`visible`) — the lock can only
   form at "update the rendering", which never interleaves with an input
   dispatch. Scope: the deferral covers the className-swap-on-existing-
   element path (the crashing one). An element INSERTED already carrying
   this class takes the lock in its first style recalc — transitions do
   not start for an element absent from the previous style change event
   (CSS Transitions §3) and there is no `@starting-style` here. That
   first-insertion path is click-safe by construction (a freshly inserted
   node cannot be an ancestor of a node hit-tested earlier in the same
   dispatch), but do not rely on the deferral for newly mounted subtrees.
   Do NOT read this deferral as equivalent to what `content-visibility: auto`
   does natively — an earlier version of this note did, and the corrected
   account is on `.ok-chunk-wrapper` below. cv:auto defers only its
   INTERSECTION-driven lock; a style-driven one still lands at the next
   recalc. The deferral here is explicit and owned by this rule.
   `visibility: hidden` covers the deferral window: it removes the subtree
   from hit-testing entirely (unlike `pointer-events: none`, which does not
   invalidate a hit test captured earlier in the same dispatch), and it
   stops the deactivated pane's paint at the same recalc that reveals the
   activated sibling, keeping the flip flash-free while the lock is
   pending. Do not drop any of the trio (content-visibility: hidden +
   deferring transition + visibility: hidden) — the pairing is pinned by
   `globals.cv-paint-lock.test.ts` and exercised at Playwright fidelity by
   `tests/stress/cv-paint-lock-click.e2e.ts`. */
.ok-mode-hidden {
  content-visibility: hidden;
  transition: content-visibility 0s 32ms allow-discrete;
  visibility: hidden;
  contain-intrinsic-size: 0 8000px;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ── Tags ─────────────────────────────────────────────────────────────────
 *
 * `#tagname` Obsidian-parity inline atom. The TipTap atom renders as
 * `<a class="tag" data-tag="{value}" href="#tag/{value}">#{value}</a>`.
 * Pill-style chrome — small rounded background, primary-tinted color,
 * sits inline with the surrounding prose. Cursor + hover + focus give
 * the affordances of a clickable token without the underline-link look.
 */
.tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  margin: 0 0.05em;
  border-radius: 0.625rem;
  font-size: 0.85em;
  font-weight: 500;
  line-height: 1.3;
  color: var(--primary);
  background-color: color-mix(in oklab, var(--primary) 10%, transparent);
  text-decoration: none;
  cursor: pointer;
  /* Long-tag containment: no max-width or wrap rules would let a single
   * unbroken tag string (`#xxxxxxx...`) blow past the editor's content
   * column, the TagDialog body, or the Properties panel value cell —
   * PRD-7112's reported "background overflows in weird ways". Cap the
   * pill's width at the parent's content box and allow the text to break
   * mid-string when (and only when) it would otherwise overflow. Normal-
   * length tags don't trigger `overflow-wrap: anywhere` so the single-
   * line pill shape is preserved. */
  max-width: 100%;
  overflow-wrap: anywhere;
  vertical-align: baseline;
  transition:
    background-color 90ms ease,
    filter 90ms ease;
}
.tag:hover {
  background-color: color-mix(in oklab, var(--primary) 22%, transparent);
  filter: brightness(1.05);
}
.tag:active {
  filter: brightness(0.95);
}
.tag:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 1px;
}

/* Block-chunked content-visibility:auto for large-doc render. Applied to
   top-level direct doc children via PM Decoration.node from
   `chunk-wrapper-decoration.ts`. Chromium ≥85 / Firefox ≥123 / Safari ≥18
   skip layout/paint for off-viewport blocks; on intersection, the block
   re-renders within frame budget. `contain-intrinsic-size` reserves space
   so the scrollbar position stays accurate across viewport edges
   (preventing scroll-jump on materialize). The 80px default approximates
   a single text paragraph; lists / tables / headings reserve more
   accurately via their own computed style once intersected.

   Composes with `.ok-mode-hidden`: when an ancestor is CV:hidden,
   descendant CV:auto is moot until the ancestor returns to visible.

   Scoped to `.ProseMirror` so source-mode CodeMirror DOM is untouched
   (CM6 has its own line-oriented viewport rendering).

   Click-safety, corrected. An earlier version of this note argued cv:auto is
   safe under clicks because its lock state "changes only at rendering updates,
   never synchronously inside an input dispatch". That holds for the
   INTERSECTION path (scrolling a block out of the render margin) and NOT for
   the style path: a newly created display-lock context starts with its
   viewport-intersection flag false, so applying cv:auto to an element that did
   not have it locks during the very next style recalc, on-screen, and the
   mousedown path runs several forced style flushes between capturing a hit
   result and reading a caret out of it.

   What actually protects this site is the selection pin: a click places the
   caret in the block, so the clicked wrapper cannot acquire the lock that
   would make the CHECK reachable. Two things hold the pin. Chromium keeps a
   selection-containing cv:auto element relevant to the user, and the
   `data-ok-selection-block` rule below makes the wrapper that holds the caret
   `visible`. `tests/stress/cv-auto-paint-lock-click.e2e.ts` pins the clicked
   wrapper staying unlocked, so it fails only if both are lost.

   Do not replace `auto` with `hidden` here without the same deferred-lock +
   visibility pair `.ok-mode-hidden` carries — an undeferred paint lock over
   hit-testable editor content trips Blink's display-lock CHECK (see the
   `.ok-mode-hidden` comment above).

   Chromium's pin does not cover typing into a block made in the same frame
   as its caret. Enter creates a new wrapper and moves the caret into it; the
   wrapper locks at its first style recalc and unlocks only at the next
   rendering update. A key typed before that update is inserted without
   layout, so Chromium leaves the caret before the typed character and keeps
   the placeholder `<br>`. The decoration therefore marks the top-level block
   holding each selection end with `data-ok-selection-block`, which stays
   `visible`. A block the caret leaves takes `auto` back through the
   `.ok-mode-hidden` deferring transition, because a caret that moves back in
   during the same frame (ArrowUp right after Enter) would otherwise land at
   the start of a locked line. Any other rule that sets `transition` on a
   top-level block replaces this deferral, which is why the reduced-motion
   agent flash fades with an animation. Pinned by
   `tests/stress/new-block-caret.e2e.ts`. */
.ProseMirror .ok-chunk-wrapper {
  content-visibility: auto;
  contain-intrinsic-size: 0 var(--ok-cv-h, 80px);
  transition: content-visibility 0s 32ms allow-discrete;
}

.ProseMirror .ok-chunk-wrapper[data-ok-selection-block] {
  content-visibility: visible;
  transition: none;
}

/* Code-block wrapper needs an unclipped paint area — the block's chrome
   floats above the block edge (see `.ok-codeblock-chrome`). content-visibility
   auto's paint containment would otherwise clip the chrome to the wrapper's box,
   hiding it entirely. */
.ProseMirror .ok-chunk-wrapper.node-codeBlock {
  content-visibility: visible;
}

/* Neutralize Electron `-webkit-app-region: drag` regions while a Popper-based
   floater (Popover / DropdownMenu / ContextMenu) is open so outside-click
   dismissal works on the macOS title-bar zone.

   macOS hijacks pointer events in drag regions at the OS chrome level — the
   DOM never sees the `pointerdown`, so Radix's document-level outside-click
   listener cannot fire. Popper-based components render no overlay and would
   otherwise be undismissable by clicking the chrome rows (EditorHeader,
   EditorTabs, FileSidebar header, the wrapper-strip in `App.tsx`,
   NavigatorApp's chrome row). Each drag-region site carries a stable
   `data-electron-drag` attribute that this selector targets.

   Dialogs used to be exempt: `DialogOverlay`'s viewport-wide
   `[-webkit-app-region:no-drag]` suppressed every drag region beneath it. They
   are not any more — `ElectronDragStrip` paints a `drag` band back over the
   title bar so the window stays movable while a dialog is open, and that band
   carries `data-electron-drag` to opt into this rule. So the list has to cover
   floaters that open INSIDE a dialog, not just those that open from the
   chrome. `select-content` is here for that reason: Settings renders `Select`
   controls in its Attachments and Content-rules sections and for the language
   field under Preferences, all inside the Settings `Dialog`.

   The `menubar-*` entries are unrelated to dialogs. `AppMenubar` renders only
   into the two chrome rows (`EditorHeader`, `NavigatorApp`), so a menubar
   opened from a chrome row could never be dismissed by clicking that same
   row — a gap that predates the dialog work and is fixed here because the
   audit that found the `Select` case surfaced it. Tooltip / HoverCard are excluded
   intentionally — they dismiss on `pointerleave`, not pointerdown, and
   keeping drag live during a hover preserves the window-drag affordance.

   `:has()` ships in Chromium 105+; Electron's bundled Chromium is well past
   that. The `@supports` gate keeps the rule a no-op on engines without
   `:has()` rather than risking a stylesheet-parse drop of the whole block. */
@supports selector(:has(*)) {
  body:has(
      [data-slot="popover-content"][data-state="open"],
      [data-slot="dropdown-menu-content"][data-state="open"],
      [data-slot="dropdown-menu-sub-content"][data-state="open"],
      [data-slot="context-menu-content"][data-state="open"],
      [data-slot="context-menu-sub-content"][data-state="open"],
      [data-slot="select-content"][data-state="open"],
      [data-slot="menubar-content"][data-state="open"],
      [data-slot="menubar-sub-content"][data-state="open"]
    )
    [data-electron-drag] {
    -webkit-app-region: no-drag;
  }
}

/* Page header — cover banner + page icon, rendered above PropertyPanel
   inside the per-doc DocumentBoundary. The `<PageHeader>` component
   only emits this DOM when at least one of `cover` / `icon` is set in
   the doc's frontmatter, so docs without either pay zero layout cost.

   Layout posture:
     - Cover is a 200px-tall full-bleed banner (object-fit: cover so the
       image fills the column regardless of intrinsic aspect ratio).
     - Icon is a 72px square. When a cover is present, the icon overlaps
       the cover's bottom edge so half sits on the banner, half hangs
       into the property-panel gutter (Notion / AnyType convention —
       the icon visually links the banner to the doc body). Without a
       cover the icon sits inline above the property panel with no
       overlap math.
     - `aria-hidden=true` is on the wrapper (set in PageHeader.tsx) so
       screen readers don't double-announce the doc title (the H1 in
       the editor body is the canonical title — these are decoration). */
/* The page header reuses the editor-content-aligned CSS grid so the
   icon (and any future inline page-chrome) lines up horizontally with
   the editor body H1 / paragraphs — same `content` column position. */
.page-header {
  position: relative;
}

/* Cover banner deliberately escapes the content column via
   `grid-column: full-start / full-end` so it spans the editor's full
   horizontal extent (margin to margin), matching the Notion / AnyType
   convention where the banner is full-bleed and the icon hangs at the
   body indent. */
.page-header-cover {
  position: relative;
  grid-column: full-start / full-end;
  width: 100%;
  height: 200px;
  overflow: hidden;
  background-color: var(--muted);
  /* Subtle inset border on the bottom edge so the banner reads as
     "page chrome" rather than a generic image embed when the cover's
     own pixels happen to match the editor bg. */
  border-bottom: 1px solid var(--border);
}

.page-header-cover-slider {
  /* The slider is the actual interactive layer that fills the fixed-height
     .page-header-cover container. The img inside is sized 100% × 100% and
     object-fit: cover clips within THIS box — without the width/height
     here the wrapper would collapse to the img's natural aspect and
     `object-position` would move within the natural size instead of the
     visible chrome, so the drag would read as "phantom" (banner_y writes
     but the visible framing never changes).

     No `touch-action` override — the JS drag handler declines touch pointers
     (see PageHeader `onPointerDown`), so vertical scroll on mobile falls
     through as the browser default. */
  display: block;
  width: 100%;
  height: 100%;
  cursor: ns-resize;
  outline: none;
}

.page-header-cover-slider:focus-visible {
  box-shadow: inset 0 0 0 2px var(--ring);
}

.page-header-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* `object-position` is set inline from `banner_y` / `cover_y` — this is
     the fallback for docs without a focal-position frontmatter key. */
  object-position: center;
  display: block;
  /* Cover images aren't user-actionable today — disable native drag so
     authors can't accidentally drag-eject the banner into another app. */
  user-select: none;
  -webkit-user-drag: none;
}

.page-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 0.5rem;
  font-size: 56px;
  line-height: 1;
  background-color: var(--background);
  border: 1px solid var(--border);
  overflow: hidden;
  /* No horizontal margin — the icon sits at the left edge of the
     `content` grid column, which already lines up with the editor body
     H1 / paragraph text (`.editor-content-aligned` does the math).
     Vertical margins still apply: small breathing room above + below
     when no cover, or negative-top to overlap the cover when present
     (handled by the `--with-cover` modifier). */
  margin: 0.75rem 0 0.25rem 0;
}

.page-header-icon--with-cover {
  /* With cover: overlap the banner's bottom edge by half the icon
     height (-36px) so the icon visually links banner to content. */
  position: relative;
  margin-top: -36px;
  margin-bottom: 0.25rem;
  /* Slightly lift the icon above the cover via a thin ring so it
     doesn't blend into a busy banner. */
  box-shadow: 0 0 0 2px var(--background);
}

.page-header-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sonner toast interactivity under a modal Radix layer.
   sonner@2 renders its toaster via appendChild onto <body> and never sets
   pointer-events: auto on the toaster/toasts (its only pointer-events rule
   is `none` on hidden toasts). When a modal Radix layer is open (Dialog /
   Sheet / any DismissableLayer with disableOutsidePointerEvents) it
   sets `body { pointer-events: none }`, which the toast then inherits — so a
   toast paints on top (z-index 999999999) but its close/action buttons are
   click-dead. Re-enable pointer events on each toast, and keep the toaster
   gutter click-through so it doesn't swallow clicks meant for UI beneath it. */
[data-sonner-toaster] {
  pointer-events: none;
}
[data-sonner-toast] {
  pointer-events: auto;
}

.inline-code {
  @apply font-mono bg-muted text-inherit border border-border rounded-md px-1 py-0.5 text-sm;
}

/* Rendered (WYSIWYG) Timeline diff — inline track-changes decorations.
   Scoped under .ProseMirror so they render inside the read-only diff editor's
   content DOM (RenderedDiffView). `ins`/`del` are decoration classes, not real
   nodes — see lib/rendered-diff/diff-decorations.ts. */
.ProseMirror .ok-diff-ins {
  background-color: color-mix(in srgb, var(--color-emerald-500) 18%, transparent);
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Whole added block (node decoration on the `<li>`/`<p>`/`<h2>` itself). */
.ProseMirror .ok-diff-ins-block {
  background-color: color-mix(in srgb, var(--color-emerald-500) 14%, transparent);
  border-radius: 2px;
  padding-inline: 0.25rem;
  border-left: 2px solid var(--color-emerald-500);
}

.ProseMirror .ok-diff-del {
  color: var(--color-red-600);
  text-decoration: line-through;
  background-color: color-mix(in srgb, var(--color-red-500) 10%, transparent);
  border-radius: 2px;
  opacity: 0.85;
}

.dark .ProseMirror .ok-diff-del {
  color: var(--color-red-400);
}

/* Whole-block deletions render as a struck-through block (removed heading /
   list / code) rather than an inline run. */
.ProseMirror .ok-diff-del-block {
  display: block;
  margin-block: 0.15em;
  padding-inline: 0.25rem;
  border-left: 2px solid var(--color-red-500);
}

/* Removed content is chrome, not editable document — never show a text caret. */
.ProseMirror .ok-diff-del,
.ProseMirror .ok-diff-del * {
  cursor: default;
}

.ok-rendered-diff .tabs-strip {
  display: none;
}

.ok-rendered-diff
  .tabs-content
  > .component-children
  > [data-node-view-content-react]
  > .react-renderer {
  display: block;
}

.ok-rendered-diff .tab-panel[data-tab-label]::before {
  content: attr(data-tab-label);
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

/* Mermaid WYSIWYG canvas (`mermaid-wysiwyg` package). The package injects its
   own `<style data-mw>` at runtime with `--mw-*` custom-property hooks for all
   interaction chrome (selection glow, popovers, in-place editors, plus-menus).
   Map those hooks onto OK's design tokens, and pin the SVG host back to the
   exact pre-package layout (centered, filling, non-selectable) so the rendered
   diagram is pixel-identical to the previous DIY renderer. Selectors ride on
   `.ok-mermaid-svg.mw-canvas` — two classes out-specify every single-class
   rule in the runtime-injected sheet regardless of load order. */
.ok-mermaid-svg.mw-canvas {
  --mw-accent: var(--ring);
  --mw-chrome-bg: var(--popover);
  --mw-chrome-border: var(--border);
  --mw-chrome-hover: var(--accent);
  --mw-chrome-fg: var(--popover-foreground);
  --mw-chrome-dim: var(--muted-foreground);
  --mw-editor-bg: var(--background);
  /* Package default is `overflow: auto`; OK pans/zooms the SVG in place. */
  overflow: hidden;
}
.ok-mermaid-svg.mw-canvas .mw-svg-host {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ok-mermaid-svg.mw-canvas .mw-svg-host > svg {
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}
/* Mid-edit parse failures keep the last good diagram on canvas; restyle the
   package's red badge to OK's destructive banner language. */
.ok-mermaid-svg.mw-canvas .mw-error-badge {
  background: var(--background);
  color: var(--destructive);
  border: 1px solid color-mix(in srgb, var(--destructive) 30%, transparent);
  box-shadow: none;
}
/* Selection / hover / connect chrome: the package defaults to a stacked
   drop-shadow bloom, which with OK's near-white `--ring` accent reads as a
   blown-out halo on dark canvases (and puts a glow on text glyphs while
   editing). Replace with a single tight edge tint. `!important` is required
   to beat the package's own `!important` on `.mw-selected`. */
.ok-mermaid-svg.mw-canvas [data-mw-entity]:hover {
  filter: drop-shadow(0 0 1px color-mix(in srgb, var(--mw-accent) 55%, transparent));
}
.ok-mermaid-svg.mw-canvas .mw-selected,
.ok-mermaid-svg.mw-canvas .mw-connect-source {
  /* biome-ignore lint/complexity/noImportantStyles: the package's injected `.mw-selected` rule is itself `!important`; matching importance is the only way to replace its stacked-bloom filter. */
  filter: drop-shadow(0 0 1.25px var(--mw-accent)) !important;
}
/* In-place label editing shows the caret only — no outline, no underline, no
   backdrop — matching how the previous inline editor read as "the label just
   became typeable". */
.ok-mermaid-svg.mw-canvas [contenteditable="true"] {
  outline: none;
  box-shadow: none;
}
.ok-mermaid-svg.mw-canvas .mw-inplace-editor {
  box-shadow: none;
  background: transparent;
}

/* A comment highlight inside a property value.
 *
 * The document body tints commented passages with a ProseMirror decoration.
 * A property value is a `<textarea>`, whose text no decoration can reach — so
 * the highlight is the field's own selection, recoloured to match. The fill
 * comes from `--comment-reveal-fill`, set alongside the attribute in
 * `property-row-rect.ts`, so the hue has one definition rather than two that
 * can drift apart.
 *
 * Attribute-scoped on purpose: without it every ordinary selection in the field
 * would read as a comment. */
[data-comment-reveal]::selection {
  background-color: var(--comment-reveal-fill);
}
[data-comment-reveal]::-moz-selection {
  background-color: var(--comment-reveal-fill);
}

/* Pierre diff surface CHROME — maps Pierre's --diffs-* custom properties to
   the app's existing design tokens. These properties inherit through the open
   shadow root of <diffs-container>, so no unsafeCSS injection is needed for
   colour theming. The underlying --diff-added / --diff-removed tokens already
   respond to .dark, so this single rule block covers both themes.

   Chrome only — the SYNTAX colours inside a hunk come from the Shiki theme
   (lib/ok-syntax-theme.ts), not from anything here. Four of the properties
   below (--diffs-fg, --diffs-bg, --diffs-addition-color,
   --diffs-deletion-color) are also written by Pierre at :host from that
   theme's colors, and :host wins over this rule — the two are kept resolving
   to the same tokens deliberately, so neither can silently take over.

   Both surfaces use Pierre as their renderer and share this custom-property block. */
.pierre-diff,
.conflict-view {
  --diffs-bg: var(--background);
  --diffs-fg: var(--foreground);
  --diffs-bg-context: var(--background);
  --diffs-bg-context-gutter: var(--muted);
  --diffs-fg-number: var(--muted-foreground);
  --diffs-bg-addition: color-mix(in oklab, var(--diff-added) 15%, transparent);
  --diffs-addition-color: var(--diff-added);
  --diffs-bg-deletion: color-mix(in oklab, var(--diff-removed) 15%, transparent);
  --diffs-deletion-color: var(--diff-removed);
  /* Fills the incoming half of a merge conflict, against --diffs-addition-color
     on the current half. Pierre routes the incoming side through its
     "modified" channel, so this is a conflict-region fill, not a small status
     indicator — it is why the value belongs here beside the other chrome
     rather than inside the Shiki theme. */
  --diffs-modified-color: var(--diff-modified);

  /* Conflict-region wash strength — the one knob. Pierre mixes the colours
     below into the surface itself (88% background for body rows, 78% for the
     marker rows), so this pre-lightening compounds with that: the accents are
     dark ramp steps chosen for TEXT, and at full strength they read as heavy
     blocks rather than a tint behind readable prose. Raise toward 100% for a
     stronger wash, lower for a fainter one.

     Applied through Pierre's own `--conflict-bg-*-override` hooks, which
     substitute the colour before its mix. The mix ratios themselves are set on
     elements inside the shadow root and cannot be reached from out here. */
  --ok-conflict-tint: 60%;
  --ok-conflict-current: color-mix(
    in oklab,
    var(--diff-added) var(--ok-conflict-tint),
    var(--background)
  );
  --ok-conflict-incoming: color-mix(
    in oklab,
    var(--diff-modified) var(--ok-conflict-tint),
    var(--background)
  );
  --conflict-bg-current-override: var(--ok-conflict-current);
  --conflict-bg-current-header-override: var(--ok-conflict-current);
  --conflict-bg-current-number-override: var(--ok-conflict-current);
  --conflict-bg-incoming-override: var(--ok-conflict-incoming);
  --conflict-bg-incoming-header-override: var(--ok-conflict-incoming);
  --conflict-bg-incoming-number-override: var(--ok-conflict-incoming);

  --diffs-fg-conflict-marker: var(--muted-foreground);
  --diffs-marker-bg: var(--muted);
  /* Separator background and foreground (--diffs-fg-number above) match the
     muted palette so the "N unmodified lines" widget blends with the gutters. */
  --diffs-bg-separator: var(--muted);

  /* Changed-row gutter numbers use --diffs-fg (= --foreground, WCAG-vetted on
     every registered palette) so the line-number contrast meets 4.5:1. Context
     numbers stay muted via --diffs-fg-number. The background hooks tint the
     gutter column lighter than the body row (10% vs 15%); opaque var(--background)
     as mix base avoids premultiplied-alpha collapse on Pierre's second mix pass. */
  --diffs-fg-number-addition-override: var(--diffs-fg);
  --diffs-fg-number-deletion-override: var(--diffs-fg);
  --diffs-bg-addition-number-override: color-mix(
    in oklab,
    var(--diff-added) 10%,
    var(--background)
  );
  --diffs-bg-deletion-number-override: color-mix(
    in oklab,
    var(--diff-removed) 10%,
    var(--background)
  );
}

/* Activity-panel typography: Pierre defaults to 13px sans-serif; the panel uses
   12px mono throughout to match the text-xs treatment of the rest of the panel.
   Setting on the outer wrapper lets the vars inherit through the open shadow root
   of <diffs-container>. */
.activity-panel-diff {
  --diffs-font-size: 0.75rem;
  --diffs-font-family: var(--font-mono);
}

/* Pointer marker drawn into the frame a bug-report screenshot is taken on.
 *
 * `capturePage()` omits the cursor, so without this a report about a hover
 * state shows a highlighted row and nothing explaining what highlighted it.
 * The ring is drawn one frame before the shot and taken down as soon as the
 * capture settles or the reveal timeout fires, so it is on screen only for the
 * round trip main needs to answer — during which the dialog is still held
 * closed. It is never part of the app's own UI.
 *
 * Deliberately unthemed and deliberately unanimated. It has to read as an
 * annotation on top of whatever it lands on in either colour scheme, so it
 * carries its own white piping rather than a token that could match the
 * surface underneath; and a fade-in would risk the shot catching it
 * half-transparent. The centre stays hollow so the pixel being pointed at is
 * still visible. */
.ok-pointer-marker {
  position: fixed;
  /* Above every layer in the app, including any that sets its own — an overlay
     the user is reporting is exactly what this has to sit on top of. */
  z-index: 2147483647;
  width: 22px;
  height: 22px;
  border: 2px solid rgb(220 38 38);
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 0 0 1.5px rgb(255 255 255 / 0.95),
    inset 0 0 0 1.5px rgb(255 255 255 / 0.95);
  pointer-events: none;
  transform: translate(-50%, -50%);
  /* Forced colors would force the border to a system colour and strip the
     box-shadow, collapsing both channels this ring is made of and leaving it
     the same colour as every border underneath it — the one outcome the
     comment above exists to prevent. Here the colours ARE the meaning, not
     theming, so opt the element out rather than restate them as system
     colours: the app it annotates is entirely system-coloured in this mode. */
  forced-color-adjust: none;
}

html[data-bug-report-capturing] [data-bug-report-launcher] {
  visibility: hidden;
  transition: none;
}

html[data-bug-report-capturing] [data-slot="dialog-overlay"]:has(~ [data-bug-report-launcher]) {
  visibility: hidden;
  transition: none;
}

html:not([data-color-theme]):not(.dark)
  .raw-mdx-fallback-wrapper[data-severity="error"]
  > div
  > span {
  color: #a31524;
}

html:not([data-color-theme]):not(.dark) file-tree-container {
  /* biome-ignore lint/complexity/noImportantStyles: the tree host receives --trees-selected-fg as an inline style, which no selector specificity can outrank. */
  --trees-selected-fg: #1d4ed8 !important;
}

html:not([data-color-theme]) .file-tree-empty-text {
  color: var(--muted-foreground);
}

html:not([data-color-theme]):not(.dark) .cm-gutters {
  color: #606060;
}

html:not([data-color-theme]) .color-theme-picker [data-state="off"]:not(:hover) {
  color: var(--muted-foreground);
}

html:not([data-color-theme]):not(.dark) .settings-sidebar-group-title {
  color: #5a5a5a;
}

html:not([data-color-theme]):not(.dark) .settings-sidebar-group-title[data-disabled] {
  color: var(--muted-foreground);
}

html:not([data-color-theme]).dark .settings-sidebar-group-title[data-disabled] {
  color: color-mix(in oklab, var(--muted-foreground) 80%, transparent);
}

html:not([data-color-theme]):not(.dark) .cm-content {
  --muted-foreground: #5a5a5a;
  --syntax-type: var(--color-yellow-800, oklch(0.476 0.114 61.907));
  --link-color: var(--color-azure-700, oklch(0.4895 0.233 263.93));
  --destructive: var(--color-red-800, oklch(0.444 0.177 26.899));
}
html:not([data-color-theme]).dark .cm-content {
  --link-color: #8bb9ff;
  --muted-foreground: oklch(0.78 0 0);
  --destructive: var(--color-red-300, oklch(0.808 0.114 19.571));
}
html:not([data-color-theme]):not(.dark) .cm-selectionLayer {
  --selection-soft: #e0ebfc;
}

html:not([data-color-theme]).dark .cm-selectionLayer {
  --selection-soft: #20364d;
}

html:not([data-color-theme]) .cm-editor .cm-selectionBackground,
html:not([data-color-theme])
  .cm-editor.cm-focused
  > .cm-scroller
  > .cm-selectionLayer
  .cm-selectionBackground {
  background-color: var(--selection-soft);
}

html:not([data-color-theme]):not(.dark) .cm-editor .cm-searchMatch,
html:not([data-color-theme]):not(.dark) .cm-editor .cm-selectionMatch {
  background-color: rgb(230 198 76 / 24%);
}
html:not([data-color-theme]).dark .cm-editor .cm-searchMatch,
html:not([data-color-theme]).dark .cm-editor .cm-selectionMatch {
  background-color: rgb(155 122 39 / 16%);
}
html:not([data-color-theme]):not(.dark) .cm-editor .cm-searchMatch.cm-searchMatch-selected {
  background-color: #cbdcfa;
}
html:not([data-color-theme]).dark .cm-editor .cm-searchMatch.cm-searchMatch-selected {
  background-color: #243950;
}

html:not([data-color-theme]):not(.dark) [data-slot="kbd"] {
  --muted-foreground: #686868;
}

[data-agents-panel-mount][data-chat-alone]
  [data-agent-thread-root]
  > :not(.absolute):not([data-testid="agent-thread-transcript"]):not(
    :has([data-testid="agent-thread-transcript"])
  ) {
  width: 100%;
  max-width: var(--chat-reading-width);
  margin-inline: auto;
}

[data-agents-panel-mount][data-chat-alone] [data-testid="agent-thread-transcript"] {
  padding-inline: max(0.75rem, calc((100% - var(--chat-reading-width)) / 2 + 0.75rem));
}

[data-agents-panel-mount] {
  --chat-reading-width: 48rem;
}

[data-editor-pane-projected] [data-editor-pane-panel]:not([data-editor-pane-selected]),
[data-editor-pane-projected] [data-editor-pane-tab-group]:not([data-editor-pane-selected]) {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

[data-editor-pane-projected] [data-editor-pane-resize-handle] {
  display: none;
}

[data-editor-pane-projected] [data-editor-pane-panel][data-editor-pane-selected],
[data-editor-pane-projected] [data-editor-pane-tab-group][data-editor-pane-selected] {
  min-width: 0;
}