/* Semred shared foundation. Color literals belong only in these two token blocks. */
:root {
  color-scheme: light;
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-surface-muted: #f1f2f8;
  --color-surface-hover: #e8ebf3;
  --color-text: #171a24;
  --color-text-muted: #575f70;
  --color-border: #dadde8;
  --color-border-strong: #8890a1;
  --color-action: #14161f;
  --color-action-hover: #2c3140;
  --color-on-action: #ffffff;
  --color-solid-white: #fff;
  --color-focus: #2f55a6;
  --color-selection-bg: #e3ecfa;
  --color-clear: transparent;
  --color-overlay: rgb(17 20 25 / 55%);
  --layout-page-shadow: 0 5px 24px rgb(23 32 51 / 15%);
  --layout-placeholder-shadow: 0 1px 2px rgb(15 23 42 / 12%);
  --layout-selection-bg: rgb(47 85 166 / 20%);

  /* Brand red is reserved for the logo; red tones below mark sensitive/replaced text. */
  --color-brand-red: #e50914;
  --color-sensitive-text: #a31525;
  --color-sensitive-bg: #fff0f1;
  --color-sensitive-border: #e3a3ab;
  --color-redacted-text: #962737;
  --color-redacted-bg: #fbecef;
  --color-redacted-border: #d9a1ab;
  --color-safe-text: #216444;
  --color-safe-bg: #edf7f0;
  --color-safe-border: #91b8a0;
  --color-warning-text: #805511;
  --color-warning-bg: #fff5df;
  --color-warning-border: #c6a15e;

  /* Bold but compact entity palette; categories share five related hues. */
  --entity-person-text: #8f1018;
  --entity-person-bg: #ffd6d9;
  --entity-person-border: #d92d3a;
  --entity-place-text: #0b4f9c;
  --entity-place-bg: #cfe3ff;
  --entity-place-border: #2878d4;
  --entity-temporal-text: #7a4300;
  --entity-temporal-bg: #ffecb3;
  --entity-temporal-border: #d99000;
  --entity-health-text: #05603a;
  --entity-health-bg: #c8f0d8;
  --entity-health-border: #159467;
  --entity-identifier-text: #482080;
  --entity-identifier-bg: #e5d5ff;
  --entity-identifier-border: #7541c8;

  /* Inverse tones, shared by the marketing surface and any dark-on-light block. */
  --color-inverse-bg: #08090b;
  --color-inverse-surface: #141518;
  --color-inverse-text: #ffffff;
  --color-inverse-muted: #a1a1aa;
  --color-inverse-border: #2a2b30;
  --color-inverse-redacted: #ffa2ae;

  /* Marketing surface. Follows the resolved theme like every other page. */
  --mkt-bg: #ffffff;
  --mkt-bg-raised: #f6f7fb;
  --mkt-surface: #ffffff;
  --mkt-surface-strong: #eceef6;
  --mkt-surface-hover: #e2e6f1;
  --mkt-action-hover: #2c3140;
  --mkt-text: #0c0f18;
  --mkt-text-muted: #525a6b;
  --mkt-text-faint: #6a7183;
  --mkt-border: #e4e7f0;
  --mkt-border-strong: #b7bfd1;
  --mkt-scrim: rgb(255 255 255 / 78%);
  /* A panel recessed inside a card: darker than its card in both themes. */
  --mkt-inset: #f5f6fb;
  --mkt-redacted: #962737;

  /* Light accents: an aurora over porcelain - lagoon teal into cobalt into
   * orchid. The ink stops stay dark enough to clip into 11px text on white
   * (>=5.5:1); the wash stops stay pale enough to carry --mkt-text.
   * Red stays reserved for sensitive/replaced text. */
  --accent-1: #0d6f8e;
  --accent-2: #3a4cc4;
  --accent-3: #8a3d9b;
  --accent-solid: #3a4cc4;
  --gradient-brand: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 50%, var(--accent-3) 100%);
  --gradient-brand-soft: radial-gradient(ellipse 78% 120% at 0% 0%, #c5e6f7 0%, transparent 62%),
    radial-gradient(ellipse 64% 110% at 100% 4%, #ded0f9 0%, transparent 58%),
    radial-gradient(ellipse 70% 90% at 88% 100%, #f7dcec 0%, transparent 60%),
    linear-gradient(118deg, #e9f4fb 0%, #f1effd 54%, #fbeef3 100%);
  --gradient-frame: radial-gradient(ellipse at 4% 2%, #74d2ea 0%, transparent 62%),
    radial-gradient(ellipse at 98% 98%, #edaadb 0%, transparent 58%),
    linear-gradient(135deg, #9ed3ec 0%, #eceef9 46%, #b79ae6 100%);

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  /* Display serif for the homepage headline only. Gelasio is the closest free
   * match to Robinhood's Martina Plantijn (Klim Type Foundry, licensed); to use
   * the real face, license it, self-host it with @font-face and put it first. */
  --font-display: 'Gelasio', Georgia, 'Times New Roman', serif;
  /* Hierarchy comes from size, not weight: headings stay at 500-600. */
  --text-eyebrow: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-title: 1.75rem;
  --text-display: 2.5rem;
  --text-section: clamp(2rem, 4.2vw, 2.75rem);
  --text-hero: clamp(2.375rem, 5.4vw, 3.75rem);
  --text-lead: clamp(1rem, 1.4vw, 1.125rem);
  --line-hero: 1.04;
  --line-tight: 1.25;
  --line-body: 1.5;
  --line-relaxed: 1.65;
  --line-document: 1.7;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --tracking-hero: -0.028em;
  --tracking-display: -0.018em;
  --tracking-brand: 0.12em;
  --tracking-label: 0.08em;
  --tracking-eyebrow: 0.14em;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 72px;
  --space-12: 96px;
  --space-13: 128px;
  --space-14: clamp(80px, 11vw, 160px);
  --radius-control: 6px;
  --radius-panel: 8px;
  --radius-modal: 12px;
  --radius-card: 18px;
  --radius-frame: 22px;
  --radius-pill: 999px;
  --radius-round: 50%;
  --border-width: 1px;
  --focus-width: 2px;
  --focus-offset: 3px;
  --shadow-panel: 0 1px 2px rgb(17 20 25 / 4%);
  --shadow-popover: 0 8px 24px rgb(17 20 25 / 14%);
  --shadow-modal: 0 16px 48px rgb(17 20 25 / 20%);
  /* Press mechanics shared by every control: a 1px drop with an inner shadow. */
  --shadow-press: inset 0 1px 2px rgb(17 20 25 / 14%);
  --shadow-press-strong: inset 0 2px 3px rgb(0 0 0 / 30%);
  --shadow-raise: 0 1px 2px rgb(17 20 25 / 20%);
  --shadow-home-button: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-dialog-inset: 0 1px 0 rgb(255 255 255 / 6%) inset;
  --shadow-action-inset: 0 1px 0 rgb(255 255 255 / 12%) inset;
  --shadow-action-rest: 0 1px 2px rgb(17 20 25 / 18%), 0 4px 12px -6px rgb(17 20 25 / 45%);
  --shadow-action-hover: 0 2px 4px rgb(17 20 25 / 18%), 0 8px 18px -8px rgb(17 20 25 / 55%);
  /* Motion layer (motion.css): the four stops the hero frame's shader and the
   * glass card's rotating frame mix, plus the light and shadow they cast. */
  --fx-0: #eceef9;
  --fx-1: #74d2ea;
  --fx-2: #b79ae6;
  --fx-3: #edaadb;
  --fx-highlight: rgb(255 255 255 / 30%);
  --fx-lift: 0 30px 60px -20px rgb(17 20 25 / 35%);
  --fx-hint-shadow: 0 6px 20px rgb(17 20 25 / 10%);
  /* Homepage hero: the Redact files gate's lift, at rest and on hover. */
  --hero-cta-shadow: 0 10px 28px rgb(17 20 25 / 28%);
  --hero-cta-shadow-hover: 0 14px 34px rgb(17 20 25 / 32%);

  --control-height: 44px;
  --control-compact: 32px;
  --nav-width: 208px;
  --document-list-width: 208px;
  --document-list-collapsed-width: 160px;
  --inspector-width: 288px;
  --modal-width: 420px;
  --menu-width: 160px;
  --tooltip-width: 240px;
  --document-input-height: 260px;
  --document-output-height: 120px;
  --document-output-small-height: 60px;
  --switch-width: 44px;
  --switch-height: 24px;
  --switch-thumb: 18px;
  --switch-inset: 3px;
  --switch-travel: 20px;
  --content-width: 640px;
  --hero-text-width: 520px;
  --page-width: 1200px;
  --page-gutter: clamp(20px, 4vw, 40px);
  /* How far a raised band takes to reach the page colour at each of its
     edges. Capped as a share of the band's own height so a short section
     never becomes two facing gradients with no flat middle. */
  --band-fade: min(140px, 26%);
  /* The bleed itself, written once and used by every raised band. A plain
     two-stop ramp leaves a visible crease where it starts, because the eye
     reads the change from flat to sloping, not the slope itself. The three
     interior stops approximate smoothstep, so the gradient eases in and out
     and has no corner at either end. The inner var()s resolve against the
     element, so this follows the theme like any other token. */
  --band-bleed: linear-gradient(
    to bottom,
    var(--mkt-bg) 0,
    color-mix(in srgb, var(--mkt-bg-raised) 16%, var(--mkt-bg)) calc(var(--band-fade) * 0.25),
    color-mix(in srgb, var(--mkt-bg-raised) 50%, var(--mkt-bg)) calc(var(--band-fade) * 0.5),
    color-mix(in srgb, var(--mkt-bg-raised) 84%, var(--mkt-bg)) calc(var(--band-fade) * 0.75),
    var(--mkt-bg-raised) var(--band-fade),
    var(--mkt-bg-raised) calc(100% - var(--band-fade)),
    color-mix(in srgb, var(--mkt-bg-raised) 84%, var(--mkt-bg)) calc(100% - var(--band-fade) * 0.75),
    color-mix(in srgb, var(--mkt-bg-raised) 50%, var(--mkt-bg)) calc(100% - var(--band-fade) * 0.5),
    color-mix(in srgb, var(--mkt-bg-raised) 16%, var(--mkt-bg)) calc(100% - var(--band-fade) * 0.25),
    var(--mkt-bg) 100%
  );
  --measure: 440px;
  --measure-wide: 560px;
  --duration-fast: 150ms;
  --ease-standard: ease;
  /* Theme change. The origin and reach are overwritten per switch by common.js;
   * the mask colours carry opacity only, never a hue. */
  --duration-theme: 760ms;
  --ease-theme: cubic-bezier(0.65, 0, 0.28, 1);
  --theme-origin-x: 50%;
  --theme-origin-y: 50%;
  --theme-reach: 100vmax;
  --theme-feather: 0.16;
  --theme-mask-opaque: #000000;
  --theme-mask-clear: rgb(0 0 0 / 0%);
  --layer-nav: 10;
  --layer-popover: 20;
  --layer-modal: 30;
  --layer-toolbar: 22;
  --drawer-top: 0px;
  --workspace-min-height: 520px;
  --pane-heading-height: 64px;
  --pane-caption-height: 56px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #131518;
  --color-surface: #1b1e23;
  --color-surface-muted: #24282e;
  --color-surface-hover: #30363e;
  --color-text: #edeff2;
  --color-text-muted: #adb5c1;
  --color-border: #373e48;
  --color-border-strong: #788493;
  --color-action: #e5e8ec;
  --color-action-hover: #cbd1d9;
  --color-on-action: #15171a;
  --color-focus: #9bbefa;
  --color-selection-bg: #273951;
  --color-overlay: rgb(0 0 0 / 68%);
  --color-sensitive-text: #ffabb5;
  --color-sensitive-bg: #392128;
  --color-sensitive-border: #82505a;
  --color-redacted-text: #ffb7c1;
  --color-redacted-bg: #35232b;
  --color-redacted-border: #805460;
  --color-safe-text: #a0d9b8;
  --color-safe-bg: #1c3027;
  --color-safe-border: #4b7d61;
  --color-warning-text: #ecc580;
  --color-warning-bg: #332c20;
  --color-warning-border: #856b3f;
  --entity-person-text: #ffb4ab;
  --entity-person-bg: #5a2529;
  --entity-person-border: #ff6b6b;
  --entity-place-text: #a8c7ff;
  --entity-place-bg: #183d6b;
  --entity-place-border: #5b9cff;
  --entity-temporal-text: #ffd978;
  --entity-temporal-bg: #584313;
  --entity-temporal-border: #e6aa28;
  --entity-health-text: #91e8b7;
  --entity-health-bg: #164b36;
  --entity-health-border: #38b982;
  --entity-identifier-text: #d7baff;
  --entity-identifier-bg: #40266b;
  --entity-identifier-border: #a777ff;
  --color-inverse-bg: #08090b;
  --color-inverse-surface: #141518;
  --color-inverse-border: #2a2b30;
  --mkt-bg: #000000;
  --mkt-bg-raised: #0a0b0d;
  --mkt-surface: #141518;
  --mkt-surface-strong: #1c1d21;
  --mkt-surface-hover: #26272c;
  --mkt-action-hover: #d4d4d8;
  --mkt-text: #ffffff;
  --mkt-text-muted: #a1a1aa;
  --mkt-text-faint: #86868c;
  --mkt-border: #212227;
  --mkt-border-strong: #33343a;
  --mkt-scrim: rgb(0 0 0 / 72%);
  --mkt-inset: #000000;
  --mkt-redacted: #ffa2ae;
  --accent-1: #b39dff;
  --accent-2: #ff9ecf;
  --accent-3: #7de3e8;
  --accent-solid: #c3aeff;
  --gradient-brand-soft: linear-gradient(135deg, #2a2350 0%, #40263c 50%, #1d3b3e 100%);
  --gradient-frame: linear-gradient(150deg, #b39dff 0%, #ff9ecf 45%, #7de3e8 100%);
  --shadow-panel: none;
  --shadow-popover: 0 8px 24px rgb(0 0 0 / 30%);
  --shadow-modal: 0 16px 48px rgb(0 0 0 / 45%);
  --fx-0: #2a2350;
  --fx-1: #b39dff;
  --fx-2: #ff9ecf;
  --fx-3: #7de3e8;
  --fx-highlight: rgb(255 255 255 / 18%);
  --fx-lift: 0 30px 60px -20px rgb(0 0 0 / 55%);
  --fx-hint-shadow: 0 6px 20px rgb(0 0 0 / 40%);
}

/* Base and text */
*, *::before, *::after {
  box-sizing: border-box;
}
body, h1, h2, h3, h4, p, pre, ul {
  margin: 0;
}
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-body);
  overflow-wrap: anywhere;
}
a {
  color: inherit;
  text-decoration: none;
}
button, input, textarea, select {
  font: inherit;
}
button, a, input, select, textarea {
  touch-action: manipulation;
}
img, svg {
  max-width: 100%;
}
pre {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}
::selection {
  background: var(--color-selection-bg);
  color: var(--color-text);
}
.hidden, [hidden] {
  display: none !important;
}
.logo, .sidebar-logo {
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-brand);
}
.logo {
  font-size: var(--text-sm);
}
.sidebar-logo {
  font-size: var(--text-lg);
}
.logo-sem {
  color: var(--color-text);
}
.logo-red {
  color: var(--color-brand-red);
}
.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Shared buttons: no movement or glowing hover. */
.btn-primary, .btn-secondary, .danger-btn, .nav-cta, .auth-provider, .modal-close,
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  max-width: 100%;
  padding: var(--space-2) var(--space-4);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--line-body);
  text-align: center;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard),
  border-color var(--duration-fast) var(--ease-standard);
}
.btn-primary, .nav-cta {
  background: var(--color-action);
  border-color: var(--color-action);
  color: var(--color-on-action);
}
.btn-primary:hover, .nav-cta:hover {
  background: var(--color-action-hover);
  border-color: var(--color-action-hover);
}
.btn-secondary:hover, .auth-provider:hover, .modal-close:hover, .sidebar-toggle-btn:hover {
  background: var(--color-surface-hover);
}
.danger-btn {
  background: var(--color-surface-muted);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.danger-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}
button:disabled, input:disabled, select:disabled, textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-full, .doc-btn, .auth-btn, .auth-provider, .modal-close {
  width: 100%;
}
.btn-full {
  margin-top: var(--space-4);
}

/* Shared controls */
input:not([type="checkbox"]):not([type="radio"]), textarea, select {
  min-width: 0;
  max-width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: var(--line-body);
}
textarea {
  width: 100%;
  resize: vertical;
}
input::placeholder, textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}
input:read-only:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea:read-only {
  background: var(--color-surface-muted);
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--color-action);
}
input[type="file"] {
  width: 100%;
}
input::file-selector-button {
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  padding: var(--space-1) var(--space-2);
  margin-right: var(--space-2);
  background: var(--color-surface-muted);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}
label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* Shared panels and cards */
.app-section, .card, .project-card, .project-row, .usage-card, .doc-workspace, .doc-list, .auth-card {
  min-width: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-panel);
}
/* Content cards take the softer marketing radius; dense workspace panes keep 8px. */
.app-section, .card, .project-card, .project-row, .usage-card, .auth-card {
  border-radius: var(--radius-card);
}
.app-section {
  position: relative;
  margin-bottom: var(--space-6);
  padding: var(--space-7);
}
.card, .project-card, .project-row, .usage-card {
  padding: var(--space-6);
}
.section-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
  margin-bottom: var(--space-5);
}
.card h3, .project-card h3, .project-info h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
  margin-bottom: var(--space-3);
}
.card p, .project-card p, .project-info p, .usage-label {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--line-relaxed);
}
.project-row {
  display: block;
  margin-bottom: var(--space-5);
}
.project-row:hover, .project-card:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-border-strong);
}
.usage-card {
  text-align: center;
}
.usage-label {
  display: block;
  margin-bottom: var(--space-3);
  font-size: var(--text-eyebrow);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
}
.usage-period {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  letter-spacing: normal;
  text-transform: none;
}
.usage-value {
  font-size: var(--text-display);
  font-weight: var(--weight-medium);
  line-height: var(--line-hero);
  letter-spacing: var(--tracking-display);
  font-variant-numeric: tabular-nums;
}
.project-grid, .usage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}
.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Shared modal structure; existing IDs and open/close classes remain supported. */
.modal {
  position: fixed;
  inset: 0;
  padding: var(--space-4);
  background: var(--color-overlay);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--layer-modal);
}
.modal-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: var(--modal-width);
  max-width: 100%;
  max-height: calc(100dvh - var(--space-7));
  overflow-y: auto;
  padding: var(--space-6);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  text-align: left;
}
.modal-content h2, .modal-content h3 {
  font-size: var(--text-lg);
}
.modal-content p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.modal-content input, .modal-content textarea {
  width: 100%;
}
.modal-content textarea {
  min-height: var(--document-output-height);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.modal-btn {
  width: 100%;
}

/* Existing application navigation and page layouts */
.app-body {
  display: flex;
  min-height: 100dvh;
}
.sidebar {
  flex: 0 0 var(--nav-width);
  width: var(--nav-width);
  background: var(--color-surface);
  border-right: var(--border-width) solid var(--color-border);
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar-link {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.sidebar-link:hover {
  color: var(--color-text);
  background: var(--color-surface-muted);
}
.sidebar-home {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: calc(-1 * var(--space-5));
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.sidebar-home:hover {
  color: var(--color-text);
}
.sidebar-link.active {
  color: var(--color-text);
  background: var(--color-surface-hover);
  font-weight: var(--weight-semibold);
}
.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-8) var(--space-7) var(--space-10);
}
.app-topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: var(--border-width) solid var(--color-border);
}
.account-id-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  max-width: 46rem;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface-muted);
}
.account-id-card h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}
.account-id-card .form-hint {
  margin: 0 0 var(--space-2);
}
.account-id-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: var(--text-xs);
  user-select: all;
}
.account-id-card #accountIdStatus:empty {
  display: none;
}
.account-main > .account-section {
  max-width: 56rem;
}
.account-section-intro {
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.account-profile-form {
  display: grid;
  gap: var(--space-2);
  max-width: 42rem;
}
.account-profile-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.account-profile-row input {
  flex: 1;
  min-width: 0;
}
.account-profile-form .form-hint {
  margin: 0;
}
.account-identity-copy {
  min-width: 0;
}
.app-title {
  min-width: 0;
  font-size: var(--text-display);
  font-weight: var(--weight-medium);
  line-height: var(--line-hero);
  letter-spacing: var(--tracking-hero);
}
.user-avatar {
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-round);
  background: var(--color-surface-hover);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
}
.project-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.project-title-editable {
  padding: var(--space-1);
  border-radius: var(--radius-control);
}
.project-title-editable:hover {
  background: var(--color-surface-muted);
  cursor: text;
}
.project-title-editable.editing {
  background: var(--color-surface);
  outline: var(--focus-width) solid var(--color-focus);
}

