/* Fonts are served from this app (public/fonts), never from a third party.
   Run scripts/fetch-fonts.sh once to add the files; until then the system fonts below are used. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
}

/* Design tokens, shared with the landing page (issue #23).
   Phase 0 only adds tokens and remaps the original names below; later phases move rules onto them. */
:root {
  /* Neutrals ("ink", warm stone) */
  --ink-50: #fafaf9;
  --ink-100: #f5f5f4;
  --ink-200: #e7e5e4;
  --ink-300: #d6d3d1;
  --ink-400: #a8a29e; /* decorative only: below AA for text */
  --ink-500: #78716c; /* large text only on white (4.8:1) */
  --ink-600: #57534e; /* smallest text colour allowed: 7.6:1 on white, 7.3:1 on ink-50 */
  --ink-700: #44403c;
  --ink-800: #292524;
  --ink-900: #1c1917;

  /* Accent (indigo) */
  --accent-50: #eef2ff;
  --accent-100: #e0e7ff;
  --accent-200: #c7d2fe;
  --accent-300: #a5b4fc;
  --accent-500: #6366f1;
  --accent-600: #4f46e5; /* 6.3:1 on white; white text on it 6.3:1 */
  --accent-700: #4338ca;

  /* Status (text-safe 700s on light 50s) */
  --white: #fff;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-200: #fecaca;
  --danger-600: #dc2626;
  --danger-700: #b91c1c; /* 6.5:1 on white */
  --danger-800: #991b1b; /* 6.8:1 on danger-100 */
  --warn-50: #fffbeb;
  --warn-100: #fef3c7;
  --warn-200: #fde68a;
  --warn-600: #d97706;
  --warn-700: #b45309; /* 5.0:1 on white */
  --warn-800: #92400e; /* 6.4:1 on warn-100, 5.7:1 on warn-200 */
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --success-600: #16a34a;
  --success-700: #15803d; /* 5.0:1 on white */
  --success-800: #166534; /* 6.5:1 on success-100 */

  /* Type */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", var(--font-mono);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 1px 2px rgba(28, 25, 23, 0.05), 0 4px 16px -8px rgba(28, 25, 23, 0.12);
  --ring: 0 0 0 3px var(--accent-100);
  --shadow-xl: 0 20px 25px -5px rgba(28, 25, 23, 0.05), 0 8px 10px -6px rgba(28, 25, 23, 0.05);

  /* Spacing (4px scale) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Original names, remapped onto the tokens */
  --bg: var(--ink-50);
  --ink: var(--ink-900);
  --muted: var(--ink-600);
  --line: var(--ink-200);
  --panel: #fff;
  --accent: var(--accent-600);
  --danger: var(--danger-700);
  --focus: var(--accent-600);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent); text-underline-offset: 0.15em; text-decoration-thickness: from-font; }
a:hover { color: var(--accent-700); }

/* One focus treatment for everything; a few rules below inset it (-2px) where an outer ring would clip. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.875em; }
:not(pre) > code { background: var(--ink-100); border-radius: var(--radius-sm); padding: 0.1em 0.35em; color: var(--ink-800); }
pre { background: var(--ink-50); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); overflow-x: auto; line-height: 1.6; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* Publisher split shell: libraries left, work surface right.
   Lock the shell to the viewport so main scrolls and the sidebar stays put. */
