.toolkit-hero {
  min-height: auto;
  padding: 42px 0 24px;
}

.toolkit-hero h1 {
  max-width: 100%;
  overflow-wrap: break-word;
}

.toolkit-hero .button {
  width: fit-content;
}

.toolkit-actions,
.filter-grid,
.tool-grid,
.tool-controls,
.bit-grid,
.value-grid,
.activity-actions,
.resource-meta,
.feedback-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-panel,
.resource-card,
.tool-surface,
.activity-section,
.feedback-panel,
.print-panel,
.privacy-note,
.challenge-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 28, 51, 0.94), rgba(14, 20, 36, 0.96));
}

.filter-panel,
.tool-surface,
.activity-section,
.feedback-panel,
.print-panel,
.privacy-note {
  padding: 16px;
}

.tool-surface {
  overflow: hidden;
}

.tool-surface h2 {
  margin-bottom: 14px;
  font-size: clamp(1.45rem, 2.1vw, 2rem);
  line-height: 1.08;
}

.filter-grid {
  align-items: end;
}

.filter-grid label,
.tool-field {
  display: grid;
  gap: 6px;
  min-width: 160px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.filter-grid input,
.filter-grid select,
.tool-field input,
.tool-field select,
.tool-field textarea,
.custom-data {
  min-height: 42px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(234, 240, 255, 0.055);
  color: var(--ink);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.resource-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  min-height: 260px;
}

.resource-card h3 {
  margin-bottom: 0;
}

.resource-meta span,
.label-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(234, 240, 255, 0.045);
  font-size: 0.78rem;
  font-weight: 800;
}

.native-label {
  color: var(--lime);
  border-color: rgba(124, 255, 107, 0.35);
}

.external-label {
  color: var(--gold);
  border-color: rgba(246, 201, 69, 0.35);
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.tool-controls button,
.bit-button,
.copy-button,
.small-button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(234, 240, 255, 0.055);
  color: var(--ink);
  font-weight: 850;
  cursor: pointer;
}

.logic-builder {
  display: grid;
  gap: 8px;
}

.gate-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.45fr) repeat(3, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.logic-output {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.logic-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.logic-card {
  min-height: 74px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(234, 240, 255, 0.045);
}

.logic-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.logic-card strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
}

.logic-card.is-on {
  border-color: rgba(124, 255, 107, 0.45);
  background: rgba(124, 255, 107, 0.1);
}

.logic-card.is-off {
  border-color: rgba(246, 201, 69, 0.25);
}

.logic-expression {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--cyan);
  color: var(--muted);
  background: rgba(34, 211, 238, 0.055);
}

.logic-expression strong {
  color: var(--ink);
}

.logic-svg {
  display: block;
  width: 100%;
  max-width: 460px;
  height: auto;
  margin: 0 auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(11, 15, 26, 0.36);
}

.logic-svg text {
  font-size: 13px;
  font-weight: 800;
}

.bit-grid {
  display: grid;
  grid-template-columns: repeat(var(--bits, 8), minmax(42px, 1fr));
}

.bit-cell {
  display: grid;
  gap: 5px;
  text-align: center;
}

.bit-button {
  min-height: 54px;
  font-size: 1.2rem;
}

.bit-button[aria-pressed="true"] {
  color: #07120a;
  border-color: rgba(124, 255, 107, 0.6);
  background: var(--lime);
}

.bit-label {
  color: var(--soft);
  font-size: 0.72rem;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.value-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(234, 240, 255, 0.045);
}

.value-card strong {
  display: block;
  font-size: 1.2rem;
  overflow-wrap: anywhere;
}

.mono,
.trace-table,
.pseudo-code {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.trace-table,
.truth-table,
.activity-table {
  width: 100%;
  border-collapse: collapse;
}

.trace-table th,
.trace-table td,
.truth-table th,
.truth-table td,
.activity-table th,
.activity-table td {
  padding: 8px;
  border: 1px solid var(--line);
  text-align: left;
}

.bar-row {
  display: flex;
  align-items: end;
  gap: 5px;
  min-height: 180px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.bar {
  flex: 1;
  min-width: 22px;
  display: grid;
  place-items: end center;
  padding-bottom: 5px;
  border-radius: 5px 5px 0 0;
  background: rgba(34, 211, 238, 0.25);
  color: var(--ink);
}

.bar-h-2 { height: 20px; }
.bar-h-3 { height: 30px; }
.bar-h-4 { height: 40px; }
.bar-h-5 { height: 50px; }
.bar-h-6 { height: 60px; }
.bar-h-7 { height: 70px; }
.bar-h-8 { height: 80px; }
.bar-h-9 { height: 90px; }
.bar-h-10 { height: 100px; }
.bar-h-11 { height: 110px; }
.bar-h-12 { height: 120px; }
.bar-h-13 { height: 130px; }
.bar-h-14 { height: 140px; }
.bar-h-15 { height: 150px; }
.bar-h-16 { height: 160px; }
.bar-h-17 { height: 170px; }
.bar-h-18 { height: 180px; }
.bar-h-19 { height: 190px; }
.bar-h-20 { height: 200px; }

.bar.active {
  background: var(--gold);
  color: #160f02;
}

.bar.done {
  background: var(--lime);
  color: #07120a;
}

.pseudo-code {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  color: var(--muted);
}

.pseudo-code mark {
  display: block;
  color: #160f02;
  background: var(--gold);
}

.activity-page .activity-section {
  margin-bottom: 14px;
}

.activity-list li {
  margin-bottom: 8px;
}

.answer-block {
  border-left: 3px solid var(--gold);
}

.feedback-panel {
  margin-top: 22px;
}

.feedback-links a {
  color: var(--cyan);
  font-weight: 850;
}

.print-only {
  display: none;
}

.board-display {
  min-height: 420px;
}

.board-display.classroom-mode {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  padding: 32px;
  background: var(--stage-0);
}

.group-output.classroom-mode {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  padding: 32px;
  background: var(--stage-0);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.timer-display {
  font-size: clamp(3rem, 12vw, 8rem);
  color: var(--gold);
  line-height: 1;
}

.group-output {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.group-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(234, 240, 255, 0.045);
}

@media (max-width: 900px) {
  .tool-grid,
  .tool-layout,
  .value-grid {
    grid-template-columns: 1fr;
  }

  .gate-row {
    grid-template-columns: 1fr;
  }

  .logic-summary {
    grid-template-columns: 1fr;
  }

  .bit-grid {
    grid-template-columns: repeat(4, minmax(42px, 1fr));
  }
}

@media (max-width: 520px) {
  .toolkit-hero h1 {
    font-size: 2rem;
    line-height: 1.05;
  }
}

@media print {
  body {
    color: #111;
    background: #fff;
  }

  .site-header,
  .site-footer,
  .feedback-panel,
  .no-print,
  .button {
    display: none !important;
  }

  main,
  .site-footer {
    width: 100%;
  }

  .activity-section,
  .print-panel {
    border: 1px solid #bbb;
    background: #fff;
    color: #111;
    box-shadow: none;
  }

  p,
  li,
  .eyebrow {
    color: #222;
  }

  .teacher-only {
    display: none;
  }

  body.teacher-print .teacher-only {
    display: block;
  }
}