/* Document workspace: source + result, with two independently collapsible side panes. */
.workspace-main {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  overflow: hidden;
  transition: gap .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1);
}
.workspace-header, .workspace-toolbar, .toolbar-context, .toolbar-actions, .pane-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.workspace-header {
  justify-content: space-between;
  flex-wrap: wrap;
  max-height: 10rem;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.22,1,.36,1), min-height .3s cubic-bezier(.22,1,.36,1),
    opacity .3s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.22,1,.36,1),
    margin .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1),
    border-width .3s cubic-bezier(.22,1,.36,1);
}
.workspace-heading {
  min-width: 0;
}
.workspace-back {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.eyebrow {
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--color-text-muted);
}
.workspace-back:hover {
  text-decoration: underline;
}
.workspace-heading .app-title {
  margin-top: var(--space-1);
  font-size: var(--text-xl);
}
.workspace-header .project-header-actions {
  gap: var(--space-2);
  margin-left: auto;
}
.workspace-toolbar {
  position: sticky;
  top: 0;
  z-index: var(--layer-toolbar);
  justify-content: space-between;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  transition: padding .3s cubic-bezier(.22,1,.36,1), gap .3s cubic-bezier(.22,1,.36,1);
}
.toolbar-context {
  flex-wrap: wrap;
  flex: 1;
}
.toolbar-actions {
  flex-wrap: wrap;
}
.panel-toggles {
  display: flex;
  gap: var(--space-1);
}
.panel-toggles button {
  padding-inline: var(--space-2);
}
.panel-toggles button[aria-expanded="true"] {
  background: var(--color-surface-hover);
}
.rule-context {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.rule-context .eyebrow {
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}
.text-link {
  text-decoration: underline;
  text-underline-offset: var(--space-1);
  color: var(--color-text-muted);
}
.save-status {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.workspace-status {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
  max-height: 3rem;
  overflow: hidden;
  transition: max-height .3s cubic-bezier(.22,1,.36,1), min-height .3s cubic-bezier(.22,1,.36,1),
    opacity .3s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.22,1,.36,1),
    margin .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1),
    border-width .3s cubic-bezier(.22,1,.36,1);
}

.sanitize-progress { max-height: 8rem; overflow: hidden; margin: 0 0 1rem; padding: .75rem 1rem; border: 1px solid var(--color-border); border-radius: .75rem; background: var(--color-surface); transition: max-height .3s cubic-bezier(.22,1,.36,1), opacity .3s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.22,1,.36,1), margin .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1), border-width .3s cubic-bezier(.22,1,.36,1); }
.progress-heading { display: flex; justify-content: space-between; gap: 1rem; font-size: .82rem; color: var(--color-text); }
.progress-track { height: .45rem; margin-top: .55rem; overflow: hidden; border-radius: 999px; background: var(--color-surface-muted); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gradient-brand); transition: width .35s ease; }
.progress-note { margin: .45rem 0 0; font-size: .72rem; color: var(--color-text-muted); }


/* A deliberate scroll gesture tucks context away with a weighted, eased snap. */
.workspace-focus-mode .workspace-header,
.workspace-focus-mode .workspace-status:not(.focus-status-visible),
.workspace-focus-mode .run-activity {
  max-height: 0;
  min-height: 0;
  margin-block: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  transform: translateY(-.65rem);
  pointer-events: none;
}
.workspace-focus-mode .workspace-toolbar {
  gap: var(--space-2);
  padding-block: var(--space-2);
}
.workspace-focus-mode .workspace-main {
  gap: var(--space-2);
  padding-block: var(--space-3);
}
.workspace-focus-mode .workspace-shell {
  margin-top: 0;
  gap: 0;
}
.workspace-focus-mode .doc-list,
.workspace-focus-mode .inspector {
  flex-basis: 0;
  width: 0;
  min-width: 0;
  max-width: 0;
  min-height: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  transform: translate3d(-.5rem, 0, 0);
  overflow: hidden;
  pointer-events: none;
}
.workspace-focus-mode .inspector {
  transform: translate3d(.5rem, 0, 0);
}
.doc-list,
.inspector {
  transition: flex-basis .3s cubic-bezier(.22,1,.36,1), width .3s cubic-bezier(.22,1,.36,1),
    min-width .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1),
    border-width .3s cubic-bezier(.22,1,.36,1), opacity .3s cubic-bezier(.22,1,.36,1),
    transform .3s cubic-bezier(.22,1,.36,1);
}
.workspace-shell {
  transition: gap .3s cubic-bezier(.22,1,.36,1);
}
@media (max-width: 900px) {
  .workspace-focus-mode .document-text,
  .workspace-focus-mode textarea.document-text {
    height: 76dvh;
    max-height: 76dvh;
  }
}
.focus-workspace-btn {
  white-space: nowrap;
  min-inline-size: 9rem;
}
.focus-workspace-control {
  position: relative;
  flex: 0 0 auto;
}
.workspace-scroll-help {
  flex: 0 0 auto;
  margin: 0;
  padding-inline: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.focus-view-hint {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: var(--layer-toolbar);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  width: min(19rem, calc(100vw - var(--space-8)));
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  color: var(--color-text);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.focus-view-hint p {
  flex: 1;
  margin: 0;
}
.focus-view-hint .icon-button {
  flex: 0 0 auto;
}
body:has(.tour-live-layer:not([hidden])) .focus-view-hint {
  display: none;
}
.workspace-focus-mode .workspace-status.focus-status-visible {
  max-height: none;
  overflow: visible;
  opacity: 1;
  transform: none;
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
  transition: none;
}
@media (max-width: 900px) {
  .focus-view-hint {
    position: static;
    width: 100%;
    margin-top: var(--space-2);
  }
  .focus-workspace-control:has(.focus-view-hint:not(.hidden)) {
    grid-column: 1 / -1;
  }
}

.similarity-label {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.metric-help-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.metric-help {
  display: inline-grid;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  min-height: 1.05rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font: inherit;
  font-size: .68rem;
  line-height: 1;
  cursor: help;
}
.metric-help-popover {
  position: fixed;
  z-index: var(--layer-popover);
  right: 1rem;
  bottom: 1rem;
  width: min(18rem, calc(100vw - 2rem));
  padding: .65rem .75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-popover);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: 1.45;
  visibility: hidden;
  opacity: 0;
  transform: translateY(.25rem);
  transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
  pointer-events: none;
}
.metric-help:hover + .metric-help-popover,
.metric-help:focus + .metric-help-popover {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0s;
}
@media (prefers-reduced-motion: reduce) {
  .workspace-header, .workspace-status, .sanitize-progress,
  .metric-help-popover {
    transition-duration: .01ms;
  }
}
.is-warning, .modal-error {
  color: var(--color-warning-text);
}
.workspace-shell {
  display: flex;
  gap: var(--space-4);
  flex: 1;
  min-height: 0;
  position: relative;
  isolation: isolate;
}
.doc-list, .inspector {
  flex: 0 0 var(--document-list-width);
  width: var(--document-list-width);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--space-4);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
}
.inspector {
  flex-basis: var(--inspector-width);
  width: var(--inspector-width);
  gap: var(--space-2);
}
.pane-heading {
  justify-content: space-between;
  flex-shrink: 0;
}
.pane-heading h2 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.count-badge {
  display: inline-block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: var(--space-1);
}
.icon-button, .text-button {
  border: none;
  border-radius: var(--radius-control);
  background: var(--color-clear);
  color: var(--color-text-muted);
  min-height: var(--control-compact);
  cursor: pointer;
}
.icon-button {
  flex-shrink: 0;
  width: var(--control-compact);
  font-size: var(--text-lg);
}
.text-button {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
}
.icon-button:hover, .text-button:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.doc-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-block: var(--space-2);
  max-height: 5em;
  overflow: auto;
}
#docList {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding: var(--space-1);
  margin-inline: calc(-1 * var(--space-1));
}
.doc-item {
  position: relative;
  margin-bottom: var(--space-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
}
.doc-item.active {
  border-color: var(--color-focus);
  background: var(--color-selection-bg);
}
.doc-open {
  display: block;
  text-align: left;
  width: 100%;
  min-width: 0;
  background: var(--color-clear);
  border: none;
  color: var(--color-text);
  padding: var(--space-3);
  padding-right: var(--space-8);
  cursor: pointer;
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
}
.doc-open:hover {
  background: var(--color-surface-hover);
}
.doc-item-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.doc-item-meta {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.doc-actions-btn {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: var(--control-compact);
  height: var(--control-compact);
  border: none;
  border-radius: var(--radius-control);
  background: var(--color-clear);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
}
.doc-actions-menu {
  padding: var(--space-1);
  border-top: var(--border-width) solid var(--color-border);
}
.doc-actions-item {
  display: block;
  width: 100%;
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-control);
  background: var(--color-clear);
  color: var(--color-text);
  text-align: left;
  font-size: var(--text-sm);
  cursor: pointer;
}
.doc-actions-item:hover, .doc-actions-btn:hover {
  background: var(--color-surface-hover);
}
.doc-actions-item.danger {
  border-top: var(--border-width) solid var(--color-border);
}
.doc-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: none;
  padding: 0;
  background: var(--color-clear);
  box-shadow: none;
}
.doc-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  flex: 1;
  min-height: 0;
}
.page-layout-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); overflow: hidden; }
.page-layout-toolbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; padding:.75rem 1rem; border-bottom:1px solid var(--color-border); }
.page-layout-toolbar h2 { margin:0; font-size:var(--text-md); }
.page-layout-toolbar p { margin:.2rem 0 0; color:var(--color-text-muted); font-size:var(--text-xs); }
.layout-page-viewport { flex:1; min-height:0; overflow:auto; padding:1.25rem; background:var(--color-surface-muted); }
.layout-pages { display:flex; flex-direction:column; align-items:center; gap:1.25rem; min-width:100%; }
.layout-sheet { display:flex; flex-direction:column; align-items:center; gap:.35rem; width:max-content; max-width:none; }
.layout-sheet-label { align-self:flex-start; color:var(--color-text-muted); font-size:var(--text-xs); line-height:1.3; }
.layout-page-placeholder { min-width:16rem; min-height:18rem; display:grid; place-items:center; color:var(--color-text-muted); background:var(--color-surface); border:var(--border-width) solid var(--color-border); border-radius:var(--radius-panel); }
.layout-page { position:relative; width:max-content; max-width:none; margin:0; background:var(--color-surface); box-shadow:var(--layout-page-shadow); line-height:0; }
.layout-page img { display:block; max-width:none; width:100%; height:auto; user-select:none; -webkit-user-drag:none; }
.layout-redaction-layer { position:absolute; inset:0; pointer-events:none; }
.layout-entity-placeholder { position:absolute; display:flex; align-items:center; box-sizing:border-box; min-width:2.2rem; padding:.08rem .22rem; color:var(--entity-color); background:var(--entity-bg); border:1px solid var(--entity-border); border-radius:.25rem; font:600 clamp(6px, .62vw, 10px)/1.1 var(--font-mono); letter-spacing:-.02em; white-space:nowrap; overflow:visible; text-overflow:clip; pointer-events:auto; cursor:pointer; z-index:2; box-shadow:var(--layout-placeholder-shadow); }
.layout-original-tooltip { position:absolute; z-index:4; max-width:min(24rem, 90%); padding:.3rem .5rem; border:var(--border-width) solid var(--color-border-strong); border-radius:.35rem; background:var(--color-surface); color:var(--color-text); box-shadow:var(--layout-page-shadow); font:500 var(--text-xs)/1.35 var(--font-sans); white-space:normal; overflow-wrap:anywhere; pointer-events:none; }
.layout-entity-placeholder:hover { outline:2px solid var(--entity-person-border); outline-offset:1px; }
.layout-entity-placeholder.is-selected { outline:3px solid var(--entity-person-border); outline-offset:1px; }
.layout-drag-select { position:absolute; border:2px solid var(--color-focus); background:var(--layout-selection-bg); pointer-events:none; z-index:2; }
.page-layout-panel .result-warning { margin:.5rem 1rem 0; }
.doc-panel {
  scroll-margin-top: var(--drawer-top);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  overflow: hidden;
}
.doc-panel .pane-heading {
  min-height: var(--pane-heading-height);
  padding: var(--space-3) var(--space-4) 0;
  flex-wrap: wrap;
}
.pane-caption {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.doc-panel > .pane-caption {
  min-height: var(--pane-caption-height);
  padding: var(--space-2) var(--space-4) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}
.manual-redaction-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.manual-redaction-tools > span { flex: 1 1 12rem; }
.manual-redaction-tools select { min-width: 9rem; }
.manual-redaction-tools button { min-height: var(--control-compact); padding-block: var(--space-1); font-size: var(--text-xs); }
.document-text, textarea.document-text {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  resize: none;
  padding: var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-document);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.document-text:focus-visible {
  outline-offset: calc(-1 * var(--focus-width));
}
.view-tabs {
  display: flex;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  padding: var(--space-1);
  gap: var(--space-1);
}
.view-tabs button {
  min-height: var(--control-compact);
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--radius-control);
  background: var(--color-clear);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-xs);
}
.view-tabs button[aria-selected="true"] {
  background: var(--color-surface-hover);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}
.result-warning {
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-bottom: var(--border-width) solid var(--color-warning-border);
  font-size: var(--text-xs);
  padding: var(--space-3) var(--space-4);
  max-height: 10em;
  overflow: auto;
}
.diff-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-bottom: var(--border-width) solid var(--color-border);
}
.diff-legend s {
  color: var(--color-sensitive-text);
}
.diff-legend u {
  color: var(--color-redacted-text);
}
.source-entity, .diff-delete {
  color: var(--color-sensitive-text);
  background: var(--color-sensitive-bg);
}
.entity-pill, .diff-insert {
  color: var(--color-redacted-text);
  background: var(--color-redacted-bg);
}
.entity-pill {
  display: inline;
  border: var(--border-width) solid var(--color-redacted-border);
  border-radius: var(--radius-control);
  padding-inline: var(--space-1);
  font: inherit;
  white-space: normal;
  overflow-wrap: anywhere;
  position: relative;
}
.entity-type-person { --entity-color: var(--entity-person-text); --entity-bg: var(--entity-person-bg); --entity-border: var(--entity-person-border); }
.entity-type-organization, .entity-type-location, .entity-type-address { --entity-color: var(--entity-place-text); --entity-bg: var(--entity-place-bg); --entity-border: var(--entity-place-border); }
.entity-type-date, .entity-type-time, .entity-type-duration, .entity-type-age { --entity-color: var(--entity-temporal-text); --entity-bg: var(--entity-temporal-bg); --entity-border: var(--entity-temporal-border); }
.entity-type-medical_condition, .entity-type-medication, .entity-type-clinical_test, .entity-type-medical_procedure,
.entity-type-vital_sign, .entity-type-clinical_finding, .entity-type-symptom, .entity-type-diagnosis,
.entity-type-lab_result, .entity-type-family_history, .entity-type-negated_condition { --entity-color: var(--entity-health-text); --entity-bg: var(--entity-health-bg); --entity-border: var(--entity-health-border); }
.entity-type-substance_use { --entity-color: var(--entity-person-text); --entity-bg: var(--entity-person-bg); --entity-border: var(--entity-person-border); }
.entity-type-medical_record_number, .entity-type-email, .entity-type-phone, .entity-type-ssn { --entity-color: var(--entity-identifier-text); --entity-bg: var(--entity-identifier-bg); --entity-border: var(--entity-identifier-border); }
.entity-type-person, .entity-type-organization, .entity-type-location, .entity-type-address,
.entity-type-date, .entity-type-time, .entity-type-duration, .entity-type-age, .entity-type-medical_condition,
.entity-type-medication, .entity-type-clinical_test, .entity-type-medical_procedure, .entity-type-medical_record_number,
.entity-type-email, .entity-type-phone, .entity-type-ssn, .entity-type-vital_sign,
.entity-type-clinical_finding, .entity-type-symptom, .entity-type-diagnosis, .entity-type-lab_result,
.entity-type-family_history, .entity-type-substance_use, .entity-type-negated_condition {
  color: var(--entity-color);
  background: var(--entity-bg);
  border-color: var(--entity-border);
}
.entity-pill[data-original] { cursor: help; }
.layout-entity-placeholder.entity-pill {
  position: absolute;
  display: flex;
  align-items: center;
  padding: .08rem .22rem;
  font: 600 clamp(6px, .62vw, 10px)/1.1 var(--font-mono);
  white-space: nowrap;
  overflow: visible;
  overflow-wrap: normal;
  z-index: 2;
}
.layout-redaction-cover {
  position: absolute;
  box-sizing: border-box;
  background: var(--surface);
  z-index: 1;
  pointer-events: none;
}
.layout-mask-svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.layout-entity-placeholder.layout-hit-target {
  z-index: 3;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  opacity: 0;
  overflow: hidden;
  pointer-events: auto;
}
.layout-entity-placeholder.layout-hit-target:hover { outline: 0; }
.layout-entity-placeholder.layout-hit-target:focus-visible {
  opacity: .16;
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}
.layout-entity-continuation {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 1.2rem;
  padding: 0 .2rem;
  color: var(--entity-color);
  background: var(--entity-bg);
  border: 1px solid var(--entity-border);
  border-radius: .25rem;
  font: 700 8px/1 var(--font-mono);
  pointer-events: auto;
  cursor: pointer;
  z-index: 2;
}
.entity-pill[data-original]:hover::after, .entity-pill[data-original]:focus-visible::after {
  content: attr(data-original);
  position: absolute;
  z-index: 5;
  left: 0;
  bottom: calc(100% + .4rem);
  min-width: 12rem;
  max-width: 24rem;
  padding: .45rem .6rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-action);
  color: var(--color-on-action);
  font: 0.75rem/1.3 var(--font-sans);
  white-space: normal;
  pointer-events: none;
}
.source-entity {
  border-bottom: var(--border-width) solid var(--color-sensitive-border);
}
.diff-delete {
  text-decoration: line-through;
}
.diff-insert {
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}
.document-text .record-selected {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--border-width);
  background: var(--color-selection-bg);
  color: var(--color-text);
}
.inspector-intro {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.inspector select {
  width: 100%;
  flex-shrink: 0;
}
.audit-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-1);
  margin-inline: calc(-1 * var(--space-1));
}
.audit-empty {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding-block: var(--space-4);
}
.audit-record {
  display: block;
  width: 100%;
  margin-bottom: var(--space-2);
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.audit-record-card { margin-bottom: var(--space-2); }
.audit-record-card .audit-record { margin-bottom: 0; border-end-start-radius: 0; border-end-end-radius: 0; }
.restore-redaction {
  width: 100%;
  min-height: 2rem;
  padding: var(--space-1) var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-top: 0;
  border-radius: 0 0 var(--radius-control) var(--radius-control);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-xs);
  text-align: left;
  cursor: pointer;
}
.restore-redaction:hover:not(:disabled) { color: var(--color-text); background: var(--color-surface-hover); }
.restore-redaction:disabled { opacity: .55; cursor: not-allowed; }
.audit-record:hover {
  background: var(--color-surface-muted);
}
.audit-record[aria-pressed="true"] {
  border-color: var(--color-focus);
  background: var(--color-selection-bg);
}
.record-type {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: var(--weight-semibold);
}
.record-values {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  margin-block: var(--space-2);
  font-size: var(--text-sm);
}
.record-original {
  color: var(--color-sensitive-text);
}
.record-arrow {
  color: var(--color-text-muted);
}
.record-reason, .record-location {
  display: block;
  font-size: var(--text-xs);
}
.record-reason {
  color: var(--color-text-muted);
}
.record-location {
  margin-top: var(--space-2);
}
.inspector-footer {
  border-top: var(--border-width) solid var(--color-border);
  padding-top: var(--space-3);
}
.similarity-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  margin-bottom: var(--space-1);
}
.similarity-row output {
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
}
.export-records-label {
  font-size: var(--text-sm);
  margin-top: var(--space-3);
}
.export-records-label span {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.audit-export-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.audit-export-actions button {
  flex: 1;
}
.export-control {
  position: relative;
}
.export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-2));
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: var(--menu-width);
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
  z-index: var(--layer-popover);
}
.export-menu-note {
  margin: 0;
  max-width: 28rem;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.export-feedback {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.export-feedback.is-error {
  border-color: var(--color-warning-border);
}
.export-ready-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-compact);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-control);
  background: var(--color-action);
  color: var(--color-on-action);
  font-weight: 650;
  text-decoration: none;
}
.export-ready-link:hover { filter: brightness(1.08); }
.workspace-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
  border: var(--border-width) dashed var(--color-border-strong);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  text-align: center;
  overflow: auto;
}
.workspace-empty h2 {
  font-size: var(--text-xl);
}
.workspace-empty > p {
  max-width: var(--hero-text-width);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.empty-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-9);
  height: var(--space-9);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  font-size: var(--text-xl);
}
.import-guide {
  width: 100%;
  max-width: var(--modal-width);
}
.drop-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border: var(--border-width) dashed var(--color-border-strong);
  border-radius: var(--radius-panel);
  background: var(--color-surface-muted);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: var(--space-3);
}
.drop-zone:focus-within, .drop-zone.drag-over {
  outline: var(--focus-width) solid var(--color-focus);
  background: var(--color-selection-bg);
}
.drop-title {
  font-size: var(--text-sm);
  color: var(--color-text);
}
/* Folder import and Sanitize all (project.js). */
.import-guide-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.doc-item-status {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: var(--space-2);
  padding: 1px var(--space-2);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.doc-item-status.is-running {
  border-color: var(--color-focus);
  color: var(--color-focus);
}
.doc-item-status.is-done {
  border-color: var(--color-safe-border);
  background: var(--color-safe-bg);
  color: var(--color-safe-text);
}
.doc-item-status.is-review,
.doc-item-status.is-skipped {
  border-color: var(--color-warning-border);
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
}
.doc-item-status.is-failed {
  border-color: var(--color-sensitive-border);
  background: var(--color-sensitive-bg);
  color: var(--color-sensitive-text);
}
.batch-report {
  position: relative;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-3);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}
