/* ============================================================
   D&D Module — Campaign Journal Shell
   ------------------------------------------------------------
   Independent shell for the D&D module under /dnd/*. Active
   whenever site_module(request) == "dnd".
   Canonical reference: docs/05-design-und-historie/mockups/backend-campaign-journal/.
   Classes are `cj-*` prefixed so they cannot collide with
   site-shell's `sh-*` classes or with Tailwind utilities.
   ============================================================ */

/* ---------- 1 · TOKENS ---------- */

body.cj-body {
  --cj-bg:            #f7eed7;       /* Parchment */
  --cj-bg-alt:        #f2e5c8;
  --cj-surface:       rgba(255, 255, 255, 0.58);
  --cj-surface-raise: rgba(255, 255, 255, 0.82);
  --cj-ink:           #2a1d1a;
  --cj-ink-muted:     #4a3328;
  --cj-ink-faint:     #8a6a2a;
  --cj-primary:       #7a2a2a;       /* Burgundy */
  --cj-primary-soft:  rgba(122, 42, 42, 0.12);
  --cj-primary-ink:   #f5ebd6;
  --cj-accent:        #d4a24c;       /* Gold */
  --cj-accent-bright: #f3c967;
  --cj-accent-ink:    #2a1d1a;
  --cj-border:        rgba(160, 122, 42, 0.35);
  --cj-border-soft:   rgba(160, 122, 42, 0.20);
  --cj-cream:         #f5ebd6;
  --cj-success:       #2b8a42;
  --cj-danger:        #c2413c;
  --cj-warning:       #a06a2a;
  --cj-z-skip-link:   220;
  --cj-z-backdrop:    110;
  --cj-z-drawer:      120;

  --cj-font-display:  "Cinzel", "Palatino Linotype", Georgia, serif;
  --cj-font-body:     "EB Garamond", Georgia, serif;
  --cj-font-ui:       "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --cj-font-mono:     "JetBrains Mono", "SFMono-Regular", Menlo, monospace;

  background:
    radial-gradient(circle at top left, rgba(212, 162, 76, 0.16), transparent 30%),
    radial-gradient(circle at right 20%, rgba(122, 42, 42, 0.08), transparent 28%),
    linear-gradient(180deg, var(--cj-bg), var(--cj-bg-alt));
  color: var(--cj-ink);
  font-family: var(--cj-font-body);
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

html[data-theme="light"] body.cj-body {
  --cj-bg:            #f7eed7;
  --cj-bg-alt:        #f2e5c8;
  --cj-surface:       rgba(255, 255, 255, 0.58);
  --cj-surface-raise: rgba(255, 255, 255, 0.82);
  --cj-ink:           #2a1d1a;
  --cj-ink-muted:     #4a3328;
  --cj-ink-faint:     #8a6a2a;
  --cj-primary:       #7a2a2a;
  --cj-primary-soft:  rgba(122, 42, 42, 0.12);
  --cj-primary-ink:   #f5ebd6;
  --cj-accent:        #d4a24c;
  --cj-accent-bright: #f3c967;
  --cj-accent-ink:    #2a1d1a;
  --cj-border:        rgba(160, 122, 42, 0.35);
  --cj-border-soft:   rgba(160, 122, 42, 0.20);
  --cj-cream:         #f5ebd6;
  --cj-success:       #2b8a42;
  --cj-danger:        #c2413c;
  --cj-warning:       #a06a2a;
}

body.cj-body a { color: inherit; text-decoration: none; }

.sh-skip-link {
  position: absolute;
  left: 16px;
  top: 12px;
  transform: translateY(-180%);
  z-index: var(--cj-z-skip-link);
  border-radius: 999px;
  background: var(--cj-primary);
  color: var(--cj-primary-ink);
  padding: 10px 14px;
  font-family: var(--cj-font-ui);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(42, 16, 12, 0.24);
  transition: transform 160ms ease;
}

.sh-skip-link:focus,
.sh-skip-link:focus-visible {
  transform: translateY(0);
}

/* Dark theme — Midnight Library */
html[data-theme="dark"] body.cj-body {
  --cj-bg:            #071221;
  --cj-bg-alt:        #0b1827;
  --cj-surface:       rgba(24, 34, 48, 0.82);
  --cj-surface-raise: rgba(28, 39, 55, 0.96);
  --cj-ink:           #eef3f8;
  --cj-ink-muted:     #a8b6c6;
  --cj-ink-faint:     #d4a24c;
  --cj-primary:       #f3c967;
  --cj-primary-soft:  rgba(243, 201, 103, 0.15);
  --cj-primary-ink:   #071221;
  --cj-border:        rgba(226, 232, 240, 0.16);
  --cj-border-soft:   rgba(226, 232, 240, 0.10);
  --cj-success:       #8bd8a0;
  --cj-danger:        #e07070;
  background:
    radial-gradient(circle at top left, rgba(243, 201, 103, 0.10), transparent 30%),
    radial-gradient(circle at right 20%, rgba(176, 60, 72, 0.10), transparent 28%),
    linear-gradient(180deg, var(--cj-bg), var(--cj-bg-alt));
}

@media (prefers-reduced-motion: reduce) {
  body.cj-body *,
  body.cj-body *::before,
  body.cj-body *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

/* ---------- 2 · SHELL ---------- */

.cj-page {
  padding:
    max(28px, env(safe-area-inset-top))
    max(28px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(28px, env(safe-area-inset-left));
}

.cj-shell {
  width: min(1520px, calc(100vw - 56px));
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(122, 42, 42, 0.98), rgba(90, 24, 24, 0.96));
  box-shadow: 0 30px 80px rgba(42, 16, 12, 0.28);
}

html[data-theme="dark"] body.cj-body .cj-shell {
  background: linear-gradient(180deg, rgba(9, 20, 34, 0.98), rgba(7, 16, 28, 0.96));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}

.cj-sidebar {
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(243, 201, 103, 0.14), transparent 40%),
    linear-gradient(180deg, rgba(90, 24, 24, 0.96), rgba(60, 12, 12, 0.98));
  color: rgba(245, 235, 214, 0.92);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html[data-theme="dark"] body.cj-body .cj-sidebar {
  background:
    radial-gradient(circle at top left, rgba(243, 201, 103, 0.10), transparent 40%),
    linear-gradient(180deg, rgba(9, 20, 34, 0.98), rgba(5, 12, 22, 0.99));
  color: rgba(238, 243, 248, 0.92);
}

.cj-brand { display: flex; flex-direction: column; gap: 6px; }
.cj-eyebrow {
  font-family: var(--cj-font-ui);
  font-weight: 600; font-size: 10px;
  letter-spacing: 0.22em; text-transform: uppercase;
}
.cj-brand-name {
  font-family: var(--cj-font-display); font-weight: 700;
  font-size: 22px; color: var(--cj-accent-bright); line-height: 1.05;
  letter-spacing: -0.3px;
}
.cj-brand-sub {
  font-family: var(--cj-font-ui); color: rgba(245, 235, 214, 0.55);
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 600;
}

.cj-nav-group { display: flex; flex-direction: column; gap: 4px; }
.cj-nav-group-label {
  font-family: var(--cj-font-display); font-weight: 700;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--cj-accent); padding: 6px 6px 4px;
  border-bottom: 1px solid rgba(212, 162, 76, 0.25); margin-bottom: 4px;
}
.cj-nav-link {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: rgba(245, 235, 214, 0.8); font-family: var(--cj-font-display);
  font-weight: 500; font-size: 12px; letter-spacing: 0.03em;
  transition: 180ms ease; cursor: pointer; border: 1px solid transparent;
}
.cj-nav-link .cj-nav-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cj-nav-link .cj-glyph {
  width: 20px; height: 20px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; background: rgba(212, 162, 76, 0.12);
  color: var(--cj-accent); flex-shrink: 0;
}
.cj-nav-link:hover {
  color: #fff;
  background: rgba(212, 162, 76, 0.1);
  border-color: rgba(212, 162, 76, 0.18);
}
.cj-nav-link.is-active {
  color: var(--cj-accent-bright);
  background: rgba(243, 201, 103, 0.15);
  border-color: rgba(243, 201, 103, 0.3);
}
.cj-nav-link.is-active .cj-glyph {
  background: rgba(243, 201, 103, 0.25); color: var(--cj-accent-bright);
}
.cj-nav-meta {
  font-family: var(--cj-font-mono); font-size: 10px; font-weight: 600;
  color: rgba(245, 235, 214, 0.45);
}

.cj-sidebar-note {
  margin-top: auto;
  padding: 14px 16px; border-radius: 12px;
  background: rgba(58, 34, 26, 0.5);
  border: 1px solid rgba(160, 122, 42, 0.35);
}
.cj-sidebar-note h4 {
  margin: 6px 0 0; font-family: var(--cj-font-display);
  font-size: 14px; color: var(--cj-accent-bright);
}
.cj-sidebar-note p {
  margin: 6px 0 0; font-family: var(--cj-font-body);
  color: rgba(245, 235, 214, 0.75); font-size: 13px; line-height: 1.4;
}

.cj-user-panel {
  padding: 11px 12px; border-radius: 12px;
  background: rgba(58, 34, 26, 0.4);
  border: 1px solid rgba(160, 122, 42, 0.25);
  display: flex; align-items: center; gap: 10px;
}
.cj-user-panel .cj-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--cj-accent), var(--cj-accent-bright));
  color: var(--cj-accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--cj-font-display); font-weight: 700; font-size: 13px;
  flex-shrink: 0; overflow: hidden;
}
.cj-user-panel .cj-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cj-user-panel .cj-u-name {
  font-family: var(--cj-font-display); color: #fff; font-size: 13px; font-weight: 600;
}
.cj-user-panel .cj-u-role {
  font-family: var(--cj-font-ui); color: rgba(245, 235, 214, 0.55);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600;
}

