/* ═══════════════════════════════════════════════════════════
   YC Brain — Live Server  |  Mintlify-inspired
   English: Noto Serif  |  Chinese: Noto Serif SC
   ═══════════════════════════════════════════════════════════ */

:root {
  --green: #16a34a;
  --green-light: #dcfce7;
  --green-hover: #15803d;
  --bg: #ffffff;
  --sidebar-bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --sidebar-w: 260px;
  --toc-w: 200px;
}

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

body {
  font-family: 'Noto Serif', 'Noto Serif SC', serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar (left) ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.sidebar-logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.02em;
}

.search-box {
  padding: 0 0.75rem 0.75rem;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}

.search-box input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-light);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0.75rem;
  right: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
}

.search-results.hidden { display: none; }

.search-result-item {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--green-light); }

/* Nav items */
.sidebar nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem;
}

.nav-section {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.75rem 0.5rem 0.3rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-section::-webkit-details-marker { display: none; }
.nav-section::before {
  content: '▸';
  font-size: 0.55rem;
  transition: transform 0.15s;
  display: inline-block;
  width: 10px;
}

details[open] > .nav-section::before {
  transform: rotate(90deg);
}

.nav-group {
  margin: 0;
}

.nav-group .nav-sub { padding-left: 1.25rem; font-size: 0.78rem; }

.nav-item {
  display: block;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  color: var(--text);
  border-radius: 4px;
  transition: background 0.1s;
}

.nav-item:hover { background: var(--green-light); text-decoration: none; }
.nav-item.active { color: var(--green); font-weight: 600; background: var(--green-light); }

/* ── Main content ───────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3rem;
  max-width: 780px;
}

.content h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.content h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.8rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 1.4rem;
  margin-bottom: 0.35rem;
}

.content h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 1rem;
}

.content p { margin-bottom: 0.65em; }
.content img { max-width: 100%; height: auto; border-radius: 4px; }
.content ul, .content ol { padding-left: 1.5rem; margin-bottom: 0.65em; }
.content li { margin-bottom: 0.2em; }
.content blockquote {
  border-left: 3px solid var(--green);
  padding: 0.4rem 1rem;
  margin: 0.75rem 0;
  color: var(--muted);
  background: var(--sidebar-bg);
  border-radius: 0 4px 4px 0;
}

/* Tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.content th {
  background: var(--sidebar-bg);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.content td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

/* Code */
.content code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.85em;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* Wikilinks */
.wikilink { color: var(--green); border-bottom: 1px dotted var(--green); }
.wikilink-broken { color: #94a3b8; text-decoration: line-through; }

/* Admonition-style callouts */
.content .admonition {
  border-left: 3px solid var(--green);
  background: var(--green-light);
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
  border-radius: 0 6px 6px 0;
}

/* ── Right TOC ──────────────────────────────────────────── */
.toc-sidebar {
  width: var(--toc-w);
  min-width: var(--toc-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0;
  font-size: 0.78rem;
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.toc-nav ul { list-style: none; padding: 0; }
.toc-nav li { margin-bottom: 0.25rem; }
.toc-nav a {
  color: var(--muted);
  display: block;
  padding: 0.15rem 0;
  font-size: 0.76rem;
}

.toc-nav a:hover { color: var(--text); text-decoration: none; }
.toc-nav li ul { padding-left: 0.75rem; }

/* ── Mobile nav ─────────────────────────────────────────── */
.nav-toggle, .nav-overlay { display: none; }

/* ── Pygments code highlighting overrides ───────────────── */
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #6a9955; font-style: italic } /* Comment */
.highlight .k { color: #569cd6 } /* Keyword */
.highlight .s { color: #ce9178 } /* String */
.highlight .n { color: #d4d4d4 } /* Name */

/* ═══════════════════════════════════════════════════════════
   MOBILE  —  ≤ 900px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .toc-sidebar { display: none; }
  .main { padding: 1.5rem 1.25rem; max-width: 100%; }
}

/* ═══════════════════════════════════════════════════════════
   TABLET / SMALL  —  ≤ 768px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body {
    font-size: 15px;
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    transition: left 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
  }

  body.nav-open .sidebar { left: 0; }
  body.nav-open .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 150;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 300;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }

  .nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
  }

  .main { padding: 3rem 1rem 1.5rem; }

  .content h1 { font-size: 1.1rem; }
  .content h2 { font-size: 0.98rem; }
  .content h3 { font-size: 0.88rem; }

  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══════════════════════════════════════════════════════════
   PHONE  —  ≤ 480px
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .content h1 { font-size: 1.05rem; }
  .content h2 { font-size: 0.93rem; }
  .content h3 { font-size: 0.85rem; }
  .content table { font-size: 0.72rem; }
}