.batch-report-title {
  margin-bottom: var(--space-2);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}
.batch-report ul {
  display: grid;
  gap: var(--space-1);
  max-height: 220px;
  margin: 0;
  padding-left: var(--space-4);
  overflow-y: auto;
}
.batch-report-close {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
}
.panel-scrim {
  position: fixed;
  inset: var(--drawer-top) 0 0;
  border: none;
  background: var(--color-overlay);
  z-index: var(--layer-nav);
}
.has-panel-overlay {
  overflow: hidden;
}

/* Project workspace: one quiet canvas, one action rail, and aligned work panes. */
body.workspace-page {
  background: var(--color-bg);
}
.workspace-main {
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) var(--space-6);
}
.run-activity {
  flex: 0 0 auto;
  min-width: 0;
  overflow: hidden;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  transition: max-height .3s cubic-bezier(.22,1,.36,1), min-height .3s cubic-bezier(.22,1,.36,1),
    opacity .3s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.22,1,.36,1),
    margin .3s cubic-bezier(.22,1,.36,1), padding .3s cubic-bezier(.22,1,.36,1),
    border-width .3s cubic-bezier(.22,1,.36,1);
}
.run-activity:has(#sanitizeProgress:not(.hidden)) {
  padding: var(--space-3) var(--space-4);
}
.run-activity:not(:has(#sanitizeProgress:not(.hidden))) { display: none; }
.run-activity:has(#sanitizeProgress:not(.hidden)) .sanitize-progress {
  padding: 0 0 var(--space-2);
}
.run-activity .sanitize-progress {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
/* The :has() padding rule above outranks a plain class pair, so Focus view
   names it too; otherwise 24px of padding survives the collapse. */
.workspace-focus-mode .run-activity,
.workspace-focus-mode .run-activity:has(#sanitizeProgress:not(.hidden)) {
  max-height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border-width: 0;
  opacity: 0;
  transform: translateY(-.65rem);
  pointer-events: none;
}
.workspace-header {
  min-height: 3.25rem;
  gap: var(--space-4);
  flex-wrap: nowrap;
  padding-inline: var(--space-1);
}
.workspace-heading {
  display: grid;
  gap: var(--space-1);
}
.workspace-back {
  width: fit-content;
  font-weight: var(--weight-medium);
  letter-spacing: .01em;
}
.workspace-heading .app-title {
  margin: 0;
  line-height: var(--line-tight);
}
.workspace-header .project-header-actions {
  flex-wrap: nowrap;
}
.workspace-header .project-header-actions .btn-secondary {
  min-height: 2.25rem;
  padding-block: var(--space-1);
  font-size: var(--text-xs);
}
.workspace-toolbar {
  gap: var(--space-3);
  padding: var(--space-2);
  border-color: var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}
.toolbar-context,
.toolbar-actions {
  gap: var(--space-2);
}
.toolbar-context {
  flex-wrap: nowrap;
  min-width: 0;
}
.panel-toggles {
  flex: 0 0 auto;
  padding: 3px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
}
.panel-toggles button {
  min-height: 2rem;
  border-color: transparent;
  background: transparent;
  font-size: var(--text-xs);
}
.panel-toggles button[aria-expanded="true"] {
  border-color: var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}
.rule-context {
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border-left: var(--border-width) solid var(--color-border);
  color: var(--color-text);
  font-size: var(--text-xs);
}
.rule-context #currentRule {
  font-weight: var(--weight-semibold);
}
.save-status {
  overflow: hidden;
  max-width: 13rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toolbar-actions > .btn-secondary,
.toolbar-actions > .btn-primary,
.toolbar-actions .focus-workspace-btn,
.toolbar-actions .export-control > button {
  min-height: 2.25rem;
  padding-block: var(--space-1);
  font-size: var(--text-xs);
}
.workspace-status {
  min-height: 1rem;
  margin: 0;
  padding-inline: var(--space-1);
  font-size: var(--text-xs);
}
.sanitize-progress {
  flex-shrink: 0;
  margin-bottom: 0;
  border-color: var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}
.sanitize-progress {
  padding: var(--space-3) var(--space-4);
}
.workspace-shell {
  gap: var(--space-3);
}
.doc-list,
.inspector {
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}
.doc-list {
  flex-basis: 12.25rem;
  width: 12.25rem;
  padding: var(--space-3);
}
.inspector {
  flex-basis: 17rem;
  width: 17rem;
  padding: var(--space-3);
  gap: var(--space-2);
  /* The workspace never scrolls as a page, so when a short window cannot fit
     the record list and the export footer, the panel scrolls instead of
     clipping the footer. */
  overflow-y: auto;
}
.inspector .audit-list {
  /* Keep a few records visible rather than letting the footer squeeze the
     list to nothing. */
  min-height: 9rem;
}
.pane-heading {
  min-height: 2.75rem;
  gap: var(--space-2);
}
.pane-heading h2 {
  letter-spacing: -.01em;
}
.doc-subtitle {
  padding: var(--space-2) var(--space-1) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
  line-height: var(--line-body);
}
.doc-item {
  border-color: transparent;
  background: transparent;
}
.doc-item.active {
  border-color: var(--color-focus);
}
.doc-panels {
  gap: var(--space-3);
}
.doc-panel {
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-panel);
}
.doc-panel .pane-heading {
  min-height: 3rem;
  padding: var(--space-2) var(--space-4);
}
.doc-panel > .pane-caption {
  min-height: 2.5rem;
  padding: var(--space-1) var(--space-4) var(--space-3);
  line-height: var(--line-body);
}
.document-text,
textarea.document-text {
  padding: var(--space-4) var(--space-5);
  line-height: 1.68;
}
.original-panel textarea.document-text {
  background: var(--color-surface);
}
.result-panel .doc-output {
  background: var(--color-surface);
}
.view-tabs {
  gap: 2px;
  padding: 2px;
  background: var(--color-surface-muted);
}
.view-tabs button {
  min-height: 1.8rem;
  padding-inline: var(--space-3);
}
.view-tabs button[aria-selected="true"] {
  box-shadow: var(--shadow-panel);
}
.inspector-intro {
  line-height: var(--line-body);
}
.inspector select {
  min-height: 2.25rem;
  font-size: var(--text-xs);
}
.audit-record {
  border-radius: var(--radius-control);
}
.inspector-footer {
  padding-top: var(--space-3);
}

@media (max-width: 1200px) {
  .toolbar-context {
    flex-wrap: wrap;
  }
  .rule-context {
    border-left: 0;
    padding-left: var(--space-1);
  }
}


@media (max-width: 1100px) {
  .inspector {
    position: fixed;
    top: var(--drawer-top);
    bottom: var(--space-4);
    right: var(--space-4);
    width: var(--inspector-width);
    max-width: calc(100vw - var(--space-7));
    z-index: var(--layer-popover);
    box-shadow: var(--shadow-popover);
  }
}
@media (max-width: 900px) {
  .workspace-header {
    flex-wrap: wrap;
  }
  .workspace-header .project-header-actions {
    flex-wrap: wrap;
  }
  .workspace-main {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .workspace-shell {
    min-height: var(--workspace-min-height);
  }
  .doc-list {
    position: fixed;
    top: var(--drawer-top);
    bottom: var(--space-4);
    left: var(--space-4);
    width: var(--inspector-width);
    max-width: calc(100vw - var(--space-7));
    z-index: var(--layer-popover);
    box-shadow: var(--shadow-popover);
  }
  .document-text, textarea.document-text {
    min-height: var(--document-input-height);
    height: 60dvh;
    max-height: 60dvh;
    flex: none;
  }
}
@media (max-width: 600px) {
  .workspace-main {
    padding: var(--space-4);
  }
  .account-id-card {
    align-items: stretch;
    flex-direction: column;
  }
  .account-profile-row {
    align-items: stretch;
    flex-direction: column;
  }
  .workspace-header .project-header-actions {
    width: 100%;
  }
  .workspace-header .project-header-actions .btn-secondary {
    min-height: var(--control-height);
    font-size: var(--text-sm);
  }
  .workspace-header .project-header-actions button {
    flex: 1;
  }
  .workspace-toolbar {
    padding: var(--space-2);
    gap: var(--space-2);
  }
  .toolbar-context {
    gap: var(--space-2);
  }
  .toolbar-context,
  .rule-context {
    width: 100%;
  }
  .panel-toggles {
    flex: 1 1 100%;
  }
  .panel-toggles button {
    flex: 1;
  }
  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1);
    width: 100%;
  }
  .toolbar-actions button {
    padding-inline: var(--space-2);
  }
  .export-control > button {
    width: 100%;
  }
  .doc-panels {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace-empty {
    padding: var(--space-4);
  }
}

/* Settings and switches */
.settings-container {
  max-width: var(--modal-width);
  width: 100%;
}
.settings-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.settings-input-row input {
  flex: 1 1 140px;
  width: 100%;
}
.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: var(--border-width) solid var(--color-border);
}
.setting-row:last-child {
  border-bottom: none;
}
#customPanel {
  margin-top: var(--space-3);
}
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-6);
  margin-bottom: var(--space-5);
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  background: var(--color-surface-muted);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
}
.switch {
  position: relative;
  display: inline-block;
  flex: 0 0 var(--switch-width);
  width: var(--switch-width);
  height: var(--control-height);
}
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.slider {
  position: absolute;
  left: 0;
  right: 0;
  top: calc((var(--control-height) - var(--switch-height)) / 2);
  height: var(--switch-height);
  border-radius: var(--radius-modal);
  background: var(--color-border-strong);
  pointer-events: none;
  transition: background-color var(--duration-fast);
}
.slider::before {
  content: '';
  position: absolute;
  width: var(--switch-thumb);
  height: var(--switch-thumb);
  left: var(--switch-inset);
  top: var(--switch-inset);
  border-radius: var(--radius-round);
  background: var(--color-surface);
  transition: transform var(--duration-fast);
}
.switch input:checked + .slider {
  background: var(--color-action);
}
.switch input:checked + .slider::before {
  transform: translateX(var(--switch-travel));
  background: var(--color-on-action);
}
.switch input:focus-visible + .slider {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

/* Sign in uses the same components as the application. */
.auth-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: var(--space-5);
}
.auth-container {
  width: 100%;
  max-width: var(--modal-width);
}
.auth-card {
  padding: var(--space-7);
}
.auth-logo {
  text-align: center;
  font-size: var(--text-lg);
  margin-bottom: var(--space-5);
}
.auth-title {
  text-align: center;
  font-size: var(--text-xl);
}
.auth-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: var(--space-2) 0 var(--space-6);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.auth-divider {
  text-align: center;
  color: var(--color-text-muted);
  margin-block: var(--space-5);
  font-size: var(--text-sm);
}
.auth-provider {
  margin-bottom: var(--space-2);
}
.auth-footer {
  margin-top: var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.auth-footer a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

/* Responsive foundation. Keep existing page order, make every child shrinkable. */
@media (max-width: 960px) {
  .app-body {
    flex-direction: column;
  }
  .sidebar {
    flex: none;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-right: none;
    border-bottom: var(--border-width) solid var(--color-border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
  }
  .sidebar-home {
    margin-top: 0;
  }
  .app-main {
    padding: var(--space-5);
  }
  .project-grid, .usage-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 600px) {
  .app-main {
    padding: var(--space-4);
  }
  .app-section {
    padding: var(--space-4);
  }
  .app-title {
    font-size: var(--text-xl);
  }
  .toggle-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth-card {
    padding: var(--space-6);
  }
  .modal-content {
    padding: var(--space-5);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Theme change: a soft-edged light sweeps out of the control that was pressed,
 * carrying the new theme with it. The old paint stays put underneath, so the
 * page is never blank and nothing reflows. The sweep is driven from
 * common.js (WAAPI on the pseudo-element); --theme-progress starts at 1 so a
 * browser that cannot animate it simply shows the new theme at once instead of
 * hiding it. Browsers without view transitions fall back to the cross-fade
 * below, and reduced-motion users get an instant swap via the block above. */
@property --theme-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}
@media (prefers-reduced-motion: no-preference) {
  /* Replace the default cross-fade: the outgoing paint holds still while the
   * incoming one is unmasked over it. */
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
  }
  ::view-transition-old(root) { z-index: 0; }
  ::view-transition-new(root) { z-index: 1; }

  /* A feathered edge rather than a hard circle: the two themes meet in a band
   * of light instead of a cut line. */
  :root[data-theme-anim="sweep"]::view-transition-new(root) {
    mask-image: radial-gradient(circle at var(--theme-origin-x) var(--theme-origin-y),
      var(--theme-mask-opaque) 0,
      var(--theme-mask-opaque) max(0px, calc(var(--theme-reach) * var(--theme-progress)
        - var(--theme-reach) * var(--theme-feather))),
      var(--theme-mask-clear) calc(var(--theme-reach) * var(--theme-progress)));
    mask-repeat: no-repeat;
  }

  /* No view transitions: ease the colour tokens across instead of cutting. */
  :root[data-theme-fade] *,
  :root[data-theme-fade] *::before,
  :root[data-theme-fade] *::after {
    transition: background-color 420ms var(--ease-theme),
      background-image 420ms var(--ease-theme),
      border-color 420ms var(--ease-theme),
      color 420ms var(--ease-theme),
      fill 420ms var(--ease-theme),
      stroke 420ms var(--ease-theme),
      box-shadow 420ms var(--ease-theme) !important;
  }
}

/* Theme switch: one control, used in the marketing nav and in settings. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}
.theme-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: var(--control-compact);
  min-height: var(--control-compact);
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--color-clear);
  border-radius: var(--radius-pill);
  background: var(--color-clear);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard),
  color var(--duration-fast) var(--ease-standard);
}
.theme-option:hover {
  color: var(--color-text);
}
.theme-option[aria-pressed="true"] {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.theme-switch-labelled .theme-option {
  padding: 0 var(--space-3);
}
.theme-option svg {
  transition: transform 420ms var(--ease-theme);
}
.theme-option:active svg {
  transform: scale(0.86);
}
.theme-option[aria-pressed="true"] svg {
  transform: scale(1.08);
}


/* ==========================================================================
   Workspace · Assurance desk
   The verdict leads, navigation folds into an icon rail, menus group related
   actions, and replacement notes sit beside the lines they changed.
   ========================================================================== */
:root {
  --assure: #0f766e;
  --assure-bg: #e6f4f1;
  --assure-border: #8cc7bd;
  --assure-busy: #3a4cc4;
  --assure-on: #ffffff;
  --check-on: #ffffff;
  --shadow-rail: 12px 0 32px -18px rgb(15 23 42 / 35%);
  --shadow-menu: 0 18px 40px -16px rgb(15 23 42 / 35%);
  --shadow-segment: 0 1px 2px rgb(15 23 42 / 14%);
  --shadow-note: 0 1px 1px rgb(15 23 42 / 5%);
  /* Sidebar padding (16) + link padding (12) on both sides + an 18px icon. */
}
:root[data-theme="dark"] {
  --assure: #5ccfbf;
  --assure-bg: rgb(92 207 191 / 12%);
  --assure-border: rgb(92 207 191 / 38%);
  --assure-busy: #8b98ff;
  --assure-on: #04201c;
  --shadow-rail: 12px 0 32px -18px rgb(0 0 0 / 60%);
  --shadow-menu: 0 18px 40px -16px rgb(0 0 0 / 60%);
  --shadow-segment: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-note: 0 1px 1px rgb(0 0 0 / 30%);
}

.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon { width: 15px; height: 15px; flex: 0 0 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.workspace-page .project-header-actions .btn-secondary { display: inline-flex; align-items: center; gap: var(--space-2); }
.workspace-page .btn-secondary.icon-only { padding-inline: var(--space-2); min-width: 2.25rem; justify-content: center; }

/* Menus share one look: a floating card of grouped actions. */
.menu-control { position: relative; display: inline-flex; }
.action-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 14rem;
  display: grid; gap: 2px; padding: var(--space-2);
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-modal);
  background: var(--color-surface); box-shadow: var(--shadow-menu);
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  width: 100%; min-height: 2.1rem; padding: var(--space-1) var(--space-3);
  border: 0; border-radius: var(--radius-control); background: transparent;
  color: var(--color-text); font-size: var(--text-sm); text-align: left; cursor: pointer;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--color-surface-muted); }
.menu-item:disabled { opacity: .5; cursor: default; }
.menu-item.danger-btn { color: var(--color-sensitive-text); }
.menu-note, .help-menu p { margin: 0; padding: var(--space-1) var(--space-3); color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.5; }
.help-menu { width: 18rem; }
.help-menu .workspace-scroll-help { display: block; margin: 0; }

/* Verdict bar (keeps .workspace-toolbar for focus gestures and drawers). */
.workspace-page .workspace-toolbar.verdict {
  --tone: var(--color-text-muted);
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  overflow: visible;
  border: var(--border-width) solid var(--color-border);
  background: var(--color-surface);
}
.verdict::before { content: ''; position: absolute; inset: -1px auto -1px -1px; width: 3px; border-radius: var(--radius-panel) 0 0 var(--radius-panel); background: var(--tone); transition: background .3s; }
.verdict[data-state="ok"] { --tone: var(--assure); }
.verdict[data-state="busy"] { --tone: var(--assure-busy); }
.verdict[data-state="warn"] { --tone: var(--color-warning-text); }
.verdict[data-state="empty"], .verdict[data-state="idle"] { --tone: var(--color-border-strong); }
.verdict-seal { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 10px; color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, var(--color-surface)); transition: color .3s, background .3s; }
.verdict-seal svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: none; }
.verdict[data-state="ok"] .seal-done, .verdict[data-state="warn"] .seal-warn,
.verdict:not([data-state="ok"]):not([data-state="warn"]) .seal-wait { display: block; }
.verdict[data-state="busy"] .seal-wait { animation: verdict-pulse 1.2s ease-in-out infinite; }
@keyframes verdict-pulse { 50% { opacity: .45; } }
.workspace-page .verdict-body { display: grid; gap: 3px; min-width: 0; flex-wrap: initial; }
.verdict-title { margin: 0; font-size: var(--text-base); font-weight: var(--weight-semibold); line-height: 1.3; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.verdict-meta { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--color-text-muted); font-size: var(--text-xs); }
.verdict-document { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22rem; }
.workspace-page .verdict .rule-context { min-height: 0; padding: 0 0 0 var(--space-2); border-left: var(--border-width) solid var(--color-border); gap: var(--space-1); }
.workspace-page .verdict .save-status { padding: 1px var(--space-2); font-size: var(--text-eyebrow); }
.verdict-checks { display: flex; flex-wrap: wrap; gap: var(--space-1) 6px; margin: var(--space-1) 0 0; padding: 0; list-style: none; }
.verdict-check {
  --check: var(--color-text-muted);
  display: inline-flex; align-items: center; gap: 6px; min-height: 1.6rem; padding: 2px var(--space-2) 2px 6px;
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-control);
  background: var(--color-surface-muted); color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.verdict-check .check-value { color: var(--color-text); font-weight: var(--weight-semibold); }