.dnd-sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dnd-help-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.dnd-help-link-row .cj-pill {
  flex: 1 1 92px;
  min-width: 0;
  white-space: nowrap;
}

.dnd-sidebar-theme-button {
  width: 100%;
}

.dnd-sidebar-logout-button {
  flex-shrink: 0;
  min-width: 34px;
}

.cj-sidebar-language,
.cj-sidebar-language .sh-language-switcher__inner {
  width: 100%;
}

.cj-sidebar-language .sh-language-switcher__inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(160, 122, 42, 0.24);
  border-radius: 999px;
  padding: 4px;
  background: rgba(58, 34, 26, 0.36);
}

.cj-sidebar-language .sh-language-switcher__button {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: transparent;
  color: rgba(245, 235, 214, 0.62);
  cursor: pointer;
  font-family: var(--cj-font-ui);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.cj-sidebar-language .sh-language-switcher__button.is-active {
  background: rgba(246, 199, 104, 0.16);
  color: var(--cj-accent-bright);
}

/* ---------- 3 · CONTENT + TOPBAR ---------- */

.cj-content {
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(247, 238, 215, 0.75), rgba(242, 229, 200, 0.92));
  padding: 22px 26px 28px; overflow: hidden; min-width: 0;
}
html[data-theme="dark"] body.cj-body .cj-content {
  background: linear-gradient(180deg, rgba(7, 18, 33, 0.88), rgba(9, 20, 34, 0.96));
}

