/* =========================================================
   e-Pub groWING aero DMS — Premium Design System v5
   Compact · Luxury enterprise · Highly readable
   ========================================================= */

:root {
  --bg: #f3f5f8;
  --bg-soft: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6ebf2;
  --line-strong: #d4dce6;

  --brand: #1d4ed8;
  --brand-2: #2563eb;
  --brand-soft: #e8f0fe;
  --brand-deep: #1e3a8a;
  --brand-action: #16a34a;
  --brand-action-hover: #15803d;
  --violet: var(--brand);
  --violet-soft: var(--brand-soft);
  --success: #047857;
  --success-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --aqua: var(--brand);

  --sidebar: #0b1220;
  --sidebar-2: #111827;
  --sidebar-text: #f8fafc;
  --sidebar-muted: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 28px rgba(15, 23, 42, .08);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-pill: 8px;
  --font-display: "Manrope", system-ui, sans-serif;
  --font-ui: "Manrope", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .22, 1);

  --fs-title: 24px;
  --fs-section: 17px;
  --fs-card: 15px;
  --fs-body: 13.5px;
  --fs-label: 12.5px;
  --fs-table: 13px;
  --fs-help: 11.5px;
  --fs-btn: 13px;
  --fs-nav: 13.5px;
  --control-h: 40px;
  --btn-h: 38px;
  --nav-item-h: 42px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.dms-body, body.guest-body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .page-title, .brand-name, .login-hero h1, .stat-card strong, .lux-card h3, .panel-h h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}
a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { color: var(--brand-deep); }
::selection { background: var(--brand-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Atmosphere — subtle, professional */
.dream-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, #f5f7fa 0%, #eef2f6 100%);
}
.orb, .mist, .grain, .float-particle, .cursor-glow { display: none !important; }

/* Shell */
.app-shell {
  position: relative; z-index: 3; min-height: 100vh;
  display: grid; grid-template-columns: 72px 1fr;
  transition: grid-template-columns .25s var(--ease);
}
.app-shell.nav-expanded {
  grid-template-columns: 280px 1fr;
}
.side-nav {
  background: linear-gradient(180deg, var(--sidebar) 0%, #020617 100%);
  color: var(--sidebar-text);
  padding: 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
  height: 100vh; position: sticky; top: 0;
  box-shadow: 8px 0 30px rgba(2, 6, 23, .18);
  overflow-y: auto;
  overflow-x: hidden;
  transition: padding .2s var(--ease);
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.35) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.35);
  border-radius: 999px;
}
.side-nav::-webkit-scrollbar-track { background: transparent; }
.side-nav.is-expanded {
  padding: 18px 12px;
}
.side-nav-icons .brand-icon-only {
  display: flex; justify-content: center; align-items: center;
  padding: 8px 4px 12px; margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.side-nav.is-expanded .brand-icon-only {
  justify-content: flex-start;
  padding-left: 8px;
}
.side-nav-icons .brand-icon-only .brand-logo-sm {
  height: 28px; max-width: 48px; border-radius: 8px;
}
.side-nav.is-expanded .brand-icon-only .brand-logo-sm {
  max-width: 160px; height: 34px;
}
.side-nav-icons .nav-sec { display: none; }
.side-nav-icons .nav-links a.nav-top-link,
.side-nav-icons .nav-operators-toggle,
.side-nav-icons .nav-group-toggle {
  justify-content: center;
  padding: 12px 8px;
  position: relative;
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  border-radius: 12px;
  font-weight: 600;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: .2s var(--ease);
  text-align: left;
}
.side-nav-icons .nav-operators-toggle:hover,
.side-nav-icons .nav-group-toggle:hover,
.side-nav-icons .nav-links a.nav-top-link:hover {
  color: #fff; background: rgba(255,255,255,.08);
}
.side-nav-icons .nav-operators-toggle.active,
.side-nav-icons .nav-group-toggle.active,
.side-nav-icons .nav-links a.nav-top-link.active {
  color: #fff; background: rgba(37, 99, 235, .28);
  box-shadow: inset 3px 0 0 #60a5fa;
}
.side-nav-icons .nav-label,
.side-nav-icons .side-user-text,
.side-nav-icons .nav-caret,
.side-nav-icons .nav-operators-panel,
.side-nav-icons .nav-group-panel {
  display: none;
}
.side-nav.is-expanded .nav-label,
.side-nav.is-expanded .side-user-text,
.side-nav.is-expanded .nav-caret {
  display: inline;
}
.side-nav.is-expanded .nav-operators-panel:not([hidden]),
.side-nav.is-expanded .nav-group-panel:not([hidden]) {
  display: block;
}
.side-nav.is-expanded .nav-links a.nav-top-link,
.side-nav.is-expanded .nav-operators-toggle,
.side-nav.is-expanded .nav-group-toggle {
  justify-content: flex-start;
  padding: 10px 12px;
}
.side-nav-icons .nav-ico {
  width: auto; font-size: 1.15rem; opacity: 1; margin: 0; flex-shrink: 0;
}
.side-nav-icons .nav-caret {
  margin-left: auto; font-size: .7rem; opacity: .7;
}
.side-nav-icons .side-user {
  justify-content: center; padding: 10px 6px;
}
.side-nav.is-expanded .side-user {
  justify-content: flex-start; gap: 12px; padding: 12px;
}
.side-nav-icons .side-user .avatar {
  width: 36px; height: 36px; font-size: .9rem;
}
.nav-rail-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--ink-2);
  cursor: pointer;
}
.nav-rail-toggle:hover { border-color: var(--brand); color: var(--brand); }