.app-body {
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.app-body > .nav {
  flex: 0 0 auto;
  position: static;
}
.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(15rem, 17.5rem) minmax(0, 1fr);
  overflow: hidden;
}
.lib-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--ink-50);
  font-family: var(--font-sans);
  min-height: 0;
  overflow: hidden;
}
.sidebar-head {
  flex: 0 0 auto;
  padding: 0.65rem 0.65rem 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
}
.sidebar-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
}
.sidebar-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}
.sidebar-title a {
  color: inherit;
  text-decoration: none;
}
.sidebar-title a:hover { color: var(--accent); }
.sidebar-add-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink-700);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
}
.sidebar-add-link:hover {
  border-color: var(--ink-400);
  background: var(--ink-50);
  color: var(--ink-900);
}
.sidebar-add-link.is-active {
  border-color: var(--ink-900);
  background: var(--ink-900);
  color: var(--white);
}
.add-library-form { max-width: 36rem; }
.add-library-form .btn { margin-top: 1.25rem; }
/* Section titles: Library name, Data schema, Write settings */
.add-library-form > label {
  margin: 0.35rem 0 0;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.add-library-form .schema-choices {
  margin-top: 1.75rem;
}
.add-library-form .schema-choices legend {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.7rem;
}
.schema-choices {
  border: 0;
  margin: 0.15rem 0 0;
  padding: 0;
  min-width: 0;
}
.schema-choices legend {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 650;
  padding: 0;
  margin-bottom: 0.45rem;
}
/* Schema: segmented control + one detail panel under it */
.schema-segments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink-100);
}
.schema-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 0.55rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-600);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
  text-align: center;
  cursor: pointer;
}
.schema-segment:hover { color: var(--ink-900); }
.schema-segment-radio {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.schema-segment:has(.schema-segment-radio:checked) {
  background: var(--ink-900);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.schema-segment:has(.schema-segment-radio:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  z-index: 1;
}
.schema-segment-label { pointer-events: none; }
.schema-detail-panel {
  margin-top: 0.85rem;
  padding: 0.85rem 0 0.15rem;
  border-top: 1px solid var(--line);
}
.schema-detail { display: none; }
.schema-choices-segmented:has(#schema-general:checked) .schema-detail-general,
.schema-choices-segmented:has(#schema-policy:checked) .schema-detail-policy,
.schema-choices-segmented:has(#schema-procedure:checked) .schema-detail-procedure,
.schema-choices-segmented:has(#schema-custom:checked) .schema-detail-custom {
  display: block;
}
.schema-choices-segmented .schema-fields { display: block; }
.schema-blurb-guide {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
}
.schema-prompt-label {
  margin: 0.85rem 0 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}
.schema-prompt-label .hint { font-weight: 450; margin-left: 0.35rem; }
.custom-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(6.5rem, 0.7fr) minmax(5.5rem, 0.55fr) auto;
  gap: 0.5rem;
  align-items: end;
  margin-top: 0.65rem;
}
.custom-field-row label {
  margin: 0;
  font-size: 0.8rem;
}
.custom-fields .btn { margin-top: 0.75rem; }
.custom-field-remove.btn {
  margin-top: 0;
  min-height: 44px;
}
.custom-field-add:disabled { opacity: 0.45; cursor: not-allowed; }
@media (max-width: 640px) {
  .custom-field-row { grid-template-columns: 1fr 1fr; }
  .custom-field-label { grid-column: 1 / -1; }
  .custom-field-remove { grid-column: 1 / -1; }
}
/* Write mode: stacked radios (unchanged interaction) */
.schema-option {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr);
  column-gap: 0.45rem;
  align-items: center;
  margin: 0.2rem 0;
  padding: 0.1rem 0.35rem 0.35rem;
  border: 1px solid transparent;
  border-radius: 8px;
}
.schema-option:has(.schema-radio:checked) {
  border-color: var(--line);
  background: var(--ink-100);
}
.write-mode-choices .schema-radio {
  grid-column: 1;
  grid-row: 1;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
}
.add-library-form .write-mode-choices .schema-option label {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  min-height: 44px;
  margin: 0;
  font-size: 0.9rem;
  cursor: pointer;
}
.write-mode-choices .schema-blurb,
.write-mode-choices .schema-fields { grid-column: 1 / -1; }
.schema-blurb {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 450;
  line-height: 1.45;
  color: var(--muted);
}
.schema-fields {
  display: none;
  list-style: none;
  max-height: 14rem;
  overflow: auto;
  margin: 0.65rem 0 0;
  padding: 0;
}
.schema-option:has(.schema-radio:checked) .schema-fields { display: block; }
.schema-fields li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.35;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.schema-field-name { font-weight: 600; color: var(--muted); }
.schema-field-req {
  color: var(--ink-600); /* was a 78% tint of --muted: 4.1:1, below AA */
  font-weight: 450;
  flex-shrink: 0;
}
.write-mode-choices { margin-top: 1.75rem; }
/* On/off switch between Review Lock and Review Unlock (right of library tabs). */
.write-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-family: var(--font-sans);
}
.write-mode-toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.write-mode-toggle-label.is-current { color: var(--ink); }
.write-mode-toggle-btn {
  position: relative;
  width: 2.75rem;
  height: 1.55rem;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--ink-500);
  border-radius: var(--radius-full);
  background: var(--ink-500); /* off track 4.8:1 against white: meets 3:1 for UI components */
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.25s var(--ease-out), border-color 0.25s var(--ease-out);
}
.write-mode-toggle-btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
}
.write-mode-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.55rem - 6px);
  height: calc(1.55rem - 6px);
  border-radius: var(--radius-full);
  background: var(--white);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.25);
  transition: transform 0.25s var(--ease-out);
}
.write-mode-toggle-btn.is-on .write-mode-toggle-knob {
  transform: translateX(1.15rem);
}
@media (prefers-reduced-motion: reduce) {
  .write-mode-toggle-btn,
  .write-mode-toggle-knob { transition: none; }
}
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.5rem 0.55rem 1.25rem;
}
.sidebar-libs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sidebar-lib-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.15rem;
}
.sidebar-lib-row.is-active .sidebar-lib,
.sidebar-lib.is-active {
  background: var(--white);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px var(--ink-200), var(--shadow-sm);
}
.sidebar-lib-row.is-active .sidebar-lib-name,
.sidebar-lib.is-active .sidebar-lib-name { color: var(--ink-900); }
.sidebar-lib {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-700);
  min-height: 44px;
  transition: background-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out);
}
.sidebar-lib-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.sidebar-lib-count {
  flex: 0 0 auto;
  align-self: center;
  min-width: 1.5rem;
  padding: 0.15rem 0.35rem;
  color: var(--ink-600);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sidebar-lib:hover { background: var(--ink-100); color: var(--ink-900); }
.sidebar-pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.55rem;
  border-radius: 8px;
  background: var(--warn-100);
  color: var(--warn-800);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
}
.sidebar-pending:hover { background: var(--warn-200); }
.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  margin: 0.85rem 0.35rem 0.15rem;
}
.sidebar-section-head .sidebar-section-label { margin: 0; }
.sidebar-shelf-add {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.15rem;
}
.sidebar-shelf-add.is-active { text-decoration: underline; }
.sidebar-shelf-section .sidebar-shelf-link { margin: 0 0 0.2rem; }
.sidebar-shelf-empty {
  margin: 0 0.7rem 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.shelf-libraries-heading {
  margin: 0.25rem 0 0.35rem;
  font-size: 1rem;
}
.shelf-libraries {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.shelf-libraries li { margin: 0.2rem 0; }
.sidebar-lib-name {
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.3;
  word-break: break-word;
}
.sidebar-lib-meta {
  font-size: 0.75rem;
  color: var(--ink-600);
  font-weight: 400;
}
.sidebar-empty {
  margin: 0.75rem 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
/* Pinned account strip + Settings cog under the library list. */
.sidebar-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border-top: 1px solid var(--line);
  background: var(--ink-50);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}
.sidebar-user-avatar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}
.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  line-height: 1.2;
}
.sidebar-settings {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--muted);
  text-decoration: none;
}
.sidebar-settings:hover {
  border-color: var(--ink-400);
  color: var(--ink-900);
  background: var(--white);
}
.sidebar-settings.is-active {
  border-color: var(--ink-900);
  background: var(--ink-900);
  color: var(--white);
}
.sidebar-settings:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.sidebar-section-label {
  margin: 1rem 0.5rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-orphans { margin-top: 0.35rem; }
.app-main {
  min-width: 0;
  min-height: 0;
  padding: 1.35rem 1.5rem 3.5rem;
  overflow: auto;
}
.empty-pane {
  max-width: 28rem;
  padding: 1.5rem 0.25rem 2rem;
}
.empty-pane h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.empty-pane-lead {
  margin: 0.5rem 0 0;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink);
}
.empty-pane-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
/* First-run empty state: one centered stack, CTA near the lead. */
.empty-pane-start {
  box-sizing: border-box;
  width: min(22rem, 100%);
  max-width: 22rem;
  min-height: min(28rem, calc(100dvh - 8rem));
  margin: 0 auto;
  padding: 2.5rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
}
.empty-pane-start h1 { font-size: 1.85rem; }
.empty-pane-start .empty-pane-lead { margin-top: 0.65rem; }
.empty-pane-start .empty-action {
  margin: 1.35rem 0 0;
}
.empty-pane-start .empty-pane-note {
  margin-top: 1.1rem;
  max-width: 20rem;
}
.home-pane { max-width: 36rem; }
.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}
.home-head h1 { margin: 0; }
.home-actions { margin: 0; }
.home-idle { align-items: flex-start; }
.home-kicker {
  margin: 0 0 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.home-idle h1 {
  font-size: clamp(1.65rem, 3vw, 2rem);
  max-width: 18ch;
}
.home-idle .empty-pane-lead {
  max-width: 28rem;
  color: var(--muted);
}
.home-idle .empty-action { margin-top: 1.5rem; }
.home-idle .empty-pane-note { margin-top: 1rem; }
.nav-context {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-left: 0.9rem;
  border-left: 1px solid var(--line);
}
.nav-context .nav-muted,
.nav-context .nav-current {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-muted { color: var(--ink-600); font-size: 0.875rem; font-weight: 500; }
.nav-context .nav-muted { font-size: 0.85rem; }
/* MCP link sits in the library header, beside Add item. */
.mcp-menu { position: relative; }
.mcp-menu > summary::-webkit-details-marker,
.item-menu > summary::-webkit-details-marker { display: none; }
.text-summary {
  list-style: none;
  cursor: pointer;
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.9rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-800);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.text-summary:hover { background: var(--ink-50); border-color: var(--ink-400); color: var(--ink-900); }
.mcp-menu[open] > .text-summary { background: var(--accent-50); border-color: var(--accent-300); color: var(--accent-700); }
.icon-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-700);
  box-shadow: var(--shadow-sm);
}
.icon-summary:hover { background: var(--ink-100); }
.item-menu[open] > .icon-summary { background: var(--accent-50); border-color: var(--accent-300); color: var(--accent-700); }
.icon-summary-svg { display: block; }
.mcp-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 4;
  width: min(26rem, calc(100vw - 2.5rem));
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(28, 25, 23, 0.02);
  overflow: hidden;
  font-family: var(--font-sans);
}
.mcp-panel-head {
  padding: 1rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--ink-50) 0%, var(--panel) 100%);
}
.mcp-panel-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.mcp-panel-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}
.mcp-panel-lead {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--muted);
}
.mcp-link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.95rem 1.15rem;
}
.mcp-link {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 55%, var(--white));
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  user-select: all;
}
.mcp-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.mcp-copy {
  flex: 0 0 auto;
  min-width: 5.25rem;
  justify-content: center;
}
.mcp-copy.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
}
.mcp-panel-note {
  margin: 0;
  padding: 0.7rem 1.15rem 0.95rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}
