/* source-glossary-edit.css - the write forms of the Sources workspace (web/modules/source-glossary-edit.js).
   Theme tokens only. Statement states reuse the workspace's .sg-state chip (source-glossary.css): colour, border style
   and word together. A change the person has not saved is a dashed left rule plus the words "changed by you"; a
   refusal is a solid danger rule plus a "!" mark and its words; a result is an ok rule plus a tick and its words. */

.sg-ed { display: grid; gap: var(--space-3); max-width: 980px; }
.sg-ed-head { display: grid; gap: var(--space-1); }
.sg-ed-title { margin: 0; font-size: var(--fs-h3); color: var(--text); }
.sg-ed-sub { margin: 0; font-size: var(--fs-small); color: var(--text-dim); }
.sg-ed-context { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--fs-small); color: var(--text-body); background: var(--surface-subtle); border: 1px solid var(--border-subtle); border-left: 3px solid var(--warn-border); border-radius: var(--radius-sm); }
.sg-ed-label { display: block; font-size: var(--fs-small); font-weight: 600; color: var(--text); }

.sg-ed-group { margin: 0; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); display: grid; gap: var(--space-2); min-width: 0; }
.sg-ed-group > legend { padding: 0 var(--space-1); font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed-group label { font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed input:not([type="checkbox"]):not([type="radio"]), .sg-ed select, .sg-ed textarea {
  font: inherit; font-size: var(--fs-small); padding: 6px 8px; width: 100%; box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.sg-ed textarea { resize: vertical; }
.sg-ed-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }
.sg-ed-three { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.sg-ed-field { display: grid; gap: 4px; align-content: start; padding-left: var(--space-2); border-left: 3px solid transparent; min-width: 0; }
.sg-ed-field[data-ed-changed="true"] { border-left: 3px dashed var(--warn-border); }
.sg-ed-field[data-ed-changed="true"] > label::after, .sg-ed-field[data-ed-changed="true"] > .sg-ed-label::after { content: " (changed by you, not saved)"; font-weight: 400; color: var(--warn-text); }
.sg-ed-now { margin: 0; font-size: var(--fs-micro); color: var(--text-dim); }
.sg-ed-current-value { color: var(--text-body); }
.sg-ed-current[data-sg-state="suggested"] .sg-ed-current-value { font-style: italic; }
.sg-ed-hint { margin: 0; font-size: var(--fs-micro); color: var(--text-dim); }
.sg-ed-check { display: inline-flex; gap: var(--space-1); align-items: center; font-size: var(--fs-small); font-weight: 400; color: var(--text-body); }
.sg-ed-choices { display: grid; gap: var(--space-1); }

/* Columns: a filter, a window of rows, a pager. */
.sg-ed-colbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.sg-ed-colbar input[type="search"] { max-width: 280px; }
.sg-ed-count { margin: 0; font-size: var(--fs-small); color: var(--text-dim); }
.sg-ed-cols { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.sg-ed-col { border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); background: var(--surface); }
.sg-ed-col[data-ed-changed="true"] { border-color: var(--warn-border); border-style: dashed; }
.sg-ed-col-head { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; margin-bottom: var(--space-2); }
.sg-ed-col-name { font-family: var(--mono); font-size: var(--fs-small); color: var(--text); }
.sg-ed-col-type { font-size: var(--fs-micro); color: var(--text-faint); }
.sg-ed-edited { font-size: var(--fs-micro); color: var(--warn-text); font-weight: 600; }
.sg-ed-col-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-2); }
.sg-ed-pager { display: flex; gap: var(--space-2); align-items: center; font-size: var(--fs-small); color: var(--text-dim); }

/* The concept picker and the table search answers: buttons a person presses, never free text sent. */
.sg-ed-picker, .sg-ed-issuer { display: grid; gap: 4px; padding: var(--space-2); background: var(--surface-subtle); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); }
.sg-ed-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 320px; overflow-y: auto; }
.sg-ed-option { display: block; width: 100%; text-align: left; font: inherit; padding: 6px var(--space-2); background: var(--surface); color: var(--text); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); cursor: pointer; }
.sg-ed-option:hover:not([disabled]), .sg-ed-option:focus-visible { border-color: var(--brand-border); background: var(--brand-tint); }
.sg-ed-option[disabled] { cursor: not-allowed; color: var(--text-dim); border-style: dotted; }
.sg-ed-option-name { font-weight: 600; font-size: var(--fs-small); }
.sg-ed-option-meta { display: block; font-size: var(--fs-micro); color: var(--text-dim); }
.sg-ed-picked { margin: 0; font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-searchrow { display: flex; gap: var(--space-2); }
.sg-ed-pairs { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-2); }
.sg-ed-pairs li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.sg-ed-pairs select { max-width: 300px; }

