/* Domain layout; colors and controls follow the shared Basecoat workspace. */
.heading,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.heading {
  margin-bottom: 1.5rem;
}
.heading p,
.section-title h2,
.section-title p {
  margin-bottom: 0;
}
.material-workspace > section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.65rem;
}
label {
  display: grid;
  gap: 0.3rem;
  margin: 0.8rem 0;
}
label > input,
label > select,
label > textarea {
  width: 100%;
}
dialog .section-title {
  position: sticky;
  top: -24px;
  z-index: 1;
  padding: 0.5rem 0;
  background: var(--card);
}
.conflict-panel {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.conflict-panel > p {
  margin: 0.75rem 0;
}
.conflict-panel table {
  table-layout: fixed;
  margin: 1rem 0;
}
.conflict-panel :is(th, td) {
  vertical-align: top;
  overflow-wrap: anywhere;
}
.material-workspace {
  display: grid;
  grid-template-columns: minmax(290px, 0.9fr) minmax(0, 1.35fr);
  gap: 1rem;
  align-items: start;
}
.material-workspace > section {
  min-width: 0;
  margin: 0;
}
.material-library {
  padding: 1rem;
}
.material-library .section-title {
  align-items: baseline;
  gap: 0.4rem;
}
.material-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.6rem;
  align-items: end;
  margin: 1rem 0 0.75rem;
}
.material-filters label {
  margin: 0;
  min-width: 0;
}
.material-search-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: end;
}
.material-tag {
  grid-column: 1 / -1;
}
#list-status {
  min-height: 1.2em;
  font-size: 0.75rem;
}
.materials {
  list-style: none;
  margin: 0.75rem -0.45rem 0;
  padding: 0;
  max-height: 64dvh;
  overflow: auto;
  scrollbar-width: thin;
}
.materials li {
  border-top: 1px solid var(--border);
  padding: 0.8rem 0.65rem;
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}
.materials li:has(button):hover,
.materials li.is-selected {
  background: var(--muted);
}
.materials button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 600;
  border: 0;
  border-radius: 0.25rem;
  padding: 0.1rem 0;
  min-height: 1.8rem;
  box-shadow: none;
  background: transparent;
  color: var(--foreground);
}
.materials li > span,
.materials li > small {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}
.materials li > small:empty {
  display: none;
}
#more-materials {
  width: 100%;
  margin-top: 0.75rem;
}
.material-placeholder {
  min-height: 25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background: var(--card);
}
.material-workspace.has-detail .material-placeholder {
  display: none;
}
#material-detail {
  min-height: 25rem;
  max-height: calc(100dvh - 11rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem;
  scrollbar-width: thin;
}
.material-detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
#detail-title {
  line-height: 1.5;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
}
#detail-meta {
  overflow-wrap: anywhere;
}
.tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0.75rem 0;
}
.tags span {
  font-size: 0.75rem;
  background: var(--muted);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: 0.35rem;
}
#detail-source,
#detail-links {
  overflow-wrap: anywhere;
}
#detail-source p {
  margin: 0.5rem 0;
}
.body-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  line-height: 1.9;
  margin: 1.5rem 0;
}
.material-links {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.material-links > ul {
  padding-left: 1.25rem;
}
#editor-dialog {
  width: min(740px, calc(100% - 2rem));
}
.editor-version {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  margin: 0.6rem 0;
}
.editor-options {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 0;
  margin: 0.75rem 0;
}
.material-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.editor-actions {
  justify-content: flex-end;
}
.reference-picker {
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--muted);
}
.reference-controls {
  display: flex;
  align-items: end;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.reference-controls label {
  flex: 1 1 130px;
}
.reference-results,
.reference-selected {
  padding-left: 1.2rem;
  overflow-wrap: anywhere;
}
.reference-results {
  max-height: 16rem;
  overflow: auto;
}
.reference-results li,
.reference-selected li {
  margin: 0.5rem 0;
}
.reference-selected small {
  display: block;
}
#conflict-detail pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 28rem;
  overflow: auto;
}
@media (max-width: 900px) {
  .material-workspace {
    grid-template-columns: 1fr;
  }
  .material-placeholder {
    display: none;
  }
  .material-workspace.has-detail .material-library {
    display: none;
  }
  .materials,
  #material-detail {
    max-height: none;
  }
}
@media (max-width: 520px) {
  .conflict-panel :is(table, tbody, tr, td) {
    display: block;
    width: 100%;
  }
  .conflict-panel thead {
    display: none;
  }
  .conflict-panel td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--foreground);
  }
  .material-editor-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  #material-detail {
    padding: 1rem;
  }
  .editor-actions > button {
    flex: 1 1 auto;
  }
}
