.ngram-build-workspace {
  display: grid;
  grid-template-columns: minmax(0, 980px);
  justify-content: center;
  align-items: start;
  gap: 18px;
  padding-bottom: 180px;
}

.ngram-training-panel,
.ngram-count-panel,
.ngram-probability-panel,
.ngram-generator-panel {
  min-height: 0;
}

.ngram-build-panel-body {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: #fbfcfa;
}

.ngram-build-settings {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.55fr);
  gap: 14px;
  align-items: end;
}

.ngram-generation-settings {
  max-width: 360px;
}

#build-training-text {
  min-height: 128px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.ngram-build-note {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
}

.ngram-build-note strong {
  color: var(--accent-strong);
}

.ngram-build-note p,
.ngram-step-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.ngram-build-note.compact {
  color: var(--muted);
  line-height: 1.45;
}

.ngram-count-panel .button-row,
.ngram-generator-panel .button-row {
  gap: 10px;
  flex-wrap: wrap;
}

.ngram-build-status {
  min-height: 20px;
  color: var(--muted);
  font-weight: 750;
}

.ngram-build-status.good {
  color: var(--accent-strong);
}

.ngram-build-status.needs-work {
  color: #8a3d31;
}

.ngram-build-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.ngram-build-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.ngram-build-table caption {
  padding: 10px 12px;
  color: var(--accent-strong);
  font-weight: 850;
  text-align: left;
}

.ngram-build-table th,
.ngram-build-table td {
  padding: 8px 10px;
  border-top: 1px solid #e4ebe6;
  text-align: left;
  white-space: nowrap;
}

.ngram-build-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3ef;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.ngram-build-table td:first-child,
.ngram-build-table td:nth-child(2) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.ngram-table-placeholder td {
  color: var(--muted);
  font-family: inherit;
  font-weight: 750;
  white-space: normal;
}

.ngram-probability-row.current-context td {
  background: #fff7e9;
  box-shadow: inset 0 1px 0 #f2d6ad, inset 0 -1px 0 #f2d6ad;
}

.ngram-probability-row.current-context td:first-child {
  border-left: 5px solid var(--warm);
  color: var(--accent-strong);
  font-weight: 850;
}

.ngram-count-input {
  width: 76px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.ngram-count-input.correct {
  border-color: var(--accent);
  background: var(--selected);
}

.ngram-count-input.incorrect {
  border-color: #a54a3d;
  background: #fff5f2;
}

.ngram-result-cell {
  color: var(--muted);
  font-weight: 750;
}

.ngram-result-cell.correct {
  color: var(--accent-strong);
}

.ngram-result-cell.incorrect {
  color: #8a3d31;
}

.ngram-generator-panel button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 760px) {
  .ngram-build-settings {
    grid-template-columns: 1fr;
  }

  .ngram-build-table {
    min-width: 460px;
  }
}
