
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1e40af;
  --color-secondary: #3b82f6;
  --color-accent: #60a5fa;
  --color-background: #0a0e1a;
  --color-background-light: #0f1629;
  --color-background-card: #111827;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-border: #1f2937;
  --animation-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(270deg, #0a0e1a 0%, #0f1629 100%);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--color-accent); }

h1, h2, h3, h4 { font-weight: 700; text-wrap: balance; }
h1 { font-size: 1.875rem; margin-bottom: 8px; }
h2 { font-size: 1.5rem; margin: 28px 0 10px; }
h3 { font-size: 1.2rem; margin: 22px 0 8px; }
h4 { font-size: 1.05rem; margin: 18px 0 6px; }
p { margin: 12px 0; }
hr { border: none; height: 1px; background: var(--color-border); margin: 16px 0; }

.top-nav {
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(17, 24, 39, 0.95);
  padding: 8px 16px;
  color: white;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.nav-1 { display: flex; align-items: center; font-size: 18px; color: inherit; text-decoration: none; gap: 8px; font-weight: 600; }
.nav-1:hover { color: var(--color-accent); }
.nav-1 img { max-height: 28px; border-radius: 50%; }

.docs-nav-right { display: flex; align-items: center; gap: 14px; }
.docs-nav-link { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); text-decoration: none; font-size: 0.9rem; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.docs-nav-link:hover { color: var(--color-text); background: rgba(37, 99, 235, 0.08); }

.docs-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-background-light);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 6px 12px;
  color: var(--color-text-muted);
  transition: border-color 0.2s var(--animation-smooth);
  width: clamp(160px, 30vw, 280px);
}
.docs-search:focus-within { border-color: var(--color-primary); }
.docs-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
}
.docs-search input::placeholder { color: var(--color-text-muted); }

.docs-shell { display: grid; grid-template-columns: 280px 1fr; max-width: 1360px; width: 100%; margin: 0 auto; flex: 1 0 auto; }
.docs-shell.docs-shell-solo { grid-template-columns: 1fr; }
.docs-sidebar { padding: 24px 18px; border-right: 1px solid var(--color-border); }
.docs-main { padding: 32px clamp(20px, 5vw, 56px) 96px; min-width: 0; max-width: 860px; }
.docs-shell-solo .docs-main { max-width: 1080px; margin: 0 auto; width: 100%; }

/* Table of contents — .docs-main only switches into this two-column mode
   when it actually has a .docs-toc child (see TableOfContents' len>=2
   guard), so a page with no TOC pays nothing for this rule existing. */
.docs-main:has(> .docs-toc) { display: flex; gap: 32px; align-items: flex-start; max-width: none; }
.docs-reading-column { max-width: 860px; min-width: 0; flex: 1 1 auto; }
.docs-toc {
  flex: 0 0 220px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  padding-left: 18px;
  border-left: 1px solid var(--color-border);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.docs-toc-label { font-size: 0.72rem; color: var(--color-text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.docs-toc a { display: block; padding: 4px 0; color: var(--color-text-muted); text-decoration: none; font-size: 0.85rem; line-height: 1.4; }
.docs-toc a:hover { color: var(--color-accent); }
.docs-toc a.docs-toc-h3 { padding-left: 12px; font-size: 0.8rem; }

@media (max-width: 1200px) {
  .docs-toc { display: none; }
}

.docs-hero { margin-bottom: 28px; }
.docs-hero h1 { font-size: 2.1rem; }
.docs-hero p { color: var(--color-text-muted); font-size: 1.05rem; max-width: 640px; margin: 0; }

.docs-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: 20px; }

.docs-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.docs-meta-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--color-text-muted); }
.docs-meta-item i { font-size: 0.8em; opacity: 0.8; }
.docs-card-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.docs-card-meta .docs-meta-item { font-size: 0.8rem; }
.docs-crumbs a { color: var(--color-text-muted); text-decoration: none; }
.docs-crumbs a:hover { color: var(--color-accent); }
.docs-crumbs .sep { color: var(--color-border); }
.docs-crumbs .current { color: var(--color-text); }

