/* ==========================================================
   Coin Listing Docs — GitBook-inspired styling.
   Single file. Light/dark via [data-theme] on <html>.
   Shiki produces both themes inline; we just toggle CSS vars.
   ========================================================== */

:root {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Inter", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, "Cascadia Mono", "Roboto Mono", monospace;

  --container: 1400px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-max: 760px;

  /* Light theme (default) */
  --bg: #ffffff;
  --bg-soft: #fafbfc;
  --bg-code: #f9fafb;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-faint: #8b949e;
  --border: #d0d7de;
  --border-soft: #eaeef2;
  --link: #0969da;
  --link-hover: #0550ae;
  --accent: #0969da;
  --shadow-sm: 0 1px 0 rgba(31,35,40,.04);
  --shadow-md: 0 8px 24px rgba(31,35,40,.08);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-code: #222223;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-faint: #6e7681;
  --border: #30363d;
  --border-soft: #21262d;
  --link: #58a6ff;
  --link-hover: #79b8ff;
  --accent: #58a6ff;
  --shadow-sm: 0 1px 0 rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

kbd {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-muted);
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); text-decoration: none; }

.logo-dot {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: linear-gradient(135deg, #5eead4 0%, #0ea5e9 50%, #7c3aed 100%);
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  padding: 6px 10px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  min-width: 180px;
}
.search-trigger:hover { border-color: var(--border); }
.search-trigger kbd { margin-left: auto; }

.icon-btn {
  height: 32px; width: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { background: var(--bg-soft); }
[data-theme="light"] .icon-dark, [data-theme="dark"] .icon-light { display: none; }

.topbar-link {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 4px;
}
.topbar-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: var(--container);
  margin: 0 auto;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 24px 12px 40px 20px;
  border-right: 1px solid var(--border-soft);
}

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar > ul > li { margin-bottom: 4px; }
.sidebar > ul > li.section { margin-top: 6px; margin-bottom: 6px; }
.sidebar .section details { padding: 0; }
.sidebar .section summary {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.sidebar .section summary:hover { background: var(--bg-soft); }
.sidebar .section summary::-webkit-details-marker { display: none; }
.sidebar .section .chevron {
  width: 10px; height: 10px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  margin-right: 2px;
}
.sidebar .section details[open] > summary .chevron {
  transform: rotate(45deg);
}
.sidebar .section ul {
  padding-left: 18px;
  margin-top: 2px;
  border-left: 1px solid var(--border-soft);
  margin-left: 14px;
}

.sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  text-decoration: none;
  line-height: 1.4;
}
.sidebar a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.sidebar a.active {
  color: var(--link);
  background: rgba(9, 105, 218, 0.08);
  font-weight: 600;
}
[data-theme="dark"] .sidebar a.active {
  background: rgba(88, 166, 255, 0.12);
}

/* ---------- Content ---------- */

.content {
  padding: 40px 56px 80px;
  min-width: 0;
}
.content article {
  max-width: var(--content-max);
  margin: 0 auto;
}

.content h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  scroll-margin-top: 80px;
}
.content .lede {
  font-size: 17px;
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.5;
}
.content h2 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  padding-top: 8px;
  scroll-margin-top: 80px;
  border-top: 1px solid var(--border-soft);
}
.content h2:first-of-type { border-top: 0; padding-top: 0; }
.content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  scroll-margin-top: 80px;
}
.content h4 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 8px;
  scroll-margin-top: 80px;
}

.content p, .content ul, .content ol { margin: 12px 0; }
.content ul, .content ol { padding-left: 24px; }
.content li { margin: 4px 0; }

.content blockquote {
  margin: 16px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 0 6px 6px 0;
}
.content blockquote p { margin: 4px 0; }

.content hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 32px 0;
}

/* Header anchor links */
.header-anchor {
  margin-left: 6px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity .15s;
  text-decoration: none;
  font-weight: 400;
}
.content h1:hover .header-anchor,
.content h2:hover .header-anchor,
.content h3:hover .header-anchor,
.content h4:hover .header-anchor { opacity: 1; }

/* Inline code */
.content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}

/* Code blocks: shiki produces <pre class="shiki" style="...">; we wrap in .code-block */
.code-block {
  position: relative;
  margin: 16px 0;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
.code-block pre {
  margin: 0;
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.55;
  font-family: var(--font-mono);
  background: var(--bg-code) !important;
}
.code-block code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
}
[data-theme="light"] .code-block .shiki span { color: var(--shiki-light) !important; }
[data-theme="dark"] .code-block .shiki span { color: var(--shiki-dark) !important; }
[data-theme="dark"] .code-block .shiki { background-color: var(--bg-code) !important; }

.code-block .copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.code-block:hover .copy-btn { opacity: 1; }
.code-block .copy-btn:hover { color: var(--text); }
.code-block .copy-btn.copied { color: #1a7f37; border-color: #1a7f37; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 16px 0; }
.table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.table-wrap th, .table-wrap td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.table-wrap th {
  font-weight: 600;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

/* ---------- Prev / Next ---------- */

.prev-next {
  max-width: var(--content-max);
  margin: 56px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.prev-next a {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s;
}
.prev-next a:hover { border-color: var(--border); text-decoration: none; }
.prev-next a.next { text-align: right; align-items: flex-end; }
.prev-next .lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.prev-next .ttl { font-weight: 600; font-size: 14px; }

/* ---------- TOC right rail ---------- */

.toc {
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 40px 24px 40px 0;
  font-size: 13px;
}
.toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 8px 8px;
}
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin: 0; }
.toc li.lvl-3 { padding-left: 12px; }
.toc a {
  display: block;
  padding: 4px 8px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  text-decoration: none;
  line-height: 1.4;
}
.toc a:hover { color: var(--text); }
.toc a.active {
  color: var(--link);
  border-left-color: var(--accent);
}

/* ---------- Search dialog ---------- */

.search-dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-md);
  max-width: 600px;
  width: 90vw;
  max-height: 70vh;
  margin: 10vh auto 0;
}
.search-dialog::backdrop { background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.search-dialog input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  outline: none;
  color: var(--text);
  font-family: inherit;
}
#search-results {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
#search-results li { margin: 0; padding: 0; }
#search-results li a {
  display: block;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
#search-results li a:hover,
#search-results li a.selected { background: var(--bg-soft); }
#search-results .res-title { font-weight: 600; font-size: 14px; }
#search-results .res-section {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#search-results .res-snippet {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
  font-family: inherit;
}
#search-results .res-snippet mark {
  background: rgba(255, 213, 0, 0.45);
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}
[data-theme="dark"] #search-results .res-snippet mark {
  background: rgba(255, 213, 0, 0.30);
}
#search-results .empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 40px 32px 80px; }
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 280px;
    height: calc(100vh - 56px);
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open::before {
    content: '';
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(0,0,0,0.4);
    z-index: 30;
  }
  .menu-toggle { display: inline-flex; }
  .content { padding: 24px 20px 60px; }
  .content h1 { font-size: 26px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-trigger { min-width: 0; }
  .search-trigger span { display: none; }
  .topbar-link { display: none; }
}
