:root {
  /* Light theme */
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --text: #1a1a1a;
  --text-muted: #555;
  --border: #e5e7eb;
  --code-bg: #f3f4f6;
  --primary: #CB3837;          /* npm pink */
  --primary-hover: #a82e2d;
  --accent: #F7DF1E;           /* JS orange */
  --accent-dark: #c5b100;
  --nav-bg: #ffffff;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --text: #e5e5e5;
  --text-muted: #a3a3a3;
  --border: #2a2a2a;
  --code-bg: #1e1e1e;
  --primary: #CB3837;
  --primary-hover: #e04544;
  --accent: #F7DF1E;
  --accent-dark: #F7DF1E;
  --nav-bg: #141414;
  --card-bg: #1a1a1a;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.25s, color 0.25s;
}

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

/* Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
  min-height: 100vh;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  padding: 0 1rem;
}

.logo-placeholder {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  font-size: 14px;
}

.logo-text {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.logo-text span {
  color: var(--primary);
}

/* Search */
.search-box {
  margin: 0 1rem 1.5rem;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-box svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* Navigation */
.nav-section {
  margin-bottom: 1.5rem;
}

.nav-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 1rem;
  margin-bottom: 0.4rem;
}

.nav-links a {
  display: block;
  padding: 0.4rem 1rem;
  color: var(--text);
  font-size: 0.92rem;
  border-radius: 6px;
  margin: 0 0.5rem;
  transition: background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--bg-secondary);
  text-decoration: none;
  color: var(--primary);
}

/* Main content */
.content {
  padding: 2.5rem 0 4rem;
  max-width: 760px;
}

h1 {
  font-size: 2.1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-top: 0.5rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.8rem 0 0.7rem;
}

p {
  margin-bottom: 1.1rem;
  color: var(--text);
}

.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Code */
pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem !important;
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

:not(pre) > code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* Cards / Notes */
.note {
  background: var(--bg-secondary);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
}

.note.warning {
  border-left-color: var(--accent);
}

.note strong {
  color: var(--primary);
}

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

th, td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.9rem;
  text-align: left;
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: transform 0.2s;
}

.theme-toggle:hover {
  transform: scale(1.08);
}

/* Header bar on mobile */
.topbar {
  display: none;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  align-items: center;
  justify-content: space-between;
}

/* Responsive */
@media (max-width: 860px) {
  .container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: 1.5rem;
    width: 280px;
  }
  .sidebar.open {
    display: block;
  }
  .topbar {
    display: flex;
  }
  .content {
    padding: 1.5rem 0 3rem;
  }
}

/* Feature grid on home */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.feature-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--primary);
}

.feature-card p {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text-muted);
}