.docs-tree { font-size: 0.9rem; }
.docs-tree-group { margin-bottom: 18px; }
.docs-tree-label { font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 6px; padding-left: 10px; }
.docs-tree a {
  display: block;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s var(--animation-smooth);
}
.docs-tree a:hover { color: var(--color-text); background: rgba(37, 99, 235, 0.08); }
.docs-tree a.current { color: var(--color-accent); background: rgba(37, 99, 235, 0.12); font-weight: 600; }
.docs-tree .docs-tree-chapter { margin-left: 8px; border-left: 1px solid var(--color-border); padding-left: 8px; }
.docs-tree a i { width: 14px; margin-right: 6px; text-align: center; font-size: 0.8em; opacity: 0.8; }

.docs-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 20px; }
.docs-card {
  display: block;
  background: var(--color-background-card);
  border: 1px solid var(--color-border);
  border-radius: 15px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s var(--animation-smooth);
}
.docs-card:hover { border-color: var(--color-primary); box-shadow: 0 8px 16px rgba(37, 99, 235, 0.15); }
.docs-card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--color-text); }
.docs-card p { margin: 0; font-size: 0.9rem; color: var(--color-text-muted); }

.docs-empty { color: var(--color-text-muted); font-style: italic; margin-top: 16px; }

/* Entity type badges — shelf/book/chapter/page need to read as different
   kinds of thing at a glance, not just differently-worded cards. */
.docs-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
}
.docs-badge-shelf { color: #c084fc; border-color: rgba(192, 132, 252, 0.35); background: rgba(192, 132, 252, 0.08); }
.docs-badge-book { color: var(--color-accent); border-color: rgba(96, 165, 250, 0.35); background: rgba(96, 165, 250, 0.08); }
.docs-badge-chapter { color: #34d399; border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }
.docs-badge-page { color: var(--color-text-muted); border-color: var(--color-border); background: rgba(156, 163, 175, 0.08); }
.docs-badge-visibility-public { color: #34d399; border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); margin-bottom: 0; }
.docs-badge-visibility-internal { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); margin-bottom: 0; }

.docs-staffbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.docs-edit-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  transition: all 0.15s var(--animation-smooth);
}
.docs-edit-link:hover { color: var(--color-accent); border-color: var(--color-primary); }

/* Prev/Next pager */
.docs-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; }
.docs-pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--color-border);
  border-radius: 15px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s var(--animation-smooth);
}
.docs-pager-link:hover { border-color: var(--color-primary); box-shadow: 0 8px 16px rgba(37, 99, 235, 0.15); }
.docs-pager-next { grid-column: 2; text-align: right; align-items: flex-end; }
.docs-pager-dir { font-size: 0.75rem; color: var(--color-text-muted); }
.docs-pager-label { font-weight: 600; color: var(--color-text); }

.docs-search-results { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.docs-search-result { max-width: 720px; }

@media (max-width: 560px) {
  .docs-pager { grid-template-columns: 1fr; }
  .docs-pager-next { grid-column: 1; text-align: left; align-items: flex-start; }
}

/* Rendered Markdown content */
.docs-content code { font-family: 'JetBrains Mono', monospace; font-size: 0.9em; background: var(--color-background-light); border: 1px solid var(--color-border); padding: 1px 6px; border-radius: 4px; }
.docs-content pre { position: relative; background: var(--color-background-light); border: 1px solid var(--color-border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 16px 0; }
.docs-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--color-background-card);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s var(--animation-smooth), color 0.15s var(--animation-smooth), border-color 0.15s var(--animation-smooth);
}
.docs-content pre:hover .docs-copy-btn, .docs-copy-btn:focus-visible { opacity: 1; }
.docs-copy-btn:hover { color: var(--color-accent); border-color: var(--color-primary); }
.docs-content pre code { background: none; border: none; padding: 0; }
.docs-content table { width: 100%; border-collapse: collapse; margin: 16px 0; overflow-x: auto; display: block; }
.docs-content th, .docs-content td { border: 1px solid var(--color-border); padding: 8px 12px; text-align: left; font-size: 0.95rem; }
.docs-content th { background: var(--color-background-light); font-weight: 600; }
.docs-content blockquote { border-left: 3px solid var(--color-primary); padding: 4px 16px; margin: 16px 0; color: var(--color-text-muted); }
.docs-content img { max-width: 100%; border-radius: 10px; }
.docs-content ul, .docs-content ol { margin: 12px 0; padding-left: 24px; }
.docs-content li { margin: 4px 0; }