.check-mark { position: relative; width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--color-border-strong); flex: none; }
.verdict-check[data-tone="pass"] .check-mark { border: 0; background: var(--assure); }
.verdict-check[data-tone="pass"] .check-mark::after { content: ''; position: absolute; left: 4.5px; top: 2px; width: 3px; height: 6px; border: solid var(--check-on); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.verdict-check[data-tone="warn"] { border-color: var(--color-warning-border); background: var(--color-warning-bg); }
.verdict-check[data-tone="warn"] .check-mark { border: 0; background: var(--color-warning-text); }
.verdict-check[data-tone="warn"] .check-mark::after { content: '!'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--check-on); font-size: 9px; font-weight: 800; line-height: 1; }
.verdict-check[data-tone="off"] .check-mark { border: 0; background: var(--color-border-strong); }
.verdict-check[data-tone="off"] .check-mark::after { content: ''; position: absolute; left: 3.5px; right: 3.5px; top: 6px; height: 1.5px; background: var(--check-on); }
.verdict-check[data-tone="info"] .check-mark { border-color: var(--color-text-muted); border-style: dotted; }
.verdict-check .similarity-label { display: inline-flex; align-items: center; gap: var(--space-1); }
.verdict-check .metric-help { width: 1rem; height: 1rem; font-size: 10px; }
.workspace-page .verdict-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; }
.toolbar-divider { width: 1px; align-self: stretch; margin: 2px var(--space-1); background: var(--color-border); }
.sanitize-split { align-items: stretch; }
.sanitize-split > #sanitizeBtn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.sanitize-split > .split-caret { min-width: 2rem; padding-inline: var(--space-2); border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid color-mix(in srgb, var(--color-on-action) 28%, var(--color-action)); }
.sanitize-split.batch-active .action-menu { position: static; display: flex; min-width: 0; margin-left: var(--space-2); padding: 0; border: 0; box-shadow: none; background: transparent; }
.sanitize-split.batch-active .menu-note { display: none; }
.sanitize-split.batch-active #sanitizeAllBtn { border: var(--border-width) solid var(--color-warning-border); background: var(--color-warning-bg); color: var(--color-warning-text); font-weight: var(--weight-semibold); }
.verdict[data-state="ok"] #exportMenuBtn:not(:disabled) { border-color: var(--assure); background: var(--assure); color: var(--assure-on); }
.workspace-page .verdict .panel-toggles button { min-height: 2rem; }

/* Export menu: grouped by what is safe to share. */
.workspace-page .export-menu { width: 19rem; gap: 4px; }
.export-group-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin: var(--space-2) 0 2px; padding-top: var(--space-2); border-top: var(--border-width) solid var(--color-border); }
.export-group-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.export-group-title .eyebrow { margin: 0; }
.tag-safe, .tag-sensitive { padding: 1px 7px; border-radius: var(--radius-pill); font-size: var(--text-eyebrow); font-weight: var(--weight-semibold); white-space: nowrap; }
.tag-safe { background: var(--assure-bg); color: var(--assure); }
.tag-sensitive { background: var(--color-sensitive-bg); color: var(--color-sensitive-text); }
.workspace-page .export-menu .audit-export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.menu-hint { margin-left: auto; color: var(--color-text-muted); font-size: var(--text-eyebrow); font-weight: var(--weight-regular); }
#exportReport { display: flex; align-items: center; gap: var(--space-2); }

/* The status line reads as a quiet caption under the verdict. */
.workspace-page .workspace-status { padding-inline: var(--space-4); color: var(--color-text-muted); }
.workspace-page .workspace-status.is-warning { color: var(--color-warning-text); }

/* Viewer bar: one switch for Page, Text and Diff, then category chips. */
.viewer-bar { display: flex; align-items: center; gap: var(--space-3); min-height: 2.5rem; padding: 0 var(--space-1) var(--space-2); flex-wrap: wrap; }
.workspace-page .viewer-bar .view-tabs { display: inline-flex; gap: 2px; padding: 3px; border: 0; border-radius: var(--radius-control); background: var(--color-surface-muted); }
.workspace-page .viewer-bar .view-tabs button { min-height: 1.9rem; padding: 0 var(--space-4); border: 0; border-radius: 5px; background: transparent; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.workspace-page .viewer-bar .view-tabs button[aria-selected="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-segment); }
.workspace-page .viewer-bar .view-tabs button:disabled { opacity: .45; cursor: not-allowed; }
.entity-chips { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 6px; min-width: 0; }
.entity-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 1.6rem; padding: 0 var(--space-2); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-xs); text-transform: capitalize; cursor: pointer; }
.entity-chip::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--entity-border, var(--color-text-muted)); }
.entity-chip[data-filter="ALL"]::before { display: none; }
.entity-chip-count { color: var(--color-text); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.entity-chip[aria-pressed="true"] { border-color: var(--color-text); background: var(--color-text); color: var(--color-surface); }
.entity-chip[aria-pressed="true"] .entity-chip-count { color: inherit; }
.records-layout { display: inline-flex; gap: 2px; margin-left: auto; padding: 3px; border-radius: var(--radius-control); background: var(--color-surface-muted); }
.records-layout button { min-height: 1.75rem; padding: 0 var(--space-3); border: 0; border-radius: 5px; background: transparent; color: var(--color-text-muted); font-size: var(--text-xs); cursor: pointer; }
.records-layout button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-segment); }
.workspace-page .doc-workspace > .manual-redaction-tools { margin: 0 0 var(--space-2); }

/* Document stage: the active view plus the notes margin beside it. */
.doc-stage { display: flex; flex: 1; min-height: 0; gap: var(--space-3); }
.doc-stage > .doc-panels, .doc-stage > .page-layout-panel { flex: 1 1 auto; min-width: 0; }
.workspace-page .page-layout-toolbar { padding: var(--space-2) var(--space-3); }
.workspace-page .page-layout-toolbar > p { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); }

.record-notes { flex: 0 0 19rem; width: 19rem; min-height: 0; display: flex; flex-direction: column; border: var(--border-width) solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-panel); overflow: hidden; }
.record-notes-head { display: flex; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: var(--border-width) solid var(--color-border); color: var(--color-text-muted); font-size: var(--text-eyebrow); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; }
.record-notes-hint { color: var(--color-text-muted); font-weight: var(--weight-medium); white-space: nowrap; }
.record-notes-unplaced { display: flex; flex-wrap: wrap; gap: 2px 10px; max-height: 7rem; overflow: auto; padding: var(--space-2) var(--space-3); border-bottom: var(--border-width) solid var(--color-border); background: var(--color-warning-bg); }
.record-notes-subhead { flex-basis: 100%; margin: 0; color: var(--color-warning-text); font-size: var(--text-eyebrow); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow); }
.record-notes-track { position: relative; flex: 1; min-height: 0; overflow: hidden; overflow: clip; background: color-mix(in srgb, var(--color-surface-muted) 55%, var(--color-surface)); }
.record-notes-leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.record-notes-leaders path { fill: none; stroke: var(--color-border-strong); stroke-width: 1.2; opacity: .7; }
.record-notes-leaders path.is-traced { stroke: var(--color-text); stroke-width: 1.8; opacity: 1; }
.note-row {
  position: absolute; top: 0; left: 18px; right: 8px;
  display: flex; flex-wrap: wrap; gap: 0 10px; padding: 1px 7px;
  border-radius: 5px; background: var(--color-surface);
  box-shadow: inset 2px 0 0 var(--color-border-strong), var(--shadow-note);
  will-change: transform;
}
.note-item { display: inline-flex; align-items: baseline; gap: 5px; max-width: 100%; padding: 0; border: 0; background: none; color: var(--color-text); font-size: 11.5px; line-height: 1.6; text-align: left; cursor: pointer; border-radius: 3px; }
.note-pill { padding: 0 4px; border-radius: 3px; background: var(--entity-bg, var(--color-surface-muted)); box-shadow: inset 0 0 0 1px var(--entity-border, var(--color-border)); color: var(--entity-color, var(--color-text)); font-family: var(--font-mono); font-size: 10px; font-weight: var(--weight-semibold); white-space: nowrap; }
.note-original { color: var(--color-sensitive-text); overflow-wrap: anywhere; }
.note-item.is-traced, .note-item:focus-visible { outline: 2px solid var(--entity-border, var(--color-focus)); outline-offset: 1px; }
#docOutput .is-traced, #diffOutput .is-traced { outline: 2px solid var(--entity-border, var(--color-focus)); outline-offset: 1px; }
.layout-hit-target.is-traced { outline: 2px solid var(--color-text); outline-offset: 1px; border-radius: 2px; }
.inspector-export-hint { margin: 0; color: var(--color-text-muted); font-size: var(--text-xs); }

/* Focus view keeps the verdict line but drops its checks for more room. */
.workspace-focus-mode .verdict-checks, .workspace-focus-mode .verdict-meta { display: none; }

@media (max-width: 1280px) {
  .workspace-page .verdict .panel-toggles { display: none; }
  .record-notes { flex-basis: 16rem; width: 16rem; }
}
@media (max-width: 1100px) {
  .workspace-page .workspace-toolbar.verdict { grid-template-columns: auto minmax(0, 1fr); }
  .workspace-page .verdict-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .workspace-page .verdict .panel-toggles { display: inline-flex; }
}
@media (max-width: 600px) {
  .workspace-page .workspace-toolbar.verdict { grid-template-columns: minmax(0, 1fr); padding-left: var(--space-3); }
  .verdict-seal { display: none; }
  .verdict-title { white-space: normal; }
  .verdict-meta { flex-wrap: wrap; }
  .workspace-page .verdict-actions { grid-column: auto; }
  .toolbar-divider { display: none; }
  .records-layout { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .verdict-seal, .verdict::before { transition: none; }
  .verdict[data-state="busy"] .seal-wait { animation: none; }
}
/* Assurance desk · density and sizing refinements */
.workspace-page .verdict-actions .btn-primary,
.workspace-page .verdict-actions .btn-secondary { min-height: 2.25rem; padding-block: var(--space-1); font-size: var(--text-xs); }
.workspace-page .verdict-actions .panel-toggles button { min-height: 1.9rem; padding-inline: var(--space-3); }
.workspace-page .project-header-actions .btn-secondary { white-space: nowrap; }
.record-notes-head { text-transform: none; letter-spacing: 0; font-size: var(--text-xs); font-weight: var(--weight-medium); align-items: baseline; }
#recordNotesSummary { color: var(--color-text); font-weight: var(--weight-semibold); }
.workspace-page .export-menu > .btn-secondary,
.workspace-page .export-menu .audit-export-actions .btn-secondary {
  min-height: 2rem; padding: var(--space-1) var(--space-3); justify-content: flex-start;
  border-color: transparent; background: transparent; font-size: var(--text-sm); font-weight: var(--weight-regular); text-align: left;
}
.workspace-page .export-menu > .btn-secondary:hover:not(:disabled),
.workspace-page .export-menu .audit-export-actions .btn-secondary:hover:not(:disabled) { background: var(--color-surface-muted); }
.workspace-page .export-menu .audit-export-actions { gap: 2px; }
.workspace-page .export-menu .export-menu-note { margin: 0; padding: 0 var(--space-3) var(--space-1); }
@media (max-width: 600px) {
  .workspace-page .workspace-toolbar.verdict { gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .verdict-title { font-size: var(--text-sm); }
  .verdict-meta { flex-wrap: wrap; row-gap: 2px; }
  .workspace-page .verdict .rule-context { border-left: 0; padding-left: 0; }
  .verdict-checks { gap: 4px; margin-top: 2px; }
  .verdict-check { min-height: 1.4rem; padding-block: 0; }
  .workspace-page .verdict-actions { gap: 6px; }
  .workspace-page .verdict .panel-toggles { order: 0; }
  .workspace-page .verdict-actions .btn-primary,
  .workspace-page .verdict-actions .btn-secondary { min-height: 2rem; }
}
@media (max-width: 900px) {
  .workspace-page .verdict .panel-toggles { flex: 0 0 auto; width: auto; }
  .workspace-page .verdict .panel-toggles button { flex: 0 0 auto; }
  .verdict-meta > * { flex: 0 1 auto; width: auto; }
}
.workspace-crumbs { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.workspace-badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px var(--space-2); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-text-muted); font-size: var(--text-eyebrow); font-weight: var(--weight-semibold); white-space: nowrap; }
.workspace-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--assure); }
.workspace-badge.is-shared { border-color: var(--color-warning-border); background: var(--color-warning-bg); color: var(--color-warning-text); }
.workspace-badge.is-shared::before { background: var(--color-warning-text); }
/* Actions wrap instead of pushing past the edge when space is briefly short. */
.workspace-page .workspace-toolbar.verdict { grid-template-columns: auto minmax(16rem, 1fr) minmax(0, max-content); }
.workspace-page .verdict-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; row-gap: 6px; }
@media (max-width: 1100px) { .workspace-page .workspace-toolbar.verdict { grid-template-columns: auto minmax(0, 1fr); } .workspace-page .verdict-actions { justify-content: flex-start; } }
@media (max-width: 600px) { .workspace-page .workspace-toolbar.verdict { grid-template-columns: minmax(0, 1fr); } }
.workspace-page .page-layout-panel .result-warning { margin: var(--space-2) var(--space-3) 0; padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

/* PDF placeholder labels: the same face is embedded in exported PDFs. */
@font-face {
  font-family: 'Semred Placeholder';
  src: url('fonts/IBMPlexMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

/* Shared icon navigation and spacing across all application pages. */
.sidebar-logo, .sidebar-home { padding-inline: var(--space-3); }
.sidebar .sidebar-link { gap: var(--space-3); padding-inline: var(--space-3); white-space: nowrap; }
@media (max-width: 960px) {
  .sidebar .nav-icon { display: none; }
  .sidebar-logo, .sidebar-home { padding-inline: 0; }
}

/* ---------- Dashboard: work on the left, numbers on the right ---------- */
.dash-topbar {
  align-items: flex-end;
}
.dash-heading {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}
.dash-subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.dash-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.dash-actions .app-user {
  margin-left: var(--space-2);
}
.dash-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.dash-panel {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-6);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}
.dash-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
}
.dash-panel-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-display);
}
.dash-link {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  white-space: nowrap;
}
.dash-link:hover {
  color: var(--color-text);
}
.dash-muted {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.dash-project-list {
  display: grid;
}
.dash-project-list:empty {
  display: none;
}
.dash-project {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-inline: calc(-1 * var(--space-3));
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-control);
  color: var(--color-text);
  transition: background-color var(--duration-fast) var(--ease-standard);
}
.dash-project-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline: calc(-1 * var(--space-3));
}
.dash-project-row .dash-project {
  flex: 1;
  min-width: 0;
  margin-inline: 0;
}
.dash-project-row + .dash-project-row {
  box-shadow: 0 calc(-1 * var(--border-width)) 0 var(--color-border);
}
.dash-project-delete {
  flex: none;
  min-width: 64px;
  min-height: 44px;
  margin-right: var(--space-3);
  padding: var(--space-2);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-sensitive-text);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}
.dash-project-delete:hover { background: var(--color-surface-muted); }
.dash-project-delete:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.dash-project-delete:disabled { opacity: .6; cursor: wait; }
.dash-project:hover {
  background: var(--color-surface-muted);
}
.dash-project:focus-visible {
  outline: 2px solid var(--color-focus, var(--color-text));
  outline-offset: 2px;
}
.dash-project-info {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}
.dash-project-info strong {
  overflow: hidden;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-open {
  flex: none;
  padding: var(--space-1) var(--space-3);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.dash-project:hover .dash-open {
  background: var(--color-surface);
}
.dash-empty {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  padding: var(--space-5);
  border: var(--border-width) dashed var(--color-border-strong);
  border-radius: var(--radius-control);
}
.dash-empty h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}
.dash-empty ol {
  display: grid;
  gap: var(--space-1);
  padding-left: var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.dash-usage .usage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.dash-stat {
  display: grid;
  gap: var(--space-1);
  padding-block: var(--space-4);
}
.dash-stat:first-child {
  padding-top: 0;
}
.dash-stat:last-child {
  padding-bottom: 0;
}
.dash-stat + .dash-stat {
  border-top: var(--border-width) solid var(--color-border);
}
.dash-stat .usage-label {
  margin-bottom: 0;
}
.dash-stat .usage-period {
  margin-top: 0;
  color: var(--color-text-muted);
}
.dash-stat .usage-value {
  font-size: var(--text-xl);
  line-height: var(--line-tight, 1.2);
}
.dash-meter {
  height: 6px;
  margin-top: var(--space-2);
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--color-surface-muted);
}
.dash-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--assure);
  transition: width 700ms var(--ease-standard);
}
@media (max-width: 1080px) {
  .dash-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (prefers-reduced-motion: reduce) {
  .dash-meter span {
    transition: none;
  }
}

/* ---------- Page view: compare with original ---------- */
:root {
  --mark-person-bg: rgb(239 68 68 / 16%); --mark-person-line: rgb(220 38 38 / 70%);
  --mark-place-bg: rgb(59 130 246 / 16%); --mark-place-line: rgb(37 99 235 / 70%);
  --mark-date-bg: rgb(245 158 11 / 18%); --mark-date-line: rgb(217 119 6 / 75%);
  --mark-contact-bg: rgb(139 92 246 / 16%); --mark-contact-line: rgb(124 58 237 / 70%);
  --handle-lift: 0 1px 2px rgb(17 20 25 / 6%), 0 4px 12px -6px rgb(17 20 25 / 25%);
  --handle-lift-strong: 0 1px 2px rgb(17 20 25 / 6%), 0 8px 18px -10px rgb(17 20 25 / 30%);
}
:root[data-theme="dark"] {
  --mark-person-bg: rgb(248 113 113 / 22%); --mark-person-line: rgb(252 165 165 / 85%);
  --mark-place-bg: rgb(96 165 250 / 22%); --mark-place-line: rgb(147 197 253 / 85%);
  --mark-date-bg: rgb(251 191 36 / 22%); --mark-date-line: rgb(252 211 77 / 85%);
  --mark-contact-bg: rgb(167 139 250 / 22%); --mark-contact-line: rgb(196 181 253 / 85%);
  --handle-lift: 0 4px 14px -6px rgb(0 0 0 / 60%);
  --handle-lift-strong: 0 8px 20px -10px rgb(0 0 0 / 70%);
}
.layout-pair { display: flex; align-items: flex-start; gap: 20px; }
/* The untouched copy shares the page frame styles but not the .layout-page
   class, so code and tests that find the redacted page are unaffected. */
.layout-original-page { position: relative; display: none; margin: 0; background: var(--color-surface); box-shadow: var(--layout-page-shadow); line-height: 0; }
.layout-original-page img { display: block; max-width: none; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.layout-compare-labels { display: none; }
.page-layout-panel.is-comparing .layout-original-page { display: block; }
.page-layout-panel.is-comparing .layout-compare-labels {
  display: flex;
  gap: 20px;
  align-self: stretch;
  position: sticky;
  top: -.75rem;
  z-index: 3;
  margin-inline: -.5rem;
  padding: .35rem .5rem;
  background: var(--color-surface-muted);
}
.layout-compare-labels span {
  flex: 1;
  color: var(--color-text-muted);
  font-size: var(--text-eyebrow);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}
.layout-original-mark.layout-hit-target {
  --mark-bg: var(--mark-person-bg); --mark-line: var(--mark-person-line);
  position: absolute;
  pointer-events: auto;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: var(--mark-bg);
  box-shadow: inset 0 -1.5px 0 var(--mark-line);
  cursor: pointer;
}
.layout-original-mark.entity-type-organization,
.layout-original-mark.entity-type-location,
.layout-original-mark.entity-type-address { --mark-bg: var(--mark-place-bg); --mark-line: var(--mark-place-line); }
.layout-original-mark.entity-type-date,
.layout-original-mark.entity-type-time,
.layout-original-mark.entity-type-duration,
.layout-original-mark.entity-type-age { --mark-bg: var(--mark-date-bg); --mark-line: var(--mark-date-line); }
.layout-original-mark.entity-type-email,
.layout-original-mark.entity-type-phone,
.layout-original-mark.entity-type-url,
.layout-original-mark.entity-type-ssn,
.layout-original-mark.entity-type-ip_address,
.layout-original-mark.entity-type-zipcode,
.layout-original-mark.entity-type-credit_card,
.layout-original-mark.entity-type-medical_record_number { --mark-bg: var(--mark-contact-bg); --mark-line: var(--mark-contact-line); }
.layout-original-mark.layout-hit-target:hover,
.layout-original-mark.is-traced { outline: 2px solid var(--color-text); outline-offset: 1px; }
.layout-original-mark:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
/* Redacted / Compare switch: the page view's main control. */
.layout-view-switch {
  display: inline-flex;
  padding: 2px;
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-control);
  background: var(--color-surface-muted);
}
.layout-view-switch button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2rem;
  padding: var(--space-1) var(--space-3);
  border: 0;
  border-radius: calc(var(--radius-control) - 2px);
  background: var(--color-clear);
  color: var(--color-text-muted);
  font: var(--weight-medium) var(--text-xs)/1.2 var(--font-sans);
  cursor: pointer;
}
.layout-view-switch button:hover { color: var(--color-text); }
.layout-view-switch button[aria-pressed="true"] {
  background: var(--color-action);
  color: var(--color-on-action);
}
.layout-view-switch button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.layout-view-icon {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.layout-view-switch .shortcut-key { margin-left: var(--space-1); }

/* Compare runs inside Focus view: keep only the controls and the two pages. */
.page-layout-panel.is-comparing #pageLayoutCaption,
.page-layout-panel.is-comparing .zoom-help,
.page-layout-panel.is-comparing #layoutReviewWarning:not(.is-alert) { display: none; }
.page-layout-panel.is-comparing .page-layout-toolbar { padding-block: var(--space-2); }
.page-layout-panel.is-comparing .layout-page-viewport { padding-block: .75rem; }
.page-layout-panel.is-comparing .layout-sheet-label { display: none; }
/* Narrow panels stack the two copies instead of shrinking them unreadably. */
@media (max-width: 1100px) {
  .page-layout-panel.is-comparing .layout-pair { flex-direction: column; }
  .page-layout-panel.is-comparing .layout-compare-labels { display: none; }
  .page-layout-panel.is-comparing .layout-original-page::before {
    content: "Original";
    position: absolute;
    top: -1.2rem;
    left: 0;
    color: var(--color-text-muted);
    font: var(--weight-semibold) var(--text-xs)/1 var(--font-sans);
  }
}
.shortcut-key {
  margin-left: var(--space-2);
  padding: 0 .3rem;
  border: var(--border-width) solid currentColor;
  border-radius: 4px;
  font: var(--weight-medium) .7rem/1.4 var(--font-mono);
  opacity: .7;
}

/* ---------- Project header: back link and collapse ---------- */
.workspace-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 1.75rem;
  padding: 0 var(--space-3) 0 var(--space-2);
  border: var(--border-width) solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-decoration: none;
}
.workspace-back:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
}
.workspace-back .btn-icon { width: 14px; height: 14px; }
.verdict-back { display: none; }
.collapse-top-btn .btn-icon { transition: transform var(--duration-fast) var(--ease-standard); }
body.workspace-top-collapsed .collapse-top-btn .btn-icon { transform: rotate(180deg); }
body.workspace-top-collapsed .workspace-header,
body.workspace-top-collapsed .verdict-meta,
body.workspace-top-collapsed .verdict-checks,
body.workspace-top-collapsed .verdict-seal,
body.workspace-top-collapsed .workspace-status:not(.focus-status-visible),
body.workspace-top-collapsed .run-activity:not(.is-busy) { display: none; }
/* The page caption repeats what the placeholders already show, and the yellow
   note is informational unless it is an alert; a collapsed header drops both. */
