@import url('/materials/notebook-theme.css');

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; line-height: 1.58; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
}
.brand { flex: 0 0 auto; font-weight: 800; }
.main-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.app-layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 64px;
}
.rail {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 12px;
  padding: 16px;
}
.rail-title { margin: 0; font-size: 1.72rem; }
.rail-subtitle { margin: 8px 0 0; color: #71717a !important; font-size: .88rem; }
.tab-list { display: flex; flex-direction: column; gap: 7px; margin-top: 16px; }
.content-stage { min-width: 0; }
.study-grid { display: grid; gap: 16px; }

.study-card,
.activity-card,
.quiz-card {
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 12px;
  background: rgba(24,24,27,.42);
  padding: clamp(17px, 2.4vw, 24px);
}
.study-card h2,
.activity-card h2,
.quiz-card h2 { margin: 4px 0 11px; font-size: clamp(1.42rem, 2vw, 1.82rem); }
.study-card h3,
.activity-card h3,
.quiz-card h3 { margin: 19px 0 8px; font-size: 1rem; }
.study-card p,
.activity-card p,
.quiz-card p { margin: 8px 0; }
.study-card ul,
.activity-card ul,
.quiz-card ul,
.study-card ol,
.activity-card ol { margin: 9px 0 0; padding-left: 1.22rem; }
.study-card li + li,
.activity-card li + li,
.quiz-card li + li { margin-top: 7px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.topic-check {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #71717a;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
}
.topic-check input { accent-color: #e11d48; }

.source-line {
  display: inline-block;
  color: #71717a;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .69rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.note-box,
.warning-box {
  border: 1px solid rgba(225,29,72,.28);
  border-radius: 9px;
  background: rgba(225,29,72,.08);
  color: #f4f4f5;
  margin-top: 15px;
  padding: 13px 14px;
}
.warning-box {
  border-color: rgba(245,165,36,.34);
  background: rgba(245,165,36,.07);
}
.note-box strong,
.warning-box strong { color: #fff; }

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px,1fr));
  gap: 10px;
  overflow-x: auto;
  margin-top: 14px;
  padding-bottom: 4px;
}
.pipeline-step {
  position: relative;
  min-width: 150px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 11px;
  background: rgba(10,10,10,.55);
  padding: 14px;
}
.pipeline-step::after {
  content: '→';
  position: absolute;
  right: -9px;
  top: 50%;
  z-index: 2;
  color: #e11d48;
  font-weight: 900;
  transform: translateY(-50%);
}
.pipeline-step:last-child::after { display: none; }
.pipeline-step span {
  display: block;
  color: #fb7185;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.pipeline-step b { display: block; margin: 7px 0 5px; color: #fff; }
.pipeline-step p { margin: 0; color: #a1a1aa !important; font-size: .8rem; }

.grammar-box,
.code-box {
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: #080808;
  margin-top: 12px;
  padding: 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: #e4e4e7;
  white-space: pre;
}

.compare-grid,
.token-grid,
.node-grid,
.practice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-top: 14px;
}
.compare-card,
.token-card,
.node-card {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(10,10,10,.48);
  padding: 14px;
}
.compare-card b,
.token-card b,
.node-card b { display: block; color: #fff; margin-bottom: 6px; }
.compare-card p,
.token-card p,
.node-card p { margin: 0; font-size: .84rem; color: #a1a1aa !important; }

.lexer-lab {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.lexer-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
}
.lexer-row input { min-width: 0; }
.lab-output {
  min-height: 58px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(10,10,10,.7);
  padding: 12px;
}
.token-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.token-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(225,29,72,.3);
  border-radius: 999px;
  background: rgba(225,29,72,.09);
  padding: 5px 9px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
}
.token-chip small { color: #71717a; }
.error-text { color: #fb7185 !important; }

.tree-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 16px;
}
.tree-panel {
  min-width: 0;
  border-top: 1px solid rgba(255,255,255,.07);
  padding-top: 16px;
}
.tree-panel:first-child {
  border-top: 0;
  padding-top: 0;
}
.tree-panel-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tree-panel-label > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(225,29,72,.42);
  border-radius: 9px;
  background: rgba(225,29,72,.1);
  color: #fff;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .74rem;
  font-weight: 800;
}
.tree-panel-label > div {
  display: grid;
  min-width: 0;
}
.tree-panel-label strong {
  color: #fff;
  font-size: .94rem;
}
.tree-panel-label small {
  color: #71717a;
  font-size: .75rem;
}

.tree-demo {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 16px;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 12px;
  background: rgba(10,10,10,.46);
  padding: 14px;
}
.tree-demo--compact { margin-top: 14px; }
.tree-demo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.tree-demo-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tree-demo-eyebrow {
  color: #71717a;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tree-demo-title {
  color: #fafafa;
  font-size: 1rem;
}
.tree-mode-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}
.tree-mode-button,
.tree-control {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
  background: rgba(24,24,27,.72);
  color: #d4d4d8;
  cursor: pointer;
  font: 700 .72rem/1 'Space Grotesk', system-ui, sans-serif;
  padding: 0 12px;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.tree-mode-button[aria-pressed="true"] {
  border-color: rgba(225,29,72,.52);
  background: rgba(225,29,72,.13);
  color: #fff;
}
.tree-control--primary {
  border-color: rgba(225,29,72,.48);
  background: rgba(225,29,72,.14);
  color: #fff;
}
.tree-control--quiet {
  background: transparent;
  color: #a1a1aa;
}
.tree-mode-button:hover:not(:disabled),
.tree-control:hover:not(:disabled) {
  border-color: rgba(225,29,72,.45);
  color: #fff;
}
.tree-mode-button:focus-visible,
.tree-control:focus-visible {
  outline: 2px solid rgba(225,29,72,.5);
  outline-offset: 2px;
}
.tree-mode-button:disabled,
.tree-control:disabled {
  cursor: not-allowed;
  opacity: .42;
}
.tree-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  min-height: 20px;
  color: #a1a1aa;
  font-size: .7rem;
}
.tree-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tree-legend-swatch {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 3px;
  background: #18181b;
}
.tree-legend-swatch--nonterminal {
  border-color: rgba(161,161,170,.56);
  background: #18181b;
}
.tree-legend-swatch--terminal {
  border-color: rgba(147,197,253,.5);
  background: rgba(147,197,253,.12);
}
.tree-legend-swatch--operator {
  border-color: rgba(225,29,72,.56);
  background: rgba(225,29,72,.15);
}
.tree-legend-swatch--active {
  border-color: rgba(245,165,36,.8);
  background: rgba(245,165,36,.2);
}
.tree-legend-swatch--resolved {
  border-color: rgba(110,231,183,.7);
  background: rgba(110,231,183,.16);
}
.tree-canvas {
  min-width: 0;
  min-height: 430px;
  display: grid;
  place-items: center;
  overflow: auto hidden;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255,255,255,.025), transparent 34%),
    #09090b;
}
.tree-canvas svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
  aspect-ratio: var(--tree-ratio, 720 / 420);
  max-height: 590px;
}
.compiler-tree-edge {
  fill: none;
  stroke: #64748b;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke .2s ease, stroke-width .2s ease, opacity .2s ease;
}
.compiler-tree-edge.is-active {
  stroke: #f5a524;
  stroke-width: 5;
  filter: drop-shadow(0 0 5px rgba(245,165,36,.28));
}
.compiler-tree-edge.is-entering {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: tree-edge-draw .55s cubic-bezier(.2,.7,.2,1) forwards;
}
.compiler-tree-node rect,
.compiler-tree-node circle {
  transition: fill .2s ease, stroke .2s ease, stroke-width .2s ease, filter .2s ease;
}
.compiler-tree-node--nonterminal rect {
  fill: #18181b;
  stroke: #71717a;
}
.compiler-tree-node--terminal rect,
.compiler-tree-node--terminal circle {
  fill: #0f172a;
  stroke: #60a5fa;
}
.compiler-tree-node--operator circle,
.compiler-tree-node--operator rect {
  fill: #2a1119;
  stroke: #e11d48;
}
.compiler-tree-node.is-active rect,
.compiler-tree-node.is-active circle {
  stroke: #f5a524;
  stroke-width: 3.4;
  filter: drop-shadow(0 0 9px rgba(245,165,36,.32));
}
.compiler-tree-node.is-resolved rect,
.compiler-tree-node.is-resolved circle {
  stroke: #6ee7b7;
  stroke-width: 2.8;
  filter: drop-shadow(0 0 8px rgba(110,231,183,.18));
}
.compiler-tree-node.is-entering {
  transform-box: fill-box;
  transform-origin: center;
  animation: tree-node-pop .38s cubic-bezier(.2,.8,.2,1) both;
}
.compiler-tree-node-label {
  fill: #f8fafc;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 800;
  pointer-events: none;
}
.tree-step-text {
  display: grid;
  gap: 3px;
  min-height: 58px;
  border-left: 3px solid rgba(225,29,72,.8);
  padding: 8px 0 8px 12px;
}
.tree-step-text strong {
  color: #fff;
  font-size: .88rem;
}
.tree-step-text span {
  color: #a1a1aa;
  font-size: .82rem;
}
.tree-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.tree-step-count {
  flex: 1 1 80px;
  min-width: 64px;
  color: #71717a;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .72rem;
  text-align: center;
}
@keyframes tree-edge-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes tree-node-pop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.step-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.step-status { color: #a1a1aa; font-size: .78rem; }

.symbol-layout {
  display: grid;
  grid-template-columns: minmax(220px,.8fr) minmax(280px,1.2fr);
  gap: 14px;
  margin-top: 14px;
}
.program-lines,
.symbol-table {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(10,10,10,.5);
  padding: 13px;
}
.program-line {
  padding: 8px 10px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .82rem;
}
.program-line.active {
  background: rgba(225,29,72,.12);
  color: #fff;
}
.symbol-table table {
  width: 100%;
  border-collapse: collapse;
}
.symbol-table th,
.symbol-table td {
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 8px 9px;
  text-align: left;
}
.symbol-table th { color: #fff; }
.symbol-result {
  margin-top: 10px;
  color: #a1a1aa;
  font-size: .82rem;
}

details.answer-card,
details.quiz-item {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(10,10,10,.48);
  margin-top: 12px;
  overflow: hidden;
}
details summary {
  cursor: pointer;
  list-style: none;
  padding: 13px 14px;
  color: #f4f4f5;
  font-weight: 700;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
  content: '+';
  display: inline-block;
  width: 20px;
  color: #e11d48;
}
details[open] summary::before { content: '–'; }
.answer-body {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 12px 14px 14px 34px;
  color: #a1a1aa;
}
.answer-body strong { color: #fff; }

.exercise-prompt {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(10,10,10,.48);
  margin-top: 12px;
  padding: 14px;
}
.exercise-prompt h3 { margin-top: 0; }

.table-scroll { overflow-x: auto; margin-top: 12px; }
.compare-table {
  width: 100%;
  min-width: 650px;
  border-collapse: collapse;
}
.compare-table th,
.compare-table td {
  border: 1px solid rgba(255,255,255,.08);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.compare-table th { background: rgba(225,29,72,.11); color: #fff; }

@media (max-width: 920px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .main-nav { justify-content: flex-start; }
  .app-layout { grid-template-columns: 1fr; }
  .rail { position: relative; top: auto; max-height: none; }
  .pipeline-step::after { display: none; }
  .symbol-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tree-demo-head { flex-direction: column; }
  .tree-mode-switcher { justify-content: flex-start; }
  .tree-controls { align-items: stretch; }
  .tree-control { flex: 1 1 calc(50% - 7px); }
  .tree-step-count { order: -1; flex-basis: 100%; }
  .tree-canvas { min-height: 360px; }
  .tree-canvas svg { min-width: 720px; }
  .compare-grid,
  .token-grid,
  .node-grid,
  .practice-grid { grid-template-columns: 1fr; }
  .lexer-row { grid-template-columns: 1fr; }
  .card-head { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .compiler-tree-edge.is-entering,
  .compiler-tree-node.is-entering {
    animation: none !important;
  }
}