.cj-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.cj-topbar-mobile-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.cj-topbar-copy {
  min-width: 0;
}

.cj-topbar-context {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  flex-wrap: wrap;
}

.cj-topbar-module-pill,
.cj-topbar-page-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  font-family: var(--cj-font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cj-topbar-module-pill {
  background: rgba(122, 42, 42, 0.1);
  color: var(--cj-primary);
}

.cj-topbar-page-pill {
  background: rgba(212, 162, 76, 0.18);
  color: var(--cj-ink);
}

.cj-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-width: 46px;
  height: 46px;
  border: 1px solid var(--cj-border);
  border-radius: 14px;
  background: var(--cj-surface-raise);
  color: var(--cj-primary);
  box-shadow: 0 12px 28px rgba(42, 16, 12, 0.12);
}

.cj-sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.cj-sidebar-toggle:hover {
  background: rgba(212, 162, 76, 0.16);
}

html[data-theme="dark"] body.cj-body .cj-sidebar-toggle {
  color: var(--cj-accent-bright);
}
.cj-topbar-title h1 {
  margin: 0; font-family: var(--cj-font-display); font-weight: 700;
  font-size: 36px; line-height: 1.02; letter-spacing: -0.3px;
  color: var(--cj-primary);
}
html[data-theme="dark"] body.cj-body .cj-topbar-title h1 { color: var(--cj-accent-bright); }
.cj-topbar-title p {
  margin: 10px 0 0; font-family: var(--cj-font-body);
  color: var(--cj-ink-muted); font-size: 15px; line-height: 1.5; max-width: 72ch;
}
html[data-theme="dark"] body.cj-body .cj-topbar-title p { color: var(--cj-ink-muted); }
.cj-topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cj-crumbs {
  font-family: var(--cj-font-ui);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--cj-ink-faint); font-weight: 700; margin: 0 0 6px;
}
.cj-crumbs a { color: var(--cj-ink-faint); }
.cj-crumbs a:hover { color: var(--cj-primary); }
.cj-crumbs .cj-sep { margin: 0 6px; opacity: 0.5; }
.cj-crumbs .cj-here { color: var(--cj-primary); }
html[data-theme="dark"] body.cj-body .cj-crumbs .cj-here { color: var(--cj-accent-bright); }