.mcp-panel-wide { width: min(34rem, calc(100vw - 2.5rem)); }
.reader-key-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem 0.15rem;
}
.reader-key-actions form { margin: 0; }
.reader-key-config {
  margin: 0 1.15rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 55%, var(--white));
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}
/* Desktop: the drawer box disappears and the sidebar is the first column. */
.lib-drawer { display: contents; }
.lib-nav-toggle,
.lib-nav-label { display: none; }
@media (max-width: 840px) {
  /* Phone: one column — page scroll is fine; drawer overlays the list. */
  .app-body {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .app-body > .nav { position: sticky; }
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    overflow: visible;
  }
  .lib-drawer { display: block; }
  .lib-nav-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .lib-nav-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 88%, var(--white));
    font-family: var(--font-sans);
    cursor: pointer;
  }
  .lib-nav-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .lib-nav-current {
    font-weight: 650;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .lib-nav-action {
    margin-left: auto;
    color: var(--accent);
    font-weight: 650;
    flex-shrink: 0;
  }
  .lib-nav-hide { display: none; }
  .lib-nav-toggle:checked + .lib-nav-label .lib-nav-show { display: none; }
  .lib-nav-toggle:checked + .lib-nav-label .lib-nav-hide { display: inline; }
  .lib-nav-toggle:focus-visible + .lib-nav-label {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
  }
  .lib-sidebar {
    display: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 70vh;
    overflow: auto;
  }
  .lib-nav-toggle:checked ~ .lib-sidebar { display: flex; }
  .app-main { padding: 1.15rem 1.1rem 3rem; }
}
/* Sign-in, consent and first-run pages: the landing hero (grid wash, centred card). CSS only. */
.sign-in {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-12) var(--space-5);
  background: var(--white);
  font-family: var(--font-sans);
}
.sign-in::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(28, 25, 23, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(28, 25, 23, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}
.sign-in-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  color: var(--ink-900);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sign-in-brand .brand-mark { width: 2rem; height: 2rem; }
.sign-in .panel {
  width: min(28rem, 100%);
  margin: 0;
  padding: var(--space-8);
  border-color: var(--ink-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(28, 25, 23, 0.02);
  animation: sign-in-rise 0.6s var(--ease-out) both;
}
.sign-in .panel h1 { margin: 0 0 var(--space-2); font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.035em; text-align: center; }
.sign-in .panel > .hint { text-align: center; font-size: 0.9rem; line-height: 1.55; }
.sign-in .panel > .hint code { word-break: break-all; }
.sign-in form { margin-top: var(--space-5); }
.sign-in form .btn { width: 100%; min-height: 2.75rem; margin-top: var(--space-3); font-size: 0.9rem; }
.sign-in form .btn + .btn { margin-top: var(--space-2); }
.sign-in .error { padding: 0.65rem 0.85rem; border: 1px solid var(--danger-200); border-radius: var(--radius); background: var(--danger-50); color: var(--danger-800); font-size: 0.9rem; }
@keyframes sign-in-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sign-in .panel { animation: none; }
}
.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
  padding: 0.65rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.03);
  font-family: var(--font-sans);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}
