.item-header,
.field-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.item-header h1 {
  margin-right: auto;
}
.item-status {
  font-size: 0.85rem;
  font-weight: 600;
  color: #315e48;
  background: #e7f1e9;
  border-radius: 5px;
  padding: 0.4rem 0.65rem;
}
.field-header .muted {
  text-align: right;
}
.field-terms:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.7rem;
  font-size: 0.78rem;
}
.term-chip {
  background: #f0f3ed;
  color: #355b46;
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
}

.cols-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.field-column-label {
  font:
    600 11px/1.4 Inter,
    'Segoe UI',
    sans-serif;
  color: #718077;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.comparison-column {
  min-width: 0;
  border: 1px solid #e4e8e1;
  border-radius: 7px;
  padding: 14px;
}
.comparison-column.before {
  background: #fffafa;
}
.comparison-column.after {
  background: #f5faf5;
}
.comparison-column button {
  margin-top: 14px;
}
.diff-reader {
  white-space: pre-wrap;
}
.diff-reader del,
.diff-reader ins {
  border-radius: 2px;
  padding: 0 1px;
  box-decoration-break: clone;
}
.proposal-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}
@media (max-width: 1000px) {
  .cols-three {
    grid-template-columns: 1fr;
  }
  .proposal-pair {
    grid-template-columns: 1fr;
  }
}

.reading-column {
  min-width: 0;
  padding: 14px;
}
.field-history {
  margin-top: 20px;
}
.field-history-card {
  border: 1px solid #dbe5dc;
  border-radius: 9px;
  margin: 7px 0;
  background: #fff;
  overflow: hidden;
}
.field-history-summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  background: #f4f7f3;
  list-style: none;
}
.field-history-summary::-webkit-details-marker {
  display: none;
}
.field-history-summary:before {
  content: '▸';
  color: #54765f;
}
.field-history-card[open] > .field-history-summary:before {
  content: '▾';
}
.field-history-meta {
  display: flex;
  flex: 1;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.field-history-actor {
  font-size: 13px;
  color: #68776c;
}
.field-history-body {
  padding: 4px 16px 16px;
}
.glossary-highlight {
  background: #faedb5;
  color: inherit;
  border-radius: 2px;
  padding: 0;
  box-shadow: inset 0 -1px #d5ad42;
}
.reading-column.target {
  border: 1px solid #dce9de;
}
.proposal-pair .diff-reader {
  font-size: 15px;
}
.field-header {
  margin-bottom: 12px;
}

.inline-editor > summary {
  display: inline-block;
  border: 1px solid #cbdccc;
  background: #fff;
  border-radius: 6px;
  padding: 8px 10px;
  list-style: none;
}
.inline-editor > summary::-webkit-details-marker {
  display: none;
}
.inline-editor > summary:before {
  content: '▸  ';
}
.inline-editor[open] > summary:before {
  content: '▾  ';
}
.inline-editor textarea {
  min-height: 150px;
}
.inline-editor p {
  margin: 6px 0 0;
}

.ai-error {
  margin: 14px 0;
  padding: 15px 18px;
  border: 1px solid #e6b9ad;
  border-radius: 9px;
  background: #fff3ef;
  color: #733b30;
}
.ai-error p {
  white-space: pre-wrap;
  margin: 7px 0 0;
  overflow-wrap: anywhere;
}
.session-error {
  color: #8a4b3e;
  font-size: 12px;
  white-space: pre-line;
  margin-top: 6px;
  max-width: 900px;
}
.error-status {
  color: #9a493b;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.aligned-diff {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid #dce5dc;
  border-radius: 7px;
  overflow: clip;
}
.diff-column {
  display: contents;
}
.diff-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 14px;
  background: #edf3ee;
  color: #52675a;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #dce5dc;
}
.diff-before {
  grid-column: 1;
}
.diff-after {
  grid-column: 2;
}
.diff-heading.diff-before,
.diff-heading.diff-after {
  grid-row: 1;
}
.diff-paragraph {
  white-space: pre-wrap;
  padding: 12px 14px;
  min-width: 0;
  font-size: 15px;
  line-height: 1.6;
  border-bottom: 1px solid #e8eee8;
  overflow-wrap: anywhere;
}
.diff-paragraph.diff-before {
  background: #fffafa;
  border-right: 1px solid #e2e8e2;
}
.diff-paragraph.diff-after {
  background: #f8fcf8;
}
.diff-paragraph ins,
.diff-paragraph del {
  border-radius: 2px;
  box-decoration-break: clone;
}
.source-context {
  background: #fff3c4;
  outline: 2px solid #e7bf55;
  outline-offset: 3px;
  border-radius: 3px;
  transition: background 0.15s;
}
.clean-preview {
  grid-template-columns: minmax(0, 1fr);
}
.clean-preview .diff-before {
  display: none;
}
.clean-preview .diff-after {
  grid-column: 1;
}
.clean-preview ins {
  background: transparent;
  color: inherit;
  text-decoration: none;
}
.clean-preview .diff-paragraph.diff-after {
  background: #fff;
}
.field-history-body > button {
  margin-top: 12px;
}
@media (max-width: 650px) {
  .diff-paragraph {
    padding: 8px;
    font-size: 14px;
  }
}

