:root {
  --ink: #1f2937;
  --muted: #5b6472;
  --line: #d7dde8;
  --paper: #ffffff;
  --surface: #f6f8fb;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2563eb;
  --code-bg: #111827;
  --code-fg: #e5e7eb;
  --max: 1280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

.lab-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  min-height: 100vh;
}

.lab-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 20px 18px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
}

.section-nav {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.section-nav a {
  display: block;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.95rem;
}

.section-nav a:hover,
.section-nav a.active {
  color: var(--accent-dark);
  background: #eef7f6;
  border-color: #bddbd7;
  text-decoration: none;
}

.lab-main {
  min-width: 0;
  padding: 22px clamp(16px, 2.6vw, 36px) 48px;
}

.hero,
.panel {
  max-width: var(--max);
  margin: 0 auto 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(31, 41, 55, 0.07);
}

.hero {
  padding: clamp(24px, 3vw, 38px);
}

.panel {
  padding: clamp(20px, 2.6vw, 32px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(2.25rem, 4vw, 3.65rem);
  font-weight: 800;
  line-height: 1.05;
}

.lead {
  max-width: 900px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.16rem;
  line-height: 1.55;
}

.hero-grid,
.level-grid,
.concept-grid,
.two-column {
  display: grid;
  gap: 16px;
}

.hero-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 24px;
}

.hero-grid > div,
.level-card,
.concept-grid article,
.note-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.hero-grid > div {
  padding: 16px;
}

.hero-grid span,
.level-tag {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-grid strong {
  display: block;
  line-height: 1.4;
}

.section-heading {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.55rem, 2.4vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
}

.level-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.level-card,
.concept-grid article {
  padding: 16px;
}

.level-card h3,
.concept-grid h3,
.panel h3 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 800;
}

.level-card p,
.concept-grid p,
.panel p,
.panel li {
  line-height: 1.55;
}

.level-card ul {
  margin-bottom: 0;
}

.level-tag.easy {
  color: #0c4a6e;
}

.level-tag.medium {
  color: #7c2d12;
}

.level-tag.hard {
  color: #7f1d1d;
}

.concept-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.two-column {
  grid-template-columns: minmax(0, 1.05fr) minmax(330px, 0.95fr);
  gap: 20px;
  align-items: start;
}

.table {
  --bs-table-bg: #ffffff;
  margin: 0 0 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table th {
  color: #111827;
  background: #f1f5f9;
}

.table th,
.table td {
  padding: 0.65rem 0.75rem;
  line-height: 1.45;
}

/* Opt-in for tables whose description cells hold very long Java identifiers
   (e.g. enrollStudent(Set<String>)) that would otherwise force the table
   wider than its column in a .two-column layout. Only the description
   columns may break mid-word - the first column keeps class names intact. */
.table.wrap-code td:not(:first-child) code {
  overflow-wrap: anywhere;
}

.figure-svg {
  margin: 0;
  padding: 12px;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.figure-svg svg {
  display: block;
  width: 100%;
  height: auto;
}

.figure-svg figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.steps {
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 8px;
  padding-left: 0;
  list-style: none;
}

.steps li {
  position: relative;
  padding: 10px 13px 10px 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.code-panel,
.output-panel {
  position: relative;
  margin: 0.75rem 0 1rem;
  padding: 16px;
  color: var(--code-fg);
  background: var(--code-bg);
  border: 1px solid #0f172a;
  border-radius: 8px;
  overflow-x: auto;
}

.output-panel {
  background: #0f172a;
}

.code-panel code,
.output-panel code {
  color: inherit;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.93rem;
  line-height: 1.45;
}

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  padding: 4px 8px;
}

.note-box {
  padding: 14px 16px;
  line-height: 1.55;
}

.accordion-list {
  display: grid;
  gap: 8px;
}

.accordion-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.accordion-list summary {
  cursor: pointer;
  padding: 0.95rem 1rem;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.45;
}

.accordion-list summary:hover {
  color: var(--accent-dark);
  background: #f1f8f7;
}

.accordion-list details[open] summary {
  border-bottom: 1px solid var(--line);
  background: #eef7f6;
}

.accordion-list p {
  margin: 0;
  padding: 1rem;
}

.checklist {
  display: grid;
  gap: 10px;
}

.checklist label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.checklist input {
  margin-top: 5px;
}

.xp-links {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.xp-links span {
  padding: 0 12px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.xp-links a {
  display: block;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.xp-links a:hover {
  color: var(--accent-dark);
  background: #eef7f6;
  border-color: #bddbd7;
  text-decoration: none;
}

.xp-links a.current {
  color: var(--accent-dark);
  font-weight: 700;
  background: #eef7f6;
}

.exp-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.exp-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.exp-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.exp-num {
  display: inline-grid;
  place-items: center;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  font-size: 1.05rem;
}

.exp-card.soon .exp-num {
  background: #94a3b8;
}

.exp-head h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.exp-head h3 a {
  color: var(--ink);
}

.exp-head h3 a:hover {
  color: var(--accent-dark);
}

.exp-co {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.exp-card > p {
  margin: 0;
}

.exp-levels {
  margin: 0;
  padding-left: 18px;
}

.exp-levels li {
  font-size: 0.95rem;
}

.exp-open {
  margin-top: auto;
  align-self: flex-start;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

.exp-open:hover {
  color: #ffffff;
  background: var(--accent-dark);
  text-decoration: none;
}

.exp-open.soon {
  color: var(--muted);
  background: #eef2f7;
  border-color: var(--line);
  cursor: default;
}

.exp-open.soon:hover {
  color: var(--muted);
  background: #eef2f7;
}

section {
  scroll-margin-top: 18px;
}

@media (max-width: 1080px) {
  .lab-shell {
    display: block;
  }

  .lab-sidebar {
    position: static;
    display: flex;
    align-items: center;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    flex: 0 0 220px;
    padding: 12px 16px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .section-nav {
    display: flex;
    flex: 1 1 auto;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 12px;
  }

  .section-nav a {
    min-width: max-content;
    padding: 8px 10px;
    font-size: 0.88rem;
  }

  .xp-links {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    padding: 10px 12px;
    border-top: 0;
  }

  .xp-links span {
    display: none;
  }

  .xp-links a {
    min-width: max-content;
  }

  .lab-main {
    padding: 24px 16px 42px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .level-grid,
  .concept-grid,
  .two-column,
  .exp-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2rem;
  }
}

@media (max-width: 620px) {
  .lab-sidebar {
    display: block;
  }

  .brand {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media print {
  .lab-sidebar,
  .copy-code {
    display: none !important;
  }

  .lab-shell {
    display: block;
  }

  .lab-main {
    padding: 0;
  }

  .hero,
  .panel {
    box-shadow: none;
    border: 0;
  }
}
/* Layout tightening pass: keeps long lab pages denser and better aligned. */
.panel > h3 {
  margin-top: 22px;
}

.section-heading + h3,
.two-column h3:first-child {
  margin-top: 0;
}

.two-column > div {
  min-width: 0;
}

.two-column > div > h3:not(:first-child) {
  margin-top: 6px;
}

.panel ul:not(.exp-levels),
.panel ol:not(.steps) {
  margin-top: 0.35rem;
  margin-bottom: 0.85rem;
  padding-left: 1.2rem;
}

.panel p:last-child,
.level-card p:last-child,
.concept-grid article p:last-child,
.note-box p:last-child {
  margin-bottom: 0;
}

.output-panel code {
  white-space: pre-wrap;
}

.output-panel + .output-panel {
  margin-top: -0.4rem;
}

.checklist {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

@media (min-width: 1120px) {
  .accordion-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 1080px) {
  .steps,
  .checklist {
    grid-template-columns: 1fr;
  }
}
