.tlab-host {
  container-type: inline-size;
}

.tlab,
.tlab * {
  box-sizing: border-box;
}

.tlab {
  --tlab-blue-950: #082b56;
  --tlab-blue-900: #0b3f78;
  --tlab-blue-800: #125699;
  --tlab-blue-700: #1d6cb4;
  --tlab-blue-300: #91bee3;
  --tlab-blue-150: #d8eafa;
  --tlab-ink: #203348;
  --tlab-muted: #657386;
  --tlab-paper: #fffaf0;
  --tlab-cream: #f5eddd;
  --tlab-line: rgba(11, 63, 120, 0.17);
  position: relative;
  width: 100%;
  min-height: min(760px, 82vh);
  overflow: hidden;
  border: 1px solid rgba(11, 63, 120, 0.2);
  border-radius: 24px;
  color: var(--tlab-ink);
  background:
    radial-gradient(circle at 92% -15%, rgba(71, 145, 199, 0.16), transparent 34%),
    linear-gradient(145deg, #fffdf7 0%, var(--tlab-paper) 64%, #f5ead6 100%);
  box-shadow: 0 24px 70px rgba(16, 42, 75, 0.17);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  isolation: isolate;
}

.tlab::before,
.tlab::after {
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(18, 86, 153, 0.1);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.tlab::before {
  top: 16px;
  right: 34px;
  width: 120px;
  height: 120px;
  box-shadow: inset 0 0 0 14px rgba(18, 86, 153, 0.03), inset 0 0 0 30px rgba(18, 86, 153, 0.025);
}

.tlab::after {
  bottom: -90px;
  left: -50px;
  width: 220px;
  height: 220px;
  box-shadow: inset 0 0 0 24px rgba(18, 86, 153, 0.025), inset 0 0 0 52px rgba(18, 86, 153, 0.02);
}

.tlab button,
.tlab input {
  font: inherit;
}

.tlab button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tlab button:focus-visible,
.tlab input:focus-visible,
.tlab-piece:focus-visible {
  outline: 3px solid #e5a838;
  outline-offset: 3px;
}

.tlab button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.tlab-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 22px 28px 14px;
  color: #fff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(125deg, var(--tlab-blue-950), var(--tlab-blue-800));
}

.tlab-header h2 {
  margin: 0;
  font-family: "STKaiti", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: clamp(1.6rem, 2.6vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.tlab-kicker {
  margin: 0 0 2px;
  color: #b9daf3;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.tlab-header-note {
  max-width: 430px;
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.93rem;
  text-align: right;
}

.tlab-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 18px;
  background: rgba(238, 228, 208, 0.72);
  border-bottom: 1px solid var(--tlab-line);
}

.tlab-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: #56677a;
  background: transparent;
  font-weight: 700;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.tlab-tabs button:hover {
  color: var(--tlab-blue-900);
  background: rgba(255, 255, 255, 0.62);
}

.tlab-tabs button.is-active {
  color: #fff;
  background: var(--tlab-blue-800);
  box-shadow: 0 7px 18px rgba(11, 63, 120, 0.2);
}

.tlab-tabs button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.82rem;
}

.tlab-panel {
  padding: 20px 26px 28px;
}

.tlab-panel[hidden] {
  display: none !important;
}

.tlab-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.tlab-section-heading h3 {
  margin: 1px 0 0;
  color: var(--tlab-blue-950);
  font-size: clamp(1.24rem, 2vw, 1.62rem);
  line-height: 1.3;
}

.tlab-section-heading > p {
  max-width: 510px;
  margin: 0;
  color: var(--tlab-muted);
  font-size: 0.93rem;
  text-align: right;
}

.tlab-step-tag {
  display: inline-block;
  color: var(--tlab-blue-700);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.tlab-observe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tlab-observe-card {
  position: relative;
  min-width: 0;
  padding: 14px 14px 16px;
  overflow: hidden;
  border: 1px solid var(--tlab-line) !important;
  border-radius: 18px;
  color: var(--tlab-ink);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(30, 57, 86, 0.07);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.tlab-observe-card:hover {
  transform: translateY(-2px);
  border-color: rgba(18, 86, 153, 0.45) !important;
  box-shadow: 0 12px 28px rgba(30, 57, 86, 0.12);
}

.tlab-card-badge {
  position: absolute;
  top: 13px;
  left: 13px;
  z-index: 1;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--tlab-blue-800);
  font-size: 0.8rem;
  font-weight: 800;
}

.tlab-observe-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 180px;
  margin: 4px auto 8px;
  border-radius: 13px;
  background: #f7efdf;
}

.tlab-demo-tiles rect,
.tlab-demo-exact rect,
.tlab-demo-overlap polygon {
  fill: #dfeefa;
  stroke: var(--tlab-blue-700);
  stroke-width: 3;
}

.tlab-demo-tiles rect:nth-child(even),
.tlab-demo-exact rect:nth-child(3n),
.tlab-demo-overlap polygon:nth-child(2) {
  fill: #b9d8ef;
}

.tlab-gap-dots circle {
  fill: #e4a33f;
  stroke: #fff6df;
  stroke-width: 3;
}

.tlab-demo-overlap polygon {
  fill-opacity: 0.75;
}

.tlab-demo-overlap polygon:nth-child(2) {
  fill: #6eabd8;
  fill-opacity: 0.72;
}

.tlab-reveal-cue {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 11px;
  color: var(--tlab-blue-800);
  background: var(--tlab-blue-150);
  font-weight: 800;
}

.tlab-answer {
  display: block;
  max-height: 0;
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 230ms ease, opacity 180ms ease, margin 230ms ease;
}

.tlab-answer strong {
  display: block;
  color: var(--tlab-blue-900);
  font-size: 1.05rem;
}

.tlab-answer small {
  display: block;
  color: var(--tlab-muted);
  font-size: 0.87rem;
  line-height: 1.55;
}

.tlab-observe-card.is-revealed .tlab-answer {
  max-height: 120px;
  margin-top: 12px;
  opacity: 1;
}

.tlab-observe-card.is-revealed .tlab-reveal-cue {
  color: #fff;
  background: var(--tlab-blue-800);
}

.tlab-teacher-note,
.tlab-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid rgba(18, 86, 153, 0.15);
  border-radius: 15px;
  background: rgba(220, 235, 247, 0.55);
}

