.lab-page { background: #eaf1f5; }

.lab-header {
  position: relative;
  z-index: 10;
}

.lab-shell {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 900px);
  align-items: start;
  gap: clamp(1.5rem, 4vw, 4rem);
  width: min(1380px, 94vw);
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.lab-guide {
  position: sticky;
  top: 1.5rem;
  padding: 0.5rem 0;
}

.back-link {
  display: inline-flex;
  gap: 0.45rem;
  margin-bottom: 2.75rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover { color: var(--blue); }

.lab-guide h1 {
  margin-bottom: 1rem;
  font-size: clamp(2.3rem, 4vw, 3.8rem);
}

.guide-intro {
  margin: 0 0 2rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.step-nav {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 1.5rem;
  padding-left: 0.65rem;
  border-left: 1px solid var(--line-dark);
}

.step-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.step-nav a:hover { color: var(--navy); background: rgba(255,255,255,.65); }

.step-nav span {
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: var(--teal);
  font-size: 0.72rem;
}

.objectives {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.55);
  font-size: 0.88rem;
}

.objectives summary { cursor: pointer; font-weight: 750; }
.objectives ul { margin-bottom: 0; padding-left: 1.2rem; color: var(--ink-soft); }

.lab-workspace { min-width: 0; }

.lab-section {
  scroll-margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  padding: clamp(1.4rem, 4vw, 2.8rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 10px 32px rgba(16, 42, 67, 0.08);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.section-heading h2 { margin-bottom: 0.3rem; font-size: clamp(1.6rem, 3vw, 2.15rem); }
.section-heading p { margin: 0; color: var(--ink-soft); }

.step-badge {
  flex: 0 0 auto;
  margin-top: 0.2rem;
  padding: 0.32rem 0.55rem;
  border-radius: 6px;
  color: var(--teal);
  background: #e6f5f2;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field { display: grid; gap: 0.45rem; }
.field > span, fieldset legend { font-size: 0.88rem; font-weight: 780; }
.field > small, .toggle-row small { color: var(--ink-soft); font-size: 0.8rem; }

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  color: var(--ink);
  background: #fbfdfe;
}

.field input, .field select { min-height: 46px; padding: 0.65rem 0.75rem; }
.field textarea { min-height: 150px; padding: 0.75rem; resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }

.field-note {
  margin: 0.6rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-height: 46px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7fafc;
  cursor: pointer;
}

.toggle-row input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
  accent-color: var(--teal);
}

.toggle-row span { display: grid; }
.toggle-row strong { font-size: 0.88rem; }

.action-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.button {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 760;
  cursor: pointer;
}

.button.primary { color: #fff; background: var(--navy); }
.button.primary:hover { background: var(--blue); }
.button.secondary { color: var(--navy); border-color: var(--line-dark); background: #fff; }
.button.secondary:hover { border-color: var(--blue); background: #f0f7fa; }

.status-text { color: var(--teal); font-size: 0.85rem; font-weight: 700; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.metric {
  display: grid;
  gap: 0.1rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: #f7fafc;
}

.metric:last-child { border-right: 0; }
.metric span { color: var(--navy); font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric small { color: var(--ink-soft); font-size: 0.75rem; text-transform: uppercase; letter-spacing: .06em; }

.token-window {
  padding: 1.1rem;
  border: 1px dashed var(--line-dark);
  border-radius: 12px;
  background: #fbfdfe;
}

.subheading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.subheading-row h3 { margin: 0; font-size: 1rem; }
.subheading-row span { color: var(--ink-soft); font-size: 0.78rem; }

.token-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.token-chip {
  padding: 0.24rem 0.52rem;
  border: 1px solid #b9d3df;
  border-radius: 5px;
  color: #17485c;
  background: #eaf6fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.order-control { margin: 0 0 1.35rem; padding: 0; border: 0; }
.order-control legend { margin-bottom: 0.55rem; }

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 10px;
}

.segmented-control label { position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span {
  display: grid;
  padding: 0.75rem;
  border-right: 1px solid var(--line-dark);
  background: #fff;
  font-size: 0.88rem;
  font-weight: 750;
}
.segmented-control label:last-child span { border-right: 0; }
.segmented-control small { color: var(--ink-soft); font-size: 0.72rem; font-weight: 500; }
.segmented-control input:checked + span { color: #fff; background: var(--navy); }
.segmented-control input:checked + span small { color: #dcebf3; }
.segmented-control input:focus-visible + span { box-shadow: inset 0 0 0 3px var(--focus); }

.context-field { margin-bottom: 1.5rem; }

.prediction-panel {
  min-height: 280px;
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfc;
}

.bar-chart { display: grid; gap: 0.55rem; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(75px, 120px) minmax(100px, 1fr) 75px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.bar-label { overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 1rem; overflow: hidden; border-radius: 4px; background: #dfebf0; }
.bar-fill { height: 100%; min-width: 2px; border-radius: 4px; background: var(--teal); transition: width .25s ease; }
.bar-value { color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }

.empty-state {
  margin: 3rem auto;
  max-width: 440px;
  color: var(--ink-soft);
  text-align: center;
}

.formula-card {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-left: 4px solid var(--orange);
  border-radius: 4px 10px 10px 4px;
  background: var(--orange-soft);
  color: #633019;
  font-size: 0.9rem;
}

.formula-card code {
  padding: 0.12rem 0.3rem;
  border-radius: 4px;
  background: rgba(255,255,255,.7);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.prompt-card {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.prompt-card summary { padding: 0.9rem 1rem; cursor: pointer; color: var(--navy); font-weight: 760; }
.prompt-card > div { padding: 0 1rem 1rem; color: var(--ink-soft); }
.prompt-card .answer { margin-bottom: 0; padding-top: 0.8rem; border-top: 1px solid var(--line); }

.smoothing-toggle { margin-bottom: 1rem; }
.comparison-callout, .exit-ticket {
  padding: 1.1rem 1.2rem;
  border: 1px solid #b9d9d5;
  border-radius: 10px;
  background: #eff9f7;
}
.comparison-callout p:last-child, .exit-ticket p:last-child { margin-bottom: 0; }
.callout-label { margin: 0 0 0.35rem; color: var(--teal); font-size: 0.74rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }

.generation-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 0.75rem;
}

.generated-output {
  min-height: 110px;
  display: flex;
  align-items: center;
  margin: 1.25rem 0;
  padding: 1.4rem;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.35;
}

.critique-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.critique-grid > div { padding: 0.9rem; border-top: 3px solid var(--orange); background: #f7fafc; }
.critique-grid span { color: var(--navy); font-size: 0.78rem; font-weight: 850; text-transform: uppercase; }
.critique-grid p { margin: 0.35rem 0 0; color: var(--ink-soft); font-size: 0.86rem; }

.evaluation-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}
.evaluation-summary > div { display: grid; gap: .25rem; padding: 1rem; background: #f7fafc; }
.evaluation-summary small { color: var(--ink-soft); }
.evaluation-summary strong { color: var(--navy); font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.info-button { width: 1.25rem; height: 1.25rem; padding: 0; border: 1px solid var(--line-dark); border-radius: 50%; color: var(--ink-soft); background: #fff; font-size: .72rem; cursor: help; }

.table-wrap { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--ink-soft); background: #f7fafc; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
td code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.zero-probability { color: #a83c22; font-weight: 800; }
.exit-ticket { margin-top: 1.5rem; }
.exit-ticket h3 { margin: .35rem 0; font-size: 1.15rem; }

.lab-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem .5rem;
  color: var(--ink-soft);
  font-size: .82rem;
}
.lab-footer > div { display: grid; gap: .4rem; max-width: 650px; }
.lab-footer p { margin: 0; }
.lab-footer .footer-disclaimer { color: var(--ink-soft); }
.lab-footer a { color: var(--blue); font-weight: 700; text-decoration: none; }

@media (max-width: 960px) {
  .lab-shell { grid-template-columns: 1fr; width: min(100% - 2rem, 900px); padding-top: 2rem; }
  .lab-guide { position: static; }
  .lab-guide h1 { max-width: 650px; }
  .step-nav { grid-template-columns: repeat(5, minmax(130px, 1fr)); overflow-x: auto; padding: 0 0 .7rem; border: 0; }
  .step-nav a { min-width: 130px; padding: .6rem; border: 1px solid var(--line); background: rgba(255,255,255,.6); }
  .objectives { max-width: 650px; }
}

@media (max-width: 680px) {
  .lab-shell { width: min(100% - 1rem, 900px); padding-top: 1.25rem; }
  .back-link { margin-bottom: 1.5rem; }
  .lab-section { padding: 1.25rem; border-radius: 12px; }
  .section-heading { gap: .65rem; }
  .step-badge { margin-top: .1rem; }
  .control-grid, .critique-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .segmented-control { grid-template-columns: 1fr; }
  .segmented-control span { border-right: 0; border-bottom: 1px solid var(--line-dark); }
  .segmented-control label:last-child span { border-bottom: 0; }
  .bar-row { grid-template-columns: 70px 1fr 62px; gap: .5rem; }
  .generation-controls { grid-template-columns: 1fr; }
  .generation-controls .button { width: 100%; }
  .evaluation-summary { grid-template-columns: 1fr; }
  .lab-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