.nav .brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-900);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-decoration: none;
}
.nav .brand:hover { color: var(--ink-900); }
.brand-mark { display: block; width: 1.75rem; height: 1.75rem; flex: 0 0 auto; transition: transform 0.3s var(--ease-out); }
.nav .brand:hover .brand-mark { transform: scale(0.94); }
.nav-trail {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
}
.nav-link {
  color: var(--ink-600);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.35rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s var(--ease-out);
  white-space: nowrap;
}
.nav-link:hover { color: var(--ink-900); }
.nav-current {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-sep {
  color: var(--ink-400); /* decorative, aria-hidden */
  font-weight: 450;
  user-select: none;
}
.nav-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 0 0 auto;
}
.nav-role {
  color: var(--ink-600);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.nav-signout {
  color: var(--ink-800);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.nav-signout:hover {
  border-color: var(--ink-400);
  background: var(--ink-50);
  color: var(--ink-900);
}
h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; letter-spacing: -0.025em; color: var(--ink-900); text-wrap: balance; }
h1 { letter-spacing: -0.035em; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-6); margin-bottom: var(--space-8); box-shadow: var(--shadow-sm); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.75rem 0; font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500; color: var(--ink-800); }
input, textarea, select { font: inherit; font-weight: 400; color: var(--ink); padding: 0.55rem 0.75rem; border: 1px solid var(--ink-300); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow-sm); transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out); }
input::placeholder, textarea::placeholder { color: var(--ink-500); }
input:hover, textarea:hover, select:hover { border-color: var(--ink-400); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--shadow-sm), var(--ring); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
input:disabled, textarea:disabled, select:disabled { background: var(--ink-100); color: var(--ink-600); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { box-shadow: none; accent-color: var(--accent); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-lg); }
legend { font-family: var(--font-sans); font-weight: 600; color: var(--ink-800); padding: 0 0.35rem; }
@media (prefers-reduced-motion: reduce) { input, textarea, select { transition: none; } }
/* Checkboxes and radios draw no border ring, so keep the outline for keyboard focus. */
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
dl.details { display: grid; gap: 0.35rem; margin: 0.75rem 0 1rem; }
dl.details div { display: grid; grid-template-columns: 11rem 1fr; gap: 0.75rem; }
dl.details dt { color: var(--muted); }
fieldset.policy-group { border: 1px solid var(--line); border-radius: 10px; margin: 1.25rem 0; padding: 0.35rem 1rem 0.85rem; }
fieldset.policy-group legend { font-family: var(--font-sans); font-weight: 650; padding: 0 0.35rem; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; min-height: 16rem; }
.editor textarea, .preview { min-height: 16rem; }
.section-data .editor textarea, .section-data .preview { min-height: 22rem; }
.preview { border: 1px dashed var(--line); border-radius: 8px; padding: 0.75rem; overflow: auto; background: var(--white); font-weight: 400; }
/* Buttons: primary is ink-900 like the landing page; indigo stays the link/focus/selection colour. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 2.5rem; padding: 0.5rem 1rem;
  background: var(--ink-900); color: var(--white);
  border: 1px solid var(--ink-900); border-radius: var(--radius);
  font-family: var(--font-sans); font-size: 0.875rem; font-weight: 500; line-height: 1.25;
  cursor: pointer; text-decoration: none; box-shadow: var(--shadow-sm);
  transition: background-color 0.15s var(--ease-out), border-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
.btn:hover { background: var(--ink-800); border-color: var(--ink-800); color: var(--white); }
.btn:active { background: var(--ink-700); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--white); color: var(--ink-800); border-color: var(--ink-300); }
.btn.secondary:hover { background: var(--ink-50); border-color: var(--ink-400); color: var(--ink-900); }
.btn.ghost { background: transparent; color: var(--ink-700); border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn.danger { background: var(--danger-700); border-color: var(--danger-700); }
.btn.danger:hover { background: var(--danger-800); border-color: var(--danger-800); }
.btn.danger-ghost { background: var(--white); color: var(--danger-700); border-color: var(--danger-200); }
.btn.danger-ghost:hover { background: var(--danger-50); border-color: var(--danger-700); color: var(--danger-800); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }
.cards { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.cards a { display: block; padding: 0.9rem 0.35rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 44px; }
.cards a { transition: background-color 0.15s var(--ease-out); }
.cards a:hover { background: var(--ink-50); }
.cards h2 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.excerpt { color: var(--muted); }
.tag { display: inline-block; margin-right: 0.35rem; padding: 0.05rem 0.5rem; border: 1px solid var(--ink-200); border-radius: var(--radius-full); background: var(--ink-50); color: var(--ink-700); font-size: 0.75rem; font-weight: 500; font-family: var(--font-sans); }
.error { color: var(--danger); }
.empty, .hint { color: var(--muted); }
.hint code { font-size: 0.85em; word-break: break-all; }
.actions { display: flex; gap: 0.75rem; align-items: center; }
.inline { display: inline; }
.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search input { flex: 1; }
.prose :first-child { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.sheet-wrap { margin: 0.85rem 0 1rem; overflow: auto; }
.sheet-label { margin: 0 0 0.25rem; font-family: var(--font-sans); font-weight: 650; }
.section { margin: 0.5rem 0 0.25rem; }
.sheet-wrap .jss_container,
.sheet-wrap .jexcel_container,
.sheet-wrap .jexcel { font-family: var(--font-sans); }
.sheet-wrap .preview,
.table-block .preview { margin-top: 0.75rem; min-height: 8rem; }
.prose table, .preview table { width: 100%; border-collapse: collapse; }
.prose table, .preview table { border: 1px solid var(--line); border-radius: var(--radius-lg); border-collapse: separate; border-spacing: 0; overflow: hidden; font-size: 0.875rem; }
.prose th, .prose td, .preview th, .preview td { border-bottom: 1px solid var(--ink-100); padding: 0.6rem 0.85rem; text-align: left; vertical-align: top; }
.prose tr:last-child td, .preview tr:last-child td { border-bottom: 0; }
.prose thead, .preview thead { background: var(--ink-50); }
.prose th, .preview th { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-600); border-bottom-color: var(--line); }
.library-view {
  font-family: var(--font-sans);
}
.library-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  margin: 0.15rem 0 0.85rem;
}
.library-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1rem;
  min-width: 0;
}
.library-head-row h1 {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-head > h1,
.library-head > div:first-child:not(.library-head-row) h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 650;
}
.library-head .head-actions {
  flex: 0 0 auto;
  align-items: center;
}
/* Match Actions (36×36). Sidebar Add library (+) stays 28px on purpose. */
.head-actions .btn,
.library-view .head-actions .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.library-access { margin: 0; }
.library-access h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 650;
}
.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 1rem;
  margin: 0 0 1.15rem;
  border-bottom: 1px solid var(--line);
}
.library-tabs {
  display: flex;
  gap: 0.15rem;
  margin: 0;
  border-bottom: none;
  overflow-x: auto;
  min-width: 0;
  flex: 1 1 auto;
  font-family: var(--font-sans);
}
.library-toolbar .write-mode-toggle {
  flex: 0 0 auto;
  align-self: center;
  padding-bottom: 0.35rem;
}
.library-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.35rem 0.85rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-600);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.library-tabs a:hover { color: var(--ink); }
.library-tabs a:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.library-tabs a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.tab-count {
  min-width: 1.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
}
.tab-count-pending { background: var(--warn-100); color: var(--warn-800); }
.tab-count-archive { background: var(--ink-100); color: var(--ink-600); }
.library-tab-hint { margin: 0 0 0.85rem; }
/* Accounts — standard users admin surface */
.users-page {
  font-family: var(--font-sans);
  width: 100%;
  max-width: none;
}
.users-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin: 0.15rem 0 1.35rem;
}
.users-head-copy {
  min-width: 0;
  flex: 1 1 18rem;
}
.users-head h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 650;
}
.users-head .hint {
  margin: 0.45rem 0 0;
  max-width: 40rem;
}
.users-add {
  margin: 0;
  flex: 0 0 auto;
}
.users-add[open] {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.85rem 1rem;
}
.users-add > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-self: end;
}
.users-add > summary::-webkit-details-marker { display: none; }
.users-add[open] > summary {
  grid-column: 2;
}
.users-add-form {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.15rem 1.25rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.users-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.95rem 1.15rem;
  margin-bottom: 0.95rem;
}
.users-add-form .btn { margin-top: 0.25rem; }
.users-external { max-width: 36rem; }
.users-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.users-panel-head {
  display: none;
}
.users-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.user-row {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr) auto auto;
  grid-template-areas:
    "avatar identity role status"
    "actions actions actions actions";
  align-items: center;
  gap: 0.65rem 0.85rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: none; }
