:root {
  --bg: #ffffff;
  --surface: #f5f5f4;
  --fg: #1c1917;
  --text: #292524;
  --muted: #57534e;
  --line: #d6d3d1;
  --line-soft: #e7e5e4;
  --accent: #0e7490;
  --accent-hover: #155e75;
  --tok-kw: #7e22ce;
  --tok-tt: #0e7490;
  --tok-bi: #1d4ed8;
  --tok-str: #166534;
  --tok-num: #9a3412;
  --tok-cmt: #78716c;
  --tok-dec: #9a3412;
  --tok-prompt: #78716c;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #141413;
  --surface: #1c1b1a;
  --fg: #f5f5f4;
  --text: #d6d3d1;
  --muted: #a8a29e;
  --line: #2e2c2a;
  --line-soft: #242321;
  --accent: #38b2c4;
  --accent-hover: #67d3e3;
  --tok-kw: #c084fc;
  --tok-tt: #38b2c4;
  --tok-bi: #60a5fa;
  --tok-str: #4ade80;
  --tok-num: #fbbf24;
  --tok-cmt: #78716c;
  --tok-dec: #fb923c;
  --tok-prompt: #78716c;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 68px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 22px; min-width: 0; }
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--fg);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand > span { overflow: hidden; text-overflow: ellipsis; }
.brand-mark { flex-shrink: 0; }
.brand:hover { color: var(--fg); text-decoration: none; }
.version-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.top-nav { display: flex; align-items: center; gap: 16px; }
.top-nav a { font-size: 14px; color: var(--muted); white-space: nowrap; }
.top-nav a:hover { color: var(--fg); text-decoration: none; }
.top-nav a.active { color: var(--fg); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
}
.search-trigger:hover { border-color: var(--muted); color: var(--fg); }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 3px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--fg); border-color: var(--line); text-decoration: none; }

/* 3-Column Manual Layout */
.layout {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 210px;
  min-height: calc(100vh - 52px);
}

/* Left Sidebar */
.sidebar {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 20px 14px 40px 20px;
  border-right: 1px solid var(--line-soft);
}
.nav-group { margin-bottom: 18px; }
.nav-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  margin: 0 0 6px;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: block;
  padding: 3px 0 3px 10px;
  font-size: 13.5px;
  color: var(--muted);
  border-left: 2px solid transparent;
}
.nav-list a:hover { color: var(--fg); text-decoration: none; }
.nav-list a.active { color: var(--fg); border-left-color: var(--accent); font-weight: 600; }

