/**
 * Neuro OS Docs — overlays Pattern Automation landing.css (--bg, --fg, brand tokens).
 */
.neuro-docs-app {
  --nd-line: rgba(255, 255, 255, 0.1);
  --nd-panel: rgba(255, 255, 255, 0.03);
  --nd-muted: var(--muted, #a1a1aa);
  --nd-prose: #d4d4d8;

  display: grid;
  grid-template-columns: 284px minmax(0, 1fr);
  gap: 0;
  max-width: 1392px;
  margin: 0 auto;
}

.neuro-docs-app__rail {
  min-height: calc(100vh - 56px);
  border-right: 1px solid var(--nd-line);
  padding: 0.875rem 0.625rem;
  background:
    linear-gradient(180deg, rgba(24, 24, 27, 0.95) 0%, rgba(9, 9, 11, 0.6) 100%);
}

.doc-rail-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0.6rem 0.75rem;
  text-decoration: none;
  color: var(--fg);
}

.doc-rail-brand img {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.doc-rail-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.doc-rail-brand__name {
  font-size: 0.8125rem;
  font-weight: 650;
}

.doc-rail-brand__sub {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pa-brand-light, #60a5fa);
}

.doc-rail-back {
  display: inline-flex;
  margin: 0.25rem 0.65rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--nd-muted);
  text-decoration: none;
}

.doc-rail-back:hover {
  color: var(--fg);
}

.doc-rail-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.5rem 0.875rem;
  padding: 0 0.5rem 0 0.55rem;
  height: 2.0625rem;
  border-radius: 0.5rem;
  border: 1px solid var(--nd-line);
  background: rgba(255, 255, 255, 0.04);
}

.doc-rail-search:focus-within {
  border-color: var(--pa-brand-border-soft);
  box-shadow: 0 0 0 1px var(--pa-brand-ring);
}

.doc-rail-search__ico {
  flex-shrink: 0;
  color: var(--nd-muted);
}

.doc-rail-search__input {
  flex: 1;
  width: min(100%, 8rem);
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.78125rem;
  color: var(--fg);
  font-family: inherit;
}

.doc-rail-search__input::placeholder {
  color: #71717a;
}

.doc-rail-search__kbd {
  flex-shrink: 0;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.625rem;
  padding: 0.0625rem 0.28125rem;
  border-radius: 0.25rem;
  border: 1px solid var(--nd-line);
  color: var(--nd-muted);
}

#content-docs {
  min-height: calc(100vh - 56px);
  padding: clamp(1.25rem, 4vw, 2rem) clamp(1rem, 3vw, 2.125rem)
    clamp(2.75rem, 5vw, 3.75rem);
  background:
    radial-gradient(840px 480px at 18% -6%, rgba(37, 99, 235, 0.12), transparent 55%),
    radial-gradient(640px 400px at 92% 6%, rgba(56, 189, 248, 0.08), transparent 50%),
    var(--bg, #09090b);
}

#doc-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, min(240px, 28vw));
  gap: clamp(1.25rem, 3vw, 2rem);
  align-items: start;
}

@media (max-width: 1100px) {
  #doc-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

#article {
  max-width: 48rem;
  border: 1px solid var(--nd-line);
  border-radius: 1rem;
  background: var(--nd-panel);
  padding: clamp(1.35rem, 3.5vw, 2rem) clamp(1.1rem, 3vw, 1.75rem)
    clamp(2rem, 4vw, 2.75rem);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.doc-article__header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--nd-line);
}

.doc-breadcrumb {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  color: var(--nd-muted);
}

.doc-article__topline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.875rem;
}

.doc-llm-strip {
  margin: 0 0 1rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(113, 113, 122, 0.35);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--nd-muted);
}