.user-row.is-disabled {
  background: color-mix(in srgb, var(--panel) 88%, var(--ink-100));
}
.user-avatar {
  grid-area: avatar;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--white));
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}
.user-identity {
  grid-area: identity;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}
.user-name {
  font-weight: 650;
  font-size: 1.05rem;
  color: var(--ink);
  word-break: break-word;
}
.user-you {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.user-badge-on { grid-area: status; background: var(--success-50); color: var(--success-800); box-shadow: inset 0 0 0 1px var(--success-100); }
.user-badge-off { grid-area: status; background: var(--warn-50); color: var(--warn-800); box-shadow: inset 0 0 0 1px var(--warn-200); }
.user-sa {
  grid-area: role;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.user-sa-form { margin: 0; }
.user-sa .write-mode-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.user-sa-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 1.75rem;
}
.user-sa-label.is-on { color: var(--accent); }
.users-sa-opt {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.35rem 0 0.25rem;
  font-weight: 600;
  cursor: pointer;
}
.users-sa-opt input {
  width: auto;
  margin: 0.2rem 0 0;
  flex: 0 0 auto;
}
.users-sa-hint {
  margin: 0 0 0.85rem;
  max-width: 36rem;
}
.user-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}
.user-actions .btn,
.user-reset > summary.btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.9rem;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.user-reset { position: relative; }
.user-reset > summary { list-style: none; cursor: pointer; }
.user-reset > summary::-webkit-details-marker { display: none; }
.user-reset-form {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 3;
  width: min(18rem, calc(100vw - 3rem));
  margin: 0;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(28, 25, 23, 0.1);
}
.users-empty {
  padding: 1.5rem 0;
}
@media (min-width: 840px) {
  .users-panel-head {
    display: grid;
    grid-template-columns: 2.75rem minmax(10rem, 2fr) 7.5rem 7.5rem auto;
    gap: 1rem 1.25rem;
    align-items: center;
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 70%, var(--ink-100));
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .users-col-user { grid-column: 1 / 3; }
  .users-col-actions { text-align: right; }
  .user-row {
    grid-template-columns: 2.75rem minmax(10rem, 2fr) 7.5rem 7.5rem auto;
    grid-template-areas: "avatar identity role status actions";
    gap: 1rem 1.25rem;
    padding: 1.05rem 1.25rem;
  }
  .user-actions {
    flex-wrap: nowrap;
  }
}
.access-list {
  list-style: none;
  margin: 0.75rem 0 1rem;
  padding: 0;
  max-width: 36rem;
}
.access-list li,
.access-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.access-person-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.access-person-name {
  font-weight: 600;
  font-family: var(--font-sans);
}
.access-person-role {
  color: var(--muted);
  font-size: 0.9rem;
  font-family: var(--font-sans);
}
.access-person-detail {
  font-size: 0.85rem;
  word-break: break-all;
}
.access-person-detail code {
  font-size: 0.85em;
}
.access-list form.access-remove {
  margin: 0;
  flex: 0 0 auto;
}
.access-remove .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
}
.viewer-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 0.35rem;
  font-family: var(--font-sans);
}
.viewer-sub .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
}
button.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.cards .meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.kicker {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.library-view .search {
  margin: 0 0 1.25rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.15rem 0.15rem 0.15rem 0.35rem;
}
.library-view .search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.library-view .search input {
  border: 0;
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
}
.library-view .search input:focus { outline: none; box-shadow: none; }
.search-meta {
  margin: -0.35rem 0 1rem;
  color: var(--muted);
  font-family: var(--font-sans);
}
.search-meta a { font-weight: 650; }
.empty-block { margin: 0.35rem 0 1rem; }
.empty-action { margin: 0.75rem 0 0; }
.empty-action .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.library-view .search button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-sans);
  font-weight: 650;
  min-height: 44px;
  padding: 0 1rem;
  cursor: pointer;
}
.head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}
.back { margin: 0 0 1rem; }
.back a { text-decoration: none; font-family: var(--font-sans); font-weight: 650; }
.item-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
}
.item-head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 36px;
}
.item-head-start {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.item-head-start .back { margin: 0; flex-shrink: 0; }
/* Match Actions (.icon-summary): same height, border, fill, and hover. */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent);
  text-decoration: none;
}
.back-btn-icon { display: block; }
.back-btn:hover { background: var(--ink-100); }
.item-head h1 { margin: 0.15rem 0 0; }
.item-files {
  margin-top: 2rem;
  font-family: var(--font-sans);
}
.item-files h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}
.item-file-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}
.item-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
.item-file-name {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
}
.item-file-name a { font-weight: 650; }
.item-file-meta { color: var(--muted); font-size: 0.9rem; }
.item-file form { margin: 0; flex: 0 0 auto; }
.file-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}
.file-pick {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 650;
}
.file-pick input[type="file"] { font: inherit; font-weight: 450; max-width: 100%; }
.lead { margin: 0.35rem 0 0; font-size: 1.15rem; }
.item-menu { position: relative; }
.item-menu > .icon-summary { background: var(--panel); }
.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 2;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.menu-list a, .menu-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-family: var(--font-sans);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.menu-list a:hover, .menu-list button:hover { background: var(--ink-100); }
/* Must beat .menu-list button { color: inherit } so Delete stays danger-colored. */
.menu-list .menu-danger,
.menu-list button.menu-danger {
  color: var(--danger);
  font-weight: 650;
}
.menu-list .menu-danger:hover,
.menu-list button.menu-danger:hover {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
}
.menu-list .menu-danger-sep {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line);
}
.menu-list .menu-form {
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem 0.35rem 0.55rem;
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
}
.menu-list .menu-form:first-child {
  border-top: 0;
  margin-top: 0;
  padding-top: 0.35rem;
}
.menu-list .menu-field input {
  width: 100%;
  min-width: 12rem;
  box-sizing: border-box;
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.add-panel { position: relative; }
.add-panel > summary { list-style: none; cursor: pointer; }
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel > form {
  position: absolute;
  right: 0;
  z-index: 3;
  width: min(22rem, calc(100vw - 2.5rem));
  margin-top: 0.5rem;
  padding: 1rem 1rem 0.35rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
}
.section-row h2 { margin: 0; font-size: 1rem; }
.section-actions { display: flex; align-items: center; gap: 0.85rem; }
.count { margin: 0; color: var(--muted); font-size: 0.9rem; }
.library-view .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.item .btn,
.gate-actions .btn {
  box-sizing: border-box;
  min-height: 36px;
  height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.library-danger { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}
.item-list a,
.item-list .item-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.9rem 0.35rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  min-height: 44px;
  flex: 1;
  min-width: 0;
}
.item-list a,
.item-list .item-link { transition: background-color 0.15s var(--ease-out); }
.item-list a:hover,
.item-list .item-link:hover { background: var(--ink-50); }
.item-list a:focus-visible,
.item-list .item-link:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
/* Pending: one list with a header row that shares the checkbox column. */
.pending-list {
  margin: 0.35rem 0 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}
.pending-list .item-list {
  border-top: none;
  margin: 0;
}
.pending-list-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 48px;
  padding: 0.35rem 0.65rem 0.35rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, var(--ink-100));
}
.pending-list-head-main {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}
.pending-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.pending-actions .btn { margin: 0; }
.pending-selection {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}
.pending-list .item-pick {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
.item-list-selectable .item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0 0.65rem 0 0.7rem;
  border-bottom: 1px solid var(--line);
}
.item-list-selectable .item-row:last-child { border-bottom: none; }
.item-list-selectable .item-row .item-link {
  border-bottom: none;
  padding-left: 0;
  padding-right: 0.15rem;
}
.item-list-selectable .item-pick {
  margin: 0;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.pending-list .item-row > .item-pick {
  margin-top: 1.15rem;
}
#pending-publish-btn:disabled,
#pending-cancel-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.item-name { font-weight: 650; }
.item-name-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.item-status { margin: 0; }
.item-list .excerpt { margin: 0; }
.review-badge {
  display: inline-block;
  margin-top: 0.3rem;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--warn-50);
  color: var(--warn-800);
  box-shadow: inset 0 0 0 1px var(--warn-200);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
}
.review-note,
.review-hint {
  display: block;
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.review-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.review-change { display: flex; flex-direction: column; gap: 0.12rem; min-width: 0; }
.review-field {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 650;
}
.review-side {
  font-size: 0.9rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.review-k {
  display: inline-block;
  min-width: 5.6rem;
  margin-right: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.item-review {
  margin: 0.85rem 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.item-review h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}
.item-labels { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.2rem; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.01em;
}
/* Leading dot: the label text still carries the meaning (colour is never the only signal). */
.status::before { content: ""; width: 0.375rem; height: 0.375rem; border-radius: var(--radius-full); background: currentColor; opacity: 0.8; }
.status-draft { background: var(--warn-50); color: var(--warn-800); box-shadow: inset 0 0 0 1px var(--warn-200); }
.status-published { background: var(--success-50); color: var(--success-800); box-shadow: inset 0 0 0 1px var(--success-100); }
.status-archived { background: var(--ink-50); color: var(--ink-600); box-shadow: inset 0 0 0 1px var(--ink-200); }
.table-proposal {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.table-proposal h2 { margin: 0 0 0.35rem; font-size: 1.2rem; }
.table-proposal h3 { margin: 1rem 0 0.25rem; font-size: 1rem; }
.proposal-name { margin: 0.75rem 0 0.25rem; font-size: 1.05rem; }
.proposal-columns, .proposal-rows {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
}
.proposal-columns, .proposal-rows { border: 1px solid var(--line); border-radius: var(--radius-lg); border-collapse: separate; border-spacing: 0; overflow: hidden; font-size: 0.875rem; background: var(--white); }
.proposal-columns th, .proposal-rows th { background: var(--ink-50); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-600); }
.proposal-columns tr:last-child td, .proposal-rows tr:last-child td { border-bottom: 0; }
.proposal-columns th, .proposal-columns td,
.proposal-rows th, .proposal-rows td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: top;
  word-break: break-word;
}
.proposal-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.proposal-actions form { margin: 0; }
fieldset.field-group { border: 1px solid var(--line); border-radius: 10px; margin: 1.25rem 0; padding: 0.35rem 1rem 0.85rem; }
fieldset.field-group legend { font-family: var(--font-sans); font-weight: 650; padding: 0 0.35rem; }
.notice {
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--ink-50);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}
.gate-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 0.25rem; }

