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

:root {
  --color-bg: #0f1117;
  --color-surface: #1a1d27;
  --color-surface-hover: #242836;
  --color-border: #2e3348;
  --color-text: #e4e6f0;
  --color-text-secondary: #8b8fa3;
  --color-primary: #6c8cff;
  --color-primary-hover: #8aa4ff;
  --color-accent: #7c6cff;
  --color-current: rgba(108, 140, 255, 0.12);
  --sidebar-width: 280px;
  --header-height: 56px;
  --content-max-width: 960px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
  --radius: 6px;
  --transition: 0.2s ease;
}

[data-theme="light"] {
  --color-bg: #f9f9fb;
  --color-surface: #ffffff;
  --color-surface-hover: #f5f5f5;
  --color-border: #e0e0e0;
  --color-text: #494d55;
  --color-text-secondary: #8f949e;
  --color-primary: #40babd;
  --color-primary-hover: #36a0a3;
  --color-accent: #8A40A7;
  --color-current: rgba(64, 186, 189, 0.10);
}

/* Light theme overrides for hardcoded colors */
[data-theme="light"] .sidebar.open {
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .sidebar-backdrop.visible,
[data-theme="light"] .sidebar.open ~ .sidebar-backdrop {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .doc-content pre {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

[data-theme="light"] code {
  background: #eef5f5;
  color: #3a7a7c;
}

[data-theme="light"] .doc-content pre code {
  background: none;
  color: var(--color-text);
}

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

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-primary-hover);
}

code {
  font-family: var(--font-mono);
  background: var(--color-surface-hover);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Custom scrollbar */
.sidebar::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.content::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

.sidebar,
.content {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "header header"
    "sidebar content";
  height: 100vh;
  overflow: hidden;
}

.header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-title a {
  color: var(--color-text);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
}

.hamburger span {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: var(--transition);
}

.content {
  grid-area: content;
  overflow-y: auto;
  padding: 32px 40px;
  max-width: calc(var(--content-max-width) + 80px);
  width: 100%;
  justify-self: center;
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  position: relative;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.theme-toggle-icon {
  font-size: 1rem;
  line-height: 1;
  position: absolute;
  transition: opacity var(--transition), transform var(--transition);
}

.theme-icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0);
}

.theme-icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0);
}

[data-theme="light"] .theme-icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