/* ---------- 4 · FLOURISH + ORNAMENT ---------- */

.cj-flourish {
  width: 240px; max-width: 100%; height: 18px; display: block;
  color: var(--cj-accent); opacity: 0.6; margin: 8px 0 14px;
}
.cj-ornament {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0; font-family: var(--cj-font-display);
  color: var(--cj-accent); opacity: 0.75;
}
.cj-ornament::before, .cj-ornament::after {
  content: ''; flex: 1; height: 1px; background: currentColor; opacity: 0.4;
}
.cj-ornament span { font-size: 11px; letter-spacing: 0.28em; }

/* ---------- 5 · PILLS / CHIPS ---------- */

.cj-pill {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 16px; border-radius: 8px;
  font-family: var(--cj-font-ui); font-size: 12px; font-weight: 600;
  border: none; cursor: pointer; text-decoration: none; line-height: 1;
  letter-spacing: 0.02em;
}
.cj-pill.cj-primary {
  background: var(--cj-primary); color: var(--cj-primary-ink);
  box-shadow: 0 8px 20px rgba(122, 42, 42, 0.24);
}
html[data-theme="dark"] body.cj-body .cj-pill.cj-primary {
  background: var(--cj-accent-bright); color: var(--cj-accent-ink);
  box-shadow: 0 8px 20px rgba(243, 201, 103, 0.22);
}
.cj-pill.cj-gold { background: var(--cj-accent); color: var(--cj-accent-ink); }
.cj-pill.cj-ghost {
  background: transparent; color: var(--cj-ink); opacity: 0.88;
  border: 1px solid var(--cj-border);
}
.cj-pill.cj-ghost:hover { opacity: 1; background: rgba(212, 162, 76, 0.08); }
html[data-theme="dark"] body.cj-body .cj-pill.cj-ghost { color: var(--cj-ink); }
body.cj-body .cj-sidebar .cj-pill.cj-ghost {
  color: rgba(245, 235, 214, 0.9);
  background: rgba(245, 235, 214, 0.04);
  border-color: rgba(212, 162, 76, 0.38);
  opacity: 1;
}
body.cj-body .cj-sidebar .cj-pill.cj-ghost:hover,
body.cj-body .cj-sidebar .cj-pill.cj-ghost:focus-visible {
  color: #fff;
  background: rgba(212, 162, 76, 0.14);
  border-color: rgba(243, 201, 103, 0.55);
}
body.cj-body .cj-sidebar .cj-pill.cj-ghost svg {
  color: currentColor;
}
.cj-pill.cj-danger {
  background: transparent; color: var(--cj-danger);
  border: 1px solid var(--cj-danger);
}
.cj-pill.cj-sm { padding: 7px 11px; font-size: 11px; }
.cj-pill.cj-block { width: 100%; padding: 12px 18px; font-size: 13px; }