/* Nested operators → documents in side menu */
.nav-group,
.nav-operators-block { width: 100%; }
.nav-group-panel,
.nav-operators-panel {
  margin: 4px 0 8px;
  padding: 4px 0 4px 8px;
  border-left: 2px solid rgba(148, 163, 184, .25);
}
.nav-sub-link, .nav-doc-link {
  display: block;
  color: #cbd5e1 !important;
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  margin: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-sub-link:hover, .nav-doc-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff !important;
}
.nav-sub-link.active, .nav-doc-link.active {
  background: rgba(37, 99, 235, .35);
  color: #fff !important;
}
.nav-op-group { margin: 4px 0; }
.nav-op-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
}
.nav-op-row:hover { background: rgba(255,255,255,.06); }
.nav-op-caret-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nav-op-caret-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-op-caret {
  font-size: .65rem;
  transition: transform .15s ease;
  display: inline-block;
}
.nav-op-group.is-open .nav-op-caret { transform: rotate(90deg); color: #93c5fd; }
.nav-op-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e2e8f0 !important;
  font-size: .82rem;
  font-weight: 700;
  padding: 6px 8px 6px 2px;
  border-radius: 8px;
  text-decoration: none !important;
}
.nav-op-link:hover { color: #fff !important; }
.nav-op-link.active {
  color: #fff !important;
  background: rgba(37, 99, 235, .28);
}
.nav-op-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  font-size: .82rem;
  font-weight: 700;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.nav-op-toggle:hover, .nav-op-toggle.active {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.nav-op-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-op-count {
  font-size: .68rem;
  color: #94a3b8;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.nav-op-docs { padding-left: 18px; margin: 2px 0 6px; border-left: 1px solid rgba(148,163,184,.2); margin-left: 12px; }
.nav-doc-all { color: #93c5fd !important; }
.nav-doc-new { color: #86efac !important; font-weight: 700; }
.nav-doc-empty {
  display: block;
  color: #64748b;
  font-size: .75rem;
  padding: 6px 10px;
}
.nav-op-create { color: #86efac !important; margin-top: 6px; }

/* Hover tooltip only when collapsed */
.side-nav-icons:not(.is-expanded) .nav-top-link[title]:hover::after,
.side-nav-icons:not(.is-expanded) .nav-operators-toggle[title]:hover::after,
.side-nav-icons:not(.is-expanded) .nav-group-toggle[title]:hover::after,
.side-nav-icons:not(.is-expanded) .side-user[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 50;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  pointer-events: none;
}
.side-nav-icons .side-user,
.side-nav-icons .nav-top-link,
.side-nav-icons .nav-operators-toggle,
.side-nav-icons .nav-group-toggle { position: relative; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px; }
.brand.brand-with-logo {
  text-decoration: none; padding: 10px 8px 14px; margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  display: block; width: auto; object-fit: contain;
  background: #000; border-radius: 10px;
}
.brand-logo-sm { height: 28px; max-width: 140px; border-radius: 6px; }
.brand-logo-md { height: 42px; max-width: 210px; }
.brand-logo-lg { height: 52px; max-width: 260px; }
.brand-logo-hero { height: 64px; max-width: 340px; border-radius: 12px; box-shadow: 0 12px 28px rgba(0,0,0,.35); }
.brand-logo.mx-auto { margin-left: auto; margin-right: auto; }
.login-card .brand-logo-sm { margin-bottom: 6px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  font-weight: 800; font-size: 1.15rem; box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
  position: relative;
}
.brand-mark .mark-ring {
  position: absolute; inset: -4px; border-radius: 14px;
  border: 1px solid rgba(147, 197, 253, .35); border-top-color: transparent;
  animation: spin 12s linear infinite;
}
.brand-mark.lg { width: 56px; height: 56px; font-size: 1.45rem; border-radius: 14px; }
.brand-name { font-size: 1.35rem; line-height: 1; color: #fff !important; }
.brand-sub { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--sidebar-muted); margin-top: 3px; }

.nav-sec {
  font-size: .65rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 10px 12px 4px; font-weight: 700;
}
.nav-links { display: flex; flex-direction: column; gap: 6px; }
.nav-links a {
  color: #cbd5e1; padding: 11px 12px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; gap: 10px; transition: .2s var(--ease);
}
.nav-links a:hover {
  color: #fff; background: rgba(255,255,255,.08);
}
.nav-links a.active {
  color: #fff; background: rgba(37, 99, 235, .28);
  box-shadow: inset 3px 0 0 #60a5fa;
}
.nav-links a .chip {
  margin-left: auto; background: rgba(96,165,250,.2); color: #bfdbfe; border-color: transparent;
}
.nav-ico { width: 18px; opacity: .9; }
.side-user {
  margin-top: auto; display: flex; gap: 12px; align-items: center; padding: 12px;
  border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
}
.side-user strong { color: #fff; }
.side-user small { display: block; color: var(--sidebar-muted); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
}

.main-panel { padding: 20px 28px 48px; min-width: 0; background: transparent; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; margin-bottom: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  position: sticky; top: 12px; z-index: 20;
}
.crumb { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; }
.page-title { margin: 2px 0 0; font-size: clamp(1.5rem, 2.4vw, 1.9rem); line-height: 1.15; color: var(--ink) !important; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-form input, .mega-search {
  min-width: 240px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--ink); padding: 10px 16px; outline: none;
}
.search-form input:focus, .mega-search:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff;
}
.search-form input::placeholder { color: var(--muted-2); }

/* Buttons */
.btn-gold, .btn-primary, .btn-ghost, .btn-danger-ghost, .btn-soft {
  border: none; border-radius: var(--radius-pill); padding: 10px 16px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); transition: .2s var(--ease); text-decoration: none;
}
.btn-gold, .btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--violet)); color: #fff !important;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
}
.btn-gold:hover, .btn-primary:hover { transform: translateY(-1px); color: #fff !important; filter: brightness(1.05); }
.btn-ghost, .btn-soft {
  background: #fff; color: var(--ink-2) !important; border: 1px solid var(--line-strong);
}
.btn-ghost:hover, .btn-soft:hover { background: var(--surface-2); color: var(--ink) !important; }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger) !important; border: 1px solid #fecaca; }

/* Cards */
.panel, .glass-card, .stat-card, .lux-card, .widget {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.panel, .glass-card, .widget { padding: 20px; }
.panel:hover, .widget:hover { box-shadow: var(--shadow); }
.panel.narrow { max-width: 720px; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-h h3 { margin: 0; font-size: 1.15rem; color: var(--ink) !important; }
.panel-h a { color: var(--brand); font-weight: 700; }
.card-shine { display: none; }

.hero-strip {
  display: flex; justify-content: space-between; gap: 20px; align-items: flex-end;
  margin-bottom: 20px; padding: 24px 26px; border-radius: 18px;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 45%, #f5f3ff 100%);
  border: 1px solid #dbeafe; box-shadow: var(--shadow-sm);
}
.eyebrow {
  letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; font-weight: 800;
  color: var(--brand); margin: 0 0 6px;
}
.shimmer-text { color: var(--brand); -webkit-text-fill-color: unset; background: none; animation: none; }
.muted { color: var(--muted) !important; }
.hero-strip h2 { margin: 0 0 8px; font-size: clamp(1.5rem, 2.6vw, 2rem); color: var(--ink) !important; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
.stat-card { padding: 16px 18px; transition: .2s var(--ease); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #bfdbfe; }
.stat-card span {
  display: block; color: var(--muted); font-size: .75rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.stat-card strong {
  font-size: 1.9rem; display: block; margin-top: 4px; color: var(--ink) !important;
  background: none; -webkit-text-fill-color: unset;
}
.stat-card .delta { font-size: .78rem; color: var(--success); font-weight: 700; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 16px; }
.grid-2 > * { min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.charts-row { margin-bottom: 16px; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap-sm { height: 250px; }

.chip, .badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: .7rem; font-weight: 800; letter-spacing: .03em;
  background: var(--brand-soft); color: var(--brand-deep); border: 1px solid #bfdbfe;
}
.chip.success, .badge.success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.chip.violet { background: var(--violet-soft); color: var(--violet); border-color: #ddd6fe; }

.doc-row, .log-item {
  display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
  transition: .2s var(--ease);
}
.doc-row:hover, .log-item:hover {
  background: var(--bg-soft); border-radius: 10px; padding-left: 8px; padding-right: 8px;
}
.doc-row strong, .log-item strong { color: var(--ink); }
.doc-row small, .log-item small { display: block; color: var(--muted); margin-top: 3px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex-shrink: 0;
  background: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft);
}
.action-edit, .action-update { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.action-delete, .action-failed { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.action-view { background: var(--brand-2); }
.action-upload, .action-create { background: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.action-download { background: var(--aqua); }
.action-api_sync, .action-success { background: var(--success); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.lux-card {
  display: block; padding: 18px; color: inherit; text-decoration: none; transition: .2s var(--ease);
}
.lux-card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow); border-color: #bfdbfe; color: inherit;
}
.lux-card-top { display: flex; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.lux-card h3 { margin: 0 0 6px; font-size: 1.15rem; color: var(--ink) !important; }
.lux-card p { color: var(--muted); margin: 0; }
.lux-card-meta { display: flex; justify-content: space-between; color: var(--muted-2); font-size: .82rem; margin-top: 14px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filter-bar input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.filter-bar select,
.form-lux input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.form-lux select,
.form-lux textarea,
.edit-block textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="range"]),
select,
textarea {
  width: 100%; border-radius: 12px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); padding: 11px 13px; outline: none; font-family: var(--font-ui);
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft);
}
option { background: #fff; color: var(--ink); }
.form-lux label { display: block; margin: 14px 0 6px; font-weight: 700; color: var(--ink-2); }

/* Premium checkbox / radio controls site-wide */
.form-lux .check,
.check,
label.check {
  display: inline-flex !important;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  width: auto !important;
  max-width: 100%;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1.35;
  user-select: none;
}
.check.d-block { display: flex !important; width: 100% !important; }
.check.mb-0 { margin-bottom: 0 !important; }
input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  min-height: 18px !important;
  max-width: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  flex: 0 0 18px !important;
  box-sizing: border-box !important;
  border: 1.5px solid #94a3b8 !important;
  border-radius: 5px !important;
  background: #fff !important;
  box-shadow: none !important;
  outline: none !important;
  vertical-align: middle;
  cursor: pointer;
  position: relative;
  display: inline-grid !important;
  place-content: center;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
input[type="radio"] { border-radius: 50% !important; }
input[type="checkbox"]:hover,
input[type="radio"]:hover {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12) !important;
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .22) !important;
}
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: #2563eb !important;
  border-color: #2563eb !important;
}
input[type="checkbox"]:checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}
input[type="radio"]:checked::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}
input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #f1f5f9 !important;
}
/* Keep modal option radios as designed */
.dms-opt-input {
  appearance: auto !important;
  -webkit-appearance: radio !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  border-radius: 50% !important;
  display: inline-block !important;
  place-content: unset !important;
}
.dms-opt-input:checked::after { content: none !important; }

.doc-layout { display: grid; grid-template-columns: 230px 1fr 250px; gap: 14px; }
.toc-side a { display: block; color: var(--ink-2); padding: 5px 0; font-size: .9rem; font-weight: 600; }
.toc-side a:hover { color: var(--brand); }
.toc-side .indent { padding-left: 12px; } .toc-side .indent2 { padding-left: 22px; font-size: .84rem; color: var(--muted); }
.content-block { padding: 16px 0; border-bottom: 1px solid var(--line); position: relative; }
.content-block h3, .content-block h2 { color: var(--ink) !important; }
.content-block .path { font-size: .75rem; color: var(--muted-2); margin-bottom: 8px; }
.content-block-actions {
  display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap;
}
.content-block-actions a, .content-block-actions button {
  font-size: .75rem; font-weight: 700; color: #1d4ed8; text-decoration: none;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 2px 8px; cursor: pointer;
}
.content-block-actions .inline-del { display: inline; margin: 0; }
.content-block-actions .inline-del button { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.latest-chip {
  display: inline-block; background: #dcfce7; color: #166534; border-radius: 999px;
  padding: 1px 8px; font-weight: 800; font-size: .65rem; letter-spacing: .04em; margin-right: 6px; vertical-align: middle;
}
.mini-change { padding: 8px 0; border-bottom: 1px solid var(--line); }
.mini-change strong { display: block; font-size: .88rem; color: var(--ink); }
.mini-change small { color: var(--muted); font-size: .75rem; }

/* ——— Document page template (header / body / footer) ——— */
.doc-paper {
  background: #fff;
  border: 1px solid #d7dde8;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .08);
  min-height: 640px;
  display: flex;
  flex-direction: column;
  color: #0f172a;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.doc-paper.margin-narrow { padding: 28px 28px 20px; }
.doc-paper.margin-normal { padding: 32px 36px 24px; }
.doc-paper.margin-wide { padding: 40px 44px 28px; }
.doc-paper.font-sans { font-family: "Manrope", "Segoe UI", sans-serif; }
.doc-paper.font-serif { font-family: Georgia, "Times New Roman", serif; }
.doc-paper.is-compact { min-height: 520px; }
.doc-paper.is-compact.margin-narrow,
.doc-paper.is-compact.margin-normal,
.doc-paper.is-compact.margin-wide { padding: 28px 30px 22px; }

/* Bulletin candy-cane: left + right diagonal stripes, content stays inside */
.dms-bulletin-frame {
  --bt-band: 24px;
  --bt-gutter: 20px;
  --bt-red: #DB6B6B;
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  background-color: #fff;
  padding-left: calc(var(--bt-band) + var(--bt-gutter)) !important;
  padding-right: calc(var(--bt-band) + var(--bt-gutter)) !important;
}
.dms-bulletin-frame::before,
.dms-bulletin-frame::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--bt-band);
  pointer-events: none;
  z-index: 3;
  background: repeating-linear-gradient(
    -45deg,
    var(--bt-red) 0 8px,
    #ffffff 8px 16px
  );
}
.dms-bulletin-frame::before { left: 0; }
.dms-bulletin-frame::after {
  right: 0;
  background: repeating-linear-gradient(
    45deg,
    var(--bt-red) 0 8px,
    #ffffff 8px 16px
  );
}
.dms-bulletin-frame .doc-page-body,
.dms-bulletin-frame .body-text,
.dms-bulletin-frame .doc-prose,
.dms-bulletin-frame img,
.dms-bulletin-frame table,
.dms-bulletin-frame .doc-figure {
  max-width: 100%;
  box-sizing: border-box;
}

.doc-brand-logo {
  height: 40px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.doc-page-header { margin-bottom: 26px; }
.doc-page-header.with-line { border-bottom: 2px solid #1e3a8a; padding-bottom: 14px; }

/* Premium letterhead — flex, never character-stack */
.doc-letterhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px 24px;
  flex-wrap: wrap;
}
.doc-letterhead-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 220px;
}
.doc-letterhead-brand-copy {
  min-width: 0;
}
.doc-letterhead-brand-copy strong {
  font-size: .95rem;
  color: #0f172a;
  display: block;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
.doc-letterhead-center {
  flex: 1 1 160px;
  text-align: center;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .78rem;
  color: #1e3a8a;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
.doc-letterhead-right {
  flex: 0 1 auto;
  text-align: right;
  font-size: .82rem;
  color: #475569;
  white-space: nowrap;
}

/* Back-compat aliases used elsewhere */
.doc-header-row { display: contents; }
.doc-h-left { display: contents; }
.doc-h-center { display: contents; }
.doc-h-right { display: contents; }

.doc-logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #1e3a8a; color: #fff; font-weight: 800; font-size: .95rem;
  flex-shrink: 0;
}

.doc-page-body { flex: 1; min-width: 0; }
.doc-page-body .doc-h1 {
  font-size: clamp(1.35rem, 2.2vw, 1.7rem); font-weight: 800; margin: 0 0 10px;
  color: var(--doc-heading, #1e3a8a);
  line-height: 1.25;
}
.doc-page-body .doc-lead { color: #64748b; margin-bottom: 22px; font-size: .95rem; line-height: 1.55; }
.doc-page-body .doc-h2 {
  font-size: 1.1rem; font-weight: 750; margin: 22px 0 8px;
  color: var(--doc-heading, #1e3a8a);
}
.doc-page-body .doc-h3 {
  font-size: 1rem; font-weight: 700; margin: 14px 0 6px; color: #0f172a;
}
.doc-page-body p { line-height: 1.65; color: #1e293b; margin: 0 0 12px; }
.doc-page-body .content-block { border-bottom: 1px solid #eef2f7; }
.doc-page-body .content-block:last-child { border-bottom: 0; }
.doc-page-body .content-block h3 { color: var(--doc-heading, #1e3a8a) !important; font-size: 1.05rem; }
.doc-page-body .path { font-size: .72rem; color: #94a3b8; }

.doc-page-footer { margin-top: 28px; }
.doc-page-footer.with-line { border-top: 1px solid #cbd5e1; padding-top: 12px; }
.doc-letterfoot,
.doc-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 16px;
  flex-wrap: wrap;
  font-size: .72rem;
  color: #64748b;
}
.doc-f-left, .doc-f-center, .doc-f-right {
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}
.doc-f-left { flex: 1 1 140px; }
.doc-f-center { flex: 1 1 100px; text-align: center; }
.doc-f-right { flex: 1 1 140px; text-align: right; }

/* Template edit / preview stage */
.template-edit-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.nav-expanded .template-edit-layout {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}
.template-edit-fields {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.template-edit-fields .logo-upload-card--premium {
  flex-direction: column;
  align-items: stretch;
}
.template-edit-fields .logo-upload-preview {
  width: 100%;
  height: 104px;
}
.template-preview-stage {
  position: sticky;
  top: 12px;
  min-width: 0;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, .35);
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(59, 130, 246, .12), transparent 55%),
    linear-gradient(165deg, #eef2f7 0%, #e2e8f0 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 18px 40px rgba(15, 23, 42, .06);
  padding: 16px 16px 14px;
}
.template-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 4px;
}
.template-preview-toolbar .eyebrow { letter-spacing: .1em; font-size: .68rem; color: #64748b; }
.template-preview-toolbar strong { display: block; font-size: .95rem; color: #0f172a; }
.template-preview-desk {
  background: transparent;
  border-radius: 12px;
  padding: 8px;
  min-width: 0;
}
.template-preview-desk .doc-paper {
  border-radius: 4px;
  min-height: 640px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.8) inset,
    0 22px 50px rgba(15, 23, 42, .14),
    0 2px 6px rgba(15, 23, 42, .06);
}
.template-preview-hint {
  margin: 12px 4px 2px;
  font-size: .78rem;
}
.template-preview-hint code {
  font-size: .72rem;
  background: rgba(255,255,255,.7);
  padding: 1px 6px;
  border-radius: 6px;
}
.logo-upload-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  margin-bottom: 8px;
}
.logo-upload-card--premium {
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #dbe3ef;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .05);
  gap: 14px;
  flex-wrap: wrap;
}
.logo-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.logo-section-head h3 {
  margin: 2px 0 0;
  font-size: 1.05rem;
}
.logo-upload-preview {
  width: 148px;
  height: 92px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
  border: 1px solid rgba(15, 23, 42, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.logo-upload-preview-sm {
  width: 96px;
  height: 56px;
}
.logo-upload-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.25));
}
.logo-upload-fields {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}
.logo-dropzone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 14px 16px;
  border: 1.5px dashed #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.logo-dropzone:hover,
.logo-dropzone.is-dragover {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.logo-dropzone.has-file {
  border-style: solid;
  border-color: #93c5fd;
  background: #f0f9ff;
}
.logo-dropzone-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e3a8a;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: 6px;
}
.logo-dropzone-title {
  font-weight: 750;
  font-size: .9rem;
  color: var(--ink);
}
.logo-dropzone-meta {
  font-size: .75rem;
  color: var(--muted);
}
.logo-dropzone-file {
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 650;
  color: #1e40af;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logo-hint {
  margin: 10px 0 0;
  font-size: .78rem;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
}
.logo-mark-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-top: 12px;
}
.logo-mark-row > div {
  width: 96px;
  flex: 0 0 auto;
}
.logo-mark-row input {
  text-align: center;
  font-weight: 800;
  letter-spacing: .04em;
}
.logo-remove-check { margin: 0 0 8px; }
.logo-secondary-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.logo-dropzone-meta {
  font-size: .75rem;
  color: var(--muted);
}
.logo-dropzone-file {
  margin-top: 6px;
  font-size: .78rem;
  font-weight: 650;
  color: #1e40af;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-logo-thumb {
  height: 28px;
  width: auto;
  max-width: 72px;
  object-fit: contain;
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 4px;
}
.logo-branding-banner { padding: 16px 18px !important; }
.btn-xs { font-size: .78rem !important; padding: 6px 10px !important; }

@media (max-width: 640px) {
  .logo-upload-card--premium { flex-direction: column; }
  .logo-upload-preview { width: 100%; height: 100px; }
}

.email-template-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.email-template-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.email-template-card-meta { flex: 1; min-width: 0; }
.email-template-card-meta h3 { margin: 2px 0 6px; font-size: 1.05rem; }
.email-logo-slot {
  width: 72px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}
.email-logo-slot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.field-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.field-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.field-row-cover {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .template-edit-layout { grid-template-columns: 1fr; }
  .template-preview-stage { position: static; }
}
@media (max-width: 640px) {
  .field-row-2, .field-row-3, .field-row-cover { grid-template-columns: 1fr; }
  .doc-letterhead-right { white-space: normal; text-align: left; }
  .doc-f-center, .doc-f-right { text-align: left; }
}

/* Presets */
.doc-paper.preset-corporate .doc-page-header.with-line { border-bottom-color: #1e3a8a; }
.doc-paper.preset-corporate .doc-logo { background: #1e3a8a; }

.doc-paper.preset-policy {
  border: 2px solid #0f172a;
  box-shadow: none;
}
.doc-paper.preset-policy .doc-page-header.with-line { border-bottom: 3px double #0f172a; }
.doc-paper.preset-policy .doc-logo { background: #0f172a; border-radius: 0; }
.doc-paper.preset-policy .doc-letterhead-center,
.doc-paper.preset-policy .doc-h-center { color: #0f172a; letter-spacing: .12em; }

.doc-paper.preset-modern {
  border: 0;
  box-shadow: 0 1px 0 #e2e8f0, 0 24px 48px rgba(15,23,42,.06);
}
.doc-paper.preset-modern .doc-page-header.with-line { border-bottom: 1px solid #e2e8f0; }
.doc-paper.preset-modern .doc-logo { background: #0ea5e9; border-radius: 999px; }
.doc-paper.preset-modern .doc-letterhead-center,
.doc-paper.preset-modern .doc-h-center {
  color: #0ea5e9; text-transform: none; letter-spacing: 0; font-size: .9rem;
}

.doc-paper.preset-classic {
  border: 1px solid #c4b59a;
  background: #fffcf7;
}
.doc-paper.preset-classic.font-serif,
.doc-paper.preset-classic { font-family: Georgia, "Times New Roman", serif; }
.doc-paper.preset-classic .doc-page-header.with-line { border-bottom: 1px solid #8b7355; }
.doc-paper.preset-classic .doc-logo { background: #8b7355; border-radius: 50%; }
.doc-paper.preset-classic .doc-letterhead-center,
.doc-paper.preset-classic .doc-h-center { color: #5c4a32; }

.sticky-preview { position: sticky; top: 88px; }
.tpl-look-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #1e3a8a; background: #eff6ff;
  border: 1px solid #bfdbfe; padding: 4px 8px; border-radius: 6px;
}

/* Contributors / permissions */
.contributor-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.contributor-row.owner-row { border-bottom: 2px solid var(--line); }
.contributor-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.perm-chip {
  display: inline-flex; align-items: center; font-size: .7rem; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px;
  border: 1px solid transparent; white-space: nowrap;
}
.perm-chip.perm-view { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.perm-chip.perm-edit { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.perm-chip.perm-delete { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.perm-chip.perm-manage { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.share-form label { font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: 8px; }
.share-form select { width: 100%; }
.inline-perm-form select {
  font-size: .72rem; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line);
  max-width: 110px; background: #fff;
}
.btn-xs { padding: 2px 8px; font-size: .9rem; line-height: 1.2; min-width: 28px; }
.perm-legend {
  font-size: .78rem; color: var(--muted); display: grid; gap: 6px;
}
.perm-legend > div { display: flex; align-items: center; gap: 8px; }
.body-text { color: var(--ink-2); line-height: 1.7; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.diff-old, .diff-new { border-radius: 12px; padding: 12px; background: var(--bg-soft); border: 1px solid var(--line); }
.diff-old { border-left: 4px solid var(--danger); } .diff-new { border-left: 4px solid var(--success); }
.diff-old pre, .diff-new pre, .meta-json { white-space: pre-wrap; font-size: .85rem; margin: 0; color: var(--ink-2); }
.hunk { padding: 8px 10px; border-radius: 10px; margin-top: 8px; background: #fff; border: 1px solid var(--line); }
.hunk-added { border-left: 4px solid var(--success); } .hunk-removed { border-left: 4px solid var(--danger); } .hunk-modified { border-left: 4px solid var(--warn); }
.toc-node { padding: 10px 12px; border-radius: 12px; background: var(--bg-soft); margin-bottom: 8px; border: 1px solid var(--line); }
.toc-badge {
  display: inline-block; font-size: .65rem; letter-spacing: .06em; text-transform: uppercase;
  background: var(--violet-soft); color: var(--violet); padding: 3px 8px; border-radius: 999px; margin-right: 8px; font-weight: 800;
}
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty-state {
  padding: 48px 24px; text-align: center; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.empty-illu {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 18px;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  display: grid; place-items: center; font-size: 1.6rem;
}

.table-scroll {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.table-scroll .lux-table { margin: 0; }
.table-scroll .lux-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-soft);
  box-shadow: 0 1px 0 var(--line-strong);
}
.doc-meta-grid .table-scroll { max-height: 360px; }
.share-people {
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}
/* Document workspace — TOC + content + thin meta */
.doc-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.doc-workspace-dense {
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
}
.doc-main-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.crumb-trail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--muted); margin: 0 0 12px;
}
.crumb-trail a { color: var(--brand); font-weight: 600; }
.crumb-trail strong { color: var(--ink); font-weight: 700; }
.topic-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.topic-toolbar-left, .topic-toolbar-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.topic-toolbar-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin-left: auto;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.meta-pill {
  display: flex; flex-direction: column; gap: 0; font-size: .7rem; line-height: 1.2;
}
.meta-pill span { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .58rem; }
.meta-pill strong { color: var(--ink); font-weight: 700; font-size: .78rem; }
.meta-pill a { color: var(--brand); font-weight: 700; }
.btn-topic-edit {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--brand-action); color: #fff !important; border: 1px solid var(--brand-action-hover);
  border-radius: 8px; font-weight: 750; font-size: .8rem;
  letter-spacing: .02em; text-transform: uppercase; text-decoration: none;
}
.btn-topic-edit:hover { background: var(--brand-action-hover); color: #fff !important; }
.btn-tool {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2) !important;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 650;
  text-decoration: none !important;
  cursor: pointer;
}
.btn-tool:hover, .btn-tool.is-active {
  border-color: var(--brand);
  color: var(--brand) !important;
  background: var(--brand-soft);
}
.topic-toolbar-clean {
  padding: 10px 12px;
  gap: 8px;
}
.topic-toolbar-clean .topic-toolbar-meta {
  border-top: 0;
  padding-top: 0;
  width: auto;
  margin-left: auto;
}
.topic-toolbar-clean .chip.violet {
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-color: #bfdbfe;
}

/* Preview (default): compact TOC + partial content. Full: complete document. */
.doc-workspace.is-preview,
.doc-workspace.is-full {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
}
.doc-workspace.is-preview .toc-side,
.doc-workspace.is-preview #tocPanel {
  max-height: min(320px, 42vh);
  overflow: hidden;
}
.doc-workspace.is-preview .toc-panel {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.doc-workspace.is-preview .toc-tree {
  max-height: 220px;
  overflow: auto;
  mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
}
.doc-workspace.is-preview .section-reader-primary {
  min-height: 360px;
}
.doc-workspace.is-preview .section-reader-body {
  max-height: min(420px, 52vh);
  overflow: hidden;
  padding: 16px 22px 28px !important;
  position: relative;
}
.doc-workspace.is-preview .section-reader-body::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 72px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, #fff 85%);
}
.doc-workspace.is-preview .section-reader-body > .content-block {
  display: none !important;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.doc-workspace.is-preview .section-reader-body > .content-block.is-preview-block,
.doc-workspace.is-preview .section-reader-body > .content-block.is-active {
  display: block !important;
}

.doc-workspace.is-full .toc-side {
  max-height: calc(100vh - 100px);
}
.doc-workspace.is-full .section-reader-body > .content-block {
  display: block !important;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.doc-workspace.is-full .section-reader-body.is-section-focus > .content-block {
  display: none !important;
}
.doc-workspace.is-full .section-reader-body.is-section-focus > .content-block.is-active {
  display: block !important;
  border-bottom: 0;
}
.doc-workspace.is-full .section-reader-primary {
  min-height: 640px;
}
.doc-workspace.is-full .section-reader-body {
  padding: 20px 28px 40px !important;
}
@media (max-width: 900px) {
  .doc-workspace.is-preview,
  .doc-workspace.is-full {
    grid-template-columns: 1fr;
  }
  .doc-workspace.is-preview .toc-side {
    max-height: 240px;
    position: static;
  }
}
.topic-edit-btn { padding: 8px 18px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.topic-doc-meta { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px !important; font-size: .82rem !important; }
.share-panel-compact { margin-bottom: 12px; padding: 0 !important; }
.share-panel-compact > .share-summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 12px 16px; font-weight: 700;
}
.share-panel-compact > .share-summary::-webkit-details-marker { display: none; }
.share-panel-compact[open] > .share-summary { border-bottom: 1px solid var(--line); }
.share-panel-compact .share-grid { padding: 14px 16px 16px; }
.topic-meta-rail { display: none !important; }
.meta-rail-row {
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
  font-size: .78rem;
}
.meta-rail-row span { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: .65rem; }
.meta-rail-row strong { color: var(--ink); font-size: .84rem; font-weight: 700; }
.meta-rail-row a { color: var(--brand); }
.toc-kicker {
  margin: 0 0 1px;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brand);
}
.toc-side {
  max-height: calc(100vh - 100px);
  overflow: visible;
  position: sticky;
  top: 72px;
}
.toc-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px !important;
  min-height: 420px;
  background: #fff;
}
.toc-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.toc-panel-head h3 { margin: 0; font-size: .9rem; font-weight: 750; }
.toc-panel-head-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.toc-kicker { font-size: .6rem !important; letter-spacing: .08em; }
.toc-search {
  width: 100%;
  padding: 5px 8px !important;
  font-size: .74rem !important;
  border-radius: 6px !important;
  margin: 0;
  background: #fff !important;
}
.toc-tree {
  overflow: auto;
  flex: 1;
  max-height: calc(100vh - 200px);
  padding-right: 0;
  min-width: 0;
}
body.dms-body:not(.is-reader-preview) .dual-left .toc-tree,
.doc-dual.mode-editor .dual-left .toc-tree {
  max-height: none !important;
  overflow: visible !important;
}
.toc-group {
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0;
}
.toc-group.is-open {
  background: #f8fbff;
  border-color: #e8eef5;
}
.toc-group .toc-children { display: none; padding: 1px 0 2px; }
.toc-group.is-open .toc-children { display: block; }
.toc-toggle {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: .62rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease;
}
.toc-group.is-open > .toc-row .toc-toggle { transform: rotate(90deg); color: var(--brand); border-color: #93c5fd; }
.toc-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 5px;
  margin: 0;
  position: relative;
  min-height: 26px;
  height: auto;
}
.toc-row:hover,
.toc-row.is-active-row,
.toc-row.actions-pinned {
  padding-right: 72px; /* room for overlay actions */
}
.toc-row:hover { background: #f1f5f9; }
.toc-row.is-active-row {
  background: #eff6ff !important;
  box-shadow: inset 3px 0 0 var(--brand);
}
.toc-row > .toc-jump {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.35;
  color: #334155 !important;
  text-decoration: none;
  padding: 0 !important;
  margin: 0;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
.toc-row > .toc-jump:hover { color: var(--brand) !important; }
.toc-row > .toc-jump strong { font-weight: inherit; color: inherit; }
.toc-title {
  display: inline;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
.toc-topic { padding-top: 4px; padding-bottom: 4px; height: auto; min-height: 28px; }
.toc-topic > .toc-jump .toc-title {
  font-size: .78rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}
.toc-row.is-active-row > .toc-jump,
.toc-row.is-active-row > .toc-jump strong,
.toc-row.is-active-row > .toc-jump .toc-title {
  color: #1e3a8a !important;
}
.toc-row.indent { padding-left: 22px; }
.toc-row.indent2 { padding-left: 32px; }
.toc-row.indent > .toc-jump {
  font-size: .78rem !important;
  font-weight: 600;
  color: #1e293b !important;
}
.toc-row.indent2 > .toc-jump {
  font-size: .75rem !important;
  font-weight: 500;
  color: #475569 !important;
}
.toc-num {
  color: #2563eb;
  font-weight: 800;
  margin-right: 3px;
  white-space: nowrap;
  font-size: .92em;
}
.toc-actions {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  background: linear-gradient(90deg, transparent, #f8fafc 28%);
  padding-left: 10px;
}
.toc-row:hover .toc-actions,
.toc-row.is-active-row .toc-actions,
.toc-row.actions-pinned .toc-actions,
.toc-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}
.toc-row.is-active-row .toc-actions {
  background: linear-gradient(90deg, transparent, #eff6ff 28%);
}
.toc-row:hover .toc-actions {
  background: linear-gradient(90deg, transparent, #f1f5f9 28%);
}
.toc-more { position: relative; }
.toc-more-btn {
  width: 22px;
  height: 22px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 1;
}
.toc-row:hover .toc-more-btn,
.toc-row.is-active-row .toc-more-btn,
.toc-more.is-open .toc-more-btn,
.toc-row.actions-pinned .toc-more-btn {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}
.toc-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 13000;
  min-width: 168px;
  padding: 6px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
  display: grid;
  gap: 2px;
}
.toc-more-menu[hidden] { display: none !important; }
.toc-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #0f172a !important;
  font-size: .78rem;
  font-weight: 650;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none !important;
  line-height: 1.2;
}
.toc-menu-item:hover { background: #f1f5f9; }
.toc-menu-danger { color: #b91c1c !important; }
.toc-menu-danger:hover { background: #fef2f2; }
.toc-diff {
  flex: 0 0 auto; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 800; text-decoration: none;
  color: #854d0e !important; background: #fde68a;
  border: 1px solid #f59e0b; border-radius: 5px; padding: 0; margin: 0;
}
.toc-row.has-edit { box-shadow: inset 3px 0 0 #eab308; }
.toc-row.has-edit.is-active-row { box-shadow: inset 3px 0 0 var(--brand); }
.toc-row.has-edit > a,
.toc-row.has-edit > .toc-jump {
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  color: inherit !important;
}

.toc-float-host {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: none;
}
.toc-float-host .toc-add-form,
.toc-float-host .toc-rename-form {
  pointer-events: auto;
}

.section-reader-primary {
  min-height: 520px;
  padding: 0 !important;
  overflow: visible;
  background: #fff;
}
.section-reader-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fbff, #fff);
}
.section-reader-top h3 { margin: 0; font-size: 1.2rem; }
.section-chip {
  max-width: min(420px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #2563eb !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
}
.section-empty {
  text-align: center;
  padding: 56px 24px;
  margin: 20px;
  border: 1px dashed #bfdbfe;
  border-radius: 16px;
  background: #f8fbff;
}
.section-empty .empty-illu { margin-bottom: 10px; }
.section-reader-body {
  max-height: none !important;
  overflow: visible !important;
  padding: 18px 28px 32px !important;
  min-height: 360px;
}
/* Structure focus already handled above; keep legacy safe default for non-structure */
.doc-workspace:not(.is-structure) .section-reader-body > .content-block {
  display: none !important;
}
.doc-workspace.is-structure .section-reader-body:not(.is-section-focus) > .content-block.is-active {
  display: block !important;
}
.section-reader-body .content-block.is-active .section-title,
.section-reader-body .content-block.is-active .doc-h2,
.section-reader-body .content-block.is-active .doc-h3 {
  font-size: 1.45rem;
  font-weight: 800;
  margin: 0 0 6px;
  color: #0f172a !important;
  line-height: 1.3;
}
.section-reader-body .content-block.is-active .path {
  margin-bottom: 16px;
  color: #64748b;
}
.section-reader-body .content-block.is-active .body-text,
.section-reader-body .content-block.is-active .doc-prose {
  font-size: 1rem;
  line-height: 1.75;
  color: #0f172a;
  overflow: visible;
}
.btn-inline-edit {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem !important; font-weight: 800 !important;
  color: #fff !important; background: #2563eb !important;
  border: 1px solid #1d4ed8 !important; border-radius: 7px !important;
  padding: 4px 10px !important; text-decoration: none !important;
}
.btn-inline-edit:hover { background: #1d4ed8 !important; color: #fff !important; }
.section-empty-body { padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; }

/* Document prose: tables, lists, images readable like topic editor */
.doc-prose p { margin: 0 0 12px; color: #1e293b; }
.doc-prose ul, .doc-prose ol { margin: 0 0 14px; padding-left: 1.4rem; }
.doc-prose li { margin: 4px 0; }
.doc-list-disc { list-style-type: disc; }
.doc-list-circle { list-style-type: circle; }
.doc-list-square { list-style-type: square; }
.doc-list-large-circle { list-style-type: '\25CF  '; }
.doc-list-small-circle { list-style-type: '\25E6  '; }
.doc-list-hollow-square { list-style-type: '\25A1  '; }
.doc-list-small-square { list-style-type: '\25AA  '; }
.doc-list-large-square { list-style-type: '\25A0  '; }
.doc-list-small-hollow-square { list-style-type: '\25AB  '; }
.doc-list-arrow { list-style-type: '\27A4  '; }
.doc-list-arrow-line { list-style-type: '\2794  '; }
.doc-list-triangle { list-style-type: '\27A2  '; }
.doc-list-check { list-style-type: '\2713  '; }
.doc-list-cross { list-style-type: '\2717  '; }
ol.doc-list-multi,
ol.doc-list-multi ol { counter-reset: item; list-style: none; padding-left: 1.25em; }
ol.doc-list-multi li { counter-increment: item; display: block; }
ol.doc-list-multi li::before { content: counters(item, ".") ". "; font-weight: 700; }
ol.doc-list-outline,
ol.doc-list-outline ol { list-style: none; padding-left: 1.25em; }
ol.doc-list-outline { counter-reset: ol-a; }
ol.doc-list-outline > li { counter-increment: ol-a; }
ol.doc-list-outline > li::before { content: counter(ol-a, upper-roman) ". "; font-weight: 700; }
ol.doc-list-outline > li > ol { counter-reset: ol-b; }
ol.doc-list-outline > li > ol > li { counter-increment: ol-b; }
ol.doc-list-outline > li > ol > li::before { content: counter(ol-b, upper-alpha) ". "; font-weight: 700; }
ol.doc-list-outline > li > ol > li > ol { counter-reset: ol-c; }
ol.doc-list-outline > li > ol > li > ol > li { counter-increment: ol-c; }
ol.doc-list-outline > li > ol > li > ol > li::before { content: counter(ol-c, decimal) ". "; font-weight: 700; }
ol.doc-list-outline > li > ol > li > ol > li > ol { counter-reset: ol-d; }
ol.doc-list-outline > li > ol > li > ol > li > ol > li { counter-increment: ol-d; }
ol.doc-list-outline > li > ol > li > ol > li > ol > li::before { content: counter(ol-d, lower-alpha) ". "; font-weight: 700; }
.doc-callout {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0 16px;
  border: 1px solid #e2e8f0;
}
.doc-callout strong { display: block; margin-bottom: 4px; }
.doc-callout-caution { background: #fffbeb; border-color: #f59e0b; }
.doc-callout-warning { background: #fff1f2; border-color: #e11d48; }
.doc-prose img { max-width: 100%; height: auto; border-radius: 8px; }
.doc-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: .92rem;
  background: #fff;
  border: 1px solid #cbd5e1;
}
.doc-prose thead th,
.doc-prose table > tr > th,
.doc-prose tr:first-child th {
  background: #1e3a5f;
  color: #fff;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #0f2744;
  vertical-align: top;
}
.doc-prose td {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  vertical-align: top;
  color: #0f172a;
  line-height: 1.55;
}
.doc-prose tbody tr:nth-child(even) td { background: #f8fafc; }
.doc-prose tbody tr:hover td { background: #f1f5f9; }
.doc-prose figure { margin: 12px 0 18px; }
.doc-prose blockquote {
  margin: 12px 0; padding: 10px 14px;
  border-left: 4px solid #2563eb; background: #f8fbff; color: #334155;
}
.doc-prose pre, .doc-prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
}
.doc-prose pre {
  background: #0f172a; color: #e2e8f0; padding: 12px 14px;
  border-radius: 10px; overflow: auto;
}
.doc-prose .table-wrap,
.doc-prose > div {
  overflow-x: auto;
  max-width: 100%;
}

.pdf-overview {
  padding: 0 !important;
  overflow: hidden;
}
.pdf-overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #1d4ed8 100%);
  color: #fff;
}
.pdf-overview-head .toc-kicker { color: #93c5fd; }
.pdf-overview-head h3 { margin: 0 0 4px; color: #fff !important; }
.pdf-overview-head .muted { color: #cbd5e1 !important; }
.pdf-overview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pdf-overview-actions .chip {
  background: rgba(255,255,255,.12);
  color: #e2e8f0;
  border-color: rgba(255,255,255,.2);
}
.pdf-overview-actions .btn-ghost {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.25);
}
.pdf-overview-actions .btn-ghost:hover {
  background: rgba(255,255,255,.16);
  color: #fff;
}
.pdf-frame-wrap.pdf-frame-overview {
  min-height: 480px;
  height: 56vh;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}
.pdf-frame-overview .pdf-frame {
  min-height: 480px;
}
.lux-table { width: 100%; border-collapse: collapse; font-size: .9rem; table-layout: auto; }
.lux-table th {
  text-align: center; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 11px 10px; border-bottom: 1px solid var(--line-strong);
  white-space: nowrap; font-weight: 800; background: var(--bg-soft);
  width: 1%; vertical-align: middle;
}
.lux-table td {
  padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2);
  overflow-wrap: anywhere; word-break: normal; text-align: center;
}
.lux-table th:first-child,
.lux-table td:first-child {
  text-align: left;
}
.lux-table a { color: var(--brand-deep); font-weight: 700; }
.lux-table tr:hover td { background: #f8fbff; }
.lux-table td.text-nowrap,
.lux-table td.table-actions,
.table td.text-nowrap,
.table td.table-actions,
.lux-table td:last-child,
.table td:last-child {
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}
.lux-table td.text-nowrap a,
.lux-table td.text-nowrap form,
.lux-table td.table-actions a,
.lux-table td.table-actions form,
.lux-table td:last-child a,
.lux-table td:last-child form,
.table td.text-nowrap a,
.table td.text-nowrap form,
.table td.table-actions a,
.table td.table-actions form,
.table td:last-child a,
.table td:last-child form {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 4px;
}
.lux-table td .chip,
.table td .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.table { width: 100%; border-collapse: collapse; }
.table th,
.table td {
  vertical-align: middle;
  padding: 10px 12px;
  text-align: center;
}
.table th:first-child,
.table td:first-child {
  text-align: left;
}
.perm-matrix th,
.perm-matrix td {
  text-align: center !important;
  vertical-align: middle !important;
}
.perm-matrix th:first-child,
.perm-matrix td:first-child {
  text-align: left !important;
}
.perm-matrix input[type="checkbox"] {
  margin: 0 auto !important;
}
/* Hidden fields inside .check labels must not affect layout */
.check > input[type="hidden"] {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Key/value list — used for template meta panels */
.kv-list { margin: 0; display: flex; flex-direction: column; gap: 0; }
.kv-row {
  display: grid;
  grid-template-columns: minmax(110px, 36%) minmax(0, 1fr);
  gap: 12px 16px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row dt {
  margin: 0;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.4;
  white-space: normal;
}
.kv-row dd {
  margin: 0;
  color: var(--ink-2);
  font-size: .9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Template show page */
.template-show-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr);
  gap: 16px;
  align-items: start;
}
.template-show-preview,
.template-show-meta { min-width: 0; }
.template-paper-wrap {
  max-width: 100%;
  overflow: auto;
  border-radius: 12px;
  padding: 14px;
  background:
    radial-gradient(900px 280px at 0% 0%, rgba(59, 130, 246, .1), transparent 50%),
    linear-gradient(165deg, #eef2f7, #e2e8f0);
}
.template-paper-wrap .doc-paper {
  min-height: 520px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, .14);
}
.toc-node-l2 { margin-left: 18px; }
.toc-node-l3 { margin-left: 36px; }

@media (max-width: 900px) {
  .doc-paper.margin-narrow,
  .doc-paper.margin-normal,
  .doc-paper.margin-wide { padding: 22px 18px 16px; }
  .doc-letterhead { align-items: flex-start; }
  .doc-letterhead-center,
  .doc-letterhead-right,
  .doc-f-center, .doc-f-right { text-align: left; }
  .kv-row { grid-template-columns: 1fr; gap: 4px; }
}
.mt-4 { margin-top: 1.15rem; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.flash.success { background: var(--success-soft); border: 1px solid #a7f3d0; color: var(--success); }
.flash.danger { background: var(--danger-soft); border: 1px solid #fecaca; color: var(--danger); }

.qa-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.qa-btn {
  padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); text-align: left; transition: .2s var(--ease); display: block; box-shadow: var(--shadow-sm);
}
.qa-btn:hover { border-color: #93c5fd; box-shadow: var(--shadow); color: var(--ink); transform: translateY(-2px); }
.qa-btn b { display: block; font-size: .95rem; margin-bottom: 4px; color: var(--ink); }
.qa-btn span { color: var(--muted); font-size: .8rem; font-weight: 500; }
.progress-ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring {
  width: 72px; height: 72px; border-radius: 50%;
  background: conic-gradient(var(--brand-2) var(--p, 70%), #e2e8f0 0);
  display: grid; place-items: center; position: relative;
}
.ring::after {
  content: attr(data-val); position: absolute; inset: 8px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; color: var(--ink);
}
.view-toggle {
  display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 12px; border: 1px solid var(--line);
}
.view-toggle button {
  border: none; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 9px;
  font-weight: 700; cursor: pointer;
}
.view-toggle button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }

.upload-zone {
  border: 2px dashed #93c5fd; border-radius: 18px; padding: 40px 24px; text-align: center;
  background: #eff6ff; transition: .2s var(--ease); cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--brand); background: #dbeafe; box-shadow: var(--shadow);
}
.upload-zone strong { color: var(--ink) !important; }

.skeleton {
  background: linear-gradient(90deg, #e2e8f0, #f8fafc, #e2e8f0);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 10px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Guest / Login — light professional */
.guest-body { background: var(--bg); }
.guest-wrap { position: relative; z-index: 3; min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.login-stage {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 36px; max-width: 1080px; width: 100%; align-items: center;
}
.login-hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.2rem); line-height: 1; margin: 10px 0 14px; color: var(--ink) !important;
}
.login-hero em { font-style: normal; color: var(--brand) !important; -webkit-text-fill-color: unset; background: none; }
.login-hero .lead { font-size: 1.05rem; color: var(--muted); max-width: 38ch; line-height: 1.6; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.hero-pills span {
  padding: 8px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  font-size: .78rem; font-weight: 700; color: var(--ink-2); box-shadow: var(--shadow-sm);
}
.hero-line { margin-top: 22px; height: 3px; width: 88px; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--violet)); }
.login-card {
  border-radius: 20px; padding: 28px; background: #fff !important; border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 1.8rem; margin: 0 0 6px; color: var(--ink) !important; }
.login-card label { display: block; margin: 12px 0 6px; font-weight: 700; color: var(--ink-2); }
.demo-hint { margin-top: 16px; font-size: .82rem; color: var(--muted); line-height: 1.6; }
.demo-hint code { color: var(--brand-deep); background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; }
.field-error { color: var(--danger); margin-top: 8px; font-weight: 600; }
.nav-toggle { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--ink); }
.social-row { display: flex; gap: 8px; margin-top: 12px; }
.social-row button {
  flex: 1; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg-soft);
  color: var(--ink-2); padding: 10px; font-weight: 700; cursor: pointer;
}
.social-row button:hover { background: #fff; border-color: var(--brand-2); color: var(--ink); }
.divider-or { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: .78rem; margin: 16px 0; }
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; position: relative; z-index: 3; padding: 40px; }
.error-code {
  font-size: clamp(4rem, 14vw, 7rem); line-height: .9; margin: 0; color: var(--brand) !important;
  -webkit-text-fill-color: unset; background: none;
}

.pagination { gap: 6px; }
.page-link {
  background: #fff !important; border: 1px solid var(--line) !important;
  color: var(--ink-2) !important; border-radius: 10px !important;
}
.page-item.active .page-link {
  background: var(--brand) !important; border-color: var(--brand) !important; color: #fff !important;
}
.page-link:hover { background: var(--brand-soft) !important; color: var(--brand-deep) !important; }

/* Dashboard specifics that used white text */
.hero-strip .muted,
.panel .muted,
.widget .muted { color: var(--muted) !important; }
.widget strong, .panel strong { color: var(--ink); }
.log-feed strong { color: var(--ink) !important; }

/* Sidebar MUST stay visible — GSAP opacity bug fix */
.side-nav,
.side-nav .nav-links a,
.side-nav .brand,
.side-nav .brand-name,
.side-nav .brand-sub,
.side-nav .side-user,
.side-nav .side-user strong,
.side-nav .side-user small,
.side-nav .nav-sec {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Disable AOS hide behavior */
[data-aos] {
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}

.nav-links a,
.btn-primary,
.btn-gold,
.btn-ghost,
.stat-card,
.lux-card,
.qa-btn,
.panel,
.chip {
  transition: transform .22s var(--ease), box-shadow .22s var(--ease), background .22s var(--ease), color .22s var(--ease), border-color .22s var(--ease);
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.content-wrap {
  animation: pageIn .4s ease both;
}

@keyframes navPulse {
  0%, 100% { box-shadow: inset 3px 0 0 #60a5fa; }
  50% { box-shadow: inset 3px 0 0 #93c5fd; }
}
.nav-links a.active {
  animation: navPulse 2.5s ease-in-out infinite;
}

@media (max-width: 1200px) {
  .stat-grid-6, .qa-grid { grid-template-columns: repeat(3, 1fr); }
  .doc-layout, .doc-layout-pdf, .doc-workspace, .doc-workspace-dense { grid-template-columns: minmax(220px, 280px) 1fr; }
}
@media (max-width: 992px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-nav {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 60;
    transform: translateX(-105%); transition: .35s var(--ease);
    box-shadow: var(--shadow-lg);
    padding: 22px 14px;
  }
  .app-shell.nav-expanded { grid-template-columns: 1fr; }
  .side-nav-icons .nav-label,
  .side-nav-icons .side-user-text,
  .side-nav-icons .nav-caret { display: inline !important; }
  .side-nav-icons .nav-operators-panel:not([hidden]),
  .side-nav-icons .nav-group-panel:not([hidden]) { display: block !important; }
  .side-nav-icons .nav-links a.nav-top-link,
  .side-nav-icons .nav-operators-toggle,
  .side-nav-icons .nav-group-toggle {
    justify-content: flex-start; gap: 10px; padding: 11px 12px;
  }
  .side-nav-icons .side-user { justify-content: flex-start; gap: 12px; padding: 12px; }
  .side-nav-icons .nav-top-link[title]:hover::after,
  .side-nav-icons .nav-operators-toggle[title]:hover::after,
  .side-nav-icons .nav-group-toggle[title]:hover::after,
  .side-nav-icons .side-user[title]:hover::after { display: none; }
  .side-nav.open { transform: translateX(0); }
  .side-nav.open::after {
    content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: -1;
  }
  .stat-grid, .stat-grid-6, .grid-2, .grid-3, .doc-layout, .doc-layout-pdf, .doc-workspace,
  .login-stage, .diff-grid, .qa-grid, .share-grid, .doc-meta-grid {
    grid-template-columns: 1fr;
  }
  .toc-side { position: static; max-height: none; }
  .toc-tree { max-height: 420px; }
  .pdf-frame-wrap.pdf-frame-overview { min-height: 360px; height: 48vh; }
  .hero-strip, .doc-show-hero { flex-direction: column; align-items: flex-start; }
  .topbar {
    position: relative; top: 0; flex-wrap: wrap; gap: 10px;
  }
  .top-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .main-panel { padding: 14px 14px 40px; }
  .chart-wrap, .chart-wrap-sm { height: 220px; }
  .pdf-frame-wrap { min-height: 60vh; height: 70vh; }
  .pdf-frame-wrap.pdf-frame-compact { min-height: 28vh; height: 32vh; }
  .section-reader-body { max-height: none !important; min-height: 280px; }
  .owner-card { flex-wrap: wrap; }
  .nav-toggle { display: inline-flex !important; }
}
@media (max-width: 768px) {
  .stat-grid-6, .qa-grid, .stat-grid, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page-title { font-size: 1.25rem; }
  .hero-strip { padding: 16px; }
  .hero-strip h2 { font-size: 1.35rem; }
  .lux-table { font-size: .82rem; }
  .lux-table th, .lux-table td { padding: 8px 6px; }
  .btn-primary, .btn-gold, .btn-ghost { font-size: .85rem; }
  .search-form { width: 100%; }
  .mega-search { width: 100%; min-width: 0; }
}
@media (max-width: 560px) {
  .stat-grid-6, .qa-grid, .stat-grid, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .doc-show-actions { width: 100%; }
  .doc-show-actions .btn-gold,
  .doc-show-actions .btn-ghost,
  .doc-show-actions .dropdown { flex: 1 1 auto; }
  .progress-ring-wrap { flex-direction: column; align-items: flex-start; }
  .share-panel .panel-h { align-items: flex-start; }
}

/* Document show — owner / share / PDF */
.owner-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line);
}
.owner-card .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
}
.share-panel { margin-bottom: 16px; }
.share-grid {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: start;
}
.share-people { min-width: 0; }
.share-add {
  padding: 14px; border-radius: 14px; background: var(--bg-soft);
  border: 1px solid var(--line);
}
.share-add .share-form { margin: 0; }
.doc-layout-pdf {
  grid-template-columns: 240px minmax(0, 1fr); gap: 14px;
}
.pdf-body { min-width: 0; }
.pdf-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.pdf-frame-wrap {
  border-radius: 14px; overflow: hidden; border: 1px solid var(--line-strong);
  background: #1e293b; min-height: 72vh; height: 78vh;
  box-shadow: var(--shadow-sm);
}
.pdf-frame-wrap.pdf-frame-compact {
  min-height: 36vh; height: 42vh;
}
.pdf-frame {
  width: 100%; height: 100%; min-height: 72vh; border: 0; background: #525659;
}
.pdf-frame-compact .pdf-frame { min-height: 36vh; }

.section-reader { margin-top: 0; }
.section-reader-body {
  max-height: none !important;
  overflow: visible !important;
  scroll-behavior: smooth;
}
.section-reader-body > .content-block.is-active {
  outline: none;
  background: #fff;
  border-radius: 0;
  padding: 4px 0 12px;
}
.content-block.content-edited {
  background: transparent;
  border-left: 3px solid #eab308;
  border-radius: 0;
  padding-left: 12px;
}
.content-block.content-edited.is-active {
  outline: none;
  background: #fff;
}
.edit-content-anchor {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  background: #fef08a;
  padding: 8px 10px;
  border: 1px dashed #ca8a04;
  cursor: pointer;
}
.edit-content-anchor:hover {
  background: #fde047;
  box-shadow: 0 0 0 3px #fef08a;
}
a.word-edit-anchor {
  background: #fef08a;
  color: #854d0e !important;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
  box-shadow: inset 0 -2px 0 #eab308;
}
a.word-edit-anchor:hover {
  background: #fde047;
  color: #713f12 !important;
}
.diff-snippet {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.diff-snippet-label {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.diff-para {
  white-space: pre-wrap;
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
  min-height: 1.5em;
}
.diff-para.diff-structured {
  white-space: normal;
  overflow-x: auto;
}
.diff-focused {
  font-size: .92rem;
  line-height: 1.45;
  color: var(--ink);
}
.history-list-focus {
  margin: 0;
}
.history-list-line {
  margin: 0.2rem 0;
  line-height: 1.45;
}
.history-list-marker {
  font-weight: 700;
  color: var(--ink-2);
  min-width: 1.4em;
  display: inline-block;
}
.history-prose-line {
  margin: 0 0 0.4rem;
}
.history-doc-list {
  margin: 0.15rem 0 0.35rem;
  padding-left: 1.35rem;
}
.history-doc-list li {
  margin: 0.2rem 0;
}
.diff-structured .table-wrap,
.diff-structured .history-table-wrap {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
}
.diff-structured .doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  background: #fff;
}
.diff-structured .doc-table th,
.diff-structured .doc-table td {
  border: 1px solid #94a3b8;
  padding: 4px 6px;
  vertical-align: top;
  text-align: center;
}
.diff-structured .doc-table th {
  background: #f1f5f9;
  font-weight: 800;
  font-size: .68rem;
  letter-spacing: .03em;
}
.diff-structured td.diff-cell-changed,
.diff-structured th.diff-cell-changed {
  position: relative;
  box-shadow: inset 4px 0 0 #111;
}
.diff-structured td.diff-cell-new,
.diff-structured th.diff-cell-new {
  box-shadow: inset 4px 0 0 #16a34a;
  background: #f0fdf4;
}
.diff-structured td.diff-cell-old,
.diff-structured th.diff-cell-old {
  box-shadow: inset 4px 0 0 #dc2626;
  background: #fef2f2;
}
mark.diff-word {
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 700;
}
mark.diff-word-old {
  background: #fecaca;
  color: #991b1b;
  text-decoration: line-through;
}
mark.diff-word-new {
  background: #bbf7d0;
  color: #166534;
}
.edit-badge-link, .diff-link, .toc-diff {
  display: inline-flex; align-items: center;
  font-size: .68rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; text-decoration: none;
  color: #854d0e !important; background: #fde68a;
  border: 1px solid #f59e0b; border-radius: 6px;
  padding: 2px 7px; margin-left: 6px;
}
.diff-link { margin-left: 0; color: #92400e !important; }
.toc-add-wrap,
.toc-rename-wrap {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
.toc-add-btn.toc-add-root-btn {
  width: 100%;
  height: auto;
  padding: 7px 10px;
  font-size: .8rem;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  cursor: pointer;
}
.toc-add-btn.toc-add-root-btn:hover { background: #dbeafe; }
.toc-add-form,
.toc-rename-form {
  display: none;
  position: fixed;
  z-index: 12001;
  width: 240px;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .22);
  gap: 6px;
  box-sizing: border-box;
}
.toc-add-form.is-popout,
.toc-rename-form.is-popout {
  display: grid !important;
}
.toc-pop-head {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 2px;
}
.toc-pop-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 2px;
}
.toc-pop-actions .btn-ghost,
.toc-pop-actions .btn-gold {
  padding: 5px 10px !important;
  font-size: .75rem !important;
}
.toc-add-form select,
.toc-add-form input,
.toc-rename-form input {
  font-size: .78rem !important;
  padding: 6px 8px !important;
  margin: 0;
  min-height: 0;
  line-height: 1.3;
  width: 100%;
}
.toc-add-root {
  position: relative;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  overflow: visible;
}
.toc-num {
  color: #2563eb;
  font-weight: 800;
  margin-right: 4px;
  white-space: nowrap;
}
.toc-del-form { display: none; }

.dms-confirm[hidden] { display: none !important; }
html.dms-dialog-open,
body.dms-dialog-open { overflow: hidden; }
.dms-confirm {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  perspective: 1400px;
  perspective-origin: 50% 42%;
}
.dms-confirm-backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 480px at 50% 18%, rgba(15, 39, 68, .35), transparent 60%),
    radial-gradient(700px 420px at 80% 90%, rgba(37, 99, 235, .12), transparent 55%),
    rgba(7, 12, 24, .62);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
}
.dms-dialog-3d .dms-confirm-backdrop {
  opacity: 0;
  transition: opacity .38s cubic-bezier(.22, .8, .2, 1);
}
.dms-dialog-3d.is-open .dms-confirm-backdrop { opacity: 1; }
.dms-dialog-stage {
  position: relative;
  z-index: 1;
  transform-style: preserve-3d;
  width: min(520px, calc(100vw - 28px));
}
.dms-confirm-card {
  position: relative; z-index: 1;
  width: min(520px, calc(100vw - 28px));
  max-height: min(90vh, 780px);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(165deg, rgba(255,255,255,.98) 0%, #f7fafc 48%, #eef3f9 100%);
  border: 1px solid rgba(226, 232, 240, .95);
  border-radius: 24px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.85) inset,
    0 -1px 0 rgba(15, 23, 42, .04) inset,
    0 18px 28px -12px rgba(15, 39, 68, .28),
    0 42px 80px -20px rgba(7, 12, 24, .45),
    0 2px 0 rgba(15, 39, 68, .06);
  padding: 0;
  overflow: hidden;
  text-align: left;
  color: #0f172a;
  animation: dmsDialogIn .22s cubic-bezier(.2,.8,.2,1) both;
}
.dms-dialog-3d .dms-dialog-stage .dms-confirm-card,
.dms-dialog-3d > .dms-confirm-card {
  width: 100%;
  animation: none;
  transform-origin: 50% 80%;
  transform-style: preserve-3d;
  transform: translate3d(0, 36px, -80px) rotateX(14deg) scale(.92);
  opacity: 0;
  transition:
    transform .48s cubic-bezier(.16, .9, .2, 1.05),
    opacity .36s ease;
}
.dms-dialog-3d.is-open .dms-dialog-stage .dms-confirm-card,
.dms-dialog-3d.is-open > .dms-confirm-card {
  transform: translate3d(0, 0, 0) rotateX(0deg) scale(1);
  opacity: 1;
}
.dms-confirm.is-leaving .dms-confirm-card {
  animation: dmsDialogOut .16s ease forwards;
}
.dms-dialog-3d.is-leaving .dms-confirm-card {
  animation: none;
  transform: translate3d(0, 28px, -60px) rotateX(-10deg) scale(.94);
  opacity: 0;
  transition:
    transform .3s cubic-bezier(.4, 0, .7, .2),
    opacity .24s ease;
}
.dms-confirm.is-leaving .dms-confirm-backdrop { opacity: 0; transition: opacity .16s ease; }
.dms-dialog-3d.is-leaving .dms-confirm-backdrop {
  opacity: 0;
  transition: opacity .28s ease;
}
.dms-dialog-shine {
  pointer-events: none;
  position: absolute;
  inset: -40% -30%;
  background: linear-gradient(
    115deg,
    transparent 35%,
    rgba(255,255,255,.0) 42%,
    rgba(255,255,255,.55) 50%,
    rgba(255,255,255,.0) 58%,
    transparent 65%
  );
  transform: translateX(-60%) rotate(8deg);
  opacity: 0;
}
.dms-dialog-3d.is-open .dms-dialog-shine {
  animation: dmsDialogShine 1.1s .18s cubic-bezier(.2,.7,.2,1) both;
}
.dms-dialog-depth {
  pointer-events: none;
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -18px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, .28), transparent 70%);
  filter: blur(8px);
  transform: translateZ(-40px);
  opacity: .55;
}
.dms-confirm-card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  background: linear-gradient(90deg, #0f2744, #1d4ed8 42%, #38bdf8);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .28);
}
.dms-confirm-card.is-danger::before {
  background: linear-gradient(90deg, #7f1d1d, #e11d48 55%, #fb7185);
  box-shadow: 0 6px 18px rgba(225, 29, 72, .28);
}
.dms-confirm-card.is-warn::before {
  background: linear-gradient(90deg, #9a3412, #ea580c 50%, #fbbf24);
  box-shadow: 0 6px 18px rgba(234, 88, 12, .25);
}
.dms-confirm-card.is-info::before {
  background: linear-gradient(90deg, #0f2744, #2563eb 50%, #7dd3fc);
}
@keyframes dmsDialogShine {
  from { opacity: 0; transform: translateX(-70%) rotate(8deg); }
  30% { opacity: .7; }
  to { opacity: 0; transform: translateX(70%) rotate(8deg); }
}
@keyframes dmsDialogIn {
  from { opacity: 0; transform: translateY(10px) scale(.975); }
  to { opacity: 1; transform: none; }
}
@keyframes dmsDialogOut {
  to { opacity: 0; transform: translateY(8px) scale(.98); }
}
@keyframes dmsMarkFloat {
  0%, 100% { transform: translateY(0) translateZ(18px); }
  50% { transform: translateY(-3px) translateZ(24px); }
}
.dms-confirm-card.is-form {
  width: 100%;
}
.dms-confirm-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, .9);
  background: linear-gradient(180deg, rgba(255,255,255,.95) 0%, rgba(248,250,252,.9) 100%);
}
.dms-dialog-mark {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #1d4ed8;
  background:
    linear-gradient(160deg, #ffffff 0%, #eff6ff 55%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  box-shadow:
    0 1px 0 rgba(255,255,255,.9) inset,
    0 10px 22px rgba(37, 99, 235, .18),
    0 2px 0 rgba(15, 39, 68, .06);
  transform: translateZ(20px);
}
.dms-dialog-3d.is-open .dms-dialog-mark {
  animation: dmsMarkFloat 2.8s ease-in-out infinite;
}
.dms-dialog-mark span { display: block; line-height: 1; }
.dms-confirm-card.is-danger .dms-dialog-mark {
  color: #be123c;
  background: linear-gradient(160deg, #fff 0%, #fff1f2 55%, #ffe4e6 100%);
  border-color: #fecdd3;
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 10px 22px rgba(190, 18, 60, .16);
}
.dms-confirm-card.is-warn .dms-dialog-mark {
  color: #c2410c;
  background: linear-gradient(160deg, #fff 0%, #fff7ed 55%, #ffedd5 100%);
  border-color: #fed7aa;
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset, 0 10px 22px rgba(234, 88, 12, .16);
}
.dms-dialog-copy { min-width: 0; flex: 1; }
.dms-dialog-kicker {
  margin: 0 0 4px !important;
  font-size: .68rem !important;
  font-weight: 800 !important;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #64748b !important;
}
.dms-confirm-head h3 {
  margin: 0 0 6px !important;
  font-size: 1.22rem !important;
  font-weight: 800;
  color: #0f172a !important;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.dms-confirm-head .muted,
.dms-confirm-sub {
  margin: 0 !important;
  color: #64748b !important;
  font-size: .88rem !important;
  line-height: 1.5;
  display: block;
}
.dms-confirm-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: visible;
  padding: 16px 22px 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.dms-confirm-foot {
  flex: 0 0 auto;
  padding: 14px 24px 18px;
  border-top: 1px solid rgba(226, 232, 240, .9);
  background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.dms-dialog-btn {
  transition: transform .18s ease, box-shadow .18s ease;
}
.dms-dialog-btn:hover {
  transform: translateY(-1px);
}
.dms-dialog-btn-primary {
  box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
}
.dms-dialog-btn-primary:active {
  transform: translateY(1px) scale(.98);
}
.dms-confirm-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: #fef2f2; color: #b91c1c;
  font-size: 1.2rem; margin-bottom: 12px;
}
.dms-confirm-msg {
  margin: 0 0 12px; color: #64748b; font-size: .92rem; line-height: 1.5;
}
.dms-confirm-msg strong { color: #0f172a; }
.dms-confirm-points {
  margin: 0 0 18px; padding: 10px 12px 10px 28px;
  background: #f8fafc; border-radius: 10px; border: 1px solid #e2e8f0;
  color: #334155; font-size: .82rem; line-height: 1.55;
}
.dms-confirm-actions {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
@media (prefers-reduced-motion: reduce) {
  .dms-confirm-card,
  .dms-confirm-backdrop,
  .dms-dialog-mark,
  .dms-dialog-shine {
    animation: none !important;
    transition: opacity .15s ease !important;
  }
  .dms-confirm.is-open .dms-confirm-card {
    transform: none;
    opacity: 1;
  }
}
.dms-field {
  margin: 0 0 16px;
  display: block;
  width: 100%;
}
.dms-field > .dms-label {
  display: block !important;
  width: 100%;
  font-weight: 800 !important;
  font-size: .8rem !important;
  margin: 0 0 8px !important;
  color: #0f172a !important;
  letter-spacing: .01em;
}
.dms-field .req { color: #dc2626; }
.dms-field textarea,
.dms-textarea {
  display: block;
  width: 100% !important;
  min-height: 92px;
  max-width: 100%;
  resize: vertical;
  border: 1px solid #cbd5e1 !important;
  border-radius: 12px !important;
  padding: 11px 12px !important;
  font: inherit !important;
  font-size: .92rem !important;
  line-height: 1.45 !important;
  color: #0f172a !important;
  background: #fff !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}
.dms-dialog-input {
  display: block;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  font-size: .92rem;
  color: #0f172a;
  background: #fff;
}
.dms-dialog-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.dms-field textarea:focus,
.dms-textarea:focus {
  outline: none !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15) !important;
}

/* Radio options — grid so label text never collapses/hides */
.dms-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

/* Two-step save wizard */
.dms-steps {
  display: flex;
  gap: 8px;
  align-items: center;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.dms-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: #94a3b8;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, .12);
}
.dms-step + .dms-step::before {
  content: '';
  width: 14px;
  height: 1px;
  background: rgba(148, 163, 184, .5);
  margin-right: 2px;
}
.dms-step-n {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(148, 163, 184, .35);
  color: #fff;
  font-size: .72rem;
}
.dms-step.is-current { color: #0f172a; background: rgba(212, 175, 55, .18); }
.dms-step.is-current .dms-step-n { background: #d4af37; color: #1f2937; }
.dms-step.is-done { color: #15803d; background: rgba(22, 163, 74, .12); }
.dms-step.is-done .dms-step-n { background: #16a34a; }
.dms-help {
  font-size: .78rem;
  color: #64748b;
  margin: 6px 0 0;
}
.dms-recap {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(148, 163, 184, .1);
  border: 1px solid rgba(226, 232, 240, .9);
  font-size: .85rem;
  color: #334155;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dms-recap-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.dms-recap-item {
  font-size: .8rem;
  color: #475569;
  padding: 4px 8px 4px 22px;
  border-radius: 6px;
  position: relative;
  overflow-wrap: anywhere;
}
.dms-recap-item::before {
  position: absolute;
  left: 7px;
  font-weight: 700;
}
.dms-recap-item.is-added { background: rgba(22, 163, 74, .08); }
.dms-recap-item.is-added::before { content: '+'; color: #16a34a; }
.dms-recap-item.is-removed { background: rgba(220, 38, 38, .08); }
.dms-recap-item.is-removed::before { content: '−'; color: #dc2626; }
.dms-recap-item.is-modified { background: rgba(217, 119, 6, .08); }
.dms-recap-item.is-modified::before { content: '~'; color: #d97706; }
.dms-opt {
  display: grid !important;
  grid-template-columns: 22px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.dms-opt:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}
.dms-opt.is-checked,
.dms-opt:has(.dms-opt-input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #2563eb;
}
.dms-opt-input {
  appearance: auto !important;
  -webkit-appearance: radio !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  margin: 3px 0 0 !important;
  padding: 0 !important;
  opacity: 1 !important;
  position: static !important;
  flex: none !important;
  float: none !important;
  clip: auto !important;
  visibility: visible !important;
  accent-color: #2563eb;
  cursor: pointer;
}
.dms-opt-copy {
  display: block !important;
  min-width: 0;
  max-width: 100%;
  overflow: visible !important;
  white-space: normal !important;
  word-break: break-word;
}
.dms-opt-title {
  display: block !important;
  font-size: .9rem !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  line-height: 1.35 !important;
  margin: 0 0 3px !important;
  white-space: normal !important;
}
.dms-opt-desc {
  display: block !important;
  font-size: .78rem !important;
  font-weight: 500 !important;
  color: #64748b !important;
  line-height: 1.45 !important;
  margin: 0 !important;
  white-space: normal !important;
}
.dms-version-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: .78rem;
  font-weight: 700;
}
.btn-danger-confirm {
  border: 1px solid #dc2626; background: #dc2626; color: #fff;
  border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer;
}
.btn-danger-confirm:hover { background: #b91c1c; border-color: #b91c1c; }
.toc-row.has-edit > a:first-child,
.toc-row.has-edit > .toc-jump,
a.edit-anchor {
  background: transparent;
  border-radius: 0;
  padding: 0;
  color: inherit !important;
  box-shadow: none;
}
a.edit-anchor {
  background: #fef9c3; border-radius: 6px; padding: 2px 6px;
  color: #854d0e !important; box-shadow: inset 3px 0 0 #eab308;
}
.edit-snippet {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.edit-snippet:hover { background: #fffbeb; border-radius: 8px; padding-left: 6px; padding-right: 6px; }
.edit-snippet strong { display: block; font-size: .84rem; color: var(--ink); }
.edit-snippet small { color: var(--muted); font-size: .72rem; }
.edit-bar {
  width: 4px; align-self: stretch; border-radius: 99px;
  background: #eab308; flex-shrink: 0; min-height: 28px;
}
.doc-meta-grid { margin-top: 16px; }
.diff-card:target {
  outline: 2px solid #eab308; box-shadow: 0 0 0 4px #fef08a;
}
.row-unseen td { background: #fffbeb; }
.row-seen td { background: transparent; }

/* ===== Dual-mode Topic Editor + Reader Preview ===== */
:root {
  --te-green: #2f9e44;
  --te-green-dark: #237a34;
  --reader-navy: #0f1b2d;
}
body.is-reader-preview .side-nav,
body.is-reader-preview .topbar {
  display: none !important;
}
body.is-reader-preview .app-shell {
  grid-template-columns: 1fr !important;
  margin: 0 !important;
  max-width: none !important;
}
body.is-reader-preview .main-wrap,
body.is-reader-preview .content-wrap {
  padding: 0 !important;
  max-width: none !important;
}
.doc-dual { display: flex; flex-direction: column; gap: 0; }
/* Default is Topic Editor. Never show both chromes if a mode class is missing. */
.doc-dual:not(.mode-reader) .reader-only { display: none !important; }
.doc-dual.mode-reader .editor-only { display: none !important; }
.doc-dual.mode-editor .reader-only { display: none !important; }

.reader-chrome { background: #fff; border-bottom: 1px solid var(--line); }
.reader-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--reader-navy); color: #e8eef7; padding: 10px 18px;
}
.reader-back { color: #c9d4e5; text-decoration: none; font-size: .86rem; font-weight: 600; }
.reader-back:hover { color: #fff; }
.reader-topbar-center { text-align: center; }
.reader-kicker { display: block; font-size: .65rem; letter-spacing: .12em; text-transform: uppercase; color: #93a4bd; }
.reader-topbar-center strong { font-size: .95rem; }
.reader-topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn-reader-link {
  background: var(--te-green); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 14px; font-weight: 700; font-size: .82rem; cursor: pointer;
}
.btn-reader-link:hover { background: var(--te-green-dark); }
.reader-brandbar {
  display: flex; align-items: center; gap: 24px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.reader-brand { font-weight: 800; font-size: 1.05rem; color: #111827; }
.reader-brand-nav { display: flex; gap: 18px; flex: 1; justify-content: center; }
.reader-brand-nav a {
  color: #1f2937; text-decoration: none; font-size: .78rem; font-weight: 700;
  letter-spacing: .06em;
}
.reader-brand-nav a:hover { color: var(--te-green); }
.reader-user-orb {
  width: 34px; height: 34px; border-radius: 50%; background: #e5e7eb;
  display: grid; place-items: center; font-weight: 800; color: #374151;
}
.reader-crumbbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 18px; background: #f8fafc; border-bottom: 1px solid var(--line);
}
.reader-crumbs { display: flex; gap: 8px; align-items: center; font-size: .84rem; color: var(--muted); }
.reader-crumbs strong { color: var(--ink); }
.reader-search {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; min-width: 200px;
  font-size: .85rem; background: #fff;
}

.te-crumbs { margin-bottom: 10px; }
.te-toolbar {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.te-toolbar-premium {
  justify-content: flex-start;
  align-items: center;
  padding: 10px 0 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
  overflow: visible; /* never clip Export/Publish dropdowns */
}
.te-toolbar-premium .te-toolbar-left {
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  align-items: center;
  width: 100%;
  overflow: visible;
}
.te-toolbar-left { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-te-edit {
  background: var(--te-green); color: #fff !important; border: 0; border-radius: 8px;
  padding: 8px 16px; font-weight: 800; letter-spacing: .04em; text-decoration: none;
  font-size: .82rem;
  display: inline-flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
}
.btn-te-edit:hover { background: var(--te-green-dark); color: #fff !important; }
.btn-te-view {
  background: #0f2744; color: #fff !important; border: 0; border-radius: 8px;
  padding: 8px 16px; font-weight: 800; letter-spacing: .04em; text-decoration: none;
  font-size: .82rem;
  display: inline-flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
}
.btn-te-view:hover { background: #16365c; color: #fff !important; }
.btn-te-view.is-active { box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.btn-te-ghost {
  background: transparent; border: 0; color: #4b5563; font-weight: 700; font-size: .78rem;
  letter-spacing: .04em; padding: 8px 12px; cursor: pointer; text-decoration: none;
  border-radius: 8px; white-space: nowrap;
  flex: 0 0 auto;
}
.btn-te-ghost:hover, .btn-te-ghost:disabled { color: #111827; background: #f1f5f9; }
.btn-te-ghost:disabled { opacity: .45; cursor: not-allowed; }
.btn-te-danger { color: #b91c1c !important; }
.btn-te-danger:hover { background: #fef2f2 !important; color: #991b1b !important; }
.btn-te-icon {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 10px; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.te-dropdown-smooth {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
  padding: 6px;
  min-width: 180px;
  z-index: 4000 !important;
}
.te-dropdown-smooth .dropdown-item {
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 600;
  padding: 8px 12px;
}
.te-toolbar-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 4px 4px 4px 14px;
  border-left: 1px solid #e2e8f0;
  flex: 0 0 auto;
  white-space: nowrap;
}
.te-status-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}
.te-status-pill {
  font-size: .8rem;
  font-weight: 700;
  color: #0f172a;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}
.te-toolbar-meta {
  display: grid; grid-template-columns: repeat(3, minmax(110px, 1fr)); gap: 8px 14px;
  font-size: .75rem;
}
.te-meta-item span { display: block; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .62rem; }
.te-meta-item strong { color: var(--ink); font-size: .84rem; }
.te-status-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}
.te-status-form select {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 6px 28px 6px 12px;
  font-size: .8rem;
  font-weight: 700;
  background: #f8fafc;
  color: #0f172a;
  min-width: 110px;
  white-space: nowrap;
}
.dual-main-head-compact {
  padding: 4px 0 10px;
  border-bottom: 0;
  margin-bottom: 4px;
}
.dual-main-head-compact .dual-doc-title {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.doc-dual-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  align-items: start;
}
.doc-dual.mode-reader .doc-dual-body {
  grid-template-columns: 240px minmax(0, 1fr);
  padding: 0;
  background: #f3f4f6;
  gap: 0;
}
.dual-left {
  padding: 10px 8px !important;
  position: sticky; top: 64px;
  max-height: calc(100vh - 80px);
  overflow-x: hidden;
  overflow-y: auto;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  border-radius: 0 !important;
  box-shadow: none !important;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
body.is-reader-preview .dual-left { top: 12px; max-height: calc(100vh - 24px); }
.dual-toc-wrap,
#tocPanel.dual-toc-wrap,
.dual-left .toc-panel {
  overflow: visible !important;
  max-height: none !important;
  min-height: 0;
  flex: 1 1 auto;
}
.dual-left .toc-tree {
  max-height: none;
  overflow: visible;
}
.toc-more-menu {
  position: fixed !important;
  z-index: 13000 !important;
  right: auto;
  top: auto;
}
.toc-float-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12000;
}
.toc-float-host > * { pointer-events: auto; }
.dual-doc-list { display: grid; gap: 2px; margin: 8px 0 12px; }
.dual-doc-item {
  display: block; padding: 6px 8px; border-radius: 5px; text-decoration: none;
  color: var(--ink); font-size: .74rem; font-weight: 600;
  white-space: normal; overflow: visible; text-overflow: unset;
  line-height: 1.35; word-break: normal; overflow-wrap: break-word; hyphens: none;
}
.dual-doc-item:hover { background: #f3f4f6; }
.dual-doc-item.is-active { background: #ece7f5; color: #3b0764; font-weight: 800; }
.dual-toc-wrap { margin-top: 8px; padding: 10px !important; min-height: 0; }
.dual-left-foot { display: grid; gap: 8px; margin-top: 12px; }
.btn-te-new {
  background: var(--te-green); color: #fff !important; text-align: center; text-decoration: none;
  border-radius: 6px; padding: 10px; font-weight: 800; letter-spacing: .04em; font-size: .82rem;
}
.btn-te-import {
  background: #fff; color: #111 !important; text-align: center; text-decoration: none;
  border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-weight: 700; font-size: .82rem;
}
.toc-numbering-toggle {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: .78rem; font-weight: 700; color: #4b5563; cursor: pointer; width: auto;
}
.toc-numbering-toggle input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  flex: 0 0 16px !important;
}
.doc-dual.hide-numbering .toc-num { display: none !important; }

.dual-main { padding: 20px 24px 40px !important; background: #fff; min-height: 520px; min-width: 0; overflow-x: auto; }
.dual-main .section-reader-body,
.dual-main .body-text,
.dual-main .doc-prose {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}
.dual-main .body-text table,
.dual-main .doc-prose table,
.dual-main table.doc-table {
  max-width: 100%;
  width: max-content;
  min-width: 100%;
}
.dual-main .table-wrap,
.dual-main .body-text,
.dual-main .doc-prose {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Topic editor: sticky actions + independent content scroll */
.doc-dual.mode-editor {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
}
.doc-dual.mode-editor .editor-chrome {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
  background: #fff;
  padding-bottom: 2px;
  overflow: visible;
}
.doc-dual.mode-editor .editor-chrome .te-toolbar,
.doc-dual.mode-editor .editor-chrome .dropdown,
.doc-dual.mode-editor .editor-chrome .dropdown-menu {
  overflow: visible;
}
.doc-dual.mode-editor .doc-dual-body {
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}
.doc-dual.mode-editor .dual-main {
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #eef2f7;
}
.doc-dual.mode-editor .dual-main::-webkit-scrollbar { width: 10px; height: 10px; }
.doc-dual.mode-editor .dual-main::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
}
.doc-dual.mode-editor .dual-main::-webkit-scrollbar-track {
  background: #eef2f7;
  border-radius: 999px;
}

/* Closer match to uploaded Word typography in read/edit */
.dual-main .doc-prose,
.dual-main .body-text,
.doc-workspace-edit .doc-rich-editor {
  font-family: "Times New Roman", Times, "Liberation Serif", serif;
  font-size: 12pt;
  line-height: 1.5;
  color: #111;
}
.dual-main .doc-h2,
.dual-main .section-title.doc-h2 {
  font-family: "Times New Roman", Times, serif;
  font-size: 14pt;
  font-weight: 700;
  margin: 0 0 12px;
  color: #111;
}
.dual-main .doc-h3,
.dual-main .section-title.doc-h3 {
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  font-weight: 700;
  margin: 0 0 10px;
  color: #111;
}
.dual-main .doc-prose p,
.doc-workspace-edit .doc-rich-editor p {
  margin: 0 0 10px;
}
.dual-main .doc-prose table,
.doc-workspace-edit .doc-rich-editor table {
  border-collapse: collapse;
  table-layout: fixed;
  max-width: 100%;
}
.dual-main .doc-prose td,
.dual-main .doc-prose th,
.doc-workspace-edit .doc-rich-editor td,
.doc-workspace-edit .doc-rich-editor th {
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.te-locale { margin: 0 0 4px; font-size: .75rem; color: var(--muted); }
.dual-doc-title { margin: 0 0 8px; font-size: clamp(1.35rem, 2.4vw, 1.85rem); font-weight: 800; }
.dual-icon-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  text-decoration: none; color: #4b5563; font-size: .92rem; cursor: pointer;
}
.icon-btn:hover { background: #f8fafc; color: #111; }
.dual-meta-line { margin: 0 0 16px; color: var(--muted); font-size: .84rem; }

.doc-cover-page {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 420px; padding: 28px 8px 40px; margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.doc-cover-acro { display: grid; gap: 6px; }
.doc-cover-row { display: flex; gap: 10px; align-items: baseline; }
.doc-cover-letter {
  font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 900; line-height: 1; color: #111;
  min-width: 1.1ch;
}
.doc-cover-word {
  font-size: clamp(1.35rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: .02em; color: #111;
}
.doc-cover-brand {
  margin-top: 40px; text-align: center; color: #374151;
}
.doc-cover-brand strong { display: block; font-size: 1.1rem; }
.doc-cover-brand span { display: block; font-size: .72rem; letter-spacing: .08em; margin-top: 4px; }
.doc-cover-mark { margin-top: 12px; font-size: 1.4rem; color: #6b7280; }

.dual-related { padding: 14px !important; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.dual-related h3 { margin: 0 0 10px; font-size: .95rem; }
.related-list { display: grid; gap: 2px; }
.related-jump {
  display: block; padding: 7px 8px; border-radius: 4px; text-decoration: none;
  color: #374151; font-size: .72rem; font-weight: 650; line-height: 1.4;
  white-space: normal; overflow-wrap: break-word; word-break: normal; hyphens: none;
}
.related-jump:hover, .related-jump.is-active { background: #ece7f5; color: #3b0764; }

.doc-dual.mode-editor .section-reader-body > .content-block { display: none !important; }
.doc-dual.mode-editor .section-reader-body > .content-block.is-preview-block,
.doc-dual.mode-editor .section-reader-body > .content-block.is-active { display: block !important; margin-bottom: 18px; }
.doc-dual.mode-reader .section-reader-body > .content-block {
  display: block !important; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.doc-dual.mode-reader .section-reader-body.is-section-focus > .content-block { display: none !important; }
.doc-dual.mode-reader .section-reader-body.is-section-focus > .content-block.is-active { display: block !important; border-bottom: 0; }

@media (max-width: 980px) {
  .doc-dual-body,
  .doc-dual.mode-reader .doc-dual-body { grid-template-columns: 1fr; }
  .dual-left { position: static; max-height: none; }
  .te-toolbar-meta { grid-template-columns: 1fr 1fr; }
}
@media print {
  .reader-chrome, .dual-left, .side-nav, .topbar, .editor-chrome { display: none !important; }
  .doc-dual-body { display: block !important; }
  .dual-main { box-shadow: none !important; border: 0 !important; }
}

/* ---- Compact typography v44 (theme colors unchanged) ---- */
body.dms-body, body.guest-body { font-size: 14px; line-height: 1.45; }
.page-title { font-size: clamp(1.25rem, 2vw, 1.55rem) !important; }
.hero-strip { padding: 16px 18px !important; }
.hero-strip h2 { font-size: clamp(1.2rem, 2vw, 1.45rem) !important; margin-bottom: 4px !important; }
.hero-strip .muted { font-size: .85rem !important; }
.stat-card { padding: 12px 14px !important; }
.stat-card span { font-size: .7rem !important; }
.stat-card strong { font-size: 1.35rem !important; }
.panel-h h3, .lux-card h3 { font-size: .95rem !important; }
.panel { padding: 14px 16px !important; }
.lux-table, .table { font-size: .82rem !important; }
.lux-table th, .table th { font-size: .68rem !important; padding: 8px 10px !important; }
.lux-table td, .table td { padding: 8px 10px !important; }
.nav-label, .nav-sub-link, .nav-op-name, .nav-doc-link { font-size: .8rem !important; }
.btn-primary, .btn-ghost, .mag-btn { font-size: .82rem !important; padding: 7px 12px !important; }
label, .dms-label { font-size: .8rem !important; }
input, select, textarea { font-size: .85rem !important; }
.chip { font-size: .65rem !important; }
.chart-wrap { height: 220px; position: relative; }
.chart-wrap-sm { height: 200px; }
.charts-row { margin-bottom: 14px; }
.section-anchor { display: block; position: relative; top: -80px; height: 0; visibility: hidden; }
.doc-internal-link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }

/* ---- Document layout variations ---- */
.doc-layout-classic .dual-main, .doc-layout-classic .reader-body { font-family: "Instrument Serif", Georgia, serif; }
.doc-layout-classic h1, .doc-layout-classic h2, .doc-layout-classic h3 { color: #1e3a8a; letter-spacing: .01em; }
.doc-layout-modern .dual-main, .doc-layout-modern .reader-body { font-family: Manrope, system-ui, sans-serif; }
.doc-layout-modern h1, .doc-layout-modern h2, .doc-layout-modern h3 { color: #0f172a; font-weight: 800; }
.doc-layout-compact .dual-main, .doc-layout-compact .reader-body { font-size: .92rem; line-height: 1.4; }
.doc-layout-compact h1, .doc-layout-compact h2, .doc-layout-compact h3 { color: #334155; margin-bottom: .35em; }
.doc-layout-formal .dual-main, .doc-layout-formal .reader-body { font-family: "Instrument Serif", Georgia, serif; }
.doc-layout-formal h1, .doc-layout-formal h2, .doc-layout-formal h3 { color: #5c4a32; border-bottom: 1px solid rgba(92,74,50,.2); padding-bottom: .25em; }
.doc-layout-classic, .doc-layout-modern, .doc-layout-compact, .doc-layout-formal { --doc-layout-ready: 1; }

/* ---- New document mode pick ---- */
.doc-mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 760px;
}
.doc-mode-card {
  display: block;
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 24px rgba(15,23,42,.05);
}
.doc-mode-card:hover { border-color: #93c5fd; box-shadow: 0 10px 28px rgba(29,78,216,.08); }
.doc-mode-ico { display: block; font-size: 1.4rem; margin-bottom: 8px; }
.doc-mode-card strong { display: block; font-size: 1.05rem; margin-bottom: 6px; }
.doc-mode-card p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.45; }
@media (max-width: 720px) { .doc-mode-pick { grid-template-columns: 1fr; } }

/* ---- Reader chrome: logo left, links right ---- */
.reader-brand-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.reader-logo { height: 28px; width: auto; max-width: 140px; object-fit: contain; }
.reader-brand { font-size: .92rem !important; }
.reader-topbar { padding: 7px 14px !important; }
.reader-brandbar { padding: 8px 14px !important; gap: 16px !important; }
.reader-crumbbar { padding: 7px 14px !important; }
.reader-kicker { font-size: .58rem !important; }
.reader-topbar-center strong { font-size: .82rem !important; }
.btn-reader-link { padding: 6px 12px !important; font-size: .75rem !important; }
.dual-doc-title { font-size: 1.25rem !important; line-height: 1.25; }
.dual-main { padding: 14px 18px 28px !important; }
.doc-prose, .body-text, .section-reader-body { font-size: .88rem; line-height: 1.55; }
.doc-prose p, .body-text p { margin: 0 0 .55em; }
.doc-prose table, .body-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: .82rem;
}
.doc-prose th, .doc-prose td, .body-text th, .body-text td {
  border: 1px solid #cbd5e1;
  padding: 5px 7px;
  vertical-align: top;
}
.doc-prose img, .body-text img, .doc-rich-editor img { max-width: 100%; height: auto; }
.doc-rich-editor .table-wrap { overflow-x: auto; margin: 0 0 16px; }
.doc-rich-editor table {
  width: 100%; border-collapse: collapse; font-size: .82rem; background: #fff;
}
.doc-rich-editor th, .doc-rich-editor td {
  border: 1px solid #cbd5e1; padding: 5px 7px; vertical-align: top;
}
.doc-rich-editor thead th { background: #1e3a5f; color: #fff; }
.doc-table-lep { table-layout: fixed; width: 100%; }
.doc-table-lep th, .doc-table-lep td { text-align: center; }
.doc-table-lep thead th { background: #1e3a5f; color: #fff; }
.doc-table-lep td:empty {
  background: repeating-linear-gradient(-45deg, #dbeafe, #dbeafe 3px, #f1f5f9 3px, #f1f5f9 7px);
  height: 1.15em;
}
.doc-lep-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
  margin: 0 0 18px; align-items: start;
}
.doc-lep-grid .doc-table { margin: 0; font-size: .72rem; }
.doc-approval { margin: 8px 0 18px; }
.doc-approval-flags { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 10px; font-weight: 700; color: #1e3a5f; }
.doc-check.is-on { color: #0f172a; }
.doc-sign-party { font-weight: 700; margin: 0 0 8px; }
.doc-sign-field { margin: 0 0 6px; }
.doc-sign-mark { min-height: 56px; margin-top: 4px; }
.doc-sign-mark .doc-asset,
.doc-sign-mark .doc-figure {
  margin: 0; border: 0; box-shadow: none; background: transparent; overflow: visible;
}
.doc-sign-mark img, .doc-sign-mark .doc-asset img {
  max-height: 88px; width: auto; max-width: 100%; display: block;
}
@media (max-width: 900px) { .doc-lep-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- TOC change indicator + rearrange ---- */
.toc-changed-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #eab308;
  box-shadow: 0 0 0 2px #fef08a;
  flex: 0 0 auto;
}
.toc-row.has-edit { box-shadow: inset 3px 0 0 #eab308; background: #fffbeb; }
.dual-doc-item.has-edit { box-shadow: inset 3px 0 0 #eab308; background: #fffbeb; }
.toc-move-form { display: inline-flex; margin: 0; }
.toc-move-btn {
  width: 18px; height: 18px; padding: 0; border: 1px solid #e2e8f0;
  background: #fff; border-radius: 4px; font-size: .55rem; line-height: 1;
  color: #64748b; cursor: pointer;
}
.toc-move-btn:hover { border-color: #93c5fd; color: #1d4ed8; }
.toc-row.is-dragging { opacity: .45; }
.toc-row.is-drop-target { outline: 1px dashed #1d4ed8; }

/* ---- Per-line revision bars (hidden in operator document view) ---- */
.content-block.content-edited {
  background: transparent !important;
  border-left: 0 !important;
  padding-left: 0 !important;
}
.export-edit-marked {
  display: block;
  margin: 2px 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  border-left: 0 !important;
}
.export-edit-kind-edit,
.export-edit-kind-new { border-left: 0 !important; padding-left: 0 !important; }
.export-edit-kind-new .export-edit-dual { border-left: 0 !important; padding-left: 0 !important; }
.export-edit-bar,
.export-edit-bar-black,
.export-edit-bar-amber,
.export-edit-bar-link { display: none !important; width: 0 !important; padding: 0 !important; }
.export-edit-body { display: block; padding-left: 0 !important; }
.export-edit-body p { margin: 0 0 .4em; }
.export-edit-mark-link { color: inherit; text-decoration: none; }
.edit-badge-link { display: none !important; }
.toc-changed-dot { display: none !important; }
.toc-row.has-edit,
.dual-doc-item.has-edit {
  box-shadow: none !important;
  background: transparent !important;
}

/* ---- Compact premium density ---- */
.hero-strip h2 { font-size: 1.35rem !important; }
.panel { padding: 16px 18px; }
.toc-title, .toc-jump, .dual-doc-item { font-size: .78rem !important; }
.related-jump { font-size: .72rem !important; letter-spacing: .02em; }
.te-toolbar { padding: 8px 0 10px !important; margin-bottom: 8px !important; }

/* ---- Upload TOC studio (fills the page) ---- */
body:has(.toc-studio) .main-panel { padding: 10px 16px 10px; }
body:has(.toc-studio) .topbar { margin-bottom: 8px; padding: 8px 14px; }
body:has(.toc-studio) .page-title { font-size: 1.1rem !important; }
.toc-studio {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  height: calc(100vh - 96px);
  min-height: 0;
}
.toc-studio-hero {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  flex: 0 0 auto; padding: 10px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 70%);
  border: 1px solid #dbeafe;
}
.toc-studio-hero h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.02em; }
.toc-studio-hero .eyebrow { margin: 0 0 2px; }
.toc-studio-hero .muted { margin: 0; font-size: .78rem; }
.toc-studio-meta { display: flex; align-items: center; gap: 8px; }
.toc-studio-doc {
  font-weight: 700; color: var(--ink); max-width: 280px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc-studio-count {
  font-size: .75rem; color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.toc-studio-count strong { color: var(--brand); }
.toc-studio-board {
  min-height: 0; height: 100%;
  display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.15fr);
  grid-template-rows: minmax(0, 1fr);
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.toc-studio-list,
.toc-studio-preview {
  min-width: 0; min-height: 0; height: 100%; overflow: hidden;
  display: grid;
}
.toc-studio-list {
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line); background: #f8fafc;
}
.toc-studio-preview { grid-template-rows: minmax(0, 1fr); background: #fff; }
.toc-studio-toolbar {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.toc-studio-search {
  flex: 1; margin: 0 !important; padding: 7px 10px !important;
  border-radius: 9px !important; background: var(--bg-soft) !important; font-size: .8rem !important;
}
.toc-studio-tree {
  min-height: 0; height: 100%; overflow: auto;
  padding: 8px; display: flex; flex-direction: column; gap: 4px;
}
.toc-studio-row { padding-left: calc(var(--depth, 0) * 16px); flex: 0 0 auto; }
.toc-studio-main {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 32px auto;
  gap: 6px; align-items: center; padding: 6px 8px;
  background: #fff; border: 1px solid #e8eef5; border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.toc-studio-row:hover .toc-studio-main { border-color: #bfdbfe; box-shadow: 0 4px 12px rgba(29, 78, 216, .06); }
.toc-studio-row.is-open .toc-studio-main {
  background: #eff6ff; border-color: #93c5fd;
  box-shadow: inset 3px 0 0 var(--brand);
}
.toc-studio-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 24px; padding: 0 5px; border-radius: 7px;
  background: #f1f5f9; color: var(--brand-deep); font-size: .7rem; font-weight: 800;
}
.toc-studio-fields { min-width: 0; display: grid; gap: 0; }
.toc-studio-title {
  width: 100%; margin: 0 !important; padding: 2px 2px !important;
  border: 0 !important; background: transparent !important; box-shadow: none !important;
  font-size: .82rem !important; font-weight: 700 !important; color: var(--ink) !important;
}
.toc-studio-title:focus { background: #fff !important; border-radius: 6px !important; padding: 3px 7px !important; box-shadow: 0 0 0 3px var(--brand-soft) !important; }
.toc-studio-type { font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2); }
.toc-studio-docbtn {
  width: 30px; height: 30px; border: 1px solid #dbeafe; border-radius: 8px;
  background: #f8fbff; color: var(--brand); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .15s ease;
}
.toc-studio-docbtn:hover, .toc-studio-row.is-open .toc-studio-docbtn {
  background: var(--brand); color: #fff; border-color: var(--brand);
}
.toc-studio-docbtn.is-empty { color: #94a3b8; background: #f8fafc; border-color: #e2e8f0; }
.toc-studio-docbtn.has-body { box-shadow: 0 0 0 3px rgba(29, 78, 216, .08); }
.toc-studio-btns { display: flex; gap: 2px; opacity: .55; }
.toc-studio-row:hover .toc-studio-btns, .toc-studio-row.is-open .toc-studio-btns { opacity: 1; }
.toc-ed-btn {
  width: 24px; height: 24px; border: 1px solid #e2e8f0; background: #fff;
  border-radius: 6px; cursor: pointer; font-size: .64rem; color: #475569;
}
.toc-ed-btn:hover { border-color: #93c5fd; color: #1d4ed8; }
.toc-ed-btn.danger:hover { border-color: #fca5a5; color: #b91c1c; }
.toc-studio-empty {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 20px; color: var(--muted); min-height: 0;
}
.toc-studio-empty h3 { margin: 12px 0 6px; color: var(--ink); font-size: 1.05rem; }
.toc-studio-empty-ico {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; background: #eff6ff; color: var(--brand);
  border: 1px solid #dbeafe;
}
.toc-studio-article {
  min-height: 0; height: 100%;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
}
.toc-studio-article-head {
  flex: 0 0 auto; position: relative; padding: 14px 18px 10px; border-bottom: 1px solid var(--line);
  background: #f8fbff;
}
.toc-studio-article-label {
  display: block; font-size: .68rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 4px;
}
.toc-studio-article-head h3 { margin: 0 28px 0 0; font-size: 1.05rem; line-height: 1.3; }
.toc-studio-close {
  position: absolute; top: 12px; right: 12px; width: 28px; height: 28px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer;
}
.toc-studio-article-body {
  min-height: 0; height: 100%; overflow: auto;
  padding: 16px 18px 24px;
  font-size: .9rem; line-height: 1.65; color: var(--ink-2);
}
.toc-studio-article-body p { margin: 0 0 .8em; }
.toc-studio-article-body .table-wrap { overflow-x: auto; margin: 0 0 16px; }
.toc-studio-article-body table.doc-table,
.toc-studio-article-body.doc-prose table {
  width: 100%; border-collapse: collapse; font-size: .78rem;
  background: #fff; border: 1px solid #1e3a5f;
}
.toc-studio-article-body.doc-prose th {
  background: #1e3a5f !important; color: #fff !important;
  font-size: .68rem; letter-spacing: .05em; text-transform: uppercase;
  padding: 7px 8px !important; text-align: center; white-space: nowrap;
}
.toc-studio-article-body.doc-prose td {
  padding: 5px 8px !important; text-align: center; border-color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}
.toc-studio-article-body.doc-prose tbody tr:nth-child(even) td { background: #f8fafc; }
.toc-studio-article-body.doc-prose tbody tr:nth-child(even) td:nth-child(even) { background: #eef2f7; }
.doc-page, .doc-figure {
  margin: 14px 0 18px; border: 1px solid #cbd5e1; border-radius: 8px;
  overflow: hidden; background: #fff; box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}
.doc-page img, .doc-figure img, .toc-studio-article-body img {
  display: block; width: 100%; height: auto;
}
.toc-studio-article-body .doc-sign-mark img,
.doc-prose .doc-sign-mark img,
.doc-sign-mark .doc-asset img {
  width: auto; max-width: 100%; max-height: 88px; height: auto;
}
.doc-page figcaption, .doc-figure figcaption {
  padding: 6px 10px 8px; font-size: .68rem; letter-spacing: .04em;
  text-transform: uppercase; color: #64748b; background: #f8fafc; border-top: 1px solid #e2e8f0;
}
.fid-preview {
  margin: 0 0 12px; padding: 10px 12px; border: 1px solid #dbe4f0; border-radius: 10px;
  background: #f8fafc;
}
.fid-preview-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.fid-preview-label { font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #1e3a5f; }
.fid-preview-state {
  font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #e2e8f0; color: #334155; text-transform: lowercase;
}
.fid-preview[data-status="ready"] .fid-preview-state { background: #dcfce7; color: #166534; }
.fid-preview[data-status="failed"] .fid-preview-state { background: #fee2e2; color: #991b1b; }
.fid-preview[data-status="processing"],
.fid-preview[data-status="uploaded"] .fid-preview-state { background: #fef3c7; color: #92400e; }
.fid-preview-msg { font-size: .78rem; color: #b45309; flex: 1 1 160px; }
.fid-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.fid-upload-busy {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: #eff6ff; color: #1e3a8a; font-weight: 600; font-size: .85rem;
}
.doc-asset, .doc-figure { margin: 12px 0; }
.doc-asset img, .body-text img, .doc-prose img, .doc-rich-editor img {
  max-width: 100%; height: auto;
}
.doc-float-left { float: left; margin: 4px 12px 8px 0; max-width: 48%; }
.doc-float-right { float: right; margin: 4px 0 8px 12px; max-width: 48%; }
.doc-float-center { display: block; margin: 10px auto; text-align: center; }
.doc-wrap-float { overflow: hidden; width: 100%; margin: 6px 0; }
.doc-clear { clear: both; height: 0; margin: 0; padding: 0; line-height: 0; }
.doc-stamp img { max-height: 240px; width: auto !important; height: auto !important; max-width: 100%; }
.doc-table td,
.doc-table th {
  overflow: hidden; /* contain any leftover floats inside the column */
}
.doc-table .doc-float-left,
.doc-table .doc-float-right,
.doc-table .doc-wrap-float .doc-float-left,
.doc-table .doc-wrap-float .doc-float-right {
  float: none !important;
  display: block;
  max-width: 100% !important;
  margin: 4px 0 !important;
}
.doc-table .doc-wrap-float {
  overflow: visible;
  width: auto;
  margin: 2px 0;
}
.doc-stamp-inline,
.doc-table .doc-stamp {
  float: none !important;
  display: inline-block !important;
  vertical-align: middle;
  max-width: 58% !important;
  margin: 2px 0 2px 6px !important;
}
.doc-sign-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 4px 0 8px !important;
}
.doc-sign-line .doc-stamp,
.doc-sign-line .doc-stamp-inline {
  margin-left: 0 !important;
}
.doc-table-sign td p {
  margin: 0 0 4px;
}
.doc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 10px 0 16px;
}
.doc-table > tbody > tr > td,
.doc-table > tr > td {
  vertical-align: top;
  padding: 6px 10px;
  word-wrap: break-word;
}
.doc-table-bordered {
  border: 1px solid #1f2937;
}
.doc-table-bordered > tbody > tr > td,
.doc-table-bordered > tr > td {
  border: 1px solid #1f2937;
}
.doc-table-sign {
  border: 1px solid #111;
  background: #fff;
  width: 100% !important;
  max-width: 100%;
  table-layout: fixed;
}
.doc-table-sign > tbody > tr > td,
.doc-table-sign > tr > td,
.doc-prose .doc-table-sign td,
.body-text .doc-table-sign td {
  border: none !important;
  width: 50%;
  padding: 8px 12px;
}
.doc-table-sign .doc-float-left,
.doc-table-sign .doc-float-right {
  max-width: 58%;
}
.doc-table-sign .doc-wrap-float { margin: 2px 0; }
.doc-table-sign p { margin: 0 0 4px; }
.doc-asset-missing {
  margin: 12px 0; padding: 12px; border: 1px dashed #b45309; background: #fffbeb; color: #92400e;
}
.doc-sign-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 12px 0 18px; padding: 14px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff;
}
.doc-sign-col { min-width: 0; }
.doc-sign-label { display: block; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #1e3a5f; }
.doc-sign-mark .doc-float-left,
.doc-sign-mark .doc-float-right,
[data-sign-slot] .doc-float-left,
[data-sign-slot] .doc-float-right {
  float: none; max-width: 100%; margin: 2px 0;
}
@media (max-width: 720px) { .doc-sign-grid { grid-template-columns: 1fr; } }
.toc-studio-none { color: var(--muted); font-style: italic; }
.toc-studio-foot {
  flex: 0 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 0 2px;
}
.toc-studio-actions { display: flex; gap: 8px; }
@media (max-width: 980px) {
  .toc-studio { height: auto; min-height: calc(100vh - 118px); }
  .toc-studio-board { grid-template-columns: 1fr; min-height: 70vh; }
  .toc-studio-list { border-right: 0; border-bottom: 1px solid var(--line); min-height: 42vh; }
  .toc-studio-preview { min-height: 36vh; }
  .toc-studio-hero, .toc-studio-foot { flex-direction: column; align-items: flex-start; }
  .toc-studio-meta { align-items: flex-start; }
  .toc-studio-main { grid-template-columns: 48px minmax(0, 1fr) 34px; }
  .toc-studio-btns { grid-column: 1 / -1; justify-content: flex-end; }
}

/* ===== Premium reader preview ===== */
body.is-reader-preview {
  --rp-navy: #0b1220;
  --rp-navy-2: #152238;
  --rp-paper: #fcfdff;
  --rp-mist: #e7edf5;
  --rp-line: rgba(15, 23, 42, .08);
  --rp-gold: #c4a574;
  background: #e6ecf4;
}
body.is-reader-preview .dream-bg {
  background:
    radial-gradient(920px 420px at 8% -10%, rgba(29, 78, 216, .1), transparent 58%),
    radial-gradient(720px 360px at 100% 0%, rgba(15, 23, 42, .06), transparent 50%),
    linear-gradient(180deg, #eef3f8 0%, #e4ebf3 100%);
}
body.is-reader-preview .main-panel {
  padding: 0 !important;
  background: transparent;
}
body.is-reader-preview .flash {
  margin: 0;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid rgba(4, 120, 87, .18);
  padding: 10px 22px;
  font-size: .82rem;
  letter-spacing: .01em;
  text-align: center;
}
body.is-reader-preview .reader-chrome {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--rp-line);
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
body.is-reader-preview .reader-progress {
  height: 2px;
  background: transparent;
}
body.is-reader-preview .reader-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d4ed8, #16a34a);
  transition: width .12s linear;
}
body.is-reader-preview .reader-topbar {
  background: linear-gradient(180deg, var(--rp-navy) 0%, var(--rp-navy-2) 100%) !important;
  color: #e8eef7;
  padding: 9px 22px !important;
  position: relative;
}
body.is-reader-preview .reader-topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--rp-gold), #16a34a, transparent);
}
body.is-reader-preview .reader-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #c5d0e0;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .01em;
}
body.is-reader-preview .reader-back:hover { color: #fff; }
body.is-reader-preview .reader-kicker {
  display: inline-block !important;
  font-size: .58rem !important;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #9fb0c8;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 3px;
}
body.is-reader-preview .reader-topbar-center strong {
  display: block;
  font-size: .88rem !important;
  font-weight: 700;
  letter-spacing: -.01em;
  color: #f8fafc;
}
body.is-reader-preview .btn-tool {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #d7e0ee;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
body.is-reader-preview .btn-tool:hover { background: rgba(255,255,255,.12); color: #fff; }
body.is-reader-preview .btn-reader-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(180deg, #22c55e, #16a34a) !important;
  box-shadow: 0 6px 16px rgba(22, 163, 74, .28);
  border-radius: 10px !important;
  padding: 7px 13px !important;
  font-size: .75rem !important;
  letter-spacing: .02em;
}
body.is-reader-preview .btn-reader-link:hover { filter: brightness(1.05); }
body.is-reader-preview .reader-brandbar {
  padding: 10px 22px !important;
  background: rgba(255,255,255,.72) !important;
  border-bottom: 1px solid var(--rp-line) !important;
}
body.is-reader-preview .reader-logo {
  height: 30px;
  max-width: 150px;
}
body.is-reader-preview .reader-brand {
  font-size: .98rem !important;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #0f172a;
}
body.is-reader-preview .reader-brand-nav {
  gap: 6px !important;
}
body.is-reader-preview .reader-brand-nav a {
  color: #334155;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  padding: 6px 10px;
  border-radius: 999px;
}
body.is-reader-preview .reader-brand-nav a:hover {
  color: #1d4ed8;
  background: #eff6ff;
}
body.is-reader-preview .reader-user-orb {
  width: 36px;
  height: 36px;
  background: linear-gradient(180deg, #1e3a8a, #0f172a);
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px #dbeafe;
}
body.is-reader-preview .reader-crumbbar {
  padding: 8px 22px !important;
  background: rgba(248, 250, 252, .7) !important;
}
body.is-reader-preview .reader-crumbs {
  font-size: .8rem;
  color: #64748b;
}
body.is-reader-preview .reader-crumb-sep { opacity: .45; padding: 0 2px; }
body.is-reader-preview .reader-crumbs strong { color: #0f172a; font-weight: 700; }
body.is-reader-preview .reader-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  padding: 0 12px;
  border: 1px solid #d7e0ea;
  border-radius: 999px;
  background: #fff;
  color: #94a3b8;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 8px 18px rgba(15, 23, 42, .04);
}
body.is-reader-preview .reader-search-wrap:focus-within {
  border-color: #93c5fd;
  color: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, .12);
}
body.is-reader-preview .reader-search {
  border: 0 !important;
  background: transparent !important;
  padding: 8px 0 !important;
  min-width: 0;
  flex: 1;
  box-shadow: none !important;
  outline: none;
}
body.is-reader-preview .doc-dual.mode-reader .doc-dual-body {
  /* minmax(0, …) prevents long TOC titles from stretching the rail past its track */
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 36px;
  background: transparent;
}
body.is-reader-preview .dual-left,
body.is-reader-preview .dual-main {
  border: 1px solid var(--rp-line) !important;
  background: var(--rp-paper) !important;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .06);
}
body.is-reader-preview .dual-left {
  border-radius: 18px !important;
  padding: 16px 14px !important;
  top: 148px;
  max-height: calc(100vh - 168px);
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto;
}
body.is-reader-preview .dual-reader-toc,
body.is-reader-preview .dual-doc-list {
  min-width: 0;
  max-width: 100%;
}
body.is-reader-preview .dual-main {
  border-radius: 20px !important;
  padding: 28px 36px 48px !important;
  min-height: 640px;
  min-width: 0 !important;
  max-width: 100%;
  overflow-x: auto;
}
body.is-reader-preview .dual-main .section-reader-body,
body.is-reader-preview .dual-main .body-text,
body.is-reader-preview .dual-main .doc-prose {
  max-width: 100%;
  overflow-x: auto;
}
body.is-reader-preview .reader-rail-head {
  margin: 0 4px 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rp-line);
}
body.is-reader-preview .reader-rail-kicker {
  display: block;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 3px;
}
body.is-reader-preview .reader-rail-head strong,
body.is-reader-preview .reader-rail-head h3 {
  margin: 0;
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: -.015em;
  color: #0f172a;
}
body.is-reader-preview .reader-toc-search {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 2px 10px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  color: #94a3b8;
}
body.is-reader-preview .reader-toc-search .toc-search {
  border: 0;
  background: transparent;
  padding: 8px 0;
  width: 100%;
  font-size: .78rem !important;
  outline: none;
}
body.is-reader-preview .dual-doc-list { gap: 4px; margin: 4px 0 12px; width: 100%; max-width: 100%; }
body.is-reader-preview .dual-doc-item {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px !important;
  border-radius: 10px !important;
  font-size: .74rem !important;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: normal !important;
  overflow: hidden;
  text-overflow: unset;
  min-height: 0;
  height: auto;
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}
body.is-reader-preview .dual-doc-item .toc-num {
  flex: 0 0 auto;
  margin-top: 1px;
  color: #2563eb;
  font-weight: 800;
  white-space: nowrap;
}
body.is-reader-preview .dual-doc-item .toc-title,
body.is-reader-preview .dual-doc-item > span:not(.toc-num):not(.toc-changed-dot) {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  max-width: 100%;
  width: 0; /* force flex child to respect parent width */
  display: block !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}
body.is-reader-preview .dual-doc-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}
body.is-reader-preview .dual-doc-item.is-active {
  background: linear-gradient(90deg, #eff6ff, #f8fbff) !important;
  color: #1e3a8a !important;
  border-color: #dbeafe;
  box-shadow: inset 3px 0 0 #1d4ed8;
  font-weight: 750;
}
body.is-reader-preview .toc-numbering-toggle {
  margin: 8px 4px 0;
  padding-top: 10px;
  border-top: 1px solid var(--rp-line);
  color: #64748b;
  font-weight: 650;
}
body.is-reader-preview .dual-doc-title {
  font-size: clamp(1.45rem, 2.4vw, 1.9rem) !important;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: 12px !important;
}
body.is-reader-preview .dual-icon-row {
  display: inline-flex;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
body.is-reader-preview .icon-btn {
  width: 38px;
  height: 36px;
  border: 0;
  border-right: 1px solid #eef2f7;
  border-radius: 0;
  color: #475569;
  background: transparent;
}
body.is-reader-preview .icon-btn:last-child { border-right: 0; }
body.is-reader-preview .icon-btn:hover {
  background: #f8fafc;
  color: #1d4ed8;
}
body.is-reader-preview .icon-btn:disabled { opacity: .38; }
body.is-reader-preview .dual-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px !important;
  color: #64748b;
  font-size: .78rem;
}
body.is-reader-preview .meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #94a3b8;
}
body.is-reader-preview .section-reader-body > .content-block {
  margin-bottom: 28px !important;
  padding-bottom: 22px !important;
  border-bottom: 1px solid #eef2f7 !important;
}
body.is-reader-preview .section-title {
  font-size: 1.28rem;
  letter-spacing: -.02em;
  margin: 0 0 10px;
}
body.is-reader-preview .path {
  font-size: .72rem;
  color: #94a3b8;
  margin: -4px 0 12px;
}
body.is-reader-preview .doc-prose,
body.is-reader-preview .body-text {
  font-size: .95rem;
  line-height: 1.7;
  color: #1e293b;
}
body.is-reader-preview .related-list { gap: 3px; width: 100%; max-width: 100%; min-width: 0; }
body.is-reader-preview .related-jump {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px !important;
  border-radius: 10px !important;
  font-size: .72rem !important;
  letter-spacing: .01em;
  color: #334155;
  border: 1px solid transparent;
  width: 100%;
  max-width: 100%;
  min-width: 0 !important;
  box-sizing: border-box;
  white-space: normal !important;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
body.is-reader-preview .related-jump .toc-num {
  flex: 0 0 auto;
  white-space: nowrap;
}
body.is-reader-preview .related-jump .toc-title {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  width: 0;
  display: block !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}
body.is-reader-preview .related-jump:hover,
body.is-reader-preview .related-jump.is-active {
  background: linear-gradient(90deg, #eff6ff, #f8fbff) !important;
  color: #1e3a8a !important;
  border-color: #dbeafe;
  box-shadow: inset 3px 0 0 #1d4ed8;
}
@media (max-width: 1100px) {
  body.is-reader-preview .doc-dual.mode-reader .doc-dual-body {
    grid-template-columns: minmax(0, 230px) minmax(0, 1fr);
  }
  body.is-reader-preview .dual-related { display: none; }
}
@media (max-width: 820px) {
  body.is-reader-preview .reader-search-wrap { min-width: 0; width: 100%; }
  body.is-reader-preview .reader-crumbbar { flex-wrap: wrap; }
  body.is-reader-preview .doc-dual.mode-reader .doc-dual-body { grid-template-columns: 1fr; padding: 12px; }
  body.is-reader-preview .dual-left,
  body.is-reader-preview .dual-related { position: static; max-height: none; }
  body.is-reader-preview .dual-main { padding: 20px 18px 32px !important; }
}

.op-view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  gap: 18px;
  align-items: start;
}
.op-view-chrome {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
.op-view-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0b1220;
  color: #e8eef7;
  font-size: .72rem;
}
.op-view-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
}
.op-view-brand img { height: 28px; width: auto; }
.op-view-brand strong { display: block; font-size: .92rem; }
.op-view-brand small { color: #64748b; }
.op-view-brand nav { margin-left: auto; display: flex; gap: 10px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; color: #334155; }
.op-view-cover {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
}
.op-view-acronym { font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; }
@media (max-width: 900px) {
  .op-view-grid { grid-template-columns: 1fr; }
}

/* =========================================================
   Premium UI System v5 — compact enterprise overlay
   Existing class names, IDs, and JS hooks are unchanged.
   ========================================================= */

body.dms-body,
body.guest-body {
  font-size: var(--fs-body);
  line-height: 1.5;
  font-weight: 500;
  color: var(--ink-2);
}
body.dms-body h1, body.dms-body h2, body.dms-body h3, body.dms-body h4,
body.guest-body h1, body.guest-body h2, body.guest-body h3,
.page-title, .brand-name, .login-hero h1, .stat-card strong, .lux-card h3, .panel-h h3 {
  font-weight: 650;
  letter-spacing: -.015em;
}

/* ---- Shell ---- */
body.dms-body:not(.is-reader-preview) .app-shell.nav-expanded {
  grid-template-columns: 248px 1fr;
}
body.dms-body:not(.is-reader-preview) .main-panel {
  padding: 16px 22px 28px !important;
}
body.dms-body:not(.is-reader-preview) .topbar {
  padding: 8px 14px !important;
  margin-bottom: 14px !important;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  top: 8px;
}
body.dms-body .page-title {
  font-size: var(--fs-title) !important;
  line-height: 1.2 !important;
  font-weight: 650 !important;
  margin: 0 !important;
}
body.dms-body .crumb {
  font-size: 11px;
  letter-spacing: .08em;
  font-weight: 650;
}
body.dms-body .top-actions { gap: 8px; }
body.dms-body .mega-search,
body.dms-body .search-form input {
  min-width: 200px;
  height: 38px;
  padding: 0 14px;
  font-size: var(--fs-body);
  border-radius: 8px;
}

/* ---- Sidebar ---- */
body.dms-body .side-nav {
  background: var(--sidebar);
  padding: 12px 8px;
  gap: 6px;
  box-shadow: 4px 0 20px rgba(2, 6, 23, .16);
}
body.dms-body .side-nav.is-expanded { padding: 12px 10px; }
body.dms-body .side-nav-icons .nav-ico,
body.dms-body .nav-ico {
  width: 18px;
  min-width: 18px;
  font-size: 18px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  opacity: .92;
}
body.dms-body .side-nav.is-expanded .nav-links a.nav-top-link,
body.dms-body .side-nav.is-expanded .nav-operators-toggle,
body.dms-body .side-nav.is-expanded .nav-group-toggle {
  min-height: var(--nav-item-h);
  padding: 0 10px;
  border-radius: 8px;
  font-size: var(--fs-nav);
  font-weight: 550;
  gap: 10px;
  align-items: center;
}
body.dms-body .side-nav.is-expanded .nav-label {
  flex: 1;
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
}
body.dms-body .side-nav.is-expanded .nav-caret {
  display: inline-flex;
  margin-left: auto;
  flex: 0 0 14px;
  width: 14px;
  justify-content: center;
  font-size: 11px;
  opacity: .65;
}
body.dms-body .side-nav-icons .nav-operators-toggle.active,
body.dms-body .side-nav-icons .nav-group-toggle.active,
body.dms-body .side-nav-icons .nav-links a.nav-top-link.active,
body.dms-body .nav-links a.active {
  background: rgba(37, 99, 235, .22);
  box-shadow: inset 3px 0 0 #60a5fa;
  color: #fff;
}
body.dms-body .nav-group-panel,
body.dms-body .nav-operators-panel {
  margin: 2px 0 6px 12px;
  padding: 2px 0 2px 8px;
  border-left: 1px solid rgba(148, 163, 184, .22);
}
body.dms-body .nav-sub-link,
body.dms-body .nav-doc-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  margin: 1px 0;
  font-size: 13px !important;
  font-weight: 500;
  border-radius: 7px;
  line-height: 1.25;
}
body.dms-body .nav-op-docs {
  padding-left: 14px;
  margin-left: 10px;
}
body.dms-body .nav-op-link,
body.dms-body .nav-op-toggle {
  min-height: 34px;
  font-size: 13px;
  font-weight: 550;
}
body.dms-body .side-user {
  padding: 8px 10px;
  border-radius: 10px;
  gap: 10px;
}
body.dms-body .side-user .avatar,
body.dms-body .avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
  background: #1d4ed8;
}
body.dms-body .side-user strong { font-size: 13px; font-weight: 650; }
body.dms-body .side-user small { font-size: 11px; }

/* ---- Hero / cards / stats ---- */
body.dms-body .hero-strip {
  padding: 14px 16px !important;
  margin-bottom: 14px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  align-items: center;
}
body.dms-body .hero-strip h2 {
  font-size: var(--fs-title) !important;
  margin: 0 0 2px !important;
  font-weight: 650 !important;
  line-height: 1.2;
}
body.dms-body .hero-strip .muted { font-size: var(--fs-help) !important; margin: 0; }
body.dms-body .eyebrow {
  font-size: 11px;
  letter-spacing: .1em;
  font-weight: 700;
  margin: 0 0 4px;
}
body.dms-body .panel,
body.dms-body .glass-card,
body.dms-body .widget {
  padding: 16px 18px !important;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
body.dms-body .panel:hover,
body.dms-body .widget:hover { box-shadow: var(--shadow); }
body.dms-body .panel-h { margin-bottom: 10px; }
body.dms-body .panel-h h3,
body.dms-body .lux-card h3 {
  font-size: var(--fs-card) !important;
  font-weight: 650 !important;
}
body.dms-body .lux-card {
  padding: 14px 16px;
  border-radius: 10px;
}
body.dms-body .lux-card:hover { transform: none; }
body.dms-body .stat-card {
  padding: 14px 16px !important;
  border-radius: 10px;
}
body.dms-body .stat-card:hover { transform: none; }
body.dms-body .stat-card span { font-size: 11px !important; font-weight: 650; }
body.dms-body .stat-card strong { font-size: 22px !important; font-weight: 650 !important; }
body.dms-body .stat-grid,
body.dms-body .charts-row { gap: 12px; margin-bottom: 14px; }
body.dms-body .chart-wrap { height: 240px; }
body.dms-body .chart-wrap-sm { height: 210px; }

/* ---- Buttons / chips ---- */
body.dms-body .btn-gold,
body.dms-body .btn-primary,
body.dms-body .btn-ghost,
body.dms-body .btn-danger-ghost,
body.dms-body .btn-soft,
body.dms-body .mag-btn,
body.guest-body .btn-primary,
body.guest-body .btn-ghost {
  min-height: var(--btn-h);
  padding: 0 14px !important;
  font-size: var(--fs-btn) !important;
  font-weight: 600 !important;
  border-radius: 8px;
  box-shadow: none;
  transform: none !important;
}
body.dms-body .btn-gold,
body.dms-body .btn-primary,
body.guest-body .btn-primary {
  background: var(--brand);
  color: #fff !important;
}
body.dms-body .btn-gold:hover,
body.dms-body .btn-primary:hover,
body.guest-body .btn-primary:hover {
  background: var(--brand-deep);
  filter: none;
}
body.dms-body .btn-ghost,
body.dms-body .btn-soft {
  background: #fff;
  border: 1px solid var(--line-strong);
}
body.dms-body .btn-xs,
body.dms-body .btn-ghost.btn-xs,
body.dms-body .btn-primary.btn-xs {
  min-height: 30px;
  padding: 0 10px !important;
  font-size: 12px !important;
}
body.dms-body .chip,
body.dms-body .badge {
  font-size: 11px !important;
  font-weight: 650;
  padding: 2px 8px;
  letter-spacing: .02em;
}

/* ---- Forms ---- */
body.dms-body .form-lux label,
body.dms-body label,
body.dms-body .dms-label,
body.guest-body label {
  font-size: var(--fs-label) !important;
  font-weight: 600 !important;
  margin: 12px 0 5px;
  color: var(--ink-2);
}
body.dms-body .form-lux input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
body.dms-body .form-lux select,
body.dms-body .form-lux textarea,
body.dms-body .filter-bar input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
body.dms-body .filter-bar select,
body.dms-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="color"]):not([type="range"]),
body.dms-body select,
body.dms-body textarea,
body.guest-body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
body.guest-body select {
  min-height: var(--control-h);
  font-size: var(--fs-body) !important;
  border-radius: 8px;
  border-color: var(--line-strong);
  padding: 8px 12px;
}
body.dms-body textarea { min-height: 88px; }
body.dms-body .filter-bar { gap: 8px; margin-bottom: 12px; }
body.dms-body .check,
body.guest-body .check {
  margin: 10px 0;
  font-size: var(--fs-label);
  font-weight: 600;
}
body.dms-body .is-invalid,
body.dms-body .form-lux .is-invalid {
  border-color: #fca5a5;
}
body.dms-body .invalid-feedback,
body.dms-body .text-danger { font-size: var(--fs-help); }

/* ---- Tables ---- */
body.dms-body .table-scroll {
  overflow-x: auto;
  min-width: 0;
}
body.dms-body .lux-table,
body.dms-body .table {
  font-size: var(--fs-table) !important;
}
body.dms-body .lux-table th,
body.dms-body .table th {
  font-size: 11.5px !important;
  font-weight: 700 !important;
  padding: 10px 12px !important;
  background: #f8fafc;
  color: #64748b;
  vertical-align: middle !important;
  text-align: center !important;
}
body.dms-body .lux-table th:first-child,
body.dms-body .table th:first-child {
  text-align: left !important;
}
body.dms-body .lux-table td,
body.dms-body .table td {
  padding: 10px 12px !important;
  font-weight: 500;
  vertical-align: middle !important;
  text-align: center !important;
}
body.dms-body .lux-table td:first-child,
body.dms-body .table td:first-child {
  text-align: left !important;
}
body.dms-body .lux-table tr:hover td { background: #f8fafc; }
body.dms-body .lux-table a { font-weight: 600; }
body.dms-body .dropdown-menu {
  z-index: 1080;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
}
/* Bootstrap CDN can fail offline — keep Export/Publish collapsed until .show. */
body.dms-body .dropdown-menu:not(.show) {
  display: none !important;
}
body.dms-body .dropdown-item {
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
}
body.dms-body .panel,
body.dms-body .lux-card,
body.dms-body .table-scroll { overflow: visible; }
body.dms-body .table-scroll { overflow-x: auto; overflow-y: visible; }

/* ---- Flash / empty / pagination ---- */
body.dms-body .flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 550;
}
body.dms-body .empty-state { padding: 28px 16px; }
body.dms-body .empty-state h3 { font-size: var(--fs-section); }
body.dms-body .pagination { gap: 4px; }
body.dms-body .page-link {
  font-size: 13px;
  min-height: 34px;
  padding: 4px 10px;
}

/* ---- Login / guest ---- */
body.guest-body .login-card {
  padding: 28px 26px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
body.guest-body .login-card h2 {
  font-size: 22px !important;
  font-weight: 650;
}
body.guest-body .login-hero h1 {
  font-size: 26px;
  font-weight: 650;
}
body.guest-body .login-hero .lead { font-size: 14px; }

/* ---- Document / template workspaces ---- */
body.dms-body:not(.is-reader-preview) .te-toolbar {
  padding: 8px 0 10px !important;
  margin-bottom: 10px !important;
}
body.dms-body:not(.is-reader-preview) .dual-doc-title {
  font-size: 22px !important;
  font-weight: 650;
}
body.dms-body .upload-zone {
  border-radius: 10px;
  padding: 22px 16px;
}
body.dms-body .doc-rich-editor,
body.dms-body .note-editor,
body.dms-body .tox-tinymce {
  border-radius: 8px;
  overflow: visible;
}
body.dms-body .dropdown-menu,
body.dms-body .note-dropdown-menu,
body.dms-body .tox-menu {
  z-index: 2000 !important;
}
body.dms-body .toc-studio-hero h2 { font-size: 18px !important; }
body.dms-body .kv-row dt { font-size: 11px; font-weight: 650; }
body.dms-body .kv-row dd { font-size: 13px; }

/* ---- Modals ---- */
body.dms-body .modal-content,
body.dms-body .lux-modal {
  border-radius: 22px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
  overflow: hidden;
}
body.dms-body .modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid #eef2f7;
  background: linear-gradient(180deg, #fff, #f8fafc);
}
body.dms-body .modal-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid #eef2f7;
  background: #f8fafc;
}
body.dms-body .modal-title { font-size: 1.15rem; font-weight: 800; }
body.dms-body .modal-body { padding: 16px 24px; font-size: var(--fs-body); max-height: min(70vh, 640px); overflow: auto; }
body.dms-body .modal-backdrop.show {
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(8px);
}

/* ---- Overflow safety ---- */
body.dms-body .card-grid,
body.dms-body .grid-2,
body.dms-body .grid-3,
body.dms-body .stat-grid { min-width: 0; }
body.dms-body .card-grid > *,
body.dms-body .grid-2 > *,
body.dms-body .grid-3 > * { min-width: 0; }
body.dms-body .nav-op-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
body.dms-body .crumb-trail {
  font-size: 12.5px;
  margin-bottom: 12px;
}
body.dms-body .view-toggle {
  border-radius: 8px;
  overflow: hidden;
}
body.dms-body .brand-mark {
  background: var(--brand);
  box-shadow: none;
}
@media (max-width: 1280px) {
  body.dms-body .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1024px) {
  body.dms-body .stat-grid,
  body.dms-body .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }
  body.dms-body .grid-2,
  body.dms-body .template-show-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  body.dms-body:not(.is-reader-preview) .main-panel { padding: 12px 12px 24px !important; }
  body.dms-body .hero-strip { flex-direction: column; align-items: flex-start; }
  body.dms-body .topbar { flex-wrap: wrap; }
  body.dms-body .mega-search { min-width: 0; width: 100%; }
  body.dms-body .stat-grid,
  body.dms-body .stat-grid-6 { grid-template-columns: 1fr; }
}
@media (max-width: 390px) {
  body.dms-body .page-title,
  body.dms-body .hero-strip h2 { font-size: 20px !important; }
  body.dms-body .btn-primary,
  body.dms-body .btn-ghost { width: auto; }
}

/* Recycle Bin + Undo History */
body.dms-body .detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  margin: 0;
}
body.dms-body .detail-grid dt {
  margin: 0;
  color: var(--muted, #64748b);
  font-size: .82rem;
  font-weight: 600;
}
body.dms-body .detail-grid dd { margin: 0; }
body.dms-body #reasonActionModal textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  padding: 11px 12px;
}
.dms-toast {
  position: relative;
  min-width: 220px;
  max-width: 360px;
  padding: 13px 16px 13px 18px;
  border-radius: 16px;
  background:
    linear-gradient(145deg, #152238 0%, #0f172a 55%, #0b1220 100%);
  color: #fff;
  font-size: .86rem;
  font-weight: 650;
  box-shadow:
    0 1px 0 rgba(255,255,255,.1) inset,
    0 16px 40px rgba(15, 23, 42, .36),
    0 4px 0 rgba(0,0,0,.15);
  opacity: 0;
  transform: translate3d(24px, 12px, -40px) rotateY(-12deg) scale(.94);
  transition:
    transform .42s cubic-bezier(.16, .9, .2, 1.05),
    opacity .28s ease;
  pointer-events: auto;
  overflow: hidden;
}
.dms-toast.is-open {
  opacity: 1;
  transform: translate3d(0, 0, 0) rotateY(0) scale(1);
}
.dms-toast.is-leaving {
  opacity: 0;
  transform: translate3d(18px, 8px, -30px) rotateY(-8deg) scale(.96);
  transition: transform .26s ease, opacity .22s ease;
}
.dms-toast-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #38bdf8, #2563eb);
}
.dms-toast-text { display: block; padding-left: 4px; line-height: 1.4; }
.dms-toast.is-danger .dms-toast-bar,
.dms-toast.danger .dms-toast-bar { background: linear-gradient(180deg, #fb7185, #e11d48); }
.dms-toast.is-warn .dms-toast-bar,
.dms-toast.warn .dms-toast-bar { background: linear-gradient(180deg, #fbbf24, #ea580c); }
.library-share-panel .library-url-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.library-share-panel .library-url-row input {
  flex: 1;
  min-width: 220px;
  font-size: .82rem;
}
.library-slug-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.library-slug-prefix {
  padding: 10px 12px;
  background: #f8fafc;
  color: #64748b;
  font-size: .78rem;
  font-weight: 700;
  border-right: 1px solid #e2e8f0;
  white-space: nowrap;
}
.library-slug-row input {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  min-width: 0;
}

/* Online Library */
body.dms-body .library-search-panel {
  margin-bottom: 16px;
  padding: 14px 16px;
}
body.dms-body .library-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
body.dms-body .library-search-input {
  flex: 1 1 240px;
  min-width: 0;
}
body.dms-body .library-search-meta {
  margin: 0 0 12px;
  font-size: .88rem;
}
body.dms-body .library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
body.dms-body .library-card {
  display: block;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  padding: 18px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}
body.dms-body .library-card:hover {
  border-color: var(--brand, #1d4ed8);
}
body.dms-body .library-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
body.dms-body .library-paper {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
body.dms-body .library-toc {
  margin: 0 0 24px;
  padding: 12px 14px;
  background: var(--bg-soft, #f8fafc);
  border-radius: 10px;
  font-size: .85rem;
}
body.dms-body .library-toc strong {
  display: block;
  margin-bottom: 8px;
}
body.dms-body .library-toc div {
  margin: 3px 0;
}
body.dms-body .library-toc div.is-child {
  margin-left: 14px;
}

.diff-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 4px 2px 8px;
  color: var(--muted);
  font-size: .86rem;
}
.diff-meta b { color: var(--ink); font-weight: 700; }
.diff-card .diff-old h5,
.diff-card .diff-new h5 {
  margin: 0 0 8px;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.undo-created-value {
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  padding: 8px 2px 2px;
}

/* ---- ClickHelp-style Content Table editor ---- */
.toc-import-mask {
  position: absolute; inset: 0; z-index: 80;
  background: rgba(12, 18, 28, .55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ch-toc:not(.ch-toc-embedded) .toc-import-mask { position: fixed; }
.toc-import-card {
  width: min(480px, 100%); background: #fff; border-radius: 14px; padding: 24px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .2);
}
.toc-import-card h3 { margin: 0 0 8px; font-size: 1.15rem; }
.toc-import-card p { margin: 0 0 14px; color: #4b5563; font-size: .9rem; }
.toc-import-bar { height: 7px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.toc-import-bar > span { display: block; height: 100%; width: 8%; background: #2563eb; transition: width .3s ease; }
.toc-import-eta { margin: 10px 0 0; font-size: .8rem; font-weight: 650; color: #334155; }

body:has(.ch-toc:not(.ch-toc-embedded)) .main-panel { padding: 0 !important; }
body:has(.ch-toc:not(.ch-toc-embedded)) .topbar { margin-bottom: 0; border-bottom: 1px solid #e2e8f0; }

.ch-toc { height: calc(100vh - 58px); min-height: 0; position: relative; }
.ch-toc-embedded {
  /* Fixed height so the left Contents tree scrolls inside — not the whole page */
  height: min(78vh, 820px);
  min-height: 520px;
  margin-top: 16px;
  border: 1px solid #d8e0ea;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .8) inset,
    0 10px 32px rgba(15, 23, 42, .07);
  background: #fff;
}
.ch-toc-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  background: #fff;
}
.ch-toc-embedded .ch-toc-shell { height: 100%; min-height: 0; }
.ch-toc-rail {
  border-right: 1px solid #e2e8f0;
  background:
    linear-gradient(180deg, #f4f7fb 0%, #eef2f7 48%, #f8fafc 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.ch-toc-rail-head {
  flex: 0 0 auto;
  padding: 14px 14px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px solid rgba(226, 232, 240, .9);
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(6px);
}
.ch-toc-kicker {
  display: block; font-size: .62rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: #64748b; margin-bottom: 2px;
}
.ch-toc-doc {
  display: block; font-size: .88rem; line-height: 1.25; color: #0f172a; font-weight: 750;
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-toc-head-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto;
}
.ch-toc-accuracy {
  font-size: .62rem; font-weight: 800; color: #92400e;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a; border-radius: 999px; padding: 2px 7px;
  white-space: nowrap;
}
.ch-toc-accuracy.is-verified {
  color: #166534;
  background: linear-gradient(180deg, #f0fdf4, #dcfce7);
  border-color: #bbf7d0;
}
.ch-toc-count {
  font-size: .68rem; font-weight: 800; color: #1e3a8a;
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe; border-radius: 999px; padding: 3px 8px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .08);
}
.ch-toc-tools {
  flex: 0 0 auto;
  display: flex; gap: 6px; padding: 10px 12px 8px;
}
body.dms-body .ch-toc-filter,
.ch-toc-filter {
  flex: 1;
  width: auto !important;
  min-height: 32px !important;
  height: 32px !important;
  margin: 0 !important;
  padding: 0 11px !important;
  font-size: .76rem !important;
  font-weight: 600;
  border-radius: 9px !important;
  border: 1px solid #d4dce6 !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03) !important;
}
body.dms-body .ch-toc-filter:focus,
.ch-toc-filter:focus {
  border-color: #93c5fd !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12) !important;
}
.ch-toc-tool {
  width: 32px; height: 32px; border: 1px solid #d4dce6; border-radius: 9px; background: #fff;
  font-weight: 800; color: #334155; cursor: pointer; flex: 0 0 32px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.ch-toc-tool:hover { border-color: #93c5fd; color: #1d4ed8; background: #eff6ff; }
.ch-toc-import { flex: 0 0 auto; padding: 0 12px 8px; }
.ch-toc-import details {
  background: rgba(255, 255, 255, .92);
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  padding: 7px 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.ch-toc-import summary {
  cursor: pointer; font-size: .74rem; font-weight: 750; color: #334155; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.ch-toc-import summary::-webkit-details-marker { display: none; }
.ch-toc-import summary::before {
  content: '';
  width: 0; height: 0;
  border-left: 5px solid #64748b;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s var(--ease);
}
.ch-toc-import details[open] > summary::before { transform: rotate(90deg); }
.ch-toc-import-body { padding-top: 8px; display: grid; gap: 8px; max-height: 220px; overflow: auto; }
.ch-toc-import-links { display: flex; gap: 10px; font-size: .72rem; font-weight: 700; }
.ch-toc-import-links a { color: #1d4ed8; }
.ch-file-btn {
  display: block; text-align: center; font-size: .72rem; font-weight: 750;
  padding: 8px 8px; border-radius: 9px; background: #1d4ed8; color: #fff !important; cursor: pointer;
  box-shadow: 0 2px 8px rgba(29, 78, 216, .22);
}
.ch-file-btn.ghost {
  background: #fff; color: #1e293b !important; border: 1px solid #cbd5e1;
  box-shadow: none;
}
.ch-file-btn input { display: none; }

/* Scrollable Contents list — independent of page scroll */
.ch-toc-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 8px 16px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}
.ch-toc-tree::-webkit-scrollbar { width: 9px; }
.ch-toc-tree::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}
.ch-toc-tree::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #94a3b8, #64748b);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ch-toc-tree::-webkit-scrollbar-thumb:hover { background: #475569; border: 2px solid transparent; background-clip: padding-box; }

/* Beat global form input chrome — titles must not look like form fields */
body.dms-body .ch-toc .ch-toc-title,
.ch-toc .ch-toc-title {
  flex: 1 1 auto;
  min-width: 0;
  width: 100% !important;
  max-width: 100%;
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: .78rem !important;
  font-weight: 650 !important;
  color: #1e293b !important;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  outline: none;
  min-height: 0 !important;
  height: auto !important;
  line-height: 1.35 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  cursor: text;
}
.ch-toc-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  min-height: 34px;
  height: auto;
  margin: 2px 0;
  padding: 7px 10px 7px calc(10px + var(--depth, 0) * 14px);
  border-radius: 10px;
  position: relative;
  border: 1px solid transparent;
  background: transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.ch-toc-row.is-root .ch-toc-title { font-weight: 750 !important; }
.ch-toc-row.is-child::before {
  content: '';
  position: absolute;
  left: calc(6px + (var(--depth, 1) - 1) * 14px);
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: #dbe3ee;
  pointer-events: none;
}
.ch-toc-row:hover {
  background: rgba(255, 255, 255, .92);
  border-color: #e2e8f0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .05);
}
.ch-toc-row.is-open {
  background: #fff;
  border-color: #bfdbfe;
  box-shadow:
    inset 3px 0 0 #2563eb,
    0 2px 10px rgba(37, 99, 235, .08);
}
.ch-toc-num {
  flex: 0 0 auto;
  font-size: .66rem;
  font-weight: 800;
  color: #1d4ed8;
  min-width: 1.5em;
  margin-top: 2px;
  letter-spacing: -.01em;
  opacity: .9;
}
.ch-toc-row:hover .ch-toc-title,
.ch-toc-row.is-open .ch-toc-title { padding-right: 108px !important; }
body.dms-body .ch-toc .ch-toc-title:focus,
.ch-toc .ch-toc-title:focus {
  background: #f8fafc !important;
  border-radius: 6px !important;
  padding: 2px 6px !important;
  box-shadow: 0 0 0 2px #bfdbfe !important;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
.ch-toc-acts {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: inline-flex; gap: 2px; opacity: 0; pointer-events: none;
  background: #fff;
  border-radius: 8px;
  padding: 2px;
  border: 1px solid #dbe3ee;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}
.ch-toc-row:hover .ch-toc-acts,
.ch-toc-row.is-open .ch-toc-acts { opacity: 1; pointer-events: auto; }
.ch-toc-act {
  width: 22px; height: 22px; border: 0; background: transparent; color: #64748b;
  font-size: .68rem; cursor: pointer; border-radius: 6px; line-height: 1;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.ch-toc-act:hover { background: #eff6ff; color: #1d4ed8; }
.ch-toc-act.danger:hover { background: #fef2f2; color: #b91c1c; }
.ch-toc-ref {
  flex: 0 0 auto;
  padding: 8px 12px 12px;
  border-top: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, .7);
}
.ch-toc-ref img { width: 100%; border-radius: 8px; border: 1px solid #e2e8f0; max-height: 140px; object-fit: cover; }
.ch-toc-main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  overflow: hidden;
  background: #d8dee8;
}
.ch-toc-main-bar {
  flex: 0 0 auto;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(226, 232, 240, .9);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.92));
}
.ch-toc-main-id { min-width: 0; }
.ch-toc-back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .72rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
  color: #1d4ed8; text-decoration: none; margin-bottom: 4px;
}
.ch-toc-back:hover { color: #1e3a8a; }
.ch-toc-main-bar h2 { margin: 0; font-size: 1.12rem; font-weight: 750; color: #0f172a; letter-spacing: -.03em; }
.ch-toc-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px 18px 32px;
  background:
    radial-gradient(900px 280px at 50% 0%, rgba(176, 141, 87, .08), transparent 60%),
    linear-gradient(180deg, #d8dee8 0%, #c9d1de 100%);
}
.ch-toc-paper {
  width: min(820px, 100%);
  margin: 0 auto;
  background: #fffef9;
  border: 1px solid rgba(28, 25, 21, .08);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.9) inset,
    0 18px 50px rgba(15, 23, 42, .16);
  min-height: min(72vh, 820px);
}
.ch-toc-article {
  padding: 36px 48px 48px;
  font-family: "Instrument Serif", Georgia, serif;
  color: #1c1916;
}
.ch-toc-empty {
  display: grid; place-items: center; text-align: center; gap: 8px;
  min-height: 420px; color: #64748b;
}
.ch-toc-empty-mark {
  display: grid; place-items: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(180deg, #f8f1e4, #ead9b8);
  color: #8a6a32; font-family: "Instrument Serif", serif; font-size: 1.35rem;
  box-shadow: 0 8px 20px rgba(176, 141, 87, .25);
}
.ch-toc-empty strong { font-family: Manrope, system-ui, sans-serif; font-size: 1.05rem; color: #0f172a; }
.ch-toc-empty p { max-width: 420px; margin: 0; font-family: Manrope, system-ui, sans-serif; font-size: .88rem; line-height: 1.5; }
.ch-toc-sheet-meta {
  display: flex; gap: 8px; align-items: center;
  font-family: Manrope, system-ui, sans-serif;
  font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: #b08d57; margin-bottom: 8px;
}
.ch-toc-sheet-num {
  padding: 2px 8px; border-radius: 999px; background: #f4ead4; color: #7a5a24;
}
.ch-toc-sheet-title {
  margin: 0 0 18px; font-size: 1.85rem; font-weight: 500; letter-spacing: -.03em; line-height: 1.2;
}
.ch-toc-body-editor {
  min-height: 280px; padding: 8px 0; border: 0; border-radius: 0;
  background: transparent; outline: none; box-shadow: none;
  font-size: 1.05rem; line-height: 1.7;
}
.ch-toc-body-editor:focus { border: 0; box-shadow: none; }
.ch-toc-body-tools {
  margin: 0 0 12px; font-family: Manrope, system-ui, sans-serif;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #94a3b8;
}
.ch-toc-body-hint { font-family: Manrope, system-ui, sans-serif; color: #64748b; font-size: .9rem; }
.unified-toc-panel { margin-top: 8px; min-width: 0; }
.unified-toc-panel[hidden] { display: none !important; }
.unified-toc-banner {
  display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 18px 0 0; padding: 13px 15px; border-radius: 12px;
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 1px solid #bfdbfe;
  box-shadow: 0 1px 3px rgba(37, 99, 235, .06);
}
.unified-toc-banner strong { display: block; color: #1e3a8a; }
.unified-toc-banner p { margin: 2px 0 0; font-size: .82rem; color: #334155; }
@media (max-width: 900px) {
  .ch-toc-shell { grid-template-columns: 1fr; }
  .ch-toc-embedded { height: min(88vh, 900px); }
  .ch-toc-rail { border-right: 0; border-bottom: 1px solid #e2e8f0; max-height: 48%; }
  .ch-toc-article { padding: 22px 18px 32px; }
  .ch-toc-sheet-title { font-size: 1.4rem; }
}

/* —— CAME document template (screen preview) —— */
.came-screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  min-width: 0;
}
.came-screen-brand { min-width: 0; flex: 1 1 auto; }
.came-screen-brand .doc-brand-logo { height: 42px; max-width: 200px; }
.came-screen-meta {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 0 0 auto;
}
.came-screen-labels {
  text-align: right;
  padding-right: 10px;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: #1e3a8a;
  line-height: 1.55;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.came-screen-rule {
  width: 1px;
  background: #0f2744;
  align-self: stretch;
  margin: 2px 0;
}
.came-screen-values { min-width: 64px; }
.came-screen-blue {
  background: #0f2744;
  color: #fff;
  padding: 5px 12px 6px;
  font-weight: 800;
  font-size: .88rem;
  line-height: 1.25;
}
.came-screen-below {
  padding: 4px 12px 0;
  font-size: .78rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}
.came-screen-footer {
  margin-top: 28px;
  padding-top: 10px;
  border-top: 1px solid #0f2744;
  text-align: center;
  font-size: .82rem;
  font-weight: 600;
  color: #0f2744;
}
.came-screen-cover {
  text-align: center;
  padding: 48px 16px 36px;
  margin-bottom: 28px;
  border-bottom: 1px solid #e2e8f0;
}
.came-screen-cover-back {
  margin-top: 36px;
  border-bottom: 0;
  border-top: 1px solid #e2e8f0;
}
.came-screen-cover h1,
.came-screen-cover h2,
.came-screen-cover h3 {
  margin: 0 0 12px;
  line-height: 1.25;
  overflow-wrap: break-word;
}
.came-screen-cover h1 { font-size: 1.55rem; }
.came-screen-cover h2 { font-size: 1.25rem; }
.came-screen-cover h3 { font-size: 1.05rem; }
.came-screen-cover p {
  max-width: 36rem;
  margin: 0 auto 16px;
  color: #334155;
  line-height: 1.6;
}
.came-screen-cover-img {
  display: block;
  margin: 20px auto 0;
  max-width: min(280px, 100%);
  max-height: 200px;
  object-fit: contain;
}
.came-screen-contact,
.cl-screen-contact {
  margin: 28px auto 0;
  max-width: 28rem;
  text-align: left;
}
.came-screen-contact-table,
.cl-screen-contact-table {
  width: 100%;
  border-collapse: collapse;
}
.came-screen-contact-table td,
.cl-screen-contact-table td {
  vertical-align: top;
  padding: 4px 0;
}
.came-screen-contact-lbl,
.cl-screen-contact-lbl {
  width: 38%;
  font-size: .68rem;
  letter-spacing: .04em;
  color: #64748b;
  padding-right: 12px;
  white-space: nowrap;
}
.came-screen-contact-val,
.cl-screen-contact-val {
  font-size: .9rem;
  font-weight: 750;
  color: #0f172a;
  line-height: 1.4;
  overflow-wrap: break-word;
}
.doc-layout-came .doc-page-body h1,
.doc-layout-came .doc-page-body h2,
.doc-layout-came .doc-page-body h3 {
  color: #0f2744;
}

/* —— Portal overflow / alignment polish —— */
.panel, .card, .table-wrap, .data-table, .form-lux,
.dual-left, .dual-related, .dual-main, .toc-tree, .related-list {
  min-width: 0;
}
.table-wrap { overflow-x: auto; max-width: 100%; }
table.data-table td,
table.data-table th,
.table td, .table th {
  overflow-wrap: break-word;
  word-break: normal;
  vertical-align: middle;
}
.form-lux input[type="text"],
.form-lux input[type="email"],
.form-lux input[type="search"],
.form-lux textarea,
.form-lux select,
input[type="text"],
input[type="email"],
textarea,
select {
  max-width: 100%;
  box-sizing: border-box;
}
body.is-reader-preview .dual-related {
  min-width: 0 !important;
  max-width: 100%;
  overflow-x: hidden !important;
}
body.is-reader-preview .dual-doc-list,
body.is-reader-preview .related-list,
body.is-reader-preview .dual-reader-toc {
  min-width: 0 !important;
  max-width: 100%;
  overflow-x: hidden;
}
body.is-reader-preview .dual-left .dual-doc-item .toc-title {
  /* Keep long ALL-CAPS titles inside the Contents rail */
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
}
.doc-layout-came { --doc-layout-ready: 1; }

/* —— Checklist template (screen preview) —— */
.cl-screen-header { margin-bottom: 24px; min-width: 0; }
.cl-screen-box {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #111;
  table-layout: fixed;
}
.cl-screen-box td {
  border: 1px solid #111;
  vertical-align: middle;
  padding: 8px 10px;
}
.cl-screen-logo {
  width: 18%;
  text-align: center;
}
.cl-screen-logo .doc-brand-logo {
  height: 28px;
  max-width: 96px;
  width: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}
.cl-screen-title {
  width: 52%;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: #111;
}
.cl-screen-meta { width: 30%; font-size: .78rem; }
.cl-screen-meta-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  line-height: 1.45;
}
.cl-screen-meta-line span { font-weight: 700; }
.cl-screen-sub {
  min-height: 22px;
  font-size: .82rem;
  color: #334155;
}
.cl-screen-footer {
  margin-top: 28px;
  padding-top: 10px;
  border-top: 1px solid #111;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .82rem;
  font-weight: 800;
  color: #111;
}
.doc-layout-checklist { --doc-layout-ready: 1; }
.doc-layout-checklist .doc-page-body h1,
.doc-layout-checklist .doc-page-body h2,
.doc-layout-checklist .doc-page-body h3 {
  color: #111;
}




/* =========================================================
   Design system v6 — shell overflow + Online Library PDF viewer
   App UI tokens only. Never style PDF canvas page content.
   ========================================================= */
:root {
  --z-nav: 40;
  --z-topbar: 30;
  --z-modal: 1000;
  --z-toast: 1100;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .35);
  --lh-ui: 1.45;
  --lh-tight: 1.25;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --container-max: 1440px;
  --sidebar-w: 260px;
  --header-h: 64px;
}

body.dms-body,
body.guest-body {
  line-height: var(--lh-ui);
  word-spacing: normal;
  letter-spacing: normal;
}

/* Prefer intentional scroll containers over clipping the whole app */
.app-shell {
  max-width: 100vw;
  overflow-x: clip;
}
.main-panel,
.topbar,
.top-actions,
.page-title,
.library-card h3,
.library-reader-meta-line {
  min-width: 0;
  overflow-wrap: anywhere;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.table-responsive,
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.btn-primary,
.btn-ghost,
.mag-btn,
button,
a.btn-primary,
a.btn-ghost {
  min-height: 40px;
  line-height: var(--lh-tight);
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Online Library canonical PDF viewer (chrome outside page geometry) */
.library-reader {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.library-reader-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.library-reader-meta-line { margin: 0; max-width: 100%; }
.library-reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.library-pdf-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  background: #0f172a;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.library-pdf-shell:fullscreen {
  background: #0b1220;
  border-radius: 0;
}
.library-pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
  background: #111827;
  border-bottom: 1px solid rgba(148, 163, 184, .25);
}
.library-pdf-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.library-pdf-btn {
  color: #e2e8f0 !important;
  border-color: rgba(148, 163, 184, .35) !important;
  background: rgba(15, 23, 42, .55) !important;
  min-height: 36px;
  padding: 6px 10px;
}
.library-pdf-page-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  font-size: var(--fs-help);
}
.library-pdf-page-input {
  width: 3.2rem;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .4);
  background: #0b1220;
  color: #f8fafc;
  text-align: center;
}
.library-pdf-search {
  width: min(220px, 42vw);
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, .4);
  background: #0b1220;
  color: #f8fafc;
  padding: 0 10px;
  min-width: 0;
}
.library-pdf-search-count { font-size: var(--fs-help); }
.library-pdf-stage-wrap {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  min-height: min(72vh, 860px);
  max-height: calc(100vh - 180px);
}
.library-pdf-side {
  padding: 14px 14px 18px;
  background: #111827;
  border-right: 1px solid rgba(148, 163, 184, .2);
  color: #e2e8f0;
  overflow: auto;
  min-width: 0;
}
.library-pdf-side-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #f8fafc;
}
.library-pdf-side-dl {
  margin: 0;
  display: grid;
  gap: 10px;
  font-size: 0.8rem;
}
.library-pdf-side-dl div { min-width: 0; }
.library-pdf-side-dl dt {
  margin: 0;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 0.68rem;
}
.library-pdf-side-dl dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}
.library-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}
.library-pdf-side-note {
  margin: 14px 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
}
.library-pdf-stage {
  position: relative;
  overflow: auto;
  background: #334155;
  min-width: 0;
  min-height: 0;
  padding: 16px 12px 28px;
}
.library-pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.library-pdf-page {
  background: #fff;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
  line-height: 0;
  max-width: 100%;
}
.library-pdf-page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.library-pdf-loading,
.library-pdf-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: #f8fafc;
  background: rgba(15, 23, 42, .55);
  z-index: 2;
}
.library-paper-fallback {
  max-width: 920px;
}
.library-paper-fallback .doc-prose {
  overflow-wrap: anywhere;
  word-spacing: normal;
  letter-spacing: normal;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .library-pdf-stage-wrap {
    grid-template-columns: 1fr;
    max-height: none;
    min-height: 70vh;
  }
  .library-pdf-side {
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, .2);
    max-height: 160px;
  }
}
@media (max-width: 430px) {
  .library-pdf-toolbar { padding: 8px; }
  .library-pdf-search { width: 100%; }
  .library-pdf-toolbar-group { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .library-pdf-page { scroll-margin: 0; }
}

/* Isolate document page canvases from app prose rules */
.library-pdf-shell .doc-prose,
.library-pdf-page .doc-prose {
  all: unset;
}

/* Online Library — reading surface matches exported page geometry */
body.dms-body:has(.library-reader--pdf) .main-panel {
  padding-left: 16px;
  padding-right: 16px;
  max-width: none;
}
.library-reader--pdf {
  gap: 12px;
}
.library-reader-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 18px;
  min-width: 0;
}
.library-reader-bar-main { min-width: 0; flex: 1; }
.library-reader-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.library-reader-title {
  margin: 0 0 4px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.library-pdf-shell--reader {
  background: #e8edf3;
  border: 1px solid var(--line-strong);
  min-height: calc(100vh - 170px);
}
.library-pdf-shell--reader .library-pdf-toolbar {
  background: #0f172a;
  position: sticky;
  top: 0;
  z-index: 5;
}
.library-pdf-stage--reader {
  background: #c5ceda;
  min-height: calc(100vh - 230px);
  max-height: none;
  height: calc(100vh - 230px);
  padding: 28px 16px 48px;
}
.library-pdf-shell--reader .library-pdf-page {
  box-shadow: 0 12px 40px rgba(15, 23, 42, .22);
  border: 1px solid rgba(15, 23, 42, .08);
}
.library-pdf-shell--reader .library-pdf-pages {
  gap: 28px;
}
@media (max-width: 900px) {
  .library-pdf-stage--reader {
    height: auto;
    min-height: 70vh;
    max-height: none;
  }
}

/* Immersive Online Library document view — hide sidebar + topbar; only Back + page chip */
body.library-doc-immersive .side-nav,
body.library-doc-immersive .dream-bg {
  display: none !important;
}
body.library-doc-immersive .topbar { display: none !important; }
body.library-doc-immersive .app-shell,
body.library-doc-immersive .app-shell.nav-expanded {
  display: block;
  grid-template-columns: none;
  min-height: 100vh;
}
body.library-doc-immersive .main-panel {
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100vh;
}
body.library-doc-immersive .flash { display: none; }
.library-doc-back {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .88);
  color: #f8fafc !important;
  text-decoration: none !important;
  font-family: Manrope, system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .28);
  border: 1px solid rgba(248, 250, 252, .12);
  transition: background .15s ease, transform .15s ease;
}
.library-doc-back:hover {
  background: rgba(15, 23, 42, .96);
  color: #fff !important;
  transform: translateY(-1px);
}
.library-doc-back-ico {
  font-size: 1.05rem;
  line-height: 1;
}
.library-reader--immersive { gap: 0; }
.library-pdf-shell--immersive {
  border: 0;
  border-radius: 0;
  min-height: 100vh;
  position: relative;
}
.library-pdf-shell--immersive .library-pdf-stage--reader {
  height: 100vh;
  min-height: 100vh;
  padding: 56px 56px 40px 24px;
}
.library-pdf-pagechip {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  color: #f8fafc;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
  pointer-events: none;
  user-select: none;
}
@media (max-width: 640px) {
  .library-pdf-pagechip {
    right: 10px;
    top: auto;
    bottom: 16px;
    transform: none;
  }
  .library-pdf-shell--immersive .library-pdf-stage--reader {
    padding: 16px 12px 56px;
  }
}