.field > .reading-column.target {
  margin-top: 18px;
}
.field > .reading-column:not(.target) {
  background: #fafbf9;
  border: 1px solid #e6ece5;
  border-radius: 7px;
}
.field > .field-history {
  margin-top: 16px;
}

.field-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  gap: 18px;
  align-items: start;
}
.field-body,
.field-side {
  min-width: 0;
}
.field-side {
  border-left: 1px solid #e3eae3;
  padding-left: 16px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.field-side h3 {
  font-size: 13px;
  color: #42594a;
  margin: 0 0 10px;
}
.field-side h3:not(:first-child) {
  margin-top: 20px;
}
.field-side .field-terms:not(:empty) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  margin: 0 0 10px;
}
.field-side .term-chip {
  line-height: 1.4;
}
.field-note {
  background: #fffaf0;
  border-left: 3px solid #d9b46e;
  padding: 9px;
  margin: 8px 0;
}
.field-note p {
  margin: 7px 0;
}
.field-note button {
  margin-top: 8px;
  padding: 5px 8px;
}
@media (max-width: 650px) {
  .field-layout {
    grid-template-columns: 1fr;
  }
  .field-side {
    border-left: 0;
    border-top: 1px solid #e3eae3;
    padding: 14px 0 0;
  }
}

.clean-columns:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.clean-columns .reading-column {
  border: 1px solid #e2eae2;
  border-radius: 7px;
  background: #fafbf9;
}
.clean-columns .target {
  background: #f5f9f5;
}
@media (max-width: 650px) {
  .clean-columns:not([hidden]) {
    grid-template-columns: 1fr;
  }
}

.formatted-diff {
  white-space: normal;
}
.formatted-diff p:first-child {
  margin-top: 0;
}
.formatted-diff table {
  max-width: 100%;
  border-collapse: collapse;
}
.formatted-diff td,
.formatted-diff th {
  border: 1px solid #d7e1d8;
  padding: 5px;
}
.raw-diff {
  margin-top: 12px;
}
.raw-diff summary {
  cursor: pointer;
  color: #456f56;
  font-size: 13px;
}
.raw-diff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.raw-diff pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px;
  background: #f4f6f3;
  font: 12px/1.5 monospace;
}
@media (max-width: 650px) {
  .raw-diff-grid {
    grid-template-columns: 1fr;
  }
}

/* References remain recognizable as inline chips even inside highlighted text. */
.reader .foundry-ref {
  display: inline;
  color: #285b80;
  background: #eaf3fa;
  border: 1px solid #aac8db;
  border-radius: 5px;
  padding: 0 4px;
  text-decoration: none;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reader a.foundry-ref:hover,
.reader a.foundry-ref:focus-visible {
  background: #d8eaf6;
  border-color: #598dad;
  text-decoration: underline;
  outline-offset: 2px;
}
.reader .foundry-ref.warning,
.reader .foundry-ref.invalid {
  color: #96583c;
  background: #fff1df;
  border-color: #e8c59c;
}
.reader .foundry-ref .glossary-highlight {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 -2px #d5ad42;
}
.reader .foundry-ref ins,
.reader .foundry-ref del {
  border-radius: 2px;
  padding: 0 1px;
}
.reader .foundry-mechanic {
  display: inline-block;
  max-width: min(100%, 24em);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid #d5dbe4;
  border-radius: 5px;
  padding: 0 5px;
  background: #f1f3f7;
  color: #47566a;
  font:
    0.9em/1.5 ui-monospace,
    Consolas,
    monospace;
  box-decoration-break: clone;
}
.field-body {
  position: relative;
}
.field-history-summary {
  background: #f0f2f5;
}
.field-history-card {
  border-color: #dce1e7;
}
.field-history-summary:before {
  color: #697582;
}