@media (max-width: 768px) {
  .cj-nav-link,
  .cj-pill {
    min-height: 44px;
  }
}

.cj-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 5px;
  font-family: var(--cj-font-ui); font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em;
  background: rgba(160, 122, 42, 0.2); color: #5a3c10;
}
html[data-theme="dark"] body.cj-body .cj-chip {
  background: rgba(243, 201, 103, 0.15); color: var(--cj-accent-bright);
}
.cj-chip.cj-solid { background: var(--cj-primary); color: var(--cj-primary-ink); }
html[data-theme="dark"] body.cj-body .cj-chip.cj-solid {
  background: var(--cj-accent-bright); color: var(--cj-accent-ink);
}
.cj-chip.cj-gold { background: var(--cj-accent); color: var(--cj-accent-ink); }
.cj-chip.cj-ok {
  background: rgba(43, 138, 66, 0.15); color: var(--cj-success);
}
.cj-chip b { font-family: var(--cj-font-mono); font-weight: 700; }

/* ---------- 6 · ENTRY CARD ---------- */

.cj-entry {
  border-radius: 14px;
  background: var(--cj-surface);
  border: 1px solid var(--cj-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  padding: 18px 20px;
  margin-bottom: 14px;
}
html[data-theme="dark"] body.cj-body .cj-entry { box-shadow: none; }

.cj-entry h3 {
  margin: 0 0 6px; font-family: var(--cj-font-display);
  font-weight: 700; font-size: 16px; color: var(--cj-ink);
}
.cj-entry p, .cj-entry .cj-body {
  margin: 4px 0 0; font-family: var(--cj-font-body);
  font-size: 14px; line-height: 1.5; color: var(--cj-ink-muted);
}

.cj-panel {
  border-radius: 14px;
  background: var(--cj-surface-raise);
  border: 1px solid var(--cj-border);
  padding: 20px 22px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}
html[data-theme="dark"] body.cj-body .cj-panel { box-shadow: none; }

/* ---------- 7 · HERO ---------- */

.cj-hero {
  border-radius: 16px;
  padding: 22px 26px;
  color: var(--cj-cream);
  border: 1px solid var(--cj-accent);
  background: linear-gradient(160deg, var(--cj-primary) 0%, #5a1a1a 100%);
  box-shadow: 0 10px 28px rgba(42, 16, 12, 0.28);
  margin-bottom: 18px;
}
html[data-theme="dark"] body.cj-body .cj-hero {
  background: linear-gradient(160deg, #3a1510 0%, #1a0807 100%);
  border-color: rgba(212, 162, 76, 0.5);
}
.cj-hero .cj-eyebrow { color: var(--cj-accent-bright); }
.cj-hero h2 {
  margin: 8px 0 4px; font-family: var(--cj-font-display); font-weight: 700;
  font-size: 28px; color: var(--cj-accent-bright); letter-spacing: -0.3px;
}
.cj-hero .cj-sub {
  font-family: var(--cj-font-body); font-style: italic;
  font-size: 14px; opacity: 0.88; color: var(--cj-cream);
}

/* ---------- 8 · FORMS ---------- */

.cj-fld { margin-bottom: 14px; }
.cj-fld label {
  display: block; margin-bottom: 4px;
  font-family: var(--cj-font-display); font-weight: 500;
  font-size: 11px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--cj-ink-faint);
}
.cj-fld input, .cj-fld textarea, .cj-fld select {
  width: 100%; font-family: var(--cj-font-body); font-size: 14px;
  padding: 10px 14px; border-radius: 10px;
  background: var(--cj-surface-raise); color: var(--cj-ink);
  border: 1px solid var(--cj-border);
  transition: border-color 150ms, box-shadow 150ms;
}
.cj-fld input:focus, .cj-fld textarea:focus, .cj-fld select:focus {
  outline: none; border-color: var(--cj-primary);
  box-shadow: 0 0 0 3px var(--cj-primary-soft);
}

/* ---------- 9 · STAT BAR + METRIC ---------- */

.cj-stat-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0;
}
.cj-stat {
  padding: 10px 8px; border-radius: 7px; text-align: center;
  background: rgba(122, 42, 42, 0.12);
}
html[data-theme="dark"] body.cj-body .cj-stat { background: rgba(243, 201, 103, 0.1); }
.cj-stat .cj-k {
  font-family: var(--cj-font-ui); font-weight: 700;
  font-size: 9px; letter-spacing: 0.11em; text-transform: uppercase; opacity: 0.75;
}
.cj-stat .cj-v {
  font-family: var(--cj-font-mono); font-size: 15px; font-weight: 700;
  color: var(--cj-primary); line-height: 1.2;
}
html[data-theme="dark"] body.cj-body .cj-stat .cj-v { color: var(--cj-accent-bright); }

.cj-metric-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0;
}
.cj-metric {
  padding: 14px 16px; border-radius: 10px;
  background: rgba(160, 122, 42, 0.1);
}
html[data-theme="dark"] body.cj-body .cj-metric { background: rgba(243, 201, 103, 0.07); }
.cj-metric-label {
  font-family: var(--cj-font-ui); font-size: 9px; font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; opacity: 0.75;
}
.cj-metric-value {
  font-family: var(--cj-font-mono); font-size: 24px; font-weight: 700;
  color: var(--cj-primary);
}
html[data-theme="dark"] body.cj-body .cj-metric-value { color: var(--cj-accent-bright); }

