:root {
  --sidebar-width: 280px;
  --header-height: 64px;
  --content-max-width: 1200px;
  --color-bg: #ffffff;
  --color-bg-secondary: #fafafa;
  --color-text: #1a1a1a;
  --color-text-secondary: #666666;
  --color-text-muted: #999999;
  --color-border: #e5e5e5;
  --color-accent: #0066cc;
  --color-accent-hover: #0052a3;
  --color-sidebar-bg: #fafafa;
  --color-sidebar-border: #e5e5e5;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  min-height: 100vh;
}

/* Header */
.header {
  grid-column: 1 / -1;
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.header__logo {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header__logo:hover {
  color: var(--color-accent);
}

.header__search {
  flex: 1;
  max-width: 400px;
  margin: 0 2rem;
}

.header__search .search-container {
  padding: 1rem 0;
}

.header__search input {
  width: 100%;
  padding: 0.625rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--color-bg-secondary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header__search input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
  background: var(--color-bg);
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header__nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

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

/* Sidebar */
.sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  padding: 1.5rem 0;
}

.sidebar__section {
  margin-bottom: 1.5rem;
}

.sidebar__title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 0 1.5rem;
  margin-bottom: 0.5rem;
}

.sidebar__nav {
  list-style: none;
}

.sidebar__nav li {
  margin: 0;
}

.sidebar__nav a {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 2px solid transparent;
  transition: all var(--transition-fast);
}

.sidebar__nav a:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.03);
}

.sidebar__nav a.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: rgba(0, 102, 204, 0.05);
  font-weight: 500;
}

.sidebar__nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar__nav ul a {
  padding-left: 2.25rem;
  font-size: 0.8125rem;
}

.sidebar__mobile-nav {
  display: none;
  padding: 0 1.5rem 1rem;
  border-bottom: 1px solid var(--color-sidebar-border);
  margin-bottom: 1rem;
}

.sidebar__mobile-nav a {
  display: block;
  padding: 0.5rem 0;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

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

/* Main Content */
.main {
  grid-column: 2;
  grid-row: 2;
  padding: 2.5rem 3rem;
  max-width: 1200px;
  width: 100%;
}

/* Typography */
.main h1 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.main h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.main h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.main h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.main p {
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

.main a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Code */
.main code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
}

.main figure.highlight,
.main div.highlight {
  position: relative;
  margin: 1.5rem 0;
}

.main div[class*="language-"].highlighter-rouge {
  position: relative;
  margin: 1.5rem 0;
}

.main pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 2.5rem 1.25rem 1.25rem 1.25rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  position: relative;
}

.main pre code {
  background: none;
  padding: 0;
  display: block;
}

.code-copy-button-container {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 10;
}

.copy-button {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #ccc;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.copy-button svg {
  width: 14px;
  height: 14px;
}

.copy-text {
  font-weight: 500;
}

.copy-button.copy-success {
  background: rgba(46, 204, 113, 0.2);
  border-color: rgba(46, 204, 113, 0.4);
  color: #2ecc71;
}

.copy-button.copy-success:hover {
  background: rgba(46, 204, 113, 0.3);
}

/* Lists */
.main ul, .main ol {
  margin: 1.25rem 0;
  padding-left: 1.5rem;
}

.main li {
  margin-bottom: 0.5rem;
}

/* Tables */
.main table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.main th, .main td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.main th {
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg-secondary);
}

.main tr:hover td {
  background: var(--color-bg-secondary);
}

/* Blockquotes */
.main blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}

/* Footer */
.footer {
  grid-column: 2;
  padding: 2rem 3rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  margin: 4px 0;
  transition: transform var(--transition-normal);
}

/* Responsive */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) auto auto 1fr;
  }

  .header {
    padding: 0 1.5rem;
  }

  .header__search {
    display: none;
  }

  .header__nav {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: 100%;
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 99;
  }

  .sidebar__mobile-nav {
    display: block;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: block;
  }

  .main {
    grid-column: 1;
    padding: 1.5rem;
    max-width: 100%;
  }

  .footer {
    grid-column: 1;
    padding: 1.5rem;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .main {
    padding: 1rem;
  }

  .main h1 {
    font-size: 1.5rem;
  }

  .main h2 {
    font-size: 1.25rem;
  }

  .header {
    padding: 0 1rem;
  }

  .header__nav {
    display: none;
  }

  .header__logo-text {
    font-size: 0.95rem;
  }
}

/* Search Results */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
}

.search-results.active {
  display: block;
}

.search-result {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result:hover, .search-result.active {
  background: var(--color-bg-secondary);
}

.search-result:last-child {
  border-bottom: none;
}

.search-result a {
  color: var(--color-text);
  text-decoration: none;
  display: block;
}

.search-result__title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.search-result__snippet {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.breadcrumbs a {
  color: var(--color-text-secondary);
}

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

.breadcrumbs span {
  color: var(--color-text-muted);
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent);
  color: white;
  padding: 8px 16px;
  z-index: 1000;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* Highlight.js Syntax Highlighting */
.hljs {
  background: transparent !important;
  padding: 0 !important;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in,
.hljs-name,
.hljs-tag {
  color: #ff7b72;
}

.hljs-string,
.hljs-title,
.hljs-section,
.hljs-attribute,
.hljs-literal,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-addition {
  color: #a5d6ff;
}

.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
  color: #8b949e;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag,
.hljs-title,
.hljs-section,
.hljs-type,
.hljs-selector-id {
  font-weight: 500;
}

.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: #79c0ff;
}

.hljs-number,
.hljs-regexp {
  color: #79c0ff;
}

.hljs-variable,
.hljs-template-variable,
.hljs-attr {
  color: #79c0ff;
}

.hljs-function {
  color: #d2a8ff;
}

.hljs-class {
  color: #79c0ff;
}
