/* 新书专用。选择器限于 .tb- 与 #threebody-self-explain。 */
.tb-widget,
#threebody-self-explain {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0.75rem 0;
  color: inherit;
  font: inherit;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tb-widget *,
#threebody-self-explain *,
.tb-widget *::before,
#threebody-self-explain *::before,
.tb-widget *::after,
#threebody-self-explain *::after {
  box-sizing: border-box;
}

.tb-widget {
  padding: 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 8px;
}

.tb-panel,
.tb-association,
.tb-se-item {
  min-width: 0;
  max-width: 100%;
  margin: 0 0 0.9rem;
}

.tb-title,
.tb-se-title {
  margin: 0 0 0.35rem;
  font: inherit;
  font-weight: 700;
  line-height: 1.4;
}

.tb-figure-note,
.tb-lead,
.tb-explanation,
.tb-limit,
.tb-association p,
.tb-se-intro,
.tb-se-prompt {
  margin: 0.35rem 0;
  line-height: 1.55;
}

.tb-figure-note,
.tb-limit,
.tb-se-intro {
  font-size: 0.92rem;
}

.tb-controls,
.tb-readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  max-width: 100%;
  min-width: 0;
}

.tb-control,
.tb-readout {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 100%;
}

.tb-label,
.tb-readout-label,
.tb-se-prompt {
  font-weight: 700;
}

.tb-widget button,
.tb-widget select,
.tb-widget input,
#threebody-self-explain textarea {
  font: inherit;
  color: inherit;
  max-width: 100%;
  min-width: 0;
}

.tb-widget button {
  padding: 0.45rem 0.7rem;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.tb-widget select,
.tb-widget input[type="number"],
#threebody-self-explain textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
}

.tb-widget input[type="range"] {
  width: 100%;
  max-width: 100%;
  padding: 0;
}

.tb-widget button:disabled,
.tb-widget select:disabled,
.tb-widget input:disabled {
  opacity: 0.55;
}

.tb-widget button:focus-visible,
.tb-widget select:focus-visible,
.tb-widget input:focus-visible,
#threebody-self-explain textarea:focus-visible,
#threebody-self-explain summary:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.tb-readout-value {
  font-size: 1.05rem;
  line-height: 1.4;
}

.tb-table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0.6rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tb-widget table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.tb-widget caption {
  caption-side: top;
  text-align: left;
  padding: 0 0 0.35rem;
  font-weight: 700;
}

.tb-widget th,
.tb-widget td {
  max-width: 16rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid rgba(0, 0, 0, 0.35);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tb-error,
.tb-se-status {
  margin: 0.45rem 0 0;
  color: #8a1f1f;
  font-weight: 700;
}

#threebody-self-explain textarea {
  display: block;
  min-height: 6.5rem;
  line-height: 1.5;
}

.tb-se-points {
  margin-top: 0.35rem;
}

@media (max-width: 390px) {
  .tb-widget {
    padding: 0.5rem;
  }
  .tb-controls,
  .tb-readouts,
  .tb-control,
  .tb-readout {
    display: flex;
    flex-direction: column;
    flex-basis: 100%;
  }
  .tb-widget th,
  .tb-widget td {
    max-width: 12rem;
  }
}

@media (max-width: 320px) {
  .tb-widget {
    padding: 0.4rem;
  }
  .tb-widget th,
  .tb-widget td {
    padding: 0.2rem 0.3rem;
  }
  #threebody-self-explain textarea {
    min-height: 7rem;
  }
}

/* The model bridge supplies its own complete, live explanation. */
.threebody-page .activity:has(.tb-widget) > .observation,
.threebody-page .activity:has(.tb-widget) > h3,
.threebody-page .activity-guide:empty { display:none; }