body.workspace-top-collapsed #pageLayoutCaption,
body.workspace-top-collapsed #layoutReviewWarning:not(.is-alert) { display: none; }
body.workspace-top-collapsed .page-layout-toolbar { justify-content: flex-start; }
/* The header is already out of the way, so the Focus view tip has nothing to offer. */
body.workspace-top-collapsed .focus-view-hint { display: none; }
body.workspace-top-collapsed .verdict-back { display: inline-flex; }
body.workspace-top-collapsed .verdict {
  padding-block: var(--space-2);
  align-items: center;
}
body.workspace-top-collapsed .verdict-title { font-size: var(--text-base); }
@media (prefers-reduced-motion: reduce) {
  .collapse-top-btn .btn-icon { transition: none; }
}

/* ---------- Side panel handles ---------- */
/* Open: a quiet round knob in the gap beside the panel, with a hairline that
   traces the panel edge on hover. Folded: a compact tab (icon + label) at the
   top of a slim column. The whole gap is the click target in both states. */
.workspace-page {
  --panel-ease: cubic-bezier(.32, .72, 0, 1);
  --panel-time: 360ms;
  --press-ease: cubic-bezier(.2, .8, .2, 1);
}
.panel-handle {
  position: relative;
  z-index: 2;
  flex: none;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--space-3);
  margin-inline: calc(var(--space-3) * -1);
  padding: 7px 0 0;
  border: 0;
  background: var(--color-clear);
  color: var(--color-text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.panel-handle::before {
  content: "";
  position: absolute;
  inset: var(--space-2) 50%;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--color-focus);
  opacity: 0;
  transform: scaleY(.6);
  transition: opacity 200ms var(--panel-ease), transform 320ms var(--panel-ease);
}
.panel-handle-knob {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
    scale 160ms var(--press-ease), translate 260ms var(--panel-ease), box-shadow 200ms ease;
}
.panel-handle-chevron, .panel-handle-glyph {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.panel-handle-chevron { transition: rotate var(--panel-time) var(--panel-ease); }
.panel-handle-glyph { width: 15px; height: 15px; stroke-width: 1.3; }
.panel-handle-glyph circle { fill: currentColor; stroke: none; }
.panel-handle:hover { color: var(--color-text); }
.panel-handle:hover::before { opacity: .55; transform: scaleY(1); }
.panel-handle:hover .panel-handle-knob { border-color: var(--color-border-strong); box-shadow: var(--handle-lift); }
.panel-handle-left:hover .panel-handle-knob { translate: -1px 0; }
.panel-handle-right:hover .panel-handle-knob { translate: 1px 0; }
.panel-handle:active .panel-handle-knob { scale: .88; }
.panel-handle:focus-visible { outline: none; }
.panel-handle:focus-visible .panel-handle-knob { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* Folded: the knob hides and a tab takes its place. */
.panel-handle-tab {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0 var(--space-4);
  width: 34px;
  border: var(--border-width) solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 220ms ease,
    scale 160ms var(--press-ease), translate 260ms var(--panel-ease);
}
.panel-handle-label {
  writing-mode: vertical-rl;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .04em;
}
.panel-handle-left .panel-handle-label { rotate: 180deg; }
.panel-handle[aria-expanded="false"] {
  width: 34px;
  margin-inline: 0;
  padding-top: 0;
}
.panel-handle[aria-expanded="false"]::before { display: none; }
.panel-handle[aria-expanded="false"] .panel-handle-knob { display: none; }
.panel-handle[aria-expanded="false"] .panel-handle-tab {
  display: flex;
  animation: panel-tab-in 420ms var(--panel-ease) both;
}
.panel-handle-left[aria-expanded="false"] .panel-handle-tab { --tab-from: -10px; }
.panel-handle-right[aria-expanded="false"] .panel-handle-tab { --tab-from: 10px; }
.panel-handle[aria-expanded="false"]:hover .panel-handle-tab {
  border-color: var(--color-border-strong);
  box-shadow: var(--handle-lift-strong);
}
.panel-handle-left[aria-expanded="false"]:hover .panel-handle-tab { translate: 2px 0; }
.panel-handle-right[aria-expanded="false"]:hover .panel-handle-tab { translate: -2px 0; }
.panel-handle[aria-expanded="false"]:active .panel-handle-tab { scale: .95; }
.panel-handle[aria-expanded="false"]:focus-visible .panel-handle-tab { outline: 2px solid var(--color-focus); outline-offset: 2px; }
@keyframes panel-tab-in {
  from { opacity: 0; translate: var(--tab-from, 0) 0; }
  to { opacity: 1; translate: 0 0; }
}

/* Panels fold by width and fade, then leave the layout. Showing them plays the
   same motion in reverse (@starting-style). Drawers on narrow screens keep their
   own behaviour. Browsers without discrete transitions simply switch at once. */
@media (min-width: 1101px) and (prefers-reduced-motion: no-preference) {
  /* Motion runs only for a handle click (panels-animating); a panel that the
     app hides and shows again in one update must not start mid-animation. */
  body.panels-animating .doc-list,
  body.panels-animating .inspector,
  body.panels-animating .record-notes {
    transition: flex-basis var(--panel-time) var(--panel-ease), width var(--panel-time) var(--panel-ease),
      min-width var(--panel-time) var(--panel-ease), padding var(--panel-time) var(--panel-ease),
      margin var(--panel-time) var(--panel-ease), border-width var(--panel-time) var(--panel-ease),
      opacity 240ms var(--panel-ease), transform var(--panel-time) var(--panel-ease),
      display var(--panel-time) allow-discrete;
  }
  .workspace-page .doc-list, .workspace-page .record-notes { overflow: hidden; }
  .workspace-page .doc-list.hidden,
  .workspace-page .record-notes.hidden {
    flex-basis: 0;
    width: 0;
    min-width: 0;
    padding-inline: 0;
    border-width: 0;
    opacity: 0;
  }
  /* Absorb the flex gap too, so nothing jumps when the panel finally leaves. */
  .workspace-page .doc-list.hidden { margin-right: calc(var(--space-3) * -1); transform: translateX(-12px); }
  .workspace-page .record-notes.hidden { margin-left: calc(var(--space-3) * -1); transform: translateX(12px); }
  .workspace-page .inspector.hidden { margin-left: calc(var(--space-3) * -1); transform: translateX(12px); }
  @starting-style {
    body.panels-animating .doc-list:not(.hidden) { flex-basis: 0; width: 0; min-width: 0; padding-inline: 0; opacity: 0; margin-right: calc(var(--space-3) * -1); transform: translateX(-12px); }
    body.panels-animating .record-notes:not(.hidden) { flex-basis: 0; width: 0; min-width: 0; padding-inline: 0; opacity: 0; margin-left: calc(var(--space-3) * -1); transform: translateX(12px); }
    body.panels-animating .inspector:not(.hidden) { flex-basis: 0; width: 0; min-width: 0; padding-inline: 0; opacity: 0; margin-left: calc(var(--space-3) * -1); transform: translateX(12px); }
  }
  /* Keep panel contents at full width while the frame narrows, so text never reflows mid-motion. */
  .workspace-page .doc-list > * { min-width: calc(var(--document-list-width) - 2 * var(--space-4)); }
}

/* ---------- Collapsible header motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .workspace-page { interpolate-size: allow-keywords; }
  /* Only a collapse/expand click animates heights; ordinary content changes
     (progress appearing, status text) stay instant so nothing drifts. */
  body.top-animating .verdict-meta,
  body.top-animating .verdict-checks,
  body.top-animating .verdict-seal,
  body.top-animating .verdict-back,
  body.top-animating #pageLayoutCaption {
    transition: height 320ms var(--panel-ease), opacity 220ms ease, translate 320ms var(--panel-ease),
      display 320ms allow-discrete;
  }
  body.workspace-top-collapsed .verdict-meta,
  body.workspace-top-collapsed .verdict-checks,
  body.workspace-top-collapsed #pageLayoutCaption { height: 0; opacity: 0; translate: 0 -4px; overflow: hidden; }
  body.workspace-top-collapsed .verdict-seal { opacity: 0; translate: -6px 0; }
  /* Entry motion plays only for a toggle, never on page load. */
  @starting-style {
    body.top-animating .verdict-meta, body.top-animating .verdict-checks, body.top-animating #pageLayoutCaption { height: 0; opacity: 0; translate: 0 -4px; }
    body.top-animating .verdict-seal { opacity: 0; translate: -6px 0; }
    body.top-animating.workspace-top-collapsed .verdict-back { opacity: 0; translate: -6px 0; }
  }
  /* The header row folds by height as well. */
  body.top-animating .workspace-header,
  body.top-animating .run-activity,
  body.top-animating .workspace-status {
    transition: height 340ms var(--panel-ease), max-height .3s cubic-bezier(.22,1,.36,1), min-height .3s cubic-bezier(.22,1,.36,1),
      margin 340ms var(--panel-ease), padding 340ms var(--panel-ease), border-width 340ms var(--panel-ease),
      opacity 240ms ease, transform .3s cubic-bezier(.22,1,.36,1), display 340ms allow-discrete;
  }
  body.workspace-top-collapsed .workspace-header,
  body.workspace-top-collapsed .run-activity:not(.is-busy),
  body.workspace-top-collapsed .workspace-status:not(.focus-status-visible) {
    height: 0; min-height: 0; margin-block: 0; padding-block: 0; border-width: 0; opacity: 0; overflow: hidden;
  }
  @starting-style {
    body.top-animating:not(.workspace-top-collapsed) .workspace-header,
    body.top-animating:not(.workspace-top-collapsed) .run-activity,
    body.top-animating:not(.workspace-top-collapsed) .workspace-status { height: 0; min-height: 0; opacity: 0; }
  }
}

/* ---------- Press feedback ---------- */
/* Every control on the workspace answers a press with a small, quick dip. */
.workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .view-tabs button, .records-layout button,
  .layout-view-switch button, .entity-chips button, .doc-open, .doc-actions-btn, .menu-item, .text-button) {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 180ms ease,
    opacity 150ms ease, scale 140ms var(--press-ease);
}
.workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .view-tabs button, .records-layout button,
  .layout-view-switch button, .entity-chips button, .doc-open, .doc-actions-btn, .menu-item, .text-button):not(:disabled):active {
  scale: .965;
}
.workspace-page .doc-open:not(:disabled):active { scale: .985; }
@media (prefers-reduced-motion: reduce) {
  .panel-handle::before, .panel-handle-knob, .panel-handle-chevron, .panel-handle-tab { transition: none; }
  .panel-handle[aria-expanded="false"] .panel-handle-tab { animation: none; }
  .workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .view-tabs button, .records-layout button,
    .layout-view-switch button, .entity-chips button, .doc-open, .doc-actions-btn, .menu-item, .text-button):active { scale: 1; }
}
/* Narrow screens open the panels as drawers (closed by the scrim), so only the
   folded tab is needed there; the open-state knob would sit past the edge. */
@media (max-width: 1100px) {
  .panel-handle[aria-expanded="true"] { display: none; }
}

/* ==========================================================================
   Review desk (2026-10-06). The approved option A: title and actions on one
   row, the four run checks beneath, one status line, then Original, Result
   and the replacement records side by side under a single filter bar.
   Earlier verdict rules above are overridden here rather than rewritten so
   Focus view, the collapsible header and the narrow-screen drawers keep
   their behaviour.
   ========================================================================== */
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- header block ---------- */
.workspace-page .workspace-toolbar.verdict {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title actions" "checks checks" "meta meta";
  align-items: start;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4) var(--space-3);
  border-radius: var(--radius-panel);
}
.workspace-page .verdict::before { display: none; }
.workspace-page .verdict .workspace-header { grid-area: title; min-height: 0; max-height: none; padding: 0; margin: 0; overflow: visible; }
.workspace-page .verdict .verdict-actions { grid-area: actions; justify-self: end; align-self: center; flex-wrap: nowrap; gap: var(--space-2); }
.workspace-page .verdict .verdict-body { grid-area: checks; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: var(--space-2); }
.workspace-page .workspace-crumbs { gap: var(--space-2); font-size: var(--text-xs); }
.workspace-page .workspace-back { display: inline-flex; align-items: center; gap: 2px; font-size: var(--text-xs); color: var(--color-text-muted); }
.workspace-page .workspace-back .btn-icon { width: 13px; height: 13px; flex-basis: 13px; }
.workspace-page .workspace-badge { padding-block: 0; min-height: 1.25rem; }
.desk-title-row { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.workspace-page .workspace-heading .app-title { margin: 0; font-size: 1.375rem; font-weight: var(--weight-semibold); letter-spacing: -.02em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk-rename { border-color: transparent; background: transparent; color: var(--color-text-muted); min-height: 2rem; }
.desk-rename:hover { color: var(--color-text); }
.workspace-page .verdict .project-header-actions { margin-left: 0; gap: 0; }
.workspace-page .verdict-actions .btn-primary, .workspace-page .verdict-actions .btn-secondary { min-height: 2.25rem; }
.workspace-page .verdict-actions .focus-workspace-btn { min-inline-size: 8.75rem; gap: var(--space-2); justify-content: center; }
.workspace-page .verdict-actions #updateBtn:disabled { display: none; }
.workspace-page .sanitize-split .btn-primary { border-radius: var(--radius-control) 0 0 var(--radius-control); }
.workspace-page .sanitize-split .split-caret { border-radius: 0 var(--radius-control) var(--radius-control) 0; margin-left: -1px; padding-inline: var(--space-2); min-width: 2rem; }
.workspace-page .sanitize-split .split-caret .btn-icon { width: 13px; height: 13px; flex-basis: 13px; }
.menu-item .btn-icon { color: var(--color-text-muted); }
.menu-item { justify-content: flex-start; gap: var(--space-2); }
.menu-note.menu-group { padding-top: var(--space-2); margin-top: var(--space-1); border-top: var(--border-width) solid var(--color-border); font-size: var(--text-eyebrow); letter-spacing: var(--tracking-label); text-transform: uppercase; }

/* The four checks read as one row of pills. */
.workspace-page .verdict-checks { margin: 0; gap: 6px; }
.workspace-page .verdict-check { min-height: 1.65rem; padding: 0 var(--space-3) 0 var(--space-2); gap: 6px; border-radius: var(--radius-pill); font-size: var(--text-xs); color: var(--color-text-muted); background: var(--color-surface); }
.workspace-page .verdict-check .check-value { color: var(--color-text); }
.workspace-page .verdict-check[data-tone="warn"] { color: var(--color-warning-text); }
.workspace-page .verdict-check[data-tone="warn"] .check-value { color: var(--color-warning-text); }

/* One quiet status line: verdict, document, rule, saved state, data boundary. */
.workspace-page .verdict-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); min-width: 0; color: var(--color-text-muted); font-size: var(--text-xs); }
.workspace-page .verdict-meta > * + *::before { content: "·"; margin-right: var(--space-3); color: var(--color-border-strong); }
.workspace-page .verdict-meta .verdict-title { display: inline; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text-muted); white-space: normal; }
.workspace-page .verdict[data-state="ok"] .verdict-title { color: var(--assure); }
.workspace-page .verdict[data-state="warn"] .verdict-title { color: var(--color-warning-text); }
.workspace-page .verdict .rule-context { display: inline-flex; min-height: 0; padding: 0; border: 0; gap: var(--space-1); font-size: var(--text-xs); color: var(--color-text-muted); }
.workspace-page .verdict .rule-context .eyebrow { font-size: var(--text-eyebrow); letter-spacing: var(--tracking-label); }
.workspace-page .verdict .rule-context #currentRule { color: var(--color-text); }
.workspace-page .verdict .save-status { padding: 0; background: transparent; border-radius: 0; font-size: var(--text-xs); max-width: none; }
.boundary-badge { display: inline-flex; align-items: center; gap: 5px; min-height: 1.4rem; padding: 2px var(--space-2) 2px 6px; border: var(--border-width) solid var(--assure-border); border-radius: var(--radius-pill); background: var(--assure-bg); color: var(--assure); font-size: var(--text-eyebrow); font-weight: var(--weight-medium); white-space: nowrap; }
.boundary-badge b { font-weight: var(--weight-semibold); }
.boundary-badge .btn-icon { width: 12px; height: 12px; flex-basis: 12px; }
.boundary-badge.is-on { border-color: var(--color-warning-border); background: var(--color-warning-bg); color: var(--color-warning-text); }
.workspace-page .verdict-meta .boundary-badge::before { content: none; }
.workspace-page .verdict-meta .boundary-badge { margin-left: var(--space-1); }
.workspace-page .verdict-document { display: none; }
.workspace-page .verdict-meta > .rule-context::before { content: none; }
.workspace-page .verdict-meta > .verdict-title + .rule-context::before { content: "·"; margin-right: var(--space-3); color: var(--color-border-strong); }

/* Focus view and the collapsed header leave only the action row. */
.workspace-focus-mode .workspace-page .workspace-toolbar.verdict,
.workspace-page.workspace-focus-mode .workspace-toolbar.verdict,
body.workspace-top-collapsed .workspace-toolbar.verdict { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); }
.workspace-page.workspace-focus-mode .verdict .verdict-actions,
body.workspace-top-collapsed .verdict .verdict-actions { margin-left: auto; }
.workspace-page.workspace-focus-mode .verdict .verdict-body,
body.workspace-top-collapsed .verdict .verdict-body { display: none; }
.workspace-page .workspace-status { margin: calc(-1 * var(--space-1)) 0 0; }

