/* ── Learn page layout ─────────────────────────────────────────────────────── */
.learn-app {
  grid-template-rows: 44px 1fr !important;
}


#learn-layout {
  display: flex;
  overflow: hidden;
  height: 100%;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
#learn-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-xs);
  padding: 0 14px 10px;
}

#toc { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.toc-link {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
  line-height: 1.3;
}

.toc-link:hover { background: var(--border2); color: var(--text); }
.toc-link.active { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }

.toc-num {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--text-xs);
  margin-right: 4px;
}

/* ── Main content ───────────────────────────────────────────────────────────── */
#learn-main {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 80px;
  max-width: 1080px;
}

#learn-intro {
  margin-bottom: 56px;
  max-width: 680px;
}

#learn-intro h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 16px;
}

#learn-intro p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-dim);
}

/* ── Section cards ──────────────────────────────────────────────────────────── */
.learn-section {
  margin-bottom: 72px;
  scroll-margin-top: 24px;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.section-num {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: 0.05em;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.section-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 18px;
}

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--border2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.section-desc {
  max-width: 680px;
  margin-bottom: 24px;
}

.section-desc p {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.section-desc p:last-child { margin-bottom: 0; }

.section-desc code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--border2);
  color: var(--accent-h);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.section-desc strong { color: var(--text); font-weight: 600; }

/* ── Demo pane ──────────────────────────────────────────────────────────────── */
.demo-pane {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.demo-code-wrap {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.demo-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}

.demo-code-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-xs);
  font-family: var(--mono);
}

.demo-reset-btn {
  font-size: 10px;
  padding: 3px 8px;
  color: var(--text-xs);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  transition: color var(--trans), border-color var(--trans);
}

.demo-reset-btn:hover { color: var(--text-dim); border-color: var(--text-dim); }

.demo-textarea {
  flex: 1;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  padding: 14px 16px;
  background: var(--bg);
  color: #a8c4e8;
  border: none;
  resize: none;
  outline: none;
  tab-size: 2;
  min-height: 260px;
  overflow: auto;
}

.demo-textarea::selection { background: rgba(124,58,237,0.3); }

.demo-error {
  display: none;
  background: rgba(239,68,68,0.1);
  border-top: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 6px 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.demo-canvas-wrap {
  display: flex;
  flex-direction: column;
  background: #000;
  position: relative;
}

.demo-canvas-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-xs);
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border2);
  font-family: var(--mono);
  flex-shrink: 0;
}

.demo-canvas {
  flex: 1;
  display: block;
  width: 100%;
  min-height: 280px;
}

.demo-open-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.7);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: color var(--trans), border-color var(--trans);
  font-family: var(--sans);
  font-weight: 600;
}

.demo-open-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* ── Callout box ────────────────────────────────────────────────────────────── */
.callout {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  background: rgba(124,58,237,0.06);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  max-width: 680px;
}

.callout strong { color: var(--text); font-weight: 600; }
.callout code {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(124,58,237,0.12);
  color: var(--accent-h);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Scrollbar for main ─────────────────────────────────────────────────────── */
#learn-main::-webkit-scrollbar { width: 6px; }
#learn-main::-webkit-scrollbar-track { background: transparent; }
#learn-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Light mode overrides for learn page ────────────────────────────────────── */
[data-theme="light"] .demo-textarea { color: #2d4a7a; }
[data-theme="light"] .demo-canvas-wrap { background: #1a1a2e; }
