@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #e94560;
  --accent-soft: #ff6b6b;
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --sidebar-bg: #f0f2f5;
  --sidebar-hover: #e4e7ec;
  --border: #e2e6ed;
  --border-light: #eef0f4;
  --text: #1a1a2e;
  --text-secondary: #5a6177;
  --text-muted: #8b92a8;
  --code-bg: #f4f5f8;
  --code-border: #e2e6ed;
  --link: #4361ee;
  --link-hover: #3a56d4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] {
  --primary: #0f0f1a;
  --primary-light: #1a1a2e;
  --accent: #ff6b6b;
  --bg: #111118;
  --bg-subtle: #191922;
  --sidebar-bg: #16161f;
  --sidebar-hover: #1e1e2a;
  --border: #2a2a3a;
  --border-light: #222233;
  --text: #e4e4ed;
  --text-secondary: #9a9ab5;
  --text-muted: #6b6b85;
  --code-bg: #1a1a28;
  --code-border: #2a2a3a;
  --link: #6b8aff;
  --link-hover: #8aa4ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* ── Theme toggle ── */
.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.2);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ── Header ── */
.site-header {
  background: var(--primary);
  color: white;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.site-header a {
  color: white;
  text-decoration: none;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.site-description {
  display: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.site-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.75;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.site-nav a:hover {
  opacity: 1;
  background: rgba(255,255,255,0.08);
  text-decoration: none;
}

/* ── Layout ── */
.content-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  padding: 36px 0 64px;
  min-height: calc(100vh - 64px - 80px);
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-nav h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 28px 0 6px;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-nav h3:first-child { margin-top: 0; }

.sidebar-nav ul { list-style: none; }

.sidebar-nav li { margin: 1px 0; }

.sidebar-nav a {
  display: block;
  padding: 6px 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 450;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--link);
  background: var(--sidebar-bg);
  border-left-color: var(--link);
}

/* ── Content typography ── */
.content {
  flex: 1;
  min-width: 0;
  max-width: 820px;
}

.content h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
  color: var(--text);
}

.content h2 {
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 48px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
}

.content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
  color: var(--text);
}

.content h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-secondary);
}

.content p {
  margin: 0 0 20px;
  color: var(--text);
}

.content ul, .content ol {
  margin: 0 0 20px;
  padding-left: 24px;
}

.content li {
  margin: 6px 0;
  color: var(--text);
}

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

.content a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}

.content a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Code ── */
.content code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.84em;
  font-family: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
  font-weight: 450;
  color: var(--accent);
}

.content pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 0 0 24px;
  box-shadow: var(--shadow-sm);
}

.content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.84em;
  line-height: 1.65;
  color: var(--text);
  font-weight: 400;
}

/* ── Tables ── */
.content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 24px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.content th {
  background: var(--sidebar-bg);
  font-weight: 600;
  color: var(--text);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.content tr:last-child td { border-bottom: none; }

.content tr:hover td {
  background: var(--bg-subtle);
}

/* ── Blockquotes ── */
.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 14px 20px;
  margin: 0 0 24px;
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.content blockquote p:last-child { margin-bottom: 0; }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border-light);
  padding: 28px 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
}

.site-footer a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .content-wrapper {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 0 48px;
  }

  .sidebar {
    position: static;
    max-height: none;
    padding: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
  }

  .content h1 { font-size: 1.75rem; }
  .content h2 { font-size: 1.35rem; margin-top: 36px; }
}

@media (max-width: 600px) {
  .container { padding: 0 16px; }

  .site-header .container {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .site-nav {
    width: 100%;
    overflow-x: auto;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .site-nav::-webkit-scrollbar { display: none; }

  .site-nav a {
    font-size: 0.8rem;
    padding: 4px 10px;
    white-space: nowrap;
  }

  .content h1 { font-size: 1.5rem; }
  .content pre { padding: 14px 16px; }
}

/* ── Selection ── */
::selection {
  background: rgba(67, 97, 238, 0.15);
  color: var(--text);
}

/* ── Focus styles ── */
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}