/* ---------- 10 · TABLE ---------- */

.cj-tbl { width: 100%; border-collapse: collapse; }
.cj-tbl th {
  font-family: var(--cj-font-display); font-weight: 700;
  font-size: 10px; letter-spacing: 0.17em; text-transform: uppercase;
  padding: 10px 12px; border-bottom: 1px solid var(--cj-border);
  text-align: left; color: var(--cj-ink-faint);
}
.cj-tbl td {
  padding: 12px; border-bottom: 1px solid var(--cj-border-soft);
  font-family: var(--cj-font-body); font-size: 14px; color: var(--cj-ink);
}
.cj-tbl tr:last-child td { border-bottom: none; }
.cj-tbl tr:hover td { background: rgba(212, 162, 76, 0.08); }
.cj-tbl .cj-num {
  font-family: var(--cj-font-mono); font-weight: 700; color: var(--cj-primary);
}
html[data-theme="dark"] body.cj-body .cj-tbl .cj-num { color: var(--cj-accent-bright); }

/* ---------- 11 · FOOTER + CONSENT ---------- */

.cj-footer {
  margin-top: 24px; padding-top: 14px;
  border-top: 1px solid var(--cj-border);
  display: flex; justify-content: space-between; gap: 10px;
  font-family: var(--cj-font-ui); font-size: 11px;
  color: var(--cj-ink-faint); flex-wrap: wrap;
  letter-spacing: 0.08em;
}
.cj-footer a:hover { color: var(--cj-primary); }

body.cj-body .cj-topbar,
body.cj-body .cj-footer {
  background: transparent !important;
}

html[data-theme="dark"] body.cj-body :is(.cj-topbar, .cj-footer) {
  background: transparent !important;
}

body.cj-body .dnd-page {
  background: transparent;
  min-height: 0;
}

body.cj-body .audit-empty-state {
  background: var(--cj-surface-raise);
  border: 1px dashed var(--cj-border);
  color: var(--cj-ink-muted);
}

body.cj-body .audit-empty-state__title {
  color: var(--cj-ink);
}

body.cj-body .audit-empty-state__body {
  color: var(--cj-ink-muted);
}

/* ---------- 12 · UTILITIES ---------- */