/* What will be recorded, the warning, the result. */
.sg-ed-recorded { padding: var(--space-3); border: 1px dashed var(--warn-border); border-radius: var(--radius-md); background: var(--surface); display: grid; gap: var(--space-2); }
.sg-ed-recorded-title, .sg-ed-result-title, .sg-ed-refusal-title { margin: 0; font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed-changes { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-changes li { display: grid; gap: 2px; }
.sg-ed-change-label { font-weight: 600; color: var(--text); }
.sg-ed-was { display: inline-block; min-width: 3.2em; font-size: var(--fs-micro); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.02em; }
.sg-ed-change-before { color: var(--text-dim); }
.sg-ed-reason-echo, .sg-ed-figure-text { margin: 0; font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-own { margin: 0; font-size: var(--fs-small); color: var(--text-dim); }
.sg-ed-warning { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--fs-small); color: var(--text-body); background: var(--surface-subtle); border: 1px solid var(--warn-border); border-left-width: 3px; border-radius: var(--radius-sm); }
.sg-ed-warning p { margin: 0 0 var(--space-1); }
.sg-ed-mark { display: inline-block; min-width: 1em; font-weight: 700; text-align: center; }
.sg-ed-result { padding: var(--space-2) var(--space-3); border: 1px solid var(--ok-border); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--ok-tint); display: grid; gap: var(--space-1); }
.sg-ed-result .sg-ed-mark { color: var(--ok-text); }
.sg-ed-refusal, .sg-ed-problems { padding: var(--space-2) var(--space-3); border: 1px solid var(--down-border); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--down-tint); display: grid; gap: var(--space-1); }
.sg-ed-refusal .sg-ed-mark, .sg-ed-problems .sg-ed-mark { color: var(--down-text); }
.sg-ed-refusal-body { margin: 0; font-size: var(--fs-small); color: var(--text-body); }
/* A read that failed is not a refused save: a dotted outline and a cross, with the words "could not be read". */
.sg-ed-unread { padding: var(--space-2) var(--space-3); border: 1px dotted var(--border-strong); border-left: 3px dotted var(--warn-border); border-radius: var(--radius-sm); background: var(--surface-subtle); display: grid; gap: var(--space-1); justify-items: start; }
.sg-ed-unread-title { margin: 0; font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed-unread .sg-ed-mark { color: var(--warn-text); }
/* The parts a form redraws while a person types: what will be recorded, the problems, the save button. */
.sg-ed-live { display: grid; gap: var(--space-3); min-width: 0; }
.sg-ed-live:empty { display: none; }
/* The links a column already has, and the issuers a study's systems state: read before a person states one again. */
.sg-ed-known, .sg-ed-issuers { padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-subtle); display: grid; gap: var(--space-1); }
.sg-ed-known-title { margin: 0; font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed-known ul, .sg-ed-issuer-list { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-known li[data-ed-same="true"] { font-weight: 600; }
.sg-ed-issuer-list li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.sg-ed-problems ul { margin: 0; padding-left: var(--space-4); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-code { font-family: var(--mono); font-size: var(--fs-micro); color: var(--text-dim); }
p.sg-ed-code { margin: 0; }
.sg-ed-restricted { padding: var(--space-2) var(--space-3); border: 1px dotted var(--border-strong); border-radius: var(--radius-sm); font-size: var(--fs-small); color: var(--text-body); background: var(--surface-subtle); display: grid; gap: var(--space-1); }
.sg-ed-restricted p { margin: 0; }
/* A repeated scope line: said, and sent once. */
.sg-ed-repeated { margin: 0; padding-left: var(--space-4); }

/* Adding a system: what "the same system" records, the moved question, and the reason field it needs. */
.sg-ed-move { display: grid; gap: var(--space-1); padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-left: 3px solid var(--warn-border); border-radius: var(--radius-sm); background: var(--surface-subtle); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-move[data-ed-move="same-place"] { border-left-color: var(--border-strong); }
.sg-ed-move-found, .sg-ed-move-title { margin: 0; }
.sg-ed-move-title { font-weight: 600; color: var(--text); }
.sg-ed-move-lines { margin: 0; padding-left: var(--space-4); display: grid; gap: 2px; }
.sg-ed-move-ask { margin: 0; padding: 0; border: 0; }
.sg-ed-move-ask > legend { padding: 0; margin-bottom: var(--space-1); font-weight: 600; color: var(--text); }
.sg-ed-reg-reason textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.sg-ed-preview { margin: 0; font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-preview[data-ed-preview="idle"] { color: var(--text-dim); font-style: italic; }
.sg-ed-preview[data-ed-preview="counting"] { color: var(--text-dim); }
/* A count that could not be read: the same left rule as a failed read, never the solid rule of a refused save. */
.sg-ed-preview[data-ed-preview="error"] { padding-left: var(--space-2); border-left: 3px dotted var(--warn-border); }
.sg-ed-onoff { font-weight: 600; }
.sg-ed-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Round 5: a field a refused save named, the proposed keys, a link's identity, the table picker. */
.sg-ed-field[data-ed-refused="true"] { border-left: 3px solid var(--down-border); }
.sg-ed-field-refused { margin: 0; font-size: var(--fs-micro); color: var(--down-text); }
.sg-ed-keys, .sg-ed-key-pick { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-1); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-key-pick li { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }
.sg-ed-identity { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--space-1); font-size: var(--fs-small); color: var(--text-body); }
.sg-ed-identity .sg-ed-label { display: inline; margin-right: var(--space-1); }
.sg-ed-table-picker { gap: var(--space-2); }
/* Beside a link's class choice: what the class reads as. A class that will not show as chosen (a person's actor or
   lookup, a confirmed hub's class, a confirmed meaning a restatement does not change) is a ruled note, not a quiet hint. */
.sg-ed-class-shown:not([data-ed-class-shown="as-stated"]) { padding-left: var(--space-2); border-left: 3px solid var(--warn-border); color: var(--text-body); font-size: var(--fs-small); }

/* Round 5: a lifecycle (in use, deprecation proposed, deprecated) is a mark, a word and a line style; colour comes last.
   In use: dotted; a proposal: dashed and italic (a suggestion, never a fact); deprecated: solid. */
.sg-ed-life { display: inline-flex; gap: 4px; align-items: baseline; padding: 0 6px; font-size: var(--fs-micro); font-weight: 600; color: var(--text-body); border: 1px dotted var(--border-strong); border-radius: var(--radius-sm); }
.sg-ed-life[data-ed-life="proposed"] { border-style: dashed; border-color: var(--warn-border); font-style: italic; }
.sg-ed-life[data-ed-life="deprecated"] { border-style: solid; border-color: var(--down-border); background: var(--down-tint); }
/* "Take back my statement" beside a statement, and the one act that takes back every one ticked. */
.sg-ed-takeback { margin-left: var(--space-2); font-size: var(--fs-micro); }
.sg-ed-takeback-group .sg-ed-recorded { border-style: solid; }
/* A decision taken at once (a column's lifecycle) and taking back a link: their own reason and act, apart from the save. */
.sg-ed-decide { display: grid; gap: 4px; padding: var(--space-2); border: 1px solid var(--border-subtle); border-left: 3px solid var(--brand-border); border-radius: var(--radius-sm); background: var(--surface-subtle); }
.sg-ed-col-grid > .sg-ed-life-field:has(.sg-ed-decide) { grid-column: 1 / -1; }
.sg-ed-decide .sg-ed-choices { margin: 0; padding: 0; border: 0; }
.sg-ed-decide .sg-ed-choices > legend { padding: 0; margin-bottom: 2px; font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.sg-ed-life-done { margin: 0; padding-left: var(--space-2); font-size: var(--fs-small); color: var(--text-body); border-left: 3px solid var(--ok-border); }
.sg-ed-life-done .sg-ed-mark { color: var(--ok-text); }

/* The link figure: dashed, because a person's link is a suggestion until verified. */
.sg-ed-fig { max-width: 100%; height: auto; }
.sg-ed-fig-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; }
.sg-ed-fig-title { font-family: var(--mono); font-size: 12px; font-weight: 600; fill: var(--text); }
.sg-ed-fig-col { font-family: var(--mono); font-size: 11px; fill: var(--text-body); }
.sg-ed-fig-link { stroke: var(--warn-text); stroke-width: 1.5; stroke-dasharray: 6 4; }
.sg-ed-fig-head { fill: var(--warn-text); }
.sg-ed-fig-label { font-size: 11px; fill: var(--warn-text); font-weight: 600; }
.sg-ed-fig-note { font-size: 11px; fill: var(--text-body); }

@media (max-width: 720px) {
  .sg-ed-group { padding: var(--space-2); }
  .sg-ed-col-grid { grid-template-columns: 1fr; }
}