.page-footer { width: 100%; min-height: 260px; color: white; padding: 32px 16px; background: var(--color-background-card); margin-top: 48px; border-top: 1px solid var(--color-border); }
.footer-container { width: 100%; margin: 0 auto; max-width: 1100px; }
.footer-columns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; text-align: left; }
.footer-column { display: flex; flex-direction: row; flex-wrap: wrap; gap: 24px; }
.footer-text-group { display: flex; flex-direction: column; min-width: 220px; margin-bottom: 12px; gap: 6px; }
.footer-text-group h3 { margin: 0 0 6px; font-weight: 600; color: var(--color-text); font-size: 1rem; }
.footer-column a, .footer-column p { margin: 0; text-decoration: none; color: var(--color-text-muted); transition: color 0.2s var(--animation-smooth); cursor: pointer; font-size: 0.9375rem; }
.footer-column a:hover { color: var(--color-accent); }
.footer-column img { width: 100%; object-fit: cover; height: 180px; border-radius: 8px; border: 1px solid var(--color-border); }

@media (max-width: 1150px) {
  .footer-container { max-width: 900px; }
}

@media (max-width: 950px) {
  .footer-columns { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .docs-shell { grid-template-columns: 1fr; }
  .docs-sidebar { border-right: none; border-bottom: 1px solid var(--color-border); }
}

@media (max-width: 560px) {
  .docs-search { width: 40vw; }
  .docs-nav-link-label { display: none; }
  .docs-nav-link { padding: 4px 6px; }
}

/* Ripple + popup, copied from stylesv5.css to match core.js verbatim —
   core.js looks up #popup-overlay/#popup-container/#popup-text by ID and
   the ripple JS only creates the .ripple span, it doesn't style it. */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
  transition: transform 1.2s var(--animation-smooth), opacity 1.2s var(--animation-smooth);
}
.ripple.active { transform: scale(4); opacity: 0; }
.ripple.fast { transition: transform 0.4s var(--animation-smooth), opacity 0.4s var(--animation-smooth); }

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s var(--animation-smooth);
}
.popup-overlay.active { opacity: 1; visibility: visible; }
.popup-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--color-background-card);
  border: 1px solid var(--color-border);
  padding: 15px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 420px;
  width: 85%;
  z-index: 2001;
  transition: transform 0.2s var(--animation-smooth), opacity 0.2s var(--animation-smooth);
  text-align: center;
  opacity: 0;
}
.popup-overlay.active .popup-container { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.popup-container h2 { margin-top: 0; margin-bottom: 10px; color: var(--color-text); font-size: 1.25rem; }
.popup-title span { margin-left: 4px; }
.popup-container p { color: var(--color-text-muted); margin-bottom: 16px; font-size: 0.9375rem; line-height: 1.6; }
.popup-buttons { display: flex; gap: 8px; justify-content: stretch; }
.popup-btn {
  flex: 1;
  background: var(--color-primary);
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s var(--animation-smooth);
  position: relative;
  overflow: hidden;
}
.popup-btn:hover { background: var(--color-primary-dark); }
.popup-btn-text {
  flex: 1;
  background: transparent;
  color: var(--color-text-muted);
  padding: 10px 20px;
  border: none;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 400;
  transition: color 0.2s var(--animation-smooth);
  position: relative;
  overflow: hidden;
}
.popup-btn-text:hover { background: transparent; color: var(--color-text); }
.popup-btn-text:active { background: transparent; }