/* ---------- body ---------- */
.desk .doc-list { padding: var(--space-3) var(--space-2) var(--space-2); gap: 0; }
.desk .doc-list .pane-heading { padding-inline: var(--space-2); min-height: 2.25rem; }
.desk .doc-list .pane-heading .btn-secondary.icon-only { min-height: 2rem; min-width: 2rem; border-color: transparent; background: transparent; color: var(--color-text-muted); }
.desk .doc-list .pane-heading .btn-secondary.icon-only:hover:not(:disabled) { color: var(--color-text); background: var(--color-surface-hover); }
.desk-search { display: flex; align-items: center; gap: var(--space-2); min-height: 2rem; margin: var(--space-2) var(--space-2) var(--space-2); padding: 0 var(--space-2) 0 var(--space-2); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-control); background: var(--color-surface-muted); color: var(--color-text-muted); transition: border-color .12s, box-shadow .12s; }
.desk-search:focus-within { border-color: var(--color-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus) 18%, transparent); background: var(--color-surface); }
.desk-search .btn-icon { width: 13px; height: 13px; flex-basis: 13px; }
.desk-search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; font: inherit; font-size: var(--text-xs); color: var(--color-text); outline: none; }
.desk-search input::placeholder { color: var(--color-text-muted); }
.desk-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.desk #docList { padding-inline: 0; margin-inline: 0; }
.desk .doc-item { margin-bottom: 2px; border-color: transparent; border-radius: var(--radius-control); }
.desk .doc-item.active { border-color: var(--color-border); background: var(--color-surface-muted); }
.desk .doc-open { padding: var(--space-2) var(--space-7) var(--space-2) var(--space-2); display: grid; grid-template-columns: 14px minmax(0, 1fr); column-gap: var(--space-2); align-items: start; }
.desk .doc-open::before { content: ""; grid-row: 1 / 3; width: 14px; height: 14px; margin-top: 2px; background: var(--color-text-muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 2.5h4.8l2.7 2.7v8.3h-7.5z'/%3E%3Cpath d='M9.2 2.6v2.7h2.7'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 2.5h4.8l2.7 2.7v8.3h-7.5z'/%3E%3Cpath d='M9.2 2.6v2.7h2.7'/%3E%3C/svg%3E") center / contain no-repeat; }
.desk .doc-item.active .doc-open::before { background: var(--color-text); }
.desk .doc-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-xs); }
.desk .doc-item-meta { margin-top: 1px; font-size: 11px; }
.desk .doc-item-status { grid-column: 2; }
.desk .doc-actions-btn { top: 50%; translate: 0 -50%; }

.desk .doc-workspace { gap: var(--space-3); }
.desk .viewer-bar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-panel); flex: none; }
.desk .viewer-bar.hidden { display: none; }
.desk .entity-chips { flex: 1 1 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 0; mask-image: linear-gradient(90deg, black calc(100% - 28px), transparent); }
.desk .entity-chips::-webkit-scrollbar { display: none; }
.desk .entity-chip { flex: none; min-height: 1.75rem; padding: 0 var(--space-3); color: var(--color-text); font-weight: var(--weight-medium); }
.desk .entity-chip::before { width: 8px; height: 8px; border-radius: 50%; }
.desk .entity-chip[aria-pressed="true"] { color: var(--color-surface); border-color: var(--color-text); background: var(--color-text); }
.desk .entity-chip-count { color: var(--color-text-muted); font-weight: var(--weight-medium); }
.desk .entity-chip[aria-pressed="true"] .entity-chip-count { color: inherit; opacity: .75; }
.desk .desk-search-records { margin: 0; width: 15rem; flex: none; }
.desk .records-layout { margin-left: 0; }

/* Segmented groups share one sliding thumb. */
.view-tabs, .records-layout, .layout-view-switch { position: relative; }
.desk .view-tabs { border: 0; padding: 3px; gap: 2px; border-radius: 8px; background: var(--color-surface-muted); }
.desk .view-tabs button { min-height: 1.75rem; padding: 0 var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.tabs-thumb { position: absolute; left: 0; top: 0; z-index: 0; width: 0; border-radius: 6px; background: var(--color-surface); box-shadow: var(--shadow-segment); opacity: 0; pointer-events: none; transition: transform .24s cubic-bezier(.2,.8,.2,1), width .24s cubic-bezier(.2,.8,.2,1), opacity .12s; }
.layout-view-switch > .tabs-thumb { border-radius: 4px; }
:is(.view-tabs, .records-layout, .layout-view-switch) > button { position: relative; z-index: 1; }
.has-thumb.view-tabs button[aria-selected="true"], .has-thumb.records-layout button[aria-pressed="true"], .has-thumb.layout-view-switch button[aria-pressed="true"] { background: transparent; box-shadow: none; }

/* Reading controls stay below the pages, with space reserved for the dock. */
.workspace-page .page-layout-panel { overflow: clip; }
.layout-reading-dock {
  position: sticky;
  bottom: var(--space-3);
  z-index: 8;
  flex: none;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  max-width: calc(100% - 2 * var(--space-3));
  margin: var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: var(--shadow-panel);
}
.layout-reading-dock .layout-view-switch { border: 0; padding: 3px; gap: 2px; border-radius: 8px; }
.layout-reading-dock .layout-view-switch button { min-height: 2.25rem; border-radius: 6px; }
.layout-reading-dock .layout-view-switch > .tabs-thumb { border-radius: 6px; }
/* The thumb is a light surface, so its label needs the normal ink color. */
.layout-reading-dock .has-thumb.layout-view-switch button[aria-pressed="true"] { color: var(--color-text); }
.layout-zoom-controls { display: flex; align-items: center; gap: var(--space-1); padding-left: var(--space-2); border-left: 1px solid var(--color-border); }
.layout-zoom-controls output { min-width: 3.5rem; text-align: center; color: var(--color-text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.workspace-page .layout-zoom-controls .btn-secondary { min-height: 2.25rem; padding: var(--space-1) var(--space-2); border-color: transparent; background: transparent; box-shadow: none; font-size: var(--text-xs); }
.workspace-page .layout-zoom-controls .btn-secondary:hover:not(:disabled) { background: var(--color-surface-muted); }
.workspace-page .layout-zoom-controls #layoutZoomOut,
.workspace-page .layout-zoom-controls #layoutZoomIn { min-width: 2.25rem; font-size: var(--text-base); }
.workspace-page .layout-zoom-controls #layoutZoomFit { margin-left: var(--space-1); border-left-color: var(--color-border); border-radius: 0 6px 6px 0; }
@media (max-width: 600px) {
  .layout-reading-dock { gap: var(--space-2); }
  .layout-reading-dock .shortcut-key { display: none; }
  .layout-reading-dock .layout-zoom-controls { padding-left: 0; border-left: 0; }
  .layout-reading-dock .layout-view-switch button,
  .workspace-page .layout-zoom-controls .btn-secondary { min-height: 44px; }
  .workspace-page .layout-zoom-controls #layoutZoomOut,
  .workspace-page .layout-zoom-controls #layoutZoomIn { min-width: 44px; }
}

.desk-row { display: flex; flex: 1; min-height: 0; gap: var(--space-3); }
.desk .doc-workspace:has(#emptyState:not(.hidden)) .desk-row { display: none; }
.desk .workspace-empty { flex: 1; min-height: 0; overflow: auto; }
.desk .drop-zone { position: relative; }
.desk .drop-zone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.desk-row > .doc-stage { flex: 1 1 auto; min-width: 0; }
.desk .inspector { --records-panel-width: 21rem; flex: 0 0 var(--records-panel-width); width: var(--records-panel-width); padding: 0; gap: 0; overflow: hidden; }
.desk .inspector .pane-heading { padding: var(--space-3) var(--space-3) var(--space-2) var(--space-4); min-height: 0; }
.desk .inspector .pane-heading .btn-secondary.icon-only { min-height: 2rem; min-width: 2rem; border-color: transparent; background: transparent; color: var(--color-text-muted); }
.desk .inspector .pane-heading .btn-secondary.icon-only:hover:not(:disabled) { color: var(--color-text); background: var(--color-surface-hover); }
.desk .inspector .audit-list { flex: 1; min-height: 0; margin: 0; padding: 0; overflow-y: auto; }
.desk .audit-empty { padding: var(--space-4); font-size: var(--text-xs); }
.desk .audit-record-card { margin: 0; }
.desk .audit-record { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); gap: 0 var(--space-2); margin: 0; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-3); border: 0; border-bottom: var(--border-width) solid color-mix(in srgb, var(--color-border) 65%, transparent); border-radius: 0; background: transparent; }
.desk .audit-record:hover { background: var(--color-surface-hover); }
.desk .audit-record[aria-pressed="true"] { background: var(--color-selection-bg); outline: none; box-shadow: inset 2px 0 0 var(--color-focus); }
.record-index { grid-row: 1 / 3; padding-top: 3px; color: var(--color-text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.record-main { display: grid; gap: 2px; min-width: 0; }
.desk .record-type { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: var(--weight-regular); color: var(--color-text-muted); text-transform: capitalize; }
.record-type-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--entity-border, var(--color-text-muted)); }
.desk .record-values { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-xs); }
.desk .record-original { color: var(--color-text); font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.desk .record-values .entity-pill { font-size: 10px; padding: 2px 5px; }
.desk .record-reason, .desk .record-location { grid-column: 2; margin-top: var(--space-1); font-size: 11px; line-height: 1.4; }
.desk .audit-record:not([aria-pressed="true"]) .record-reason, .desk .audit-record:not([aria-pressed="true"]) .record-location { display: none; }
.desk .audit-record-card:not(:has(.audit-record[aria-pressed="true"])) .restore-redaction { display: none; }
.desk .restore-redaction { border: 0; border-bottom: var(--border-width) solid color-mix(in srgb, var(--color-border) 65%, transparent); border-radius: 0; padding-left: calc(1.25rem + var(--space-3) + var(--space-2)); background: var(--color-selection-bg); }
.inspector-foot { display: grid; gap: 2px; padding: var(--space-2) var(--space-4) var(--space-3); border-top: var(--border-width) solid var(--color-border); }
.inspector-foot .pane-caption { padding: 0; }
.desk .inspector-export-hint { font-size: 11px; }

/* Panes */
.desk .doc-panel .pane-heading { padding: var(--space-3) var(--space-4) 0; }
.desk .doc-panel .pane-heading h2 { font-size: var(--text-sm); }
.desk .doc-panel .text-button { min-height: 1.9rem; padding: 0 var(--space-3); border: var(--border-width) solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-surface); color: var(--color-text); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.desk .doc-panel .text-button:hover:not(:disabled) { background: var(--color-surface-hover); }
.desk .doc-panel .text-button:disabled { opacity: .5; cursor: default; }
.desk .doc-panel > .pane-caption { border-bottom: 0; padding-top: var(--space-1); }
.desk .result-warning { display: flex; gap: var(--space-2); align-items: flex-start; margin: 0 var(--space-4) var(--space-2); padding: var(--space-2) var(--space-3); border: var(--border-width) solid var(--color-warning-border); border-radius: var(--radius-control); max-height: 7em; }
.desk .result-warning::before { content: ""; flex: none; width: 13px; height: 13px; margin-top: 2px; border-radius: 50%; border: 1.4px solid currentColor; background: radial-gradient(circle, currentColor 1px, transparent 1.2px) center 3px / 100% 3px no-repeat, linear-gradient(currentColor, currentColor) center 7px / 1.4px 4px no-repeat; }

/* Empty state */
.desk .workspace-empty { gap: var(--space-4); }
.desk .import-guide { display: grid; gap: var(--space-3); width: min(100%, 34rem); justify-items: center; }
.desk .drop-zone { width: 100%; padding: var(--space-6) var(--space-5); border: 1.5px dashed var(--color-border-strong); border-radius: var(--radius-modal); background: var(--color-surface); display: grid; gap: var(--space-2); justify-items: center; text-align: center; transition: border-color .12s, background .12s, transform .12s cubic-bezier(.2,.8,.2,1); }
.desk .drop-zone:hover { border-color: var(--color-text); background: var(--color-surface-hover); }
.desk .drop-zone .drop-icon { width: 26px; height: 26px; fill: none; stroke: var(--color-text-muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.desk .drop-zone .drop-title { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.desk .import-guide-actions { display: flex; gap: var(--space-2); justify-content: center; }
.desk-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); width: 100%; margin: var(--space-1) 0 0; padding: 0; list-style: none; text-align: left; }
.desk-steps li { display: grid; gap: 2px; padding: var(--space-2) var(--space-3); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); font-size: var(--text-xs); color: var(--color-text-muted); }
.desk-steps li b { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--color-text); }
.desk-step-n { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--color-surface-muted); color: var(--color-text-muted); font-size: 10px; font-weight: var(--weight-semibold); }

.workspace-page .verdict[data-state="ok"] #exportMenuBtn:not(:disabled) { border-color: var(--color-border-strong); background: var(--color-surface); color: var(--color-text); }
/* Export menu reads as grouped rows. */
.workspace-page .export-menu { width: 19rem; gap: 2px; padding: var(--space-2); border-radius: var(--radius-modal); }
.workspace-page .export-group-title { margin: var(--space-1) 0 0; padding: var(--space-2) var(--space-2) 2px; }
.workspace-page .export-group-title:first-child { padding-top: var(--space-1); }
.workspace-page .export-menu .export-menu-note { padding: 2px var(--space-2) var(--space-1); }
.workspace-page .export-menu > .btn-secondary, .workspace-page .export-menu .audit-export-actions .btn-secondary { border-radius: var(--radius-control); }
.workspace-page .export-menu > .btn-secondary:hover:not(:disabled), .workspace-page .export-menu .audit-export-actions .btn-secondary:hover:not(:disabled) { background: var(--color-surface-muted); }

/* ---------- button mechanics ---------- */
/* Every control answers the pointer the same way: a hover tint, a 1px press
   with an inner shadow, and a 120 ms exponential ease out. */
.workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .text-button, .menu-item, .doc-actions-item, .entity-chip, .doc-open, .doc-actions-btn,
  .view-tabs button, .records-layout button, .layout-view-switch button, .audit-record, .restore-redaction, .note-item, .sidebar-link, .desk-rename) {
  transition: background-color .12s cubic-bezier(.2,.8,.2,1), border-color .12s cubic-bezier(.2,.8,.2,1), color .12s cubic-bezier(.2,.8,.2,1),
    box-shadow .12s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1), opacity .12s;
}
.workspace-page .btn-primary:not(:disabled) { box-shadow: var(--shadow-raise); }
.workspace-page .btn-primary:not(:disabled):hover { background: var(--color-action-hover); border-color: var(--color-action-hover); }
.workspace-page .btn-secondary:not(:disabled):hover { background: var(--color-surface-hover); }
.workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .text-button, .menu-item, .doc-actions-item, .entity-chip, .doc-open, .doc-actions-btn,
  .view-tabs button, .records-layout button, .layout-view-switch button, .audit-record, .restore-redaction, .desk-rename):not(:disabled):active {
  scale: 1; transform: translateY(1px); box-shadow: var(--shadow-press);
}
.workspace-page .btn-primary:not(:disabled):active { box-shadow: var(--shadow-press-strong); }
.workspace-page .entity-chip:not(:disabled):active { transform: scale(.96); box-shadow: none; }
.workspace-page :is(.view-tabs, .records-layout, .layout-view-switch) button:not(:disabled):active { transform: scale(.96); box-shadow: none; }
.workspace-page :is(button, [role="tab"], .doc-open):focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
/* Menus open with a short lift and their rows follow in sequence. */
.workspace-page .action-menu:not(.hidden), .workspace-page .export-menu:not(.hidden), .workspace-page .doc-actions-menu:not(.hidden) { animation: desk-pop .18s cubic-bezier(.2,.8,.2,1) both; transform-origin: top right; }
.workspace-page .action-menu:not(.hidden) > .menu-item, .workspace-page .export-menu:not(.hidden) > .btn-secondary, .workspace-page .export-menu:not(.hidden) .audit-export-actions > .btn-secondary { animation: desk-row-in .22s cubic-bezier(.2,.8,.2,1) both; }
.workspace-page .action-menu:not(.hidden) > :nth-child(2), .workspace-page .export-menu:not(.hidden) > :nth-child(3) { animation-delay: 25ms; }
.workspace-page .action-menu:not(.hidden) > :nth-child(3), .workspace-page .export-menu:not(.hidden) > :nth-child(4) { animation-delay: 50ms; }
.workspace-page .action-menu:not(.hidden) > :nth-child(4), .workspace-page .export-menu:not(.hidden) > :nth-child(7) { animation-delay: 75ms; }
.workspace-page .action-menu:not(.hidden) > :nth-child(6), .workspace-page .export-menu:not(.hidden) .audit-export-actions > .btn-secondary { animation-delay: 100ms; }
@keyframes desk-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes desk-row-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
/* A selected record pulses once in the texts; workspace-motion.js draws the leader. */
.desk .record-selected { animation: desk-pulse .7s cubic-bezier(.2,.8,.2,1); }
@keyframes desk-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-focus) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) {
  .tabs-thumb, .desk-search, .desk .drop-zone { transition: none; }
  .workspace-page .action-menu:not(.hidden), .workspace-page .export-menu:not(.hidden), .workspace-page .doc-actions-menu:not(.hidden),
  .workspace-page .action-menu:not(.hidden) > .menu-item, .workspace-page .export-menu:not(.hidden) > .btn-secondary, .workspace-page .export-menu:not(.hidden) .audit-export-actions > .btn-secondary,
  .desk .record-selected { animation: none; }
  .workspace-page :is(.btn-primary, .btn-secondary, .icon-button, .text-button, .menu-item, .entity-chip, .doc-open, .audit-record, .restore-redaction):not(:disabled):active { transform: none; }
}

/* ---------- narrower screens ---------- */
@media (max-width: 1280px) {
  .desk .inspector { --records-panel-width: 18rem; flex-basis: var(--records-panel-width); width: var(--records-panel-width); }
  .desk .desk-search-records { width: 11rem; }
}
@media (max-width: 1100px) {
  .workspace-page .workspace-toolbar.verdict { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "actions" "checks" "meta"; }
  .workspace-page .verdict .verdict-actions { justify-self: start; flex-wrap: wrap; }
  .desk .viewer-bar { flex-wrap: wrap; }
  .desk .entity-chips { flex-basis: 100%; order: 3; flex-wrap: wrap; overflow: visible; mask-image: none; }
  .desk .desk-search-records { flex: 1; width: auto; }
}
@media (max-width: 600px) {
  .desk-steps { grid-template-columns: 1fr; }
  .workspace-page .verdict-meta > * + *::before { content: none; }
}
/* Search fields inherit the app's input chrome; strip it inside the desk field. */
.desk .desk-search input, .desk .desk-search input:focus, .desk .desk-search input:focus-visible { min-height: 0; height: 1.5rem; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: none; font-size: var(--text-xs); line-height: 1.5rem; color: var(--color-text); }
.desk .workspace-empty .empty-symbol { display: none; }
.desk .workspace-empty h2 { font-size: var(--text-lg); }
/* The desk's panel sizing must yield to Focus view and to a folded panel. */
.workspace-focus-mode .desk .doc-list,
.workspace-focus-mode .desk .inspector,
.desk .doc-list.hidden,
.desk .inspector.hidden { flex-basis: 0; width: 0; min-width: 0; max-width: 0; padding: 0; border-width: 0; opacity: 0; overflow: hidden; pointer-events: none; }
.desk .doc-list.hidden { margin-right: calc(var(--space-3) * -1); }
.desk .inspector.hidden { display: none; }
@media (min-width: 1101px) and (prefers-reduced-motion: no-preference) {
  /* Clip full-width records during the same fold as Documents, without rewrapping. */
  .desk .inspector > * { min-width: var(--records-panel-width); }
  .desk .inspector.hidden { max-width: none; }
}

/* ==========================================================================
   Settings · mode picker, switches, save feedback
   The mode picker is an in-app listbox (settings.js) so it matches the
   workspace menus instead of the operating system popup.
   ========================================================================== */
.mode-setting { justify-content: space-between; gap: var(--space-4); }
.mode-left { display: grid; gap: var(--space-1); min-width: 0; flex: 1 1 18rem; }
.mode-label { font-weight: var(--weight-medium); }
.mode-hint { margin: 0; max-width: 46ch; line-height: 1.5; }

