.bw-lab {
  padding: 0.85rem;
}

.bw-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.ll-viewport .bw-grid {
  grid-template-columns: minmax(0, 1fr);
}

.bw-panel {
  border: 1px solid #d9e0eb;
  border-radius: 14px;
  background: #ffffff;
  padding: 0.75rem;
  min-height: 0;
  display: grid;
  gap: 0.6rem;
  box-shadow: 0 8px 18px rgba(15, 34, 62, 0.06);
}

.bw-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.55rem;
}

.bw-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.bw-help summary {
  cursor: pointer;
  color: #2c4f78;
  font-size: 0.84rem;
}

.bw-help ul {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
  font-size: 0.82rem;
  color: #3f5165;
}

.bw-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.bw-input-row input {
  border: 1px solid #c7d2e2;
  border-radius: 10px;
  padding: 0.52rem 0.58rem;
  font: inherit;
  color: #1d3658;
  background: #fff;
}

.bw-input-row button,
.bw-panel-head button,
.bw-examples button {
  border: 1px solid #b9c8dc;
  background: #f8fbff;
  color: #123865;
  border-radius: 10px;
  padding: 0.46rem 0.64rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.bw-input-row button {
  background: #0f4da7;
  color: #fff;
  border-color: #0f4da7;
}

.bw-input-row button:hover,
.bw-panel-head button:hover,
.bw-examples button:hover {
  filter: brightness(0.98);
}

.bw-input-row input:focus-visible,
.bw-input-row button:focus-visible,
.bw-panel-head button:focus-visible,
.bw-examples button:focus-visible,
.bw-help summary:focus-visible {
  outline: 2px solid #2f7ecf;
  outline-offset: 2px;
}

.bw-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.bw-examples button {
  border-style: dashed;
  font-size: 0.78rem;
  padding: 0.32rem 0.48rem;
  background: #fbfdff;
}

.bw-output {
  margin: 0;
  border: 1px solid #dce4f0;
  border-radius: 10px;
  padding: 0.45rem 0.52rem;
  background: #f7faff;
  color: #294464;
  font-size: 0.86rem;
}

.bw-output.is-error {
  border-color: #e0c0bd;
  background: #fff8f8;
  color: #7a2f2a;
}

.bw-output.is-success {
  border-color: #bfd8c8;
  background: #f4fbf7;
  color: #2f6142;
}

.bw-log {
  margin: 0;
  padding: 0.55rem 0.62rem 0.55rem 1.45rem;
  border: 1px solid #dce4f0;
  border-radius: 10px;
  background: #fbfdff;
  min-height: 160px;
  max-height: 270px;
  overflow: auto;
  display: grid;
  gap: 0.38rem;
}

.bw-log-item {
  color: #2d425d;
  font-size: 0.84rem;
  line-height: 1.42;
}

.bw-log-item strong {
  color: #163a67;
}

.bw-log-steps {
  margin: 0.16rem 0 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.14rem;
}

.bw-world-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.bw-world-wrap {
  border: 1px solid #d6dfec;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7ff 100%);
  padding: 0.55rem;
  min-height: 300px;
  display: grid;
}

.bw-world {
  position: relative;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf4ff 64%, #eef5ff 100%);
  min-height: 100%;
  padding: 0.35rem 0.5rem 0.8rem;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.35rem;
}

.bw-hand {
  margin: 0;
  font-size: 0.81rem;
  color: #3f5877;
}

.bw-stacks {
  min-height: 210px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 0.55rem;
}

.bw-stack {
  min-width: 72px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.22rem;
}

.bw-block {
  width: 66px;
  height: 36px;
  border: 1px solid #bccbe0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #ecf2fb 100%);
  color: #1e3f66;
  display: grid;
  place-items: center;
  font: 700 0.92rem/1 "SFMono-Regular", Menlo, Consolas, monospace;
  box-shadow: 0 4px 8px rgba(15, 33, 55, 0.08);
}

.bw-block.is-clear {
  border-color: #7ca7e2;
}

.bw-table {
  height: 9px;
  border: 1px solid #afbdd4;
  border-radius: 999px;
  background: #d8e5f8;
}

.bw-state {
  border: 1px solid #dce4f0;
  border-radius: 10px;
  background: #fbfdff;
  padding: 0.48rem 0.55rem;
}

.bw-state h4 {
  margin: 0 0 0.34rem;
  font-size: 0.86rem;
  color: #2b486b;
}

.bw-state pre {
  margin: 0;
  max-height: 170px;
  overflow: auto;
  white-space: pre-wrap;
  font: 0.78rem/1.4 "SFMono-Regular", Menlo, Consolas, monospace;
  color: #2f4258;
}

.bw-about summary {
  cursor: pointer;
  font-weight: 700;
  color: #1f3f65;
}

.bw-about-grid {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

@media (max-width: 980px) {
  .bw-grid {
    grid-template-columns: 1fr;
  }

  .bw-world-wrap {
    min-height: 250px;
  }

  .bw-about-grid {
    grid-template-columns: 1fr;
  }
}