/* Main Content */
.content-col { min-width: 0; padding: 28px 40px 64px; }
.content-inner { max-width: 760px; margin: 0 auto; }
.breadcrumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.content-inner h1 {
  margin: 0 0 16px;
  font-size: 28px;
  line-height: 1.22;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.content-inner h2 {
  margin: 34px 0 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 20px;
  line-height: 1.3;
  color: var(--fg);
}
.content-inner h3 { margin: 22px 0 8px; font-size: 16px; color: var(--fg); }
.anchor {
  margin-left: 6px;
  color: var(--muted);
  opacity: 0;
  font-weight: 400;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; color: var(--accent); }
.content-inner p { margin: 0 0 14px; }
.content-inner p.lead { font-size: 16px; color: var(--fg); }
.content-inner p.quick-links { font-size: 14.5px; margin: 16px 0 24px; }
.content-inner ul, .content-inner ol { margin: 0 0 14px; padding-left: 22px; }
.content-inner li { margin-bottom: 5px; }
.content-inner code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: var(--surface);
  color: var(--fg);
  padding: 1px 4px;
  border-radius: 3px;
}
.content-inner table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 18px;
  font-size: 13.8px;
}
.content-inner th, .content-inner td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
.content-inner th {
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.formula-box {
  padding: 10px 14px;
  margin: 14px 0;
  background: var(--surface);
  border-left: 2px solid var(--line);
}
.formula-box code { background: transparent; font-size: 14.5px; }

/* Code Blocks */
.code-wrap {
  margin: 12px 0 16px;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  background: var(--surface);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.code-actions { display: flex; align-items: center; gap: 10px; }
.code-copy, .code-tour-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.code-copy:hover, .code-tour-btn:hover { color: var(--accent); text-decoration: underline; }
.code-pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.52;
}
.code-pre code { background: transparent; padding: 0; font-size: inherit; color: var(--fg); }
.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-tt { color: var(--tok-tt); font-weight: 600; }
.tok-bi { color: var(--tok-bi); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-cmt { color: var(--tok-cmt); font-style: italic; }
.tok-dec { color: var(--tok-dec); }
.tok-prompt { color: var(--tok-prompt); user-select: none; }

/* Notes / Warnings */
.admonition {
  margin: 16px 0;
  padding: 10px 14px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  font-size: 14px;
}
.admonition.warning { border-left-color: #b45309; }
.admonition.important { border-left-color: var(--fg); }
.admonition-title { font-weight: 600; color: var(--fg); margin-bottom: 4px; }
.admonition-body p:last-child { margin-bottom: 0; }

/* API Reference Entries (pkg.go.dev style) */
.api-card {
  margin: 24px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.api-card > h3 {
  margin: 0 0 6px !important;
  font-size: 14px !important;
  line-height: 1.5;
  overflow-x: auto;
}
.api-card > h3 code {
  background: var(--surface);
  padding: 3px 7px;
  font-size: 13.5px;
  color: var(--fg);
}
.api-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.api-badge { font-family: var(--font-mono); color: var(--muted); }
.api-tla { color: var(--muted); }
.api-body p:last-child { margin-bottom: 0; }
.example-meta { font-size: 13.5px; color: var(--muted); margin-top: -6px !important; }

/* Prev / Next */
.page-pager {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
}
.pager-link { display: inline-flex; align-items: baseline; gap: 6px; }

/* Right TOC */
.toc-col {
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 24px 16px 40px 10px;
}
.toc-title { font-size: 12px; font-weight: 700; color: var(--fg); margin: 0 0 8px; }
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line-soft);
}
.toc-list a {
  display: block;
  padding: 3px 0 3px 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc-list a:hover { color: var(--fg); text-decoration: none; }
.toc-list a.active { color: var(--fg); border-left-color: var(--accent); font-weight: 600; }
.toc-list li.toc-h3 a { padding-left: 18px; font-size: 12px; }

/* Search Modal */
.search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 19, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 100;
}
.search-backdrop.open { display: flex; }
.search-modal {
  width: 540px;
  max-width: 92vw;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.search-input-wrap { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.search-input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--fg);
  font-size: 14.5px;
  font-family: var(--font-sans);
}
.search-results { max-height: 55vh; overflow-y: auto; padding: 6px; }
.search-item { display: block; padding: 7px 10px; border-radius: 3px; color: var(--text); }
.search-item:hover, .search-item.selected { background: var(--surface); text-decoration: none; }
.search-item-title { font-size: 13.8px; font-weight: 600; color: var(--fg); }
.search-item-meta { font-size: 12px; color: var(--muted); }
.search-empty { padding: 18px; text-align: center; font-size: 13.5px; color: var(--muted); }

.sidebar-backdrop { display: none; }

@media (max-width: 1120px) {
  .layout { grid-template-columns: 224px minmax(0, 1fr); }
  .toc-col { display: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .header-inner { padding: 0 12px; gap: 8px; }
  .header-left { gap: 10px; }
  .header-right { gap: 2px; }
  .menu-toggle { display: inline-flex; }
  .top-nav, .version-tag, .search-trigger kbd { display: none; }
  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 60;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.14s ease-out;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 52px 0 0 0;
    background: rgba(20, 20, 19, 0.35);
    z-index: 50;
  }
  .content-col { padding: 20px 16px 48px; }
  .content-inner table { display: block; overflow-x: auto; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