.mode-picker { position: relative; flex: 0 0 auto; }
.mode-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-width: 12.5rem; min-height: 2.5rem; padding: 0 var(--space-3) 0 var(--space-4);
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text);
  font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
  box-shadow: var(--shadow-raise);
  transition: background-color .12s cubic-bezier(.2,.8,.2,1), border-color .12s cubic-bezier(.2,.8,.2,1),
    box-shadow .12s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1);
}
.mode-trigger:hover { border-color: var(--color-border-strong); background: var(--color-surface-muted); }
.mode-trigger:active { transform: translateY(1px); box-shadow: var(--shadow-press); }
.mode-trigger:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.mode-picker.is-open .mode-trigger { border-color: var(--color-border-strong); background: var(--color-surface-muted); }
.mode-trigger-value { display: inline-block; }
.mode-trigger.is-changed .mode-trigger-value { animation: mode-value-in .32s cubic-bezier(.2,.8,.2,1); }
.mode-chevron { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--color-text-muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.mode-picker.is-open .mode-chevron { transform: rotate(180deg); }

.mode-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  width: min(23rem, calc(100vw - 2 * var(--space-4)));
  margin: 0; padding: var(--space-2); list-style: none;
  border: var(--border-width) solid var(--color-border); border-radius: var(--radius-modal);
  background: var(--color-surface); box-shadow: var(--shadow-menu);
  transform-origin: top right; outline: none;
}
.mode-menu:not([hidden]) { animation: mode-pop .2s cubic-bezier(.2,.8,.2,1) both; }
.mode-option {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-panel);
  cursor: pointer; user-select: none;
  transition: background-color .1s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1);
}
.mode-menu:not([hidden]) .mode-option { animation: mode-row-in .24s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 22ms); }
.mode-option.is-active { background: var(--color-surface-muted); }
.mode-option:active, .mode-option.just-picked { transform: scale(.985); background: var(--color-surface-hover); }
.mode-menu:focus-visible .mode-option.is-active { box-shadow: inset 2px 0 0 var(--color-focus); }
.mode-option-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.mode-option-name { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); }
.mode-option-desc { font-size: var(--text-xs); line-height: 1.45; color: var(--color-text-muted); }
.mode-check { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--color-text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 14; stroke-dashoffset: 14; transition: stroke-dashoffset .26s cubic-bezier(.2,.8,.2,1) .04s; }
.mode-option[aria-selected="true"] .mode-check { stroke-dashoffset: 0; }

@keyframes mode-pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes mode-row-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes mode-value-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Custom panel arrives instead of snapping in; switches give under the thumb. */
.settings-page #customPanel { animation: settings-panel-in .32s cubic-bezier(.2,.8,.2,1) both; }
@keyframes settings-panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.settings-page .toggle-row { transition: background-color .12s cubic-bezier(.2,.8,.2,1); }
.settings-page .toggle-row:hover { background: var(--color-surface-hover); }
.settings-page .slider { transition: background-color .2s cubic-bezier(.2,.8,.2,1); }
.settings-page .slider::before { transition: transform .26s cubic-bezier(.3,1.4,.5,1), scale .12s cubic-bezier(.2,.8,.2,1), background-color .2s; }
.settings-page .switch:active .slider::before { scale: 1.18 .92; }

.settings-page .settings-save { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 9.5rem; justify-content: center;
  box-shadow: var(--shadow-raise); transition: background-color .12s cubic-bezier(.2,.8,.2,1), box-shadow .12s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1); }
.settings-page .settings-save:not(:disabled):hover { background: var(--color-action-hover); border-color: var(--color-action-hover); }
.settings-page .settings-save:not(:disabled):active { transform: translateY(1px); box-shadow: var(--shadow-press-strong); }
.settings-page .settings-save:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.settings-page .settings-save[data-state="saving"] { opacity: .8; cursor: progress; }
.settings-page .settings-save[data-state="saving"]::before {
  content: ''; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: settings-spin .7s linear infinite;
}
.settings-page .settings-save[data-state="saved"]::before {
  content: ''; width: 10px; height: 5px; margin-top: -3px; border: solid currentColor; border-width: 0 0 2px 2px;
  transform: rotate(-45deg); animation: mode-value-in .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes settings-spin { to { transform: rotate(360deg); } }

.settings-toast {
  position: fixed; left: 50%; bottom: var(--space-6); z-index: 60;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill);
  background: var(--color-action); color: var(--color-on-action);
  font-size: var(--text-sm); font-weight: var(--weight-medium); box-shadow: var(--shadow-menu);
  transform: translateX(-50%); animation: settings-toast-in .26s cubic-bezier(.2,.8,.2,1) both;
}
.settings-toast[data-tone="error"] { background: var(--color-sensitive-bg); color: var(--color-sensitive-text); border: var(--border-width) solid var(--color-sensitive-border); }
.settings-toast.is-leaving { animation: settings-toast-out .2s cubic-bezier(.4,0,1,1) both; }
@keyframes settings-toast-in { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes settings-toast-out { to { opacity: 0; transform: translate(-50%, 6px); } }

@media (max-width: 640px) {
  .mode-picker, .mode-trigger { width: 100%; }
  .mode-menu { left: 0; right: 0; width: auto; transform-origin: top center; }
}
@media (prefers-reduced-motion: reduce) {
  .mode-menu:not([hidden]), .mode-menu:not([hidden]) .mode-option, .mode-trigger.is-changed .mode-trigger-value,
  .settings-page #customPanel, .settings-toast, .settings-toast.is-leaving { animation: none; }
  .mode-chevron, .mode-check, .settings-page .slider::before { transition: none; }
  .mode-trigger:active, .settings-page .settings-save:not(:disabled):active { transform: none; }
}

/* ==========================================================================
   Projects · the signed-in home (projects.js)
   A greeting that changes each visit, every project, and usage beside them.
   ========================================================================== */
/* The greeting: lead words rise in; the name arrives under a redaction bar
   that draws across it and then wipes away. Static when motion is reduced. */
.greeting .g-word, .greeting .g-name { display: inline-block; }
.greeting .g-name { position: relative; }
.greeting .g-name-text {
  background: var(--gradient-brand);
  background-clip: text; -webkit-background-clip: text;
  color: transparent;
}
.greeting .g-name::after {
  content: ''; position: absolute; inset: .14em -.06em .1em;
  border-radius: 4px; background: var(--color-text);
  clip-path: inset(0 0 0 100%); pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .greeting-play .g-word { animation: g-rise .62s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(60ms + var(--i) * 70ms); }
  .greeting-play .g-name-text { animation: g-name-in 1.35s linear both; animation-delay: calc(60ms + var(--i) * 70ms); }
  .greeting-play .g-name::after { animation: g-redact 1.35s cubic-bezier(.65,0,.28,1) both; animation-delay: calc(60ms + var(--i) * 70ms); }
  .greeting-play .greeting-sub { animation: g-rise .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(360ms + var(--i) * 70ms); }
}
@keyframes g-rise { from { opacity: 0; transform: translateY(.38em); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes g-name-in { 0%, 26% { opacity: 0; } 27%, 100% { opacity: 1; } }
@keyframes g-redact {
  0% { clip-path: inset(0 100% 0 0); }
  28%, 52% { clip-path: inset(0 0 0 0); }
  100% { clip-path: inset(0 0 0 100%); }
}
@media (forced-colors: active) {
  .greeting .g-name-text { background: none; color: CanvasText; -webkit-text-fill-color: currentColor; }
}

.projects-page .app-user { display: inline-flex; border-radius: var(--radius-round); transition: box-shadow .15s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1); }
.projects-page .app-user:hover { box-shadow: 0 0 0 3px var(--color-border); }
.projects-page .app-user:active { transform: scale(.94); }
.projects-page .app-user:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.projects-page .user-avatar .nav-icon { width: 18px; height: 18px; }

/* Buttons on this page answer the press the way the workspace's do. */
.projects-page :is(.btn-primary, .btn-secondary) {
  transition: background-color .12s cubic-bezier(.2,.8,.2,1), border-color .12s cubic-bezier(.2,.8,.2,1),
    box-shadow .12s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1), opacity .12s;
}
.projects-page .btn-primary:not(:disabled) { box-shadow: var(--shadow-raise); }
.projects-page .btn-primary:not(:disabled):hover { background: var(--color-action-hover); border-color: var(--color-action-hover); }
.projects-page .btn-secondary:not(:disabled):hover { background: var(--color-surface-hover); }
.projects-page :is(.btn-primary, .btn-secondary):not(:disabled):active { transform: translateY(1px); box-shadow: var(--shadow-press); }
.projects-page .btn-primary:not(:disabled):active { box-shadow: var(--shadow-press-strong); }
.projects-page :is(.btn-primary, .btn-secondary):focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* List head: title with a count, then search and sort once the list is long. */
.projects-page .dash-panel-head { align-items: center; flex-wrap: wrap; }
.dash-count {
  display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.35rem; margin-left: var(--space-1);
  padding: 0 var(--space-2); border-radius: var(--radius-pill); vertical-align: middle;
  background: var(--color-surface-muted); color: var(--color-text-muted);
  font-size: var(--text-xs); font-weight: var(--weight-medium); letter-spacing: 0;
}
.project-tools { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.project-tools[hidden] { display: none; }
.project-search { position: relative; display: block; }
.project-search svg {
  position: absolute; left: .7rem; top: 50%; width: 15px; height: 15px; translate: 0 -50%;
  fill: none; stroke: var(--color-text-muted); stroke-width: 1.6; stroke-linecap: round; pointer-events: none;
}
.projects-page .project-search input {
  width: 13rem; min-height: 2.25rem; padding: 0 var(--space-3) 0 2.1rem;
  border-color: var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface-muted); font-size: var(--text-sm);
  transition: width .22s cubic-bezier(.2,.8,.2,1), background-color .12s, border-color .12s, box-shadow .12s;
}
.projects-page .project-search input:hover { border-color: var(--color-border-strong); }
.projects-page .project-search input:focus { width: 16rem; background: var(--color-surface); border-color: var(--color-focus); box-shadow: 0 0 0 3px var(--color-selection-bg); outline: none; }
.project-sort { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--color-surface-muted); }
.project-sort button {
  min-height: 1.9rem; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); cursor: pointer;
  transition: background-color .15s cubic-bezier(.2,.8,.2,1), color .15s, box-shadow .15s, transform .12s cubic-bezier(.2,.8,.2,1);
}
.project-sort button:hover { color: var(--color-text); }
.project-sort button[aria-checked="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-segment); }
.project-sort button:active { transform: scale(.95); }
.project-sort button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.dash-no-match { padding: var(--space-4) 0; }

/* Rows: a press you can feel, and an Open pill that fills on hover. */
.projects-page .dash-project { transition: background-color .12s cubic-bezier(.2,.8,.2,1), transform .12s cubic-bezier(.2,.8,.2,1); }
.projects-page .dash-project:active { transform: scale(.992); background: var(--color-surface-hover); }
.projects-page .dash-open { display: inline-flex; align-items: center; gap: 4px; transition: background-color .15s cubic-bezier(.2,.8,.2,1), color .15s, border-color .15s; }
.dash-open-arrow { display: inline-block; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.projects-page .dash-project:hover .dash-open { background: var(--color-action); border-color: var(--color-action); color: var(--color-on-action); }
.projects-page .dash-project:hover .dash-open-arrow { transform: translateX(3px); }
@media (prefers-reduced-motion: no-preference) {
  .dash-project-list.is-entering .dash-project { animation: g-row-in .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(240ms + var(--i, 0) * 40ms); }
}
@keyframes g-row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* New project: the dialog lifts in, and a missing name shakes the form. */
.projects-page .modal:not(.hidden) { animation: g-scrim-in .18s ease-out both; }
.projects-page .modal:not(.hidden) .modal-content { animation: g-dialog-in .24s cubic-bezier(.2,.8,.2,1) both; }
.projects-page .modal-content label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.projects-page .modal-content input[aria-invalid="true"] { border-color: var(--color-sensitive-border); box-shadow: 0 0 0 3px var(--color-sensitive-bg); }
.projects-page .modal-actions .btn-secondary { width: auto; }
.form-error, .modal-content .form-error { margin: 0; color: var(--color-sensitive-text); font-size: var(--text-xs); }
.projects-page .modal-content.shake { animation: g-shake .32s cubic-bezier(.36,.07,.19,.97); }
#createProjectBtn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-width: 8.5rem; }
#createProjectBtn[data-state="saving"] { opacity: .8; cursor: progress; }
#createProjectBtn[data-state="saving"]::before {
  content: ''; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: settings-spin .7s linear infinite;
}
@keyframes g-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes g-dialog-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes g-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

@media (max-width: 640px) {
  .project-tools, .project-search, .projects-page .project-search input, .projects-page .project-search input:focus { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .projects-page .modal:not(.hidden), .projects-page .modal:not(.hidden) .modal-content, .projects-page .modal-content.shake { animation: none; }
  .projects-page :is(.btn-primary, .btn-secondary, .dash-project, .project-sort button, .app-user):active { transform: none; }
  .dash-open-arrow, .projects-page .project-search input { transition: none; }
}

/* ==========================================================================
   Shared collapsible sidebar (sidebar.js)
   Logo and a panel toggle on one row, compact rows, and an icon rail when
   collapsed. Icons keep the same x in both states, so only the labels move.
   ========================================================================== */
@media (min-width: 961px) {
  .sidebar-collapsible {
    --sb-open: 232px;
    --sb-closed: 64px;
    --sb-ease: cubic-bezier(.32, .72, 0, 1);
    position: sticky; top: 0; align-self: flex-start;
    flex: 0 0 var(--sb-open); width: var(--sb-open); height: 100dvh;
    gap: var(--space-5); padding: var(--space-5) 14px var(--space-4);
    overflow: hidden auto; overflow-x: clip;
  }
  :root.sidebar-animating .sidebar-collapsible { transition: flex-basis 300ms var(--sb-ease), width 300ms var(--sb-ease); }
  :root[data-sidebar="collapsed"] .sidebar-collapsible { flex-basis: var(--sb-closed); width: var(--sb-closed); }

  .sidebar-head { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
  .sidebar-collapsible .sidebar-logo {
    padding-inline: 9px; white-space: nowrap; font-size: var(--text-base);
    transition: opacity 180ms var(--sb-ease), translate 300ms var(--sb-ease);
  }
  .sidebar-collapse {
    display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; margin-left: auto;
    border: 0; border-radius: 8px; background: transparent; color: var(--color-text-muted); cursor: pointer;
    transition: background-color .12s cubic-bezier(.2,.8,.2,1), color .12s, transform .12s cubic-bezier(.2,.8,.2,1);
  }
  .sidebar-collapse:hover { background: var(--color-surface-muted); color: var(--color-text); }
  .sidebar-collapse:active { transform: scale(.9); }
  .sidebar-collapse:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
  .sidebar-collapse svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
  .sidebar-collapse-chevron { transform-box: fill-box; transform-origin: center; transition: transform 300ms var(--sb-ease); }
  :root[data-sidebar="collapsed"] .sidebar-collapse-chevron { transform: rotate(180deg); }

  .sidebar-collapsible .sidebar-nav { gap: 2px; }
  .sidebar-collapsible .sidebar-link {
    position: relative; gap: var(--space-3); min-height: 38px; padding: 0 9px; overflow: hidden;
    border-radius: 8px; font-size: var(--text-sm); white-space: nowrap;
    transition: background-color .12s cubic-bezier(.2,.8,.2,1), color .12s, transform .12s cubic-bezier(.2,.8,.2,1);
  }
  .sidebar-collapsible .sidebar-link.active { font-weight: var(--weight-medium); }
  .sidebar-collapsible .sidebar-link:active { transform: scale(.97); }
  .sidebar-collapsible .sidebar-link:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
  .sidebar-collapsible .sidebar-link .nav-icon { transition: transform .2s cubic-bezier(.2,.8,.2,1); }
  .sidebar-collapsible .sidebar-link:hover .nav-icon { transform: scale(1.06); }
  .sidebar-collapsible :is(.nav-label, .feature-log-label) {
    transition: opacity 200ms var(--sb-ease) 60ms, translate 300ms var(--sb-ease);
  }

  /* Collapsed: the logo and labels fade and slide under the icons. */
  :root[data-sidebar="collapsed"] .sidebar-collapsible .sidebar-logo { position: absolute; left: 0; opacity: 0; translate: -8px 0; pointer-events: none; }
  :root[data-sidebar="collapsed"] .sidebar-collapsible :is(.nav-label, .feature-log-label) {
    opacity: 0; translate: -6px 0; pointer-events: none; transition-delay: 0s;
  }

}
@media (max-width: 960px) {
  .sidebar-collapse { display: none; }
  .sidebar-head { display: contents; }
}

.sidebar-tip {
  position: fixed; z-index: 70; translate: 0 -50%;
  padding: 5px var(--space-2); border-radius: 6px;
  background: var(--color-action); color: var(--color-on-action);
  font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: pre; pointer-events: none;
  box-shadow: var(--shadow-menu);
}
.sidebar-tip.is-in { animation: sb-tip-in 140ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes sb-tip-in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .sidebar-collapsible, .sidebar-collapsible * { transition: none !important; }
  .sidebar-tip.is-in { animation: none; }
}

/* Document reading follows the page; records remain a bounded side panel. */
.workspace-page:not(.workspace-focus-mode) .workspace-main {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
.workspace-page:not(.workspace-focus-mode) .workspace-shell { flex: none; align-items: flex-start; }
.workspace-page:not(.workspace-focus-mode) .doc-workspace { min-height: 70dvh; }
.workspace-page:not(.workspace-focus-mode) .doc-stage { align-items: flex-start; }
.workspace-page:not(.workspace-focus-mode) .page-layout-panel { flex: 1; }
.workspace-page:not(.workspace-focus-mode) .layout-page-viewport { flex: none; height: auto; max-height: none; }
.workspace-page:not(.workspace-focus-mode) .doc-panels { min-height: 70dvh; }
.workspace-page:not(.workspace-focus-mode) .document-text:not(textarea) { height: auto; max-height: none; min-height: 60dvh; overflow: visible; }
.workspace-page .layout-sheet { margin-inline: auto; align-self: flex-start; }
.workspace-toolbar-slot { flex: none; min-width: 0; }
.workspace-page.workspace-toolbar-pinned .workspace-toolbar.verdict {
  position: fixed;
  top: 12px;
  left: var(--toolbar-left);
  width: var(--toolbar-width);
  z-index: 45;
  grid-template-areas: "title actions";
  padding-block: var(--space-2);
  box-shadow: var(--shadow-panel);
}
.workspace-toolbar-pinned .verdict .verdict-body,
.workspace-toolbar-pinned .verdict .workspace-crumbs { display: none; }
@media (min-width: 1101px) {
  .workspace-page:not(.workspace-focus-mode) .inspector,
  .workspace-page:not(.workspace-focus-mode) .doc-list,
  .workspace-page:not(.workspace-focus-mode) .record-notes {
    position: sticky;
    top: calc(var(--reading-toolbar-height, 64px) + 24px);
    height: calc(100dvh - var(--reading-toolbar-height, 64px) - 40px);
    max-height: calc(100dvh - var(--reading-toolbar-height, 64px) - 40px);
  }
}
@media (max-width: 960px) {
  .workspace-page.workspace-toolbar-pinned .workspace-toolbar.verdict { grid-template-areas: "title" "actions"; }
}
.workspace-page .doc-stage { min-width: 0; }
.workspace-page .doc-panels { min-width: 0; }
.workspace-page .document-text { overflow-wrap: anywhere; }

/* The Custom editor expands below the toolbar; the collapsed toolbar stays compact. */
.workspace-page .rule-edit { border: 0; background: transparent; color: var(--color-text-muted); padding: 0 var(--space-1); font: inherit; cursor: pointer; }
.workspace-page .rule-edit:hover { color: var(--color-text); }
.workspace-page .rule-edit:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.custom-rule-panel { margin-block: var(--space-3); padding: var(--space-4); background: var(--color-surface); border: var(--border-width) solid var(--color-border); border-radius: var(--radius-panel); }
.custom-rule-panel .btn-primary, .custom-rule-panel .btn-secondary { min-height: var(--control-compact); padding-block: var(--space-1); }
.custom-rule-heading, .custom-rule-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3); }
.custom-rule-heading h2 { margin: 0; font-size: var(--text-lg); }
.custom-rule-heading p, .custom-rule-footer p { margin: var(--space-1) 0 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.custom-rule-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-3); }
.custom-rule-tabs [aria-selected="true"] { background: var(--color-action); color: var(--color-on-action); border-color: var(--color-action); }
#customRuleFields { padding: 0; margin: 0; border: 0; min-width: 0; }
.custom-rule-categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1) var(--space-5); }
.custom-rule-option { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block: var(--space-1); font-size: var(--text-sm); cursor: pointer; }
.custom-rule-option input { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; flex: none; accent-color: var(--color-action); }
.custom-rule-note { grid-column: 1 / -1; margin: 0 0 var(--space-2); color: var(--color-text-muted); font-size: var(--text-xs); }
.custom-rule-footer { margin-top: var(--space-4); padding-top: var(--space-3); border-top: var(--border-width) solid var(--color-border); }
.custom-rule-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
@media (max-width: 1100px) { .custom-rule-categories { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .custom-rule-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .custom-rule-panel { padding: var(--space-4); }
  .custom-rule-panel .btn-primary, .custom-rule-panel .btn-secondary { min-height: 44px; }
  .custom-rule-categories { grid-template-columns: minmax(0, 1fr); }
  .custom-rule-option { min-height: 44px; }
  .workspace-page .rule-edit { min-height: 44px; }
}
.workspace-page .desk-row > .doc-stage { flex: 1 1 0; }
.workspace-page:not(.workspace-focus-mode) .desk-row { flex: none; align-items: flex-start; }

/* Settings: category workspace, with every rule kept in the saved draft. */
.settings-page .custom-settings-head .section-title { margin-bottom: .5rem; }
.settings-page .custom-settings-head .form-hint { margin: 0 0 1.5rem; }
.settings-rule-workspace { display: grid; grid-template-columns: 14rem minmax(0, 1fr); border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.settings-rule-nav { padding: .75rem; background: var(--color-surface-muted); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; gap: .25rem; }
.settings-rule-nav button { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; min-height: 48px; padding: .75rem; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--color-text-muted); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s, transform .12s; }
.settings-rule-nav button:hover { background: var(--color-surface-hover); color: var(--color-text); }
.settings-rule-nav button[aria-selected="true"] { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); box-shadow: var(--shadow-panel); font-weight: 600; }
.settings-rule-nav button:active { transform: scale(.98); }
.settings-rule-nav button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.settings-rule-count { font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--color-text-muted); }
#settingsRuleFields { margin: 0; padding: 1.5rem; border: 0; min-width: 0; }
.settings-rule-group:not([hidden]) { animation: settings-rules-in .18s ease-out; }
.settings-rule-group header { margin-bottom: 1.25rem; }
.settings-rule-group h3 { font-size: var(--text-lg); margin: 0 0 .4rem; }
.settings-rule-group header p { margin: 0; }
.settings-rule-group .toggle-row { border-radius: 0; border-bottom: 1px solid var(--color-border); background: transparent; padding: .8rem .25rem; gap: .75rem; min-height: 72px; }
.settings-rule-group .toggle-row:last-child { border-bottom: 0; }
.settings-rule-copy { flex: 1; min-width: 0; }
.settings-rule-copy label { cursor: pointer; font-weight: 500; }
.settings-rule-copy p { color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.5; margin: .2rem 0 0; }
.settings-rule-state { width: 1.8rem; text-align: right; color: var(--color-text-muted); font-size: var(--text-xs); }
.settings-ai-note { margin: 0 0 1.25rem; padding: .8rem 1rem; background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: 8px; color: var(--color-text-muted); font-size: var(--text-xs); line-height: 1.6; }
.settings-rule-group h4 { font-size: var(--text-sm); margin: 0; }
.settings-rule-group h4.settings-ai-categories { margin: 1.5rem 0 .5rem; }
.settings-rule-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1.25rem; }
.settings-rule-footer p { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }
.settings-rule-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.settings-rule-actions button { min-height: 44px; }
.settings-rule-actions button:disabled { opacity: .5; cursor: default; }
@keyframes settings-rules-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (max-width: 700px) {
  .settings-rule-workspace { grid-template-columns: 1fr; }
  .settings-rule-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--color-border); }
  .settings-rule-nav button { width: auto; flex: 1 1 9rem; min-height: 44px; }
  #settingsRuleFields { padding: 1rem; }
  .settings-rule-footer { align-items: flex-start; flex-direction: column; }
  .settings-rule-actions { width: 100%; }
  .settings-rule-actions button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .settings-rule-group:not([hidden]) { animation: none; }
  .settings-rule-nav button { transition: none; }
  .settings-rule-nav button:active { transform: none; }
}