.tlab-teacher-note strong {
  flex: 0 0 auto;
  color: var(--tlab-blue-900);
}

.tlab-teacher-note span {
  color: #50657b;
  font-size: 0.92rem;
}

.tlab-workspace {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 14px;
}

.tlab-palette {
  padding: 14px;
  border: 1px solid var(--tlab-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
}

.tlab-palette h4 {
  margin: 0 0 9px;
  color: var(--tlab-blue-950);
  font-size: 0.98rem;
}

.tlab-palette > p {
  margin: 10px 2px 0;
  color: var(--tlab-muted);
  font-size: 0.78rem;
}

.tlab-shape-button {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 54px !important;
  margin: 7px 0;
  padding: 5px 8px;
  border: 1px solid rgba(18, 86, 153, 0.17) !important;
  border-radius: 12px;
  color: var(--tlab-blue-950);
  background: #fffdf8;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.tlab-shape-button:hover {
  transform: translateX(2px);
  border-color: var(--tlab-blue-300) !important;
  background: #f0f7fc;
}

.tlab-shape-button svg {
  width: 38px;
  height: 38px;
}

.tlab-shape-button polygon {
  fill: #cce3f3;
  stroke: var(--tlab-blue-800);
  stroke-width: 2.4;
}

.tlab-shape-button span {
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.25;
}

.tlab-shape-button b {
  color: var(--tlab-blue-700);
  font-size: 1.2rem;
}

.tlab-board-wrap {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(11, 63, 120, 0.2);
  border-radius: 17px;
  background: #e9ddc8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.tlab-board {
  display: block;
  width: 100%;
  min-height: 330px;
  max-height: 47vh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.tlab-board-paper {
  fill: #fffdf8;
}

.tlab-board-grid {
  opacity: 0.7;
}

.tlab-grid-minor {
  fill: none;
  stroke: rgba(29, 108, 180, 0.08);
  stroke-width: 1;
}

.tlab-grid-major {
  fill: none;
  stroke: rgba(29, 108, 180, 0.13);
  stroke-width: 1.5;
}

.tlab-piece {
  cursor: grab;
  transform-box: fill-box;
  transform-origin: center;
}

.tlab.is-dragging .tlab-piece.is-selected {
  cursor: grabbing;
}

.tlab-piece-shape {
  fill: #b9d9f0;
  fill-opacity: 0.86;
  stroke: var(--tlab-blue-800);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.tlab-piece:nth-child(4n + 2) .tlab-piece-shape {
  fill: #e4eef5;
}

.tlab-piece:nth-child(4n + 3) .tlab-piece-shape {
  fill: #83b8dc;
}

.tlab-piece:nth-child(4n + 4) .tlab-piece-shape {
  fill: #f3e5ca;
}

.tlab-piece-halo {
  fill: none;
  stroke: transparent;
  stroke-width: 12;
  vector-effect: non-scaling-stroke;
}

.tlab-piece-center {
  fill: transparent;
  stroke: transparent;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.tlab-piece.is-selected .tlab-piece-halo {
  stroke: #e6aa3b;
  stroke-dasharray: 5 5;
}

.tlab-piece.is-selected .tlab-piece-center {
  fill: #fff;
  stroke: #d99116;
}

.tlab-empty-hint {
  color: var(--tlab-blue-700);
  pointer-events: none;
}

.tlab-empty-hint circle {
  fill: #edf6fc;
  stroke: #a8cde8;
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.tlab-empty-hint path {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
}

.tlab-empty-hint text {
  fill: #617890;
  font-size: 22px;
  font-weight: 700;
}

.tlab-board-status {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  padding: 8px 14px;
  border-top: 1px solid rgba(11, 63, 120, 0.14);
  color: #52677b;
  background: rgba(255, 253, 248, 0.9);
  font-size: 0.78rem;
}

.tlab-board-status span:first-child {
  color: var(--tlab-blue-800);
  font-weight: 800;
}

.tlab-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--tlab-line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.74);
}

.tlab-tools > button,
.tlab-example-topline button {
  flex: 0 0 auto;
  min-width: 78px;
  padding: 8px 13px;
  border: 1px solid rgba(11, 63, 120, 0.22);
  border-radius: 11px;
  color: var(--tlab-blue-900);
  background: #f4f8fb;
  font-weight: 700;
}

.tlab-tools > button:hover:not(:disabled),
.tlab-example-topline button:hover:not(:disabled) {
  background: var(--tlab-blue-150);
}

.tlab-tools .tlab-danger {
  color: #9b3c34;
  border-color: rgba(155, 60, 52, 0.22);
  background: #fff7f5;
}

.tlab-tools .tlab-reset {
  margin-left: auto;
}

.tlab-rotation {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) 44px;
  align-items: center;
  flex: 1 1 260px;
  gap: 9px;
  min-height: 44px;
  padding: 0 9px;
  color: #52677b;
  font-size: 0.82rem;
  font-weight: 700;
}

.tlab-rotation input {
  width: 100%;
  accent-color: var(--tlab-blue-700);
}

.tlab-rotation output {
  color: var(--tlab-blue-900);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.tlab-example-shell {
  overflow: hidden;
  border: 1px solid rgba(11, 63, 120, 0.2);
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 9px 26px rgba(27, 55, 82, 0.08);
}

.tlab-example-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--tlab-line);
  color: var(--tlab-blue-800);
  background: #f3ead9;
  font-size: 0.86rem;
  font-weight: 800;
}

.tlab-example-stage {
  display: block;
  width: 100%;
  max-height: 43vh;
  min-height: 290px;
  background:
    radial-gradient(circle at center, rgba(217, 236, 249, 0.34), transparent 48%),
    #fffdf8;
}

.tlab-example-grid {
  animation: tlab-reveal 550ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tlab.is-presentation-paused .tlab-example-grid {
  animation-play-state: paused;
}

.tlab-example-grid rect,
.tlab-example-grid polygon {
  fill: #c2deef;
  stroke: var(--tlab-blue-800);
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.tlab-example-grid rect:nth-child(3n),
.tlab-example-grid polygon:nth-child(3n) {
  fill: #e5f0f7;
}

.tlab-example-grid rect:nth-child(4n),
.tlab-example-grid polygon:nth-child(4n) {
  fill: #90beda;
}

.tlab-example-pentagon polygon {
  fill-opacity: 0.78;
}

.tlab-example-pentagon .tlab-gap-mark {
  fill: #e9ad42;
  stroke: #a96b12;
  stroke-width: 2;
}

.tlab-gap-label {
  fill: #9d6411;
  font-size: 20px;
  font-weight: 800;
}

.tlab-example-placeholder circle {
  fill: #edf5fa;
  stroke: #9bc4df;
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.tlab-example-placeholder path {
  fill: none;
  stroke: #5f9ccb;
  stroke-width: 4;
}

.tlab-example-placeholder text {
  fill: #6c7f91;
  font-size: 22px;
  font-weight: 700;
}

.tlab-example-caption {
  min-height: 68px;
  padding: 14px 18px;
  border-top: 1px solid var(--tlab-line);
  color: #526579;
}

.tlab-example-caption strong {
  color: var(--tlab-blue-900);
}

.tlab-example-actions {
  display: flex;
  justify-content: center;
  margin-top: 13px;
}

.tlab-primary {
  min-width: 190px;
  min-height: 50px !important;
  padding: 10px 22px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--tlab-blue-800), var(--tlab-blue-700));
  box-shadow: 0 8px 20px rgba(18, 86, 153, 0.22);
  font-weight: 800;
}

.tlab-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(18, 86, 153, 0.28);
}

/* The surrounding classroom dialog already supplies the title and height boundary. */
.lab-dialog .tlab {
  min-height: 0;
}

.lab-dialog .tlab-header {
  display: none;
}

.lab-dialog .tlab-tabs {
  padding: 6px 14px;
}

.lab-dialog .tlab-tabs button {
  min-height: 46px;
}

.lab-dialog .tlab-panel {
  padding: 12px 20px 16px;
}

.lab-dialog .tlab-section-heading {
  align-items: center;
  margin-bottom: 9px;
}

.lab-dialog .tlab-section-heading h3 {
  font-size: clamp(1.15rem, 1.7vw, 1.45rem);
}

.lab-dialog .tlab-board {
  height: clamp(250px, calc(100vh - 410px), 430px);
  min-height: 0;
  max-height: none;
}

.lab-dialog .tlab-tools {
  margin-top: 8px;
  padding: 7px;
}

.tlab-summary {
  max-width: 920px;
  margin-right: auto;
  margin-left: auto;
}

.tlab-summary-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  background: var(--tlab-blue-800);
  font-size: 1.3rem;
  font-weight: 800;
}