.cj-row { display: flex; align-items: center; gap: 12px; }
.cj-row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cj-grow { flex: 1; min-width: 0; }
.cj-muted { color: var(--cj-ink-faint); }
.cj-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cj-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .cj-cols-2, .cj-cols-3 { grid-template-columns: 1fr; } }
.cj-mt-8 { margin-top: 8px; }
.cj-mt-14 { margin-top: 14px; }
.cj-mt-20 { margin-top: 20px; }

/* Error-Hero (parity with sh-error-hero) */
.cj-error-hero { text-align: center; padding: 36px 20px; }
.cj-error-code {
  font-family: var(--cj-font-display); font-weight: 700;
  font-size: 96px; line-height: 0.9; color: var(--cj-primary);
  letter-spacing: -0.03em;
}
html[data-theme="dark"] body.cj-body .cj-error-code { color: var(--cj-accent-bright); }
.cj-error-message {
  font-family: var(--cj-font-body); font-size: 15px; color: var(--cj-ink-muted);
  margin-top: 14px; background: rgba(160, 122, 42, 0.12);
  border: 1px solid var(--cj-border); border-radius: 10px;
  padding: 12px 16px; display: inline-block; max-width: 48ch;
}

.cj-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--cj-z-backdrop);
  background: rgba(12, 10, 9, 0.56);
  backdrop-filter: blur(2px);
}

body.cj-body.cj-drawer-open {
  overflow: hidden;
}

@media (max-width: 1023px) {
  .cj-page {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }

  .cj-shell {
    width: 100%;
    min-height: calc(100vh - 28px);
    min-height: calc(100dvh - 28px);
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
    gap: 16px;
  }

  .cj-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: var(--cj-z-drawer);
    width: min(22rem, calc(100vw - 1.5rem));
    max-width: 100%;
    padding:
      max(22px, env(safe-area-inset-top))
      20px
      max(22px, env(safe-area-inset-bottom))
      max(20px, env(safe-area-inset-left));
    border-radius: 0 24px 24px 0;
    box-shadow: 0 28px 80px rgba(17, 8, 7, 0.34);
    transform: translateX(calc(-100% - 1.5rem));
    transition: transform 220ms ease, box-shadow 220ms ease;
  }

  .cj-sidebar.is-open {
    transform: translateX(0);
  }

  .cj-content {
    padding: 20px 18px 24px;
  }

  .cj-topbar {
    position: sticky;
    top: max(0px, env(safe-area-inset-top));
    z-index: 24;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 0.9rem 0 1rem;
    background: linear-gradient(180deg, rgba(247, 238, 215, 0.96), rgba(247, 238, 215, 0.78));
    backdrop-filter: blur(10px);
  }

  html[data-theme="dark"] body.cj-body .cj-topbar {
    background: linear-gradient(180deg, rgba(26, 14, 10, 0.96), rgba(26, 14, 10, 0.8));
  }

  .cj-topbar-title {
    width: 100%;
  }

  .cj-topbar-context {
    display: flex;
  }

  .cj-topbar-title h1 {
    font-size: clamp(1.8rem, 7vw, 2.35rem);
  }

  .cj-topbar-title p {
    margin-top: 8px;
    font-size: 14px;
  }

  .cj-topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

body.cj-body .cj-topbar,
html[data-theme="dark"] body.cj-body .cj-topbar,
body.cj-body .cj-footer,
html[data-theme="dark"] body.cj-body .cj-footer {
  background: transparent !important;
}

/* Public `/dnd/info` landing still contains historical inline parchment
   styling. These bridge rules make the standalone landing obey the selected
   Campaign Journal theme without rewriting the whole page in one jump. */
.cj-public-start {
  color: var(--cj-ink);
}