/* Slide-up sheet. */
.sheet {
  position: fixed;
  inset: 0;
  margin: 0;
  margin-top: auto;
  width: min(36rem, 100%);
  max-height: min(85dvh, 36rem);
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}
.sheet::backdrop {
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(2px);
}
.sheet[open] {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: sheet-backdrop-in 0.2s var(--ease-out);
}
.sheet[open] .sheet-panel {
  animation: sheet-up 0.3s var(--ease-out);
}
.sheet-panel {
  display: flex;
  flex-direction: column;
  max-height: min(85dvh, 36rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -12px 40px -8px rgba(28, 25, 23, 0.18);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex: 0 0 auto;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sheet-close {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-600);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover { background: var(--ink-100); }
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.85rem 1rem 1.5rem;
}
.sheet-actions {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.sheet-revert .btn,
.sheet-revert button {
  font: inherit;
  cursor: pointer;
}
.sheet-revert button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink-800);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.sheet-revert button[type="submit"]:hover {
  background: var(--ink-100);
}
.diff-list { list-style: none; padding: 0; margin: 0; }
.diff-list li { margin-bottom: 1rem; }
.diff-list li:last-child { margin-bottom: 0; }
.diff-field { margin: 0 0 0.35rem; font-family: var(--font-sans); font-weight: 600; }
.diff-label {
  margin: 0.45rem 0 0.2rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.diff-before, .diff-after {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.45;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  overflow: auto;
  max-height: 12rem;
  margin: 0;
}
.diff-before { border-left: 3px solid var(--danger-600); background: color-mix(in srgb, var(--danger-50) 60%, var(--white)); margin-bottom: 0.35rem; }
.diff-after { border-left: 3px solid var(--success-600); background: color-mix(in srgb, var(--success-50) 60%, var(--white)); }
/* Inline edit marks: only the changed words, not the whole block. */
mark.diff-del,
mark.diff-ins {
  color: inherit;
  border-radius: 0.2em;
  padding: 0.05em 0.12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.diff-del {
  background: var(--danger-100);
  color: var(--danger-800);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--danger-600);
}
mark.diff-ins {
  background: var(--success-100);
  color: var(--success-800);
  font-weight: 650;
}
.review-side mark.diff-del,
.review-side mark.diff-ins {
  font-family: inherit;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes sheet-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet[open],
  .sheet[open] .sheet-panel { animation: none; }
}
.library-view .panel { margin-top: 2.5rem; }
.library-view .panel h2 { font-size: 1.15rem; }
@media (max-width: 720px) {
  .row, .editor { grid-template-columns: 1fr; }
  dl.details div { grid-template-columns: 1fr; gap: 0.1rem; }
  .mcp-panel { right: auto; left: 0; }
  .add-panel > form { right: auto; left: 0; }
  .nav {
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    padding: 0.75rem 1rem;
  }
  .nav-trail { order: 3; flex: 1 1 100%; }
  .nav-end { gap: 0.6rem; }
}

/* Catch-all for reduced motion: any transition or animation added by the restyle collapses to instant. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
