:root{
  /* Dark palette provided by user */
  --bg: #131313;      /* page background (updated) */
  --surface: #181818; /* cards, panels (updated to requested card color) */
  --text: #E0E0E0;    /* main text */
  --muted: #B0B0B0;   /* muted text */
  --muted-2: #888888; /* secondary muted / borders */
  --primary: #7aa2ff; /* keep existing primary tint */
  --border: #888888;  /* border color (using muted secondary) */
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --code-bg: #1a1a1a;
  --code-text: #E0E0E0;
}

[data-theme="dark"] {
  /* mirror same dark values when theme attribute is present */
  --bg: #131313;
  --surface: #444444;
  --surface: #181818;
  --text: #E0E0E0;
  --muted: #B0B0B0;
  --muted-2: #888888;
  --primary: #7aa2ff;
  --border: #3a3a3a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --code-bg: #1a1a1a;
  --code-text: #E0E0E0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.topbar__crumb { font-weight: 600; }

.button {
  border: 1px solid var(--border);
  background: var(--primary);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Secondary button variant (dark neutral) */
.btn.secondary,
.button.secondary {
  background: #343434;
  color: var(--text);
  border-color: rgba(255,255,255,0.03);
}

.button--ghost {
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar__title { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 8px; }

.nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
}

.nav__link--active { background: rgba(122, 162, 255, 0.15); font-weight: 600; }

/* Support alternative `.active` class on links */
.nav__link.active { background: rgba(122, 162, 255, 0.15); font-weight: 600; }

.nav__link { transition: background 120ms ease, color 120ms ease; }

/* Hover and focus states for nav links */
.nav__link:hover,
.nav__link:focus-visible {
  background: rgba(122, 162, 255, 0.08);
  outline: none;
}

.nav__link:hover .nav__check,
.nav__link:focus-visible .nav__check {
  opacity: 1;
}

.nav__check {
  font-size: 0.9rem;
  color: #2ecc71;
  opacity: 0;
  transition: opacity 120ms ease;
}

.nav__check.is-done { opacity: 1; }

.content { padding: 22px 28px; }

.article {
  max-width: 900px;
  margin: 0 auto;
}

.article__header { margin-bottom: 16px; }

.article__title { margin: 0 0 10px; }

.article__intro { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.editor-panel textarea {
  width: 100%;
  min-height: 220px;
  font-family: "Consolas", monospace;
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
}

.preview-frame {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.codeblock {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 12px;
  border-radius: 12px;
  overflow-x: auto;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.codeblock code {
  display: block;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* HTML syntax highlighting */
.codeblock .tag { color: #ff7b9c; font-weight: 500; }
.codeblock .attr { color: #a0d995; }
.codeblock .string { color: #d4a574; }

/* CSS syntax highlighting */
.codeblock .selector { color: #7aa2ff; font-weight: 500; }
.codeblock .prop { color: #a0d995; }
.codeblock .value { color: #ffa563; }
.codeblock .keyword { color: #ff7b9c; font-weight: 500; }

.progress-wrap { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.progress-bar { background: var(--primary); height: 100%; width: 0%; }

.muted { color: var(--muted); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .lesson-grid { grid-template-columns: 1fr; }
}