html[data-theme="dark"] body.cj-body .cj-public-bg {
  background:
    radial-gradient(circle at top left, rgba(243, 201, 103, 0.12), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(96, 165, 250, 0.10), transparent 26%),
    radial-gradient(circle at bottom right, rgba(176, 60, 72, 0.10), transparent 32%),
    linear-gradient(180deg, #06101b 0%, #0b1827 56%, #071221 100%) !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start :is(.rounded-2xl, .rounded-3xl, .rounded-\[2rem\]) {
  background: rgba(14, 27, 44, 0.90) !important;
  border-color: rgba(226, 232, 240, 0.14) !important;
  color: var(--cj-ink) !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24) !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start figure.rounded-\[2rem\] {
  background: linear-gradient(180deg, rgba(8, 19, 33, 0.98), rgba(14, 27, 44, 0.96)) !important;
  border-color: rgba(243, 201, 103, 0.20) !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start figure .rounded-\[1\.6rem\] {
  background:
    radial-gradient(circle at top left, rgba(243, 201, 103, 0.10), transparent 34%),
    linear-gradient(180deg, rgba(8, 19, 33, 0.98), rgba(14, 27, 44, 0.96)) !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start :is(h1, h2, h3)[style*="color"] {
  color: #f8fbff !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start :is(p, div, span)[style*="color"] {
  color: #aebfd0 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start :is(.text-xs, .text-sm)[style*="color"] {
  color: #aebfd0 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start :is(.font-semibold, .font-bold)[style*="color"] {
  color: #f0bd58 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start a[style*="background: var(--cj-primary)"],
html[data-theme="dark"] body.cj-body .cj-public-start button[style*="background: var(--cj-primary)"] {
  background: #f0bd58 !important;
  border-color: rgba(240, 189, 88, 0.32) !important;
  color: #071221 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start a[style*="background: rgba(255, 251, 240"],
html[data-theme="dark"] body.cj-body .cj-public-start span[style*="background: white"] {
  background: rgba(8, 19, 33, 0.88) !important;
  border-color: rgba(226, 232, 240, 0.16) !important;
  color: #e6edf5 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start a:hover {
  filter: brightness(1.06);
}

/* Public DnD landing readability pass: keep the product mood, but use
   app-style typography and explicit CTA contrast on the dark landing. */
.cj-public-start {
  font-family: var(--cj-font-ui) !important;
}

.cj-public-start :is(h1, h2, h3),
.cj-public-start :is(.font-black, .font-bold, .font-semibold) {
  font-family: var(--cj-font-ui) !important;
  letter-spacing: 0 !important;
}

.cj-public-start h1 {
  line-height: 1.04 !important;
  max-width: 12ch;
}

.cj-public-preview {
  background: linear-gradient(180deg, rgba(7, 18, 33, 0.98), rgba(15, 26, 42, 0.98)) !important;
  border-color: rgba(243, 201, 103, 0.24) !important;
}

.cj-public-preview-board {
  overflow: hidden;
  background: transparent;
}

.cj-public-hero-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 300px;
}

html[data-theme="dark"] body.cj-body .cj-public-start h1,
html[data-theme="dark"] body.cj-body .cj-public-start h2,
html[data-theme="dark"] body.cj-body .cj-public-start h3 {
  color: #f8fbff !important;
  text-shadow: none !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start p,
html[data-theme="dark"] body.cj-body .cj-public-start .text-sm:not(.font-semibold),
html[data-theme="dark"] body.cj-body .cj-public-start .leading-7,
html[data-theme="dark"] body.cj-body .cj-public-start .leading-8 {
  color: #cbd7e6 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start .text-sm.font-semibold,
html[data-theme="dark"] body.cj-body .cj-public-start .text-base.font-bold {
  color: #f8fbff !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start .text-xs.font-semibold,
html[data-theme="dark"] body.cj-body .cj-public-start figcaption span {
  color: #f3c967 !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start .cj-public-primary-action,
html[data-theme="dark"] body.cj-body .cj-public-start .cj-public-primary-action.text-sm.font-semibold,
html[data-theme="dark"] body.cj-body .cj-public-start .cj-public-primary-action * {
  color: #071221 !important;
  text-shadow: none !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start .cj-public-primary-action {
  min-width: 12rem;
  background: #f3c967 !important;
  border-color: rgba(243, 201, 103, 0.48) !important;
}

html[data-theme="dark"] body.cj-body .cj-public-start button.cj-public-primary-action:disabled {
  opacity: 0.82 !important;
}
