/* Read the Docs shell, widened and rebalanced.
   The theme, left navigation, header and breadcrumbs are preserved. */

:root {
  --docs-bg: #f6f8fb;
  --docs-card: #ffffff;
  --docs-text: #1e293b;
  --docs-heading: #0f172a;
  --docs-muted: #64748b;
  --docs-border: #e2e8f0;
  --docs-accent: #2563eb;
  --docs-accent-dark: #1d4ed8;
  --docs-accent-soft: #eff6ff;
  --docs-radius: 12px;
  --docs-max: 1500px;
  --docs-text-max: 78ch;
  --docs-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--docs-bg);
  color: var(--docs-text);
  font-family: var(--docs-font);
}

.wy-nav-content-wrap {
  background: var(--docs-bg);
}

.wy-nav-content {
  max-width: var(--docs-max);
  margin: 0 auto;
  padding: 2rem clamp(1rem, 2.5vw, 2.5rem) 3rem;
}

.wy-docs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 48px;
  align-items: start;
}

.wy-docs-main {
  min-width: 0;
  padding: clamp(1.25rem, 2.5vw, 2.75rem);
  background: var(--docs-card);
  border: 1px solid var(--docs-border);
  border-radius: var(--docs-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.wy-docs-main .rst-content {
  max-width: none;
  color: var(--docs-text);
  font-family: var(--docs-font);
  font-size: 16px;
  line-height: 1.75;
}

.wy-docs-main .rst-content p,
.wy-docs-main .rst-content li,
.wy-docs-main .rst-content blockquote {
  max-width: var(--docs-text-max);
}

.wy-docs-main .rst-content h1,
.wy-docs-main .rst-content h2,
.wy-docs-main .rst-content h3,
.wy-docs-main .rst-content h4,
.wy-docs-main .rst-content h5,
.wy-docs-main .rst-content h6 {
  color: var(--docs-heading);
  font-family: var(--docs-font);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.wy-docs-main .rst-content h1 {
  margin: 0 0 1.25rem;
  font-size: 2rem;
  line-height: 1.25;
}

.wy-docs-main .rst-content h2 {
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--docs-border);
  font-size: 1.45rem;
  line-height: 1.35;
}

.wy-docs-main .rst-content h3 {
  margin: 1.8rem 0 0.75rem;
  font-size: 1.15rem;
  line-height: 1.45;
}

.wy-docs-main .rst-content h4 {
  margin: 1.4rem 0 0.5rem;
  font-size: 1rem;
}

.wy-docs-main a {
  color: var(--docs-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.wy-docs-main a:hover {
  color: var(--docs-accent-dark);
}

.wy-docs-main .rst-content code,
.wy-docs-main .rst-content tt {
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--docs-border);
  border-radius: 4px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 0.88em;
}

.wy-docs-main .rst-content pre {
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: none;
}

.wy-docs-main .rst-content .highlight {
  background: #f8fafc;
}

.wy-docs-main .rst-content .admonition {
  border: 1px solid #dbeafe;
  border-left: 4px solid #3b82f6;
  border-radius: 8px;
  background: #f8fbff;
  box-shadow: none;
}

.wy-docs-main .rst-content .admonition-title {
  background: transparent;
  color: #1e40af;
}

.wy-docs-main .rst-content dl.field-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 1rem;
  margin: 1rem 0 1.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  background: #f8fafc;
}

.wy-docs-main .rst-content dl.field-list dt {
  color: var(--docs-muted);
  font-weight: 600;
}

.wy-docs-main .rst-content dl.field-list dd {
  margin: 0;
  color: var(--docs-text);
}

.wy-docs-main .rst-content table.docutils {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--docs-border);
  border-radius: 8px;
  font-size: 0.93rem;
}

.wy-docs-main .rst-content table.docutils th {
  background: #f1f5f9;
  color: var(--docs-heading);
}

.wy-docs-main .rst-content table.docutils td,
.wy-docs-main .rst-content table.docutils th {
  padding: 0.55rem 0.7rem;
  border-color: var(--docs-border);
}

.wy-docs-main .rst-content table.docutils tr:nth-child(even) {
  background: #fbfdff;
}

.wy-docs-main .rst-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.wy-docs-main .rst-content blockquote {
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid #bfdbfe;
  color: #475569;
}

.wy-docs-main .rst-content .headerlink {
  opacity: 0;
  margin-left: 0.35rem;
  font-size: 0.75em;
  transition: opacity 160ms ease;
}

.wy-docs-main .rst-content h2:hover .headerlink,
.wy-docs-main .rst-content h3:hover .headerlink,
.wy-docs-main .rst-content .headerlink:focus {
  opacity: 1;
}

/* Right rail: page TOC, or previous/next fallback for pages without H2s. */
.wy-docs-rail-inner {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow: auto;
  padding: 0.25rem 0 0.5rem 1.25rem;
  border-left: 1px solid var(--docs-border);
}

.wy-docs-rail-title {
  margin: 0 0 0.7rem;
  color: var(--docs-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wy-docs-rail-inner ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wy-docs-rail-inner li {
  margin: 0.3rem 0;
  line-height: 1.45;
}

.wy-docs-rail-inner ul ul {
  padding-left: 0.75rem;
}

.wy-docs-rail-inner a {
  display: block;
  margin-left: -0.65rem;
  padding: 0.18rem 0 0.18rem 0.65rem;
  border-left: 2px solid transparent;
  color: #475569;
  font-size: 0.86rem;
  text-decoration: none;
}

.wy-docs-rail-inner a:hover,
.wy-docs-rail-inner a:focus-visible {
  border-left-color: var(--docs-accent);
  color: var(--docs-accent-dark);
}

.wy-docs-rail-nav a {
  white-space: normal;
}

/* Sidebar: keep RTD, add hierarchy and readable density. */
.wy-nav-side {
  background: #1f2937;
}

.wy-side-nav-search {
  background: #0f172a;
}

.wy-side-nav-search input[type="text"] {
  border: 1px solid #334155;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
}

.wy-menu-vertical {
  padding: 0.35rem 0 1.5rem;
  font-size: 0.87rem;
}

.wy-menu-vertical li.toctree-l1 > a {
  color: #e5e7eb;
  font-weight: 600;
}

.wy-menu-vertical li.toctree-l2 > a {
  padding-left: 1.6rem;
  color: #cbd5e1;
  font-size: 0.82rem;
}

.wy-menu-vertical li.current > a,
.wy-menu-vertical li.current > a:hover {
  border-left: 3px solid #60a5fa;
  background: #111827;
  color: #ffffff;
}

.wy-menu-vertical li.toctree-l2.current > a {
  background: #1e293b;
  color: #ffffff;
}

.wy-menu-vertical a:hover {
  background: #273449;
}

.wy-breadcrumbs {
  margin-bottom: 1.25rem;
  color: var(--docs-muted);
  font-size: 0.82rem;
}

.wy-breadcrumbs a {
  color: var(--docs-muted);
}

.wy-breadcrumbs li.breadcrumb-item.active {
  color: #475569;
}

.rst-footer-buttons {
  margin-top: 2rem;
}

/* Accessibility and motion. */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--docs-accent);
  outline-offset: 2px;
}

@media (max-width: 1280px) {
  .wy-docs-grid {
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 32px;
  }
}

@media (max-width: 1100px) {
  .wy-docs-grid {
    display: block;
  }

  .wy-docs-rail {
    display: none;
  }

  .wy-docs-main {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .wy-nav-content {
    padding: 1rem;
  }
}

@media (max-width: 900px) {
  .wy-docs-main .rst-content table.docutils {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .wy-nav-content {
    padding: 0.75rem;
  }

  .wy-docs-main .rst-content h1 {
    font-size: 1.65rem;
  }

  .wy-docs-main .rst-content h2 {
    font-size: 1.3rem;
  }

  .wy-docs-main .rst-content dl.field-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* The theme paints nested current-menu links dark; keep them readable. */
.wy-menu-vertical li.toctree-l1 > a {
  color: #e5e7eb !important;
}

.wy-menu-vertical li.toctree-l2 > a {
  color: #cbd5e1 !important;
}

.wy-menu-vertical li.toctree-l2.current > a {
  background: #1e293b !important;
  color: #ffffff !important;
}

.wy-menu-vertical li.toctree-l1.current > a {
  background: #111827 !important;
  color: #ffffff !important;
}

.wy-menu-vertical {
  scrollbar-width: thin;
}

/* Navigation: default collapsed; the current branch expands on a dark surface. */
.wy-nav-side .wy-menu-vertical a {
  color: #cbd5e1 !important;
}

.wy-nav-side .wy-menu-vertical li.current {
  background: #1f2937 !important;
}

.wy-nav-side .wy-menu-vertical li.current > a {
  background: #111827 !important;
  color: #ffffff !important;
}

.wy-nav-side .wy-menu-vertical li.current li > a {
  color: #cbd5e1 !important;
}

.wy-nav-side .wy-menu-vertical li.current li.current > a {
  background: #1e293b !important;
  color: #ffffff !important;
}

.wy-nav-side .wy-menu-vertical a:hover {
  color: #ffffff !important;
}

.wy-docs-rail-footer {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--docs-border);
}

.wy-docs-rail-footer a {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
  color: var(--docs-muted);
  font-size: 0.82rem;
}

.wy-docs-rail-footer a:hover {
  color: var(--docs-accent-dark);
}


/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  font-family: var(--docs-font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  background: #1e293b;
  color: #ffffff;
}

.theme-toggle svg {
  flex: 0 0 auto;
}

/* Dark theme */
html[data-theme="dark"] {
  --docs-bg: #0b1220;
  --docs-card: #111827;
  --docs-text: #dbe4f0;
  --docs-heading: #f8fafc;
  --docs-muted: #94a3b8;
  --docs-border: #263244;
  --docs-accent: #60a5fa;
  --docs-accent-dark: #93c5fd;
  --docs-accent-soft: #172554;
  color-scheme: dark;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .wy-nav-content-wrap {
  background: var(--docs-bg);
  color: var(--docs-text);
}

html[data-theme="dark"] .wy-docs-main {
  background: var(--docs-card);
  border-color: var(--docs-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .wy-docs-main .rst-content {
  color: var(--docs-text);
}

html[data-theme="dark"] .wy-docs-main .rst-content h1,
html[data-theme="dark"] .wy-docs-main .rst-content h2,
html[data-theme="dark"] .wy-docs-main .rst-content h3,
html[data-theme="dark"] .wy-docs-main .rst-content h4 {
  color: var(--docs-heading);
}

html[data-theme="dark"] .wy-docs-main .rst-content h2 {
  border-bottom-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-main a {
  color: var(--docs-accent);
}

html[data-theme="dark"] .wy-docs-main a:hover {
  color: var(--docs-accent-dark);
}

html[data-theme="dark"] .wy-docs-main .rst-content code,
html[data-theme="dark"] .wy-docs-main .rst-content tt {
  background: #0b1220;
  border-color: var(--docs-border);
  color: #e2e8f0;
}

html[data-theme="dark"] .wy-docs-main .rst-content pre,
html[data-theme="dark"] .wy-docs-main .rst-content .highlight {
  background: #0b1220;
  border-color: var(--docs-border);
  color: #e2e8f0;
}

html[data-theme="dark"] .wy-docs-main .rst-content table.docutils {
  border-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-main .rst-content table.docutils th {
  background: #0f172a;
  color: #e2e8f0;
  border-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-main .rst-content table.docutils td {
  background: var(--docs-card);
  border-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-main .rst-content table.docutils tr:nth-child(even) td {
  background: #0f172a;
}

html[data-theme="dark"] .wy-docs-main .rst-content dl.field-list {
  background: #0f172a;
  border-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-main .rst-content dl.field-list dt {
  color: var(--docs-muted);
}

html[data-theme="dark"] .wy-docs-main .rst-content blockquote {
  border-left-color: #1e40af;
  color: #aebdd0;
}

html[data-theme="dark"] .wy-docs-main .rst-content .admonition {
  background: #0f1b2d;
  border-color: #1e3a5f;
  border-left-color: var(--docs-accent);
}

html[data-theme="dark"] .wy-docs-main .rst-content .admonition-title {
  color: #bfdbfe;
}

html[data-theme="dark"] .wy-docs-main .rst-content hr {
  border-top-color: var(--docs-border);
}

/* Static diagrams are light-background SVG; keep them readable on dark. */
html[data-theme="dark"] .wy-docs-main .rst-content img[src*="_images"] {
  background: #ffffff;
  padding: 0.65rem;
  border-radius: 8px;
}

html[data-theme="dark"] .wy-breadcrumbs,
html[data-theme="dark"] .wy-breadcrumbs a,
html[data-theme="dark"] .wy-breadcrumbs li.breadcrumb-item.active {
  color: var(--docs-muted);
}

html[data-theme="dark"] .wy-docs-rail-inner {
  border-left-color: var(--docs-border);
}

html[data-theme="dark"] .wy-docs-rail-title {
  color: var(--docs-muted);
}

html[data-theme="dark"] .wy-docs-rail-inner a,
html[data-theme="dark"] .wy-docs-rail-footer a {
  color: #aebdd0;
}

html[data-theme="dark"] .wy-docs-rail-inner a:hover,
html[data-theme="dark"] .wy-docs-rail-footer a:hover {
  color: var(--docs-accent-dark);
}

html[data-theme="dark"] .rst-footer-buttons .btn {
  border-color: var(--docs-border);
  background: #0f172a;
  color: #dbe4f0;
}

html[data-theme="dark"] .wy-side-nav-search {
  background: #0b1220;
}

html[data-theme="dark"] .wy-nav-side {
  background: #0f172a;
}

html[data-theme="dark"] .theme-toggle {
  border-color: #334155;
  background: #111827;
  color: #e5e7eb;
}

html[data-theme="dark"] .wy-nav-side .wy-menu-vertical li.toctree-l1 > a {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] .wy-docs-rail {
  background: var(--docs-bg);
}

html[data-theme="dark"] .wy-docs-rail-inner {
  background: var(--docs-bg);
}

/* Selected/hover menu states: never put light text on a light block. */
.wy-nav-side .wy-menu-vertical a:hover,
.wy-nav-side .wy-menu-vertical a:focus,
.wy-nav-side .wy-menu-vertical li.current > a:hover,
.wy-nav-side .wy-menu-vertical li.current li > a:hover,
.wy-nav-side .wy-menu-vertical li.on > a,
.wy-nav-side .wy-menu-vertical li.on > a:hover {
  background: #273449 !important;
  color: #ffffff !important;
}

.wy-nav-side .wy-menu-vertical li.current > a,
.wy-nav-side .wy-menu-vertical li.current li.current > a,
.wy-nav-side .wy-menu-vertical li.current li.on > a {
  background: #111827 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
}
