:root {
  --blue: #0a2463;
  --blue-mid: #1e3a8a;
  --blue-bright: #1d4ed8;
  --red: #b91c1c;
  --gold: #e8c547;
  --gold-light: #fff7d6;
  --ink: #0f172a;
  --muted: #475569;
  --line: #cbd5e1;
  --bg: #f8fafc;
  --panel: #ffffff;
  --sidebar-w: 280px;
  --topbar-h: 64px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: "Inter", "Segoe UI", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #061a45 0%, var(--blue) 55%, #123a9e 100%);
  color: #fff;
  border-right: 1px solid rgba(255, 247, 214, 0.15);
}
.sidebar-brand {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-brand h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.25;
}
.sidebar-brand p {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--gold-light);
  opacity: 0.92;
}
.sidebar-search {
  padding: 12px 14px 8px;
}
.sidebar-search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
}
.sidebar-search input::placeholder { color: rgba(255, 255, 255, 0.55); }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
}
.sidebar-nav-label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: 0.75;
  padding: 12px 10px 6px;
  font-weight: 700;
}
.sidebar-nav-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 247, 214, 0.2);
}
.sidebar-nav-item:focus-visible,
.btn:focus-visible,
.home-card:focus-visible,
.moment-bar select:focus-visible,
.sidebar-search input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.sidebar-nav-item.active {
  background: linear-gradient(90deg, rgba(232, 197, 71, 0.22), rgba(255, 255, 255, 0.06));
  border-color: rgba(232, 197, 71, 0.45);
  color: #fff;
}
.sidebar-nav-item .title { font-size: 0.88rem; font-weight: 600; display: block; }
.sidebar-nav-item .lead { font-size: 0.72rem; opacity: 0.72; margin-top: 2px; display: block; line-height: 1.35; }
.sidebar-foot {
  padding: 12px 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.sidebar-foot a { color: var(--gold-light); text-decoration: underline; }
.sidebar-foot-sep { opacity: 0.5; }
.sidebar-nav-empty {
  margin: 12px 10px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.4;
}
.panel-loading { color: var(--muted); margin: 0; padding: 8px 0; }
.panel-error, .panel-error-msg { color: var(--red); margin: 0; }
.home-hero {
  margin: 0 0 28px;
  padding: 24px 26px 26px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(10, 36, 99, 0.06), rgba(232, 197, 71, 0.14));
  border: 1px solid rgba(10, 36, 99, 0.12);
}
.home-hero-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-mid);
}
.home-hero-title {
  margin: 0 0 8px;
  font-family: Georgia, serif;
  font-size: 1.45rem;
  color: var(--blue);
  line-height: 1.25;
}
.home-hero-lead {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 52ch;
  line-height: 1.5;
}
.home-routing-ref {
  margin: 14px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.home-routing-link {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: var(--blue-bright);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.home-routing-link:hover { color: var(--blue); }
.home-routing-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}
.home-section { margin-bottom: 26px; }
.home-section:last-child { margin-bottom: 0; }
.home-section-title {
  margin: 0 0 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-mid);
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0 0 4px;
  font-size: 0.72rem;
  color: var(--muted);
}
.crumb-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--blue-bright);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.crumb-link:hover { color: var(--blue); }
.crumb-sep { opacity: 0.45; }
.crumb-group { font-weight: 600; color: var(--muted); }
.crumb-current { font-weight: 600; color: var(--blue); }
.topbar-title p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms var(--ease), border-color 160ms var(--ease);
}
.btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  border-color: #c9a227;
  color: var(--blue);
}
.moment-bar {
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(10, 36, 99, 0.06), rgba(232, 197, 71, 0.12));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.moment-bar label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}
.moment-bar select {
  flex: 1;
  min-width: 220px;
  max-width: 520px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.moment-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 2px;
}
.moment-chip-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.moment-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.moment-chip:hover {
  border-color: var(--gold);
  background: rgba(255, 247, 214, 0.45);
}
.moment-chip-primary {
  border-color: rgba(10, 36, 99, 0.25);
  background: rgba(10, 36, 99, 0.06);
}
.moment-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.main-stage {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 48px;
}
.panel {
  max-width: 920px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(10, 36, 99, 0.06);
  padding: 28px 30px 36px;
}
.panel.panel--wide { max-width: 1120px; }
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.home-card {
  text-align: left;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(10, 36, 99, 0.1);
  border-color: var(--gold);
}
.home-card h3 { margin: 0 0 6px; font-size: 0.95rem; color: var(--blue); }
.home-card p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
  z-index: 100;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 45;
}
.backdrop.open { display: block; }

@media (max-width: 900px) {
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed;
    left: -100%;
    transition: left 320ms var(--ease);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open { left: 0; }
  .panel { padding: 20px 16px 28px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title p { display: none; }
  .doc-breadcrumb { display: none; }
  .btn { padding: 8px 10px; }

  .moment-bar { padding: 10px 12px; }
  .main-stage { padding: 16px 12px 32px; }
  .home-hero { padding: 18px 16px 20px; }
  .home-hero-title { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .home-grid { grid-template-columns: 1fr; }
  #btn-copy .btn-label { font-size: 0; }
  #btn-copy .btn-label::after { content: "Link"; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .sidebar,
  .menu-btn,
  .topbar-actions,
  .moment-bar,
  .backdrop,
  .toast,
  .doc-toc-rail,
  .doc-toc-mobile {
    display: none !important;
  }
  .app { display: block; }
  .topbar {
    position: static;
    border: none;
    padding: 0 0 12px;
    height: auto;
  }
  .main-stage { padding: 0; overflow: visible; }
  .panel {
    max-width: none;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .doc-body .part { page-break-before: auto; }
}