.doc-llm-strip a {
  color: var(--fg);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#doc-title {
  margin: 0;
  padding-bottom: 0.25rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.06;
  font-weight: 500;
  font-family: Instrument Serif, ui-serif, Georgia, serif;
  letter-spacing: -0.02em;
  max-width: 100%;
  background: linear-gradient(90deg, #fafafa, #cbd5ff 52%, var(--pa-brand-light, #60a5fa));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pill-doc-chapter {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pa-brand-tint, #93c5fd);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--pa-brand-border-soft, rgba(96, 165, 250, 0.35));
  background: rgba(37, 99, 235, 0.1);
}

.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.pill-btn {
  appearance: none;
  border: 1px solid var(--nd-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  padding: 0.45rem 0.78rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.pill-btn:hover {
  border-color: var(--pa-brand-border-soft);
  box-shadow: 0 0 0 1px var(--pa-brand-ring, rgba(14, 116, 200, 0.35));
  background: rgba(59, 130, 246, 0.1);
}

a.pill-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  box-sizing: border-box;
}

.neuro-docs-noscript {
  margin: 0 1.25rem 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.12);
  color: var(--fg);
  font-size: 0.875rem;
  line-height: 1.45;
}

.neuro-docs-noscript a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

#article-content {
  font-size: 1rem;
}

#article-content p {
  margin: 0 0 1.05rem;
  color: var(--nd-prose);
  line-height: 1.7;
}

#article-content h2 {
  margin: 2rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--nd-line);
  font-family: Instrument Serif, ui-serif, Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.65rem, 3vw, 2.125rem);
  line-height: 1.14;
}

#article-content h3 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1.175rem;
  font-weight: 600;
  color: #f4f4f5;
}

#article-content ul,
#article-content ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
  color: #e4e4e7;
}

#article-content li {
  margin: 0.25rem 0;
}

#article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1.125rem;
  font-size: 0.9375rem;
}

#article-content th,
#article-content td {
  border: 1px solid var(--nd-line);
  padding: 0.5rem 0.625rem;
  text-align: left;
}

#article-content pre {
  margin: 0.65rem 0 1rem;
  border: 1px solid var(--nd-line);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 0.875rem;
  overflow: auto;
}

#article-content code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85em;
}

#toc-panel {
  position: sticky;
  top: 80px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--nd-line);
  border-radius: 12px;
  background: rgba(24, 24, 27, 0.7);
  padding: 1rem;
  backdrop-filter: blur(12px);
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--nd-muted);
  margin-bottom: 0.5rem;
}

#toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.toc-item {
  display: block;
  color: var(--pa-brand-tint, #93c5fd);
  text-decoration: none;
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: 0.28rem 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.toc-item--h3 {
  padding-left: 0.625rem;
  font-size: 0.7825rem;
  line-height: 1.42;
  color: rgba(186, 220, 255, 0.92);
}

.toc-item:hover {
  color: var(--pa-brand-light, #93c5fd);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md-view pre {
  max-height: 60vh;
}

.inline-link {
  color: var(--pa-brand-light, #93c5fd);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

a.pa-docs-xlink {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

a.pa-docs-xlink:hover {
  color: var(--pa-brand-light, #93c5fd);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  #toc-panel {
    display: none;
  }
}

@media (max-width: 900px) {
  .neuro-docs-app {
    grid-template-columns: 1fr;
  }

  .neuro-docs-app__rail {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--nd-line);
  }

  .doc-article__topline {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-toolbar {
    justify-content: flex-start;
  }
}

/* ─── Light (day) theme — html[data-pa-theme="day"] from landing theme boot ─── */
html[data-pa-theme="day"] .neuro-docs-app {
  --nd-line: rgba(9, 9, 11, 0.12);
  --nd-panel: rgba(255, 255, 255, 0.94);
  --nd-muted: var(--muted);
  --nd-prose: #3f3f46;
}

html[data-pa-theme="day"] .neuro-docs-app__rail {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 244, 245, 0.94) 100%);
}

html[data-pa-theme="day"] .doc-rail-brand__sub {
  color: var(--pa-brand-deep);
}

html[data-pa-theme="day"] .doc-rail-brand img {
  filter: invert(1);
  opacity: 0.94;
}

html[data-pa-theme="day"] .doc-rail-search {
  background: rgba(255, 255, 255, 0.88);
  border-color: var(--nd-line);
}

html[data-pa-theme="day"] .doc-rail-search__input::placeholder {
  color: var(--muted);
}

html[data-pa-theme="day"] .doc-rail-search__kbd {
  border-color: var(--nd-line);
  background: rgba(9, 9, 11, 0.04);
}

html[data-pa-theme="day"] #content-docs {
  background:
    radial-gradient(840px 480px at 18% -6%, rgba(37, 99, 235, 0.07), transparent 55%),
    radial-gradient(640px 400px at 92% 6%, rgba(56, 189, 248, 0.05), transparent 50%),
    var(--bg);
}

html[data-pa-theme="day"] #article {
  box-shadow: 0 20px 50px rgba(14, 23, 41, 0.08);
}

html[data-pa-theme="day"] #doc-title {
  background: linear-gradient(90deg, #0f172a 0%, #334155 48%, var(--pa-brand-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

html[data-pa-theme="day"] .pill-doc-chapter {
  color: var(--pa-brand-deep);
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.08);
}

html[data-pa-theme="day"] .doc-llm-strip {
  border-color: var(--nd-line);
  background: rgba(37, 99, 235, 0.06);
  color: var(--muted);
}

html[data-pa-theme="day"] .doc-llm-strip a {
  color: var(--pa-brand-deep);
}

html[data-pa-theme="day"] .pill-btn {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--nd-line);
}

html[data-pa-theme="day"] .pill-btn:hover {
  background: rgba(37, 99, 235, 0.07);
  border-color: rgba(37, 99, 235, 0.22);
}

html[data-pa-theme="day"] #article-content h2 {
  color: var(--fg);
  border-top-color: var(--nd-line);
}

html[data-pa-theme="day"] #article-content h3 {
  color: var(--fg);
}

html[data-pa-theme="day"] #article-content ul,
html[data-pa-theme="day"] #article-content ol {
  color: var(--nd-prose);
}

html[data-pa-theme="day"] #article-content pre {
  background: rgba(9, 9, 11, 0.045);
  border-color: var(--nd-line);
}

html[data-pa-theme="day"] #article-content code {
  color: #1e293b;
}

html[data-pa-theme="day"] #article-content :not(pre) > code {
  background: rgba(37, 99, 235, 0.08);
  padding: 0.12em 0.35em;
  border-radius: 0.25rem;
}

html[data-pa-theme="day"] #toc-panel {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--nd-line);
  box-shadow: 0 12px 40px rgba(14, 23, 41, 0.07);
}

html[data-pa-theme="day"] .toc-item {
  color: var(--pa-brand-deep);
}

html[data-pa-theme="day"] .toc-item--h3 {
  color: var(--muted);
}

html[data-pa-theme="day"] .toc-item:hover {
  color: var(--fg);
}

html[data-pa-theme="day"] .inline-link {
  color: var(--pa-brand-deep);
}

html[data-pa-theme="day"] a.pa-docs-xlink:hover {
  color: var(--pa-brand-deep);
}

/* Sidebar primitives (inline index.html) — higher specificity for day */
html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-group .sb-label {
  color: var(--muted);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-chapter {
  border-left-color: var(--nd-line);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-chapter-title {
  color: var(--fg);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-chapter-chevron {
  color: var(--muted);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-link {
  color: var(--muted);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-link:hover {
  background: rgba(37, 99, 235, 0.07);
  color: var(--fg);
}

html[data-pa-theme="day"] #sidebar.neuro-docs-app__rail .sb-link.is-active {
  color: var(--fg);
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.28);
}
