/* lesson4 纯前端体验区 */
.xlab {
  margin: 1.1em 0 1.4em;
  padding: 14px 16px 16px;
  background: #f3f7f4;
  border: 1px solid var(--line, #c9d9d1);
  border-radius: 16px;
}
.xlab-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 4px;
}
.xlab-body pre {
  margin: 0;
  padding: 10px 12px;
  background: #f3faf7;
  border: 1px solid var(--line, #c9d9d1);
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}
.xlab-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  color: var(--teal-deep, #0b4f49);
}
.xlab-hint {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--muted, #4f635c);
}
.xlab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  width: 100%;
}
.xlab-row input[type="text"],
.xlab-row input:not([type]),
.xlab-row input[data-input],
.xlab-row textarea {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: none;
}
.xlab-row progress {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.xlab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.xlab-card {
  padding: 12px 10px;
  text-align: center;
  background: #fffdf8;
  border: 1px dashed #b9d5ca;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.92rem;
  transition: border-color 0.15s, background 0.15s;
}
.xlab-card:hover {
  border-color: var(--teal, #0f766e);
}
.xlab-card.is-natural {
  background: #eef8f3;
  border-color: #3d8b6e;
}
.xlab-card.is-made {
  background: #fff8eb;
  border-color: #c47b2d;
}
.xlab-card.is-auto {
  background: #e8f1ff;
  border-color: #4a7fd4;
}
.xlab-card.is-ai {
  background: #f3e8ff;
  border-color: #8b5cf6;
}
.xlab-card.is-picked {
  outline: 2px solid var(--teal, #0f766e);
}
.xlab-card.is-wrong {
  border-color: #c45c2d;
  background: #ffeee6;
}
.xlab-card.is-ok {
  border-color: #3d8b6e;
  background: #eef8f3;
}
.xlab button,
.xlab .xlab-btn {
  appearance: none;
  border: 1px solid #9fc2b4;
  background: #fff;
  color: var(--teal-deep, #0b4f49);
  border-radius: 10px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}
.xlab button.primary,
.xlab .xlab-btn.primary {
  background: var(--teal, #0f766e);
  border-color: var(--teal, #0f766e);
  color: #fff;
}
.xlab button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.xlab-status {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--muted, #4f635c);
  min-height: 1.4em;
}
.xlab-status.is-ok {
  color: var(--teal, #0f766e);
}
.xlab-status.is-bad {
  color: #8a5a12;
}
.xlab canvas {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  background: #fff;
  border: 1px solid #9fc2b4;
  border-radius: 12px;
  touch-action: none;
  box-sizing: border-box;
}
.xlab-bins {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.xlab-bin {
  min-height: 64px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed #b9d5ca;
  background: #fff;
}
.xlab-bin h5 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--teal-deep, #0b4f49);
}
.xlab textarea,
.xlab input[type="text"],
.xlab input:not([type]),
.xlab select {
  width: 100%;
  max-width: none;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #9fc2b4;
  font: inherit;
  font-size: 1rem;
  line-height: 1.55;
  box-sizing: border-box;
  background: #fff;
}
.xlab-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  align-items: stretch;
}
.xlab-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--teal-deep, #0b4f49);
}
.xlab-field textarea,
.xlab-field input,
.xlab-field canvas {
  font-weight: 400;
  color: var(--text, #1a2e26);
}
.xlab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.xlab-actions .xlab-fill,
.xlab button.xlab-fill {
  flex: 1 1 100%;
  width: 100%;
  padding: 12px 16px;
  font-weight: 600;
}
.xlab-plot {
  width: 100% !important;
  max-width: none !important;
}
.xlab pre,
.xlab [data-out]:not(canvas):not(div) {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .xlab-pair {
    grid-template-columns: 1fr;
  }
}
.xlab-chat {
  max-width: none;
  width: 100%;
  min-height: 140px;
  max-height: 240px;
  overflow: auto;
  padding: 10px 12px;
  background: #fff;
  border: 1px dashed #b9d5ca;
  border-radius: 12px;
  font-size: 0.9rem;
}
.xlab-chat .bubble {
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eef8f3;
}
.xlab-chat .bubble.me {
  background: #fff8eb;
}
.xlab-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.92rem;
}
.xlab-art {
  width: 100%;
  max-width: none;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid #9fc2b4;
  background: #0b4f49;
}
.xlab-poster {
  max-width: none;
  width: 100%;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eef8f3, #fff8eb);
  border: 1px solid #b9d5ca;
}
.xlab-poster h4 {
  margin: 0 0 8px;
  color: var(--teal-deep, #0b4f49);
  font-family: inherit;
}
.xlab-meter {
  height: 10px;
  border-radius: 999px;
  background: #e7f5ef;
  overflow: hidden;
  width: 100%;
  max-width: none;
}
.xlab-meter > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3d8b6e, #0f766e);
  transition: width 0.25s ease;
}
.xlab pre,
.xlab [data-out] {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid #d5e5dc;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
}
.xlab .ttt-board,
.xlab [data-board] {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 6px;
  margin: 10px 0;
}
.xlab .ttt-board button,
.xlab [data-board] button {
  width: 64px;
  height: 64px;
  font-size: 1.4rem;
  font-weight: 700;
}
.xlab table.attn,
.xlab .xlab-heat {
  border-collapse: collapse;
  font-size: 0.78rem;
}
.xlab table.attn td,
.xlab .xlab-heat td {
  width: 28px;
  height: 28px;
  text-align: center;
  border: 1px solid #ddd;
}
.xlab .idea-note {
  display: inline-block;
  margin: 6px;
  padding: 10px 12px;
  background: #fff3cd;
  border-radius: 8px;
  max-width: 180px;
  vertical-align: top;
}
.xlab-tok {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: none;
}
.xlab-tok-lead {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted, #4f635c);
  line-height: 1.65;
}
.xlab-tok-lead strong {
  color: var(--teal-deep, #0b4f49);
  font-weight: 600;
}
.xlab-tok-source,
.xlab-tok-merge,
.xlab-tok-panel {
  width: 100%;
  background: linear-gradient(180deg, #fffdf8 0%, #f7fbf8 100%);
  border: 1px solid #c9d9d1;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(15, 60, 50, 0.05);
}
.xlab-tok-source-head,
.xlab-tok-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.xlab-tok-label {
  display: block;
  margin: 0 0 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--teal-deep, #0b4f49);
}
.xlab-tok-source-head .xlab-tok-label {
  margin: 0;
}
.xlab-tok-meta,
.xlab-tok-stat {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--muted, #4f635c);
}
.xlab-tok-meta b,
.xlab-tok-stat b {
  color: var(--teal, #0f766e);
  font-variant-numeric: tabular-nums;
}
.xlab-tok .xlab-tok-input,
.xlab textarea.xlab-tok-input {
  display: block;
  width: 100% !important;
  max-width: none !important;
  min-height: 96px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #9fc2b4;
  background: #fff;
  color: var(--ink, #1e2f2a);
  font: inherit;
  line-height: 1.7;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.xlab-tok .xlab-tok-input:focus {
  outline: none;
  border-color: var(--teal, #0f766e);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.xlab-tok .xlab-tok-input-sm {
  min-height: 72px;
}
.xlab-tok-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.xlab-tok-btn {
  appearance: none;
  border: 1px solid #b9d5ca;
  background: #e7f5ef;
  color: var(--teal-deep, #0b4f49);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.xlab-tok-btn:hover {
  background: #d8eee6;
  border-color: #8fbfad;
}
.xlab-tok-btn-primary {
  background: var(--teal, #0f766e);
  border-color: var(--teal, #0f766e);
  color: #e7f5ef;
  font-weight: 600;
}
.xlab-tok-btn-primary:hover {
  background: var(--teal-deep, #0b4f49);
  border-color: var(--teal-deep, #0b4f49);
}
.xlab-tok-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
@media (max-width: 820px) {
  .xlab-tok-compare {
    grid-template-columns: 1fr;
  }
}
.xlab-tok-h {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal-deep, #0b4f49);
}
.xlab-tok-badge {
  flex: 0 0 auto;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: #e7f5ef;
  color: var(--teal, #0f766e);
  border: 1px solid #b9d5ca;
}
.xlab-tok-badge-alt {
  background: #fff4df;
  color: #8a5a12;
  border-color: #e0c08a;
}
.xlab-tok-result {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  min-height: 88px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #d5e5dc;
  background: #fff;
}
.xlab-token {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.25;
  border: 1px solid rgba(15, 60, 50, 0.08);
}
.xlab-tok-msg {
  font-size: 0.88rem;
  color: var(--muted, #4f635c);
}
.xlab-tok-msg.is-bad {
  color: #b45309;
}
.xlab input[type="range"] {
  width: min(280px, 100%);
}
.xlab textarea {
  width: min(100%, 420px);
  min-height: 72px;
  border-radius: 10px;
  border: 1px solid #9fc2b4;
  padding: 8px;
  font: inherit;
}

/* —— 井字棋：标准 3×3 —— */
.xlab-ttt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}
.xlab-ttt-lead {
  margin: 0;
  max-width: 36rem;
  font-size: 0.9rem;
  color: var(--muted, #4f635c);
  line-height: 1.65;
}
.xlab-ttt-lead strong {
  color: var(--teal-deep, #0b4f49);
}
.xlab-ttt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.xlab-ttt-turn {
  min-width: 7em;
  font-weight: 700;
  color: var(--teal-deep, #0b4f49);
}
.xlab-ttt-btn {
  appearance: none;
  border: 1px solid #1f5c4a;
  background: #1f5c4a;
  color: #e7f5ef;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.xlab-ttt-btn:hover {
  background: #0b4f49;
}
.xlab-ttt-board {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  width: min(288px, 100%);
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(160deg, #e7f5ef 0%, #d8eee6 100%);
  border: 1px solid #b9d5ca;
  box-shadow: 0 8px 22px rgba(15, 60, 50, 0.08);
}
.xlab-ttt-cell {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 1px solid #9fc2b4;
  border-radius: 12px;
  background: #fffdf8;
  color: var(--teal-deep, #0b4f49);
  font-family: system-ui,-apple-system,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  font-size: clamp(1.6rem, 8vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.xlab-ttt-cell:hover:not(:disabled) {
  background: #eef8f3;
  border-color: var(--teal, #0f766e);
  transform: translateY(-1px);
}
.xlab-ttt-cell:disabled {
  cursor: default;
}
.xlab-ttt-cell.is-x {
  color: #0f766e;
}
.xlab-ttt-cell.is-o {
  color: #c47b2d;
}
.xlab-ttt-cell.is-win {
  background: #fff4df;
  border-color: #c47b2d;
  box-shadow: inset 0 0 0 2px rgba(196, 123, 45, 0.35);
}

@media (max-width: 1024px), (pointer: coarse) {
  .xlab button,
  .xlab .xlab-btn,
  .xlab-tok-btn,
  .xlab-ttt-btn {
    min-height: 44px;
    padding: 10px 16px;
    touch-action: manipulation;
  }
  .xlab-ttt-cell {
    min-height: 64px;
    touch-action: manipulation;
  }
}