.tlab-summary strong {
  color: var(--tlab-blue-950);
}

.tlab-summary p {
  margin: 2px 0 0;
  color: #52677b;
  font-size: 0.92rem;
}

@keyframes tlab-reveal {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .tlab *,
  .tlab *::before,
  .tlab *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@container (max-width: 850px) {
  .tlab-header {
    align-items: flex-start;
    padding: 18px 20px 13px;
  }

  .tlab-header-note {
    max-width: 310px;
  }

  .tlab-panel {
    padding: 16px 17px 22px;
  }

  .tlab-workspace {
    grid-template-columns: 1fr;
  }

  .tlab-palette {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .tlab-palette h4,
  .tlab-palette > p {
    grid-column: 1 / -1;
  }

  .tlab-shape-button {
    grid-template-columns: 36px minmax(0, 1fr);
    margin: 0;
  }

  .tlab-shape-button b {
    display: none;
  }

  .tlab-board {
    min-height: 300px;
  }

  .tlab-tools {
    flex-wrap: wrap;
  }

  .tlab-rotation {
    order: 5;
    width: 100%;
  }

  .tlab-tools .tlab-reset {
    margin-left: 0;
  }
}

@container (max-width: 650px) {
  .tlab {
    min-height: 640px;
    border-radius: 16px;
  }

  .tlab-header {
    display: block;
  }

  .tlab-header-note {
    margin-top: 5px;
    max-width: none;
    font-size: 0.8rem;
    text-align: left;
  }

  .tlab-tabs {
    gap: 5px;
    padding: 8px;
  }

  .tlab-tabs button {
    gap: 5px;
    min-height: 54px;
    padding: 6px 5px;
    font-size: 0.78rem;
    line-height: 1.2;
  }

  .tlab-tabs button span {
    width: 22px;
    height: 22px;
  }

  .tlab-section-heading {
    display: block;
  }

  .tlab-section-heading > p {
    margin-top: 4px;
    text-align: left;
  }

  .tlab-observe-grid {
    grid-template-columns: 1fr;
  }

  .tlab-observe-svg {
    min-height: 140px;
    max-height: 190px;
  }

  .tlab-teacher-note,
  .tlab-summary {
    align-items: flex-start;
  }

  .tlab-palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tlab-board {
    min-height: 260px;
  }

  .tlab-board-status {
    display: block;
  }

  .tlab-board-status span {
    display: block;
  }

  .tlab-tools > button {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 72px;
  }

  .tlab-example-stage {
    min-height: 230px;
  }
}

@media (max-width: 650px) {
  .tlab-observe-grid {
    grid-template-columns: 1fr;
  }

  .tlab-workspace {
    grid-template-columns: 1fr;
  }

  .lab-dialog .tlab-board {
    height: 340px;
    min-height: 300px;
  }
}

/* v1.2: real polygon construction, classroom controls, touch-friendly palette. */
.tlab .tlab-workspace { grid-template-columns: 190px minmax(0,1fr); align-items:start; }
.tlab .tlab-palette { padding:12px; }
.tlab .tlab-shape-list {display:grid;grid-template-columns:1fr 1fr;gap:6px;}
.tlab .tlab-shape-button {display:flex;flex-direction:column;justify-content:center;gap:2px;min-height:65px;padding:5px 2px;font-size:12px;line-height:1.3;}
.tlab .tlab-shape-button svg {width:40px;height:30px;flex:none;}
.tlab .tlab-shape-button span {white-space:nowrap;}
.tlab .tlab-palette h4 {margin:0 0 8px;}
.tlab .tlab-palette p {font-size:12px;margin:8px 0 0;}
.tlab-draw-tools {display:grid;gap:6px;margin-top:10px;}
.tlab-draw-tools button {min-height:38px;font-size:13px;padding:5px;}
.tlab .tlab-board {background:#fffaf0;touch-action:none;user-select:none;min-height:280px;max-height:none;border-radius:12px;}
.tlab .tlab-piece-shape {fill-opacity:1;stroke:#2d628e;stroke-width:1.5;stroke-linejoin:miter;}
.tlab .tlab-piece.is-selected .tlab-piece-shape {stroke:#093665;stroke-width:2.6;filter:none;}
.tlab .tlab-vertex-dot {fill:#fff;stroke:#0c4a7b;stroke-width:1.2;pointer-events:none;}
.tlab-vertex-label {fill:#103653;font-size:10px;font-weight:700;paint-order:stroke;stroke:#fffaf0;stroke-width:2.5px;stroke-linejoin:round;pointer-events:none;}
.tlab-draft-line {fill:rgba(80,145,185,.13);stroke:#b07d2c;stroke-width:2.5;stroke-dasharray:7 4;}
.tlab-draft-dot {fill:#fff2c7;stroke:#a87324;stroke-width:2;}
.tlab-draft-label {font-size:18px;font-weight:700;fill:#805610;}
.tlab-live-status {margin:0;padding:10px 14px;min-height:48px;color:#315777;background:#edf4f7;font-size:14px;border-top:1px solid #d8e3e8;}
.tlab-auto-tools {display:flex;gap:10px;flex-wrap:wrap;margin:15px 0 10px;}
.tlab-auto-tools button {min-height:44px;padding:8px 16px;}
.tlab-auto-tools [data-action="auto"] {background:#125699;color:white;border-color:#125699;font-weight:700;}
.tlab .tlab-tools {gap:10px;flex-wrap:wrap;padding:12px;}
.tlab .tlab-tools button {padding:8px 12px;min-height:42px;}
.tlab .tlab-tools label {display:flex;align-items:center;gap:5px;font-size:14px;white-space:nowrap;}
.tlab .tlab-tools input[type="checkbox"] {width:18px;height:18px;accent-color:#125699;}
.tlab .tlab-rotation {flex:1 1 255px;}
.tlab .tlab-rotation input {min-width:90px;flex:1;}
.tlab-color input {width:40px;height:33px;padding:2px;border:1px solid #91aac0;background:white;border-radius:6px;}
.tlab-build-note {font-size:13px;color:#637184;margin:10px 2px 0;}
.tlab .tlab-example-actions {display:flex;gap:10px;flex-wrap:wrap;}
.tlab .tlab-example-actions button {min-height:44px;padding:8px 16px;}
.tlab-new-piece {animation:tlab-piece-arrive .22s ease-out both;}
@keyframes tlab-piece-arrive {from {opacity:0;} to {opacity:1;}}
@media (prefers-reduced-motion:reduce) {.tlab-new-piece {animation:none;}}
@media (max-width:750px) {
 .tlab .tlab-workspace {grid-template-columns:1fr;}
 .tlab .tlab-shape-list {grid-template-columns:repeat(6,minmax(0,1fr));}
 .tlab .tlab-shape-button {font-size:10px;min-height:57px;}
 .tlab .tlab-draw-tools {display:flex;}
 .tlab .tlab-draw-tools button {flex:1;}
 .tlab .tlab-palette p {display:none;}
 .tlab .tlab-board {min-height:220px;}
 .tlab .tlab-board-status {font-size:11px;gap:5px;flex-wrap:wrap;}
 .tlab .tlab-live-status {font-size:12px;}
 .tlab .tlab-tools {gap:8px;}
}
/* Keep legacy compact-dialog rules from changing geometric transforms or palette layout. */
.tlab .tlab-piece {transform-box:view-box;transform-origin:0 0;}
.tlab .tlab-palette {display:block;}
.tlab .tlab-workspace {grid-template-columns:238px minmax(0,1fr);}
.tlab .tlab-shape-list {grid-template-columns:repeat(3,minmax(0,1fr));}
.tlab .tlab-shape-button {margin:0;min-height:58px !important;}
.tlab .tlab-shape-button span {font-size:12px;}
@container (max-width:850px) {
 .tlab .tlab-workspace {grid-template-columns:1fr;}
 .tlab .tlab-shape-list {grid-template-columns:repeat(6,minmax(0,1fr));}
 .tlab .tlab-draw-tools {display:flex;}
 .tlab .tlab-draw-tools button {flex:1;}
 .tlab .tlab-palette p {display:none;}
}
@media (max-width:750px) {
 .tlab .tlab-workspace {grid-template-columns:1fr;}
 .tlab .tlab-shape-list {grid-template-columns:repeat(4,minmax(0,1fr));}
 .tlab .tlab-shape-button span {font-size:11px;}
}

/* Short classroom screens: keep the construction canvas and controls together.
   SVG keeps its 900:500 coordinate system with preserveAspectRatio="meet". */
@media (min-width: 751px) and (max-height: 900px) {
  .lab-dialog .dialog-content.tlab-host { overflow:hidden; }
  .lab-dialog .tlab { height:100%; min-height:0; display:flex; flex-direction:column; border-radius:12px; }
  .lab-dialog .tlab-tabs { flex:0 0 auto; padding:4px 12px; gap:6px; }
  .lab-dialog .tlab-tabs button { min-height:36px; padding:4px 10px; font-size:14px; }
  .lab-dialog .tlab-tabs button span { width:23px; height:23px; }
  .lab-dialog .tlab-panel { flex:1 1 auto; min-height:0; overflow:auto; padding:8px 14px; }
  .lab-dialog .tlab-build { display:grid; grid-template-rows:auto minmax(0,1fr) auto auto auto; gap:6px; overflow:hidden; }
  .lab-dialog .tlab-build .tlab-section-heading { margin:0; min-height:24px; gap:12px; }
  .lab-dialog .tlab-build .tlab-section-heading > div { display:flex; align-items:center; gap:10px; }
  .lab-dialog .tlab-build .tlab-section-heading h3 { margin:0; font-size:17px; white-space:nowrap; }
  .lab-dialog .tlab-build .tlab-section-heading > p { font-size:12px; line-height:1.3; }
  .lab-dialog .tlab-build .tlab-step-tag { font-size:10px; white-space:nowrap; }
  .lab-dialog .tlab-workspace { min-height:0; grid-template-columns:220px minmax(0,1fr); gap:10px; align-items:stretch; }
  .lab-dialog .tlab-palette { min-height:0; padding:8px; overflow:auto; overscroll-behavior:contain; }
  .lab-dialog .tlab-palette h4 { font-size:13px; margin:0 0 5px; line-height:1.2; }
  .lab-dialog .tlab-shape-list { grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
  .lab-dialog .tlab-shape-button { min-height:45px !important; padding:3px 1px; gap:0; border-radius:8px; }
  .lab-dialog .tlab-shape-button svg { width:31px; height:23px; }
  .lab-dialog .tlab-shape-button span { font-size:11px; line-height:1.2; }
  .lab-dialog .tlab-draw-tools { display:flex; gap:5px; margin-top:6px; }
  .lab-dialog .tlab-draw-tools button { flex:1; min-height:36px; padding:4px 2px; font-size:11px; }
  .lab-dialog .tlab-palette p { display:none; }
  .lab-dialog .tlab-board-wrap { min-height:0; display:grid; grid-template-rows:minmax(0,1fr) auto auto; }
  .lab-dialog .tlab-board { width:100%; height:100%; min-height:0; max-height:none; border-radius:0; }
  .lab-dialog .tlab-board-status { display:flex; padding:5px 10px; font-size:11px; line-height:1.3; gap:8px; }
  .lab-dialog .tlab-live-status { margin:0; min-height:27px; padding:5px 10px; font-size:11px; line-height:1.4; }
  .lab-dialog .tlab-auto-tools { margin:0; gap:8px; }
  .lab-dialog .tlab-auto-tools button { min-height:36px; padding:5px 12px; font-size:13px; }
  .lab-dialog .tlab-tools { margin:0; padding:5px 8px; gap:7px; }
  .lab-dialog .tlab-tools button { min-height:36px; padding:4px 10px; font-size:12px; }
  .lab-dialog .tlab-tools label { font-size:12px; }
  .lab-dialog .tlab-rotation { order:0; flex:1 1 200px; width:auto; }
  .lab-dialog .tlab-rotation input { min-width:80px; }
  .lab-dialog .tlab-color input { height:30px; width:34px; }
  .lab-dialog .tlab-build-note { margin:0; font-size:10px; line-height:1.3; }
}