/* Homepage: a separate outlined button above the navigation, since it leaves the app. */
.sidebar .sidebar-home-button {
  border: var(--border-width) solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-home-button);
}
.sidebar .sidebar-home-button:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-muted);
}
.sidebar-home-button .nav-label { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sidebar-home-arrow {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  color: var(--color-text-muted); transition: transform .2s cubic-bezier(.2,.8,.2,1), color .12s;
}
.sidebar-home-button:hover .sidebar-home-arrow { color: var(--color-text); transform: translate(1px, -1px); }
@media (min-width: 961px) {
  .sidebar-collapsible .sidebar-home-button { min-height: 36px; }
  /* Collapsed, the button keeps its outline as a square around the house icon. */
  :root[data-sidebar="collapsed"] .sidebar-collapsible .sidebar-home-button { width: 36px; }
}
@media (max-width: 960px) {
  .sidebar .sidebar-home-button { min-height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-home-arrow { transition: none; }
}

/* ==========================================================================
   Account row and menu (sidebar.js)
   The last row of the sidebar: avatar, name, chevron. It opens a menu that
   holds Account, Settings, Product tour and What's new, so the navigation
   above keeps only places to go. The menu is a sibling of the sidebar, fixed
   beside the row, so the sidebar's overflow clip never cuts it.
   ========================================================================== */
.sidebar .sidebar-account {
  gap: 10px; padding-inline: 5px; margin-top: var(--space-2);
  color: var(--color-text-muted); border: 0; background: transparent; cursor: pointer; text-align: left;
}
.sidebar .sidebar-account:hover, .sidebar .sidebar-account[aria-expanded="true"] { color: var(--color-text); background: var(--color-surface-muted); }
.sidebar .sidebar-account.is-current { color: var(--color-text); }
.sidebar-avatar {
  position: relative; flex: 0 0 26px; width: 26px; height: 26px; border-radius: var(--radius-round);
  display: grid; place-items: center; background: var(--color-surface-hover); color: var(--color-text);
  font-size: 10.5px; font-weight: var(--weight-semibold); letter-spacing: .02em; text-transform: uppercase;
  transition: box-shadow .15s cubic-bezier(.2,.8,.2,1);
}
.sidebar-avatar:empty::before { content: ""; width: 14px; height: 14px; border-radius: var(--radius-round); box-shadow: inset 0 0 0 1.5px currentColor; opacity: .55; }
.sidebar-account:hover .sidebar-avatar, .sidebar-account[aria-expanded="true"] .sidebar-avatar { box-shadow: 0 0 0 3px var(--color-border); }
/* Unread "What's new" items show on the row while the menu is closed. */
.sidebar-account.has-unread .sidebar-avatar::after {
  content: ""; position: absolute; top: -1px; right: -1px; width: 8px; height: 8px; border-radius: var(--radius-round);
  background: var(--accent-solid, var(--color-focus)); box-shadow: 0 0 0 2px var(--color-surface);
}
.sidebar-account-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--color-text); font-weight: var(--weight-medium); }
.sidebar-account-chevron {
  width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  color: var(--color-text-muted); transition: transform .2s cubic-bezier(.2,.8,.2,1), opacity 200ms var(--sb-ease, ease);
}
.sidebar-account[aria-expanded="true"] .sidebar-account-chevron { transform: rotate(180deg); }
@media (min-width: 961px) {
  /* The account row sits at the foot of the sidebar. */
  .sidebar-collapsible .sidebar-account { min-height: 40px; margin-top: auto; }
  :root[data-sidebar="collapsed"] .sidebar-collapsible .sidebar-account-chevron { opacity: 0; }
}
@media (max-width: 960px) {
  .sidebar .sidebar-account { margin: 0 0 0 auto; min-height: 36px; }
  .sidebar .sidebar-account .nav-label { display: none; }
}

.sidebar-menu {
  position: fixed; z-index: var(--layer-popover); min-width: 224px; max-width: calc(100vw - var(--space-4) * 2);
  padding: 6px; border-radius: 10px; border: var(--border-width) solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  box-shadow: var(--shadow-menu, var(--shadow-popover)), var(--shadow-popover);
  opacity: 0; transform: scale(.94) translateY(4px); transform-origin: bottom left;
  transition: opacity 120ms ease-out, transform 140ms cubic-bezier(.2,.8,.2,1);
}
.sidebar-menu.is-open { opacity: 1; transform: none; }
.sidebar-menu-head { display: flex; flex-direction: column; padding: 7px 10px 8px; line-height: 1.25; }
.sidebar-menu-name { font-size: var(--text-sm); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-menu-rule { margin: 5px 4px; border: 0; border-top: var(--border-width) solid var(--color-border); }
.sidebar-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px;
  border: 0; border-radius: 7px; background: transparent; color: var(--color-text);
  font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; white-space: nowrap;
  transition: background-color .1s, transform .1s cubic-bezier(.2,.8,.2,1);
}
.sidebar-menu-item .nav-icon { width: 16px; height: 16px; flex-basis: 16px; color: var(--color-text-muted); }
.sidebar-menu-item > span:not(.feature-log-dot) { flex: 1; }
.sidebar-menu-item:hover { background: var(--color-surface-muted); }
.sidebar-menu-item:hover .nav-icon { color: var(--color-text); }
.sidebar-menu-item:active { transform: scale(.98); background: var(--color-surface-hover); }
.sidebar-menu-item:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.sidebar-menu-item[aria-current="page"] { background: var(--color-surface-muted); font-weight: var(--weight-medium); }
.sidebar-menu-item[aria-current="page"] .nav-icon { color: var(--color-text); }
.sidebar-menu-spark { margin-left: auto; font-style: normal; font-size: 12px; color: var(--accent-2, var(--color-focus)); }
/* What's new keeps its launcher classes for feature-log.js; here it is one more row. */
.sidebar-menu .feature-log-launcher { justify-content: flex-start; gap: 10px; width: 100%; }
.sidebar-menu .feature-log-launcher .feature-log-label { flex: 1; }
.sidebar-menu .feature-log-launcher .feature-log-dot { flex: none; margin-left: auto; }
.sidebar-menu .feature-log-launcher[aria-expanded="true"] { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  .sidebar-menu { transform: none; transition: opacity 80ms; }
  .sidebar-account-chevron { transition: none; }
}

/* Workspace row and submenu (common.js builds them, sidebar.js opens the submenu).
   The first row of the account menu names the current workspace; its submenu lists
   every workspace and creates or manages one. */
.sidebar-menu-item > span.sidebar-ws-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar-menu-item > span.sidebar-ws-kind { flex: none; color: var(--color-text-muted); font-size: var(--text-xs); }
.sidebar-menu-chevron {
  width: 14px; height: 14px; flex: 0 0 14px; margin-right: -2px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  color: var(--color-text-muted);
}
.sidebar-ws-trigger[aria-expanded="true"] { background: var(--color-surface-muted); }
.sidebar-ws-trigger[aria-expanded="true"] .nav-icon, .sidebar-ws-trigger[aria-expanded="true"] .sidebar-menu-chevron { color: var(--color-text); }
.sidebar-submenu { min-width: 240px; max-width: min(320px, calc(100vw - 16px)); transform-origin: top left; }
.sidebar-ws-option .sidebar-ws-check { visibility: hidden; color: var(--color-text); }
.sidebar-ws-option[aria-checked="true"] .sidebar-ws-check { visibility: visible; }
.sidebar-ws-option[aria-checked="true"] .sidebar-ws-name { font-weight: var(--weight-medium); }

/* ==========================================================================
   New organization workspace (common.js openCreateWorkspace)
   A native <dialog>: the scrim fades, the card lifts in, the name previews as
   the workspace badge, and the primary button presses, spins, then checks.
   ========================================================================== */
.ws-dialog {
  width: min(440px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 0; background: transparent; color: var(--color-text); overflow: visible;
}
.ws-members-dialog { width: min(620px, calc(100vw - 32px)); }
.ws-members-dialog .ws-dialog-card { max-height: min(82dvh, 760px); overflow: auto; }
.ws-members-dialog .ws-member-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .7fr); gap: 12px; align-items: end; }
.ws-members-dialog .ws-member-form select { min-height: 44px; padding: 0 12px; border: var(--border-width) solid var(--color-border-strong); border-radius: 10px; background: var(--color-surface); color: var(--color-text); font: inherit; }
.ws-members-dialog .ws-member-form .ws-dialog-actions { grid-column: 1 / -1; margin-top: 0; }
.ws-member-list { display: grid; gap: 8px; max-height: 260px; margin-top: 10px; overflow: auto; }
.ws-member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: var(--border-width) solid var(--color-border); border-radius: 9px; background: var(--color-surface-muted); }
.ws-member-row code { min-width: 0; overflow-wrap: anywhere; color: var(--color-text-muted); font-size: var(--text-xs); }
@media (max-width: 560px) { .ws-members-dialog .ws-member-form { grid-template-columns: 1fr; } }
.ws-dialog::backdrop { background: var(--color-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.ws-dialog-card {
  display: flex; flex-direction: column; gap: 0;
  padding: 20px 22px 18px; border-radius: 14px;
  background: var(--color-surface); border: var(--border-width) solid var(--color-border);
  box-shadow: var(--shadow-dialog-inset), var(--shadow-modal);
}
.ws-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.ws-dialog-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  color: var(--color-warning-text); background: var(--color-warning-bg); box-shadow: inset 0 0 0 1px var(--color-warning-border);
}
.ws-dialog-mark svg, .ws-dialog-x svg, .ws-btn svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ws-dialog-mark svg { width: 18px; height: 18px; }
.ws-dialog-x {
  display: grid; place-items: center; width: 30px; height: 30px; margin: -4px -6px 0 0; padding: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--color-text-muted); cursor: pointer;
  transition: background-color .12s, color .12s, transform .12s cubic-bezier(.2,.8,.2,1);
}
.ws-dialog-x svg { width: 16px; height: 16px; }
.ws-dialog-x:hover { background: var(--color-surface-muted); color: var(--color-text); }
.ws-dialog-x:active { transform: scale(.9); }
.ws-dialog h2 { margin: 0 0 6px; font-size: var(--text-lg); font-weight: var(--weight-semibold); letter-spacing: -.01em; }
.ws-dialog-lead { margin: 0 0 18px; color: var(--color-text-muted); font-size: var(--text-sm); line-height: 1.5; }

.ws-field { display: flex; flex-direction: column; gap: 7px; }
.ws-field-label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.ws-field-box {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px 0 8px;
  border: var(--border-width) solid var(--color-border-strong); border-radius: 10px; background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
}
.ws-field-box:hover { border-color: var(--color-text-muted); }
.ws-field-box:focus-within { border-color: var(--color-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-focus) 22%, transparent); }
.ws-field-box:has(input[aria-invalid="true"]) { border-color: var(--color-sensitive-border); box-shadow: 0 0 0 3px var(--color-sensitive-bg); }
/* The box draws the field; the input inside stays bare (overrides the shared input styles). */
.ws-dialog .ws-field-box input[type="text"], .ws-dialog .ws-field-box input[type="text"]:focus, .ws-dialog .ws-field-box input[type="text"]:hover {
  flex: 1; width: auto; min-width: 0; height: 42px; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: 0; outline: 0; box-shadow: none; background: transparent;
  color: var(--color-text); font: inherit; font-size: var(--text-base);
}
.ws-dialog .ws-field-box input[type="text"]:read-only { color: var(--color-text-muted); }
.ws-field-box input::placeholder { color: var(--color-text-muted); opacity: .7; }
.ws-preview {
  display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px;
  color: var(--color-text-muted); background: var(--color-surface-muted); box-shadow: inset 0 0 0 1px var(--color-border);
  font-size: 12px; font-weight: var(--weight-semibold);
  transition: color .2s, background-color .2s, box-shadow .2s, transform .25s cubic-bezier(.34,1.56,.64,1);
}
.ws-preview.is-set {
  color: var(--color-warning-text); background: var(--color-warning-bg); box-shadow: inset 0 0 0 1px var(--color-warning-border);
  animation: ws-pop .28s cubic-bezier(.34,1.56,.64,1);
}
.ws-count { flex: none; color: var(--color-text-muted); font-size: 11px; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .15s; }
.ws-field-box:focus-within .ws-count { opacity: .8; }
.ws-count.is-near { color: var(--color-warning-text); opacity: 1; }
.ws-hint { min-height: 18px; margin: 7px 0 0; font-size: var(--text-xs); line-height: 1.4; color: var(--color-text-muted); }
.ws-hint[data-tone="warn"] { color: var(--color-warning-text); }
.ws-hint[data-tone="error"] { color: var(--color-sensitive-text); }
.ws-hint[data-tone="ok"] { color: var(--assure); }

.ws-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.ws-btn {
  position: relative; display: inline-grid; place-items: center; min-height: 40px; padding: 0 16px;
  border-radius: 10px; font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .16s cubic-bezier(.2,.8,.2,1), opacity .15s;
}
.ws-btn > * { grid-area: 1 / 1; }
.ws-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.ws-btn:active:not(:disabled) { transform: scale(.96); transition-duration: .06s; }
.ws-btn-quiet { border: var(--border-width) solid var(--color-border); background: var(--color-surface); color: var(--color-text); }
.ws-btn-quiet:hover { background: var(--color-surface-muted); border-color: var(--color-border-strong); }
.ws-btn-go {
  min-width: 168px; border: var(--border-width) solid var(--color-action); background: var(--color-action); color: var(--color-on-action);
  box-shadow: var(--shadow-action-inset), var(--shadow-action-rest);
}
.ws-btn-go:hover:not(:disabled) { background: var(--color-action-hover); border-color: var(--color-action-hover); box-shadow: var(--shadow-action-inset), var(--shadow-action-hover); }
.ws-btn-go:active:not(:disabled) { box-shadow: var(--shadow-press-strong); }
.ws-btn-go:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.ws-btn-go[data-state] { opacity: 1; cursor: progress; }
.ws-btn-face { display: inline-flex; align-items: center; gap: 8px; transition: opacity .15s, transform .2s cubic-bezier(.2,.8,.2,1); }
.ws-btn-arrow { width: 14px; height: 14px; transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.ws-btn-go:hover:not(:disabled) .ws-btn-arrow { transform: translateX(2px); }
.ws-btn-spin {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  opacity: 0; transform: scale(.6); transition: opacity .15s, transform .2s;
}
.ws-btn-done { width: 18px; height: 18px; stroke-width: 2; stroke-dasharray: 16; stroke-dashoffset: 16; opacity: 0; }
.ws-btn-go[data-state="busy"] .ws-btn-face { opacity: 0; transform: translateY(-4px); }
.ws-btn-go[data-state="busy"] .ws-btn-spin { opacity: 1; transform: none; animation: settings-spin .7s linear infinite; }
.ws-btn-go[data-state="done"] { background: var(--assure); border-color: var(--assure); color: var(--color-solid-white); }
.ws-btn-go[data-state="done"] .ws-btn-face { opacity: 0; }
.ws-btn-go[data-state="done"] .ws-btn-done { opacity: 1; animation: ws-check .32s .05s cubic-bezier(.65,0,.35,1) forwards; }

.ws-dialog[open] .ws-dialog-card { animation: g-dialog-in .24s cubic-bezier(.2,.8,.2,1) both; }
.ws-dialog[open]::backdrop { animation: g-scrim-in .18s ease-out both; }
.ws-dialog.is-closing .ws-dialog-card { animation: ws-out .15s ease-in both; }
.ws-dialog.is-closing::backdrop { animation: ws-fade-out .15s ease-in both; }
.ws-dialog-card.shake { animation: g-shake .32s cubic-bezier(.36,.07,.19,.97); }
@keyframes ws-pop { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
@keyframes ws-check { to { stroke-dashoffset: 0; } }
@keyframes ws-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes ws-fade-out { to { opacity: 0; } }
@media (max-width: 480px) {
  .ws-dialog { margin: auto auto 12px; }
  .ws-dialog-actions { flex-direction: column-reverse; }
  .ws-btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ws-dialog *, .ws-dialog::backdrop, .ws-dialog[open] .ws-dialog-card { animation: none !important; transition: none !important; }
  .ws-btn-go[data-state="busy"] .ws-btn-spin { animation: settings-spin 1.4s linear infinite !important; }
  .ws-btn-go[data-state="done"] .ws-btn-done { stroke-dashoffset: 0; }
}
