:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6f6f6f;
  --border: #e8e8e6;
  --accent: #f1490c;
  --accent-soft: #fef1ec;
  --surface: #fafaf8;
  --code-bg: #f5f5f3;
  --code-border: #ebebe8;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}

a:hover {
  border-bottom-color: var(--accent);
}

/* ---- Top nav ---- */

.topnav {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--text);
  border-bottom: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  font-size: 13.5px;
  color: var(--text-muted);
  border-bottom: none;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a.active {
  color: var(--text);
}

.nav-skill {
  position: relative;
}

.skill-tip {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  min-width: max-content;
  padding: 8px 12px;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 40;
}

.skill-tip.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.skill-tip__text {
  margin: 0;
  white-space: nowrap;
}

.skill-tip__arrow {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--text);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}

.sidebar-toggle {
  display: none;
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sidebar-toggle:hover {
  color: var(--text);
  background: var(--surface);
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ---- Shell: sidebar + main ---- */

.shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 0;
  flex: 1;
}

/* ---- Left sidebar ----
   Roles:
   - .nav-brand     product label
   - .nav-category  non-clickable group label
   - .nav-item      clickable page
   - .nav-item--series  overview page that owns nested pages
*/

.sidebar {
  position: sticky;
  top: 56px;
  align-self: start;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 32px 16px 48px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.nav-brand {
  margin: 0 12px 28px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-toc {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-category {
  margin: 0 12px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-list--nested {
  margin: 2px 0 10px 12px;
  padding: 2px 0 2px 12px;
  border-left: 1px solid var(--border);
  gap: 1px;
}

.nav-list > .nav-series + .nav-series {
  margin-top: 12px;
}

.nav-item {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  border-bottom: none;
  font-size: 13.5px;
  font-weight: 450;
  line-height: 1.35;
  color: var(--text);
  transition: background 120ms ease, color 120ms ease;
}

a.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  border-bottom-color: transparent;
}

.nav-item--series {
  font-weight: 600;
  color: var(--text);
}

.nav-item--series.is-current-series {
  color: var(--text);
}

.nav-item--nested {
  font-size: 13px;
  font-weight: 450;
  color: var(--text-muted);
  padding-top: 5px;
  padding-bottom: 5px;
}

a.nav-item--nested:hover {
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

.nav-item.is-soon {
  color: var(--text-muted);
  cursor: default;
}

.sidebar-backdrop {
  display: none;
}

/* ---- Main column ---- */

.main {
  min-width: 0;
}

/* ---- Article ---- */

article {
  max-width: 720px;
  margin: 0;
  padding: 48px 40px 64px 48px;
}

/* ---- Article toolbar (breadcrumb + Copy as md) ---- */

.article-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.article-toolbar .breadcrumb {
  margin-bottom: 0;
  min-width: 0;
}

.copy-menu {
  position: relative;
  flex-shrink: 0;
}

.copy-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 6px 8px;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.copy-menu-btn:hover,
.copy-menu.is-open .copy-menu-btn {
  color: var(--text);
  border-color: #d4d4d0;
  background: #fff;
}

.copy-menu-btn__icon {
  display: flex;
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.copy-menu-btn__caret {
  display: flex;
  width: 11px;
  height: 11px;
  color: var(--text-muted);
  transition: transform 120ms ease;
}

.copy-menu.is-open .copy-menu-btn__caret {
  transform: rotate(180deg);
}

.copy-menu-btn__icon svg,
.copy-menu-btn__caret svg {
  width: 100%;
  height: 100%;
}

.copy-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 4px;
  z-index: 40;
}

.copy-menu-item {
  display: block;
  width: 100%;
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.copy-menu-item:hover {
  background: var(--surface);
}

.copy-menu-item.is-success {
  color: #0f766e;
}

.copy-menu-item.is-error {
  color: var(--accent);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.breadcrumb a {
  color: var(--text-muted);
  border-bottom: none;
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb .sep {
  margin: 0 8px;
  opacity: 0.5;
}

article > h1 {
  font-size: 36px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 20px;
}

.meta {
  padding-bottom: 28px;
  margin-bottom: 36px;
  border-bottom: 1px solid var(--border);
}

.meta-date {
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ---- Prose ---- */

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-top: 2.4em;
  margin-bottom: 0.6em;
}

.prose h3 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

.prose p {
  color: var(--text);
}

.prose strong {
  font-weight: 650;
}

.prose em {
  font-style: italic;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.4em;
}

.prose li::marker {
  color: var(--text-muted);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  line-height: 1.55;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13.5px;
  color: var(--text);
}

/* ---- Code block copy button ---- */

.code-block {
  position: relative;
}

.code-block pre {
  margin: 0;
  padding-right: 72px;
}

.copy-code-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  appearance: none;
  border: 1px solid var(--code-border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.copy-code-btn:hover {
  color: var(--text);
  border-color: #d4d4d0;
  background: #fff;
}

.copy-code-btn svg {
  width: 13px;
  height: 13px;
  display: block;
  flex-shrink: 0;
}

.copy-code-btn.is-success {
  color: #0f766e;
  border-color: #99f6e4;
  background: #f0fdfa;
}

.copy-code-btn.is-error {
  color: var(--accent);
  border-color: #fdbaa0;
  background: var(--accent-soft);
}

.spoiler-body .code-block {
  margin-top: 0.8em;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 18px;
  color: var(--text-muted);
}

.prose blockquote p {
  color: inherit;
}

.prose blockquote p + p {
  margin-top: 0.4em;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.4em 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.prose th,
.prose td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.prose th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.prose tbody tr:nth-child(even) {
  background: var(--surface);
}

.prose img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ---- Callout ---- */

.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 14.5px;
}

.callout > strong,
.callout-title {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 4px;
  font-weight: 650;
}

.callout p {
  color: var(--text-muted);
  margin: 0;
}

.callout p strong {
  color: inherit;
  font-size: inherit;
  text-transform: none;
  letter-spacing: normal;
  display: inline;
  margin: 0;
  font-weight: 650;
}

/* ---- Spoiler / details ---- */

details.spoiler {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

details.spoiler summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 550;
  background: var(--surface);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.spoiler summary::-webkit-details-marker {
  display: none;
}

details.spoiler summary::before {
  content: "▸";
  color: var(--accent);
  font-size: 12px;
  transition: transform 120ms ease;
}

details.spoiler[open] summary::before {
  transform: rotate(90deg);
}

details.spoiler .spoiler-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
  color: var(--text-muted);
}

details.spoiler .spoiler-body > * + * {
  margin-top: 0.8em;
}

/* ---- Syntax accents ---- */

.tok-key { color: #c2410c; }
.tok-str { color: #0f766e; }
.tok-num { color: #1d4ed8; }
.tok-cmt { color: #9ca3af; }
.tok-cmd { color: #b45309; }

/* ---- Contents list (intro) ---- */

.toc {
  list-style: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.toc-section {
  padding: 12px 18px 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.toc-section:first-child {
  border-top: none;
}

.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}

.toc-section + .toc-item {
  border-top: none;
}

.toc-item a {
  color: var(--text);
  border-bottom: none;
  font-weight: 550;
}

.toc-item a:hover {
  color: var(--accent);
}

.toc-item .soon {
  color: var(--text-muted);
  font-weight: 450;
}

.toc-item .badge {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.toc-item.nested {
  padding-left: 34px;
}

.toc-item.nested .soon,
.toc-item.nested a {
  font-weight: 450;
  font-size: 14px;
}

/* ---- Article nav ---- */

.article-nav {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-size: 14px;
}

.article-nav a {
  color: var(--text-muted);
  border-bottom: none;
  max-width: 45%;
}

.article-nav a:hover {
  color: var(--accent);
}

.article-nav .label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.article-nav .next {
  text-align: right;
  margin-left: auto;
}

.article-nav .disabled {
  color: var(--text-muted);
  opacity: 0.45;
  pointer-events: none;
  max-width: 45%;
  margin-left: auto;
  text-align: right;
}

.article-nav .disabled .label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

footer {
  width: 100%;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.footer-inner a {
  color: var(--text-muted);
  border-bottom: none;
}

.footer-inner a:hover {
  color: var(--text);
}

@media (max-width: 960px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: auto;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: none;
    border-right: 1px solid var(--border);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.08);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgba(26, 26, 26, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 25;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  article {
    padding: 40px 24px 80px;
  }
}

@media (max-width: 540px) {
  article > h1 {
    font-size: 28px;
  }
}
