/* IDS Studio (D-S1-07) — Contrôles › IDS Studio. Same design system as the Workbench: DM Sans,
   surface / line / text tokens, screen cards, secondary actions. Nothing is positioned over text:
   every block flows; the consent dialog is the only overlay and it covers the page entirely. */
.ids-studio { display: grid; gap: var(--s-4); min-width: 0; }
.ist-region, .ist-screen, .ist-live { display: grid; gap: var(--s-4); min-width: 0; }
.ids-studio .mono { font-family: var(--font-mono); font-size: var(--t-xs); }
.ist-head .screen-card-head { align-items: center; flex-wrap: wrap; }
.ist-privacy { padding: var(--s-2) var(--s-3); border-left: 3px solid var(--ok); background: var(--bg-2); border-radius: var(--r-1); }

.ist-nav ul { display: flex; flex-wrap: wrap; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.ist-nav-item { min-height: 36px; padding: 0 var(--s-3); border: 1px solid var(--line); border-radius: 999px; background: var(--bg-1); color: var(--text-2); font: inherit; font-size: var(--t-xs); cursor: pointer; }
.ist-nav-item:hover { background: var(--bg-2); color: var(--text-1); }
.ist-nav-item[aria-current="page"] { border-color: var(--sel-line); background: var(--sel-bg); color: var(--text-1); font-weight: 600; }
.ist-nav-item:focus-visible, .ist-drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.ist-tiles, .ist-templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-4); }
.ist-tile, .ist-template { align-content: start; }
.ist-tile h3, .ist-template h3 { font-size: var(--t-body-strong); }
.ist-template-specs li { padding: 2px 0; font-size: var(--t-xs); color: var(--text-2); overflow-wrap: anywhere; }

.ist-editor { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: var(--s-4); align-items: start; }
.ist-editor-side, .ist-editor-main { display: grid; gap: var(--s-4); min-width: 0; }
.ist-info summary { cursor: pointer; }
.ist-info[open] summary { margin-bottom: var(--s-3); }
.ist-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3); }
.ist-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end; }
.ist-row > .ist-field { flex: 1 1 180px; }
.ist-field { display: grid; gap: var(--s-1); min-width: 0; }
.ist-field > label { color: var(--text-2); font-size: var(--t-xs); font-weight: 600; }
.ist-field .field, .ist-add .field { width: 100%; min-height: 36px; font: inherit; }
.ist-field textarea.field { min-height: 72px; padding: var(--s-2); resize: vertical; }
.ist-hint { margin: 0; font-size: var(--t-caption); }
.ist-check { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 32px; color: var(--text-1); font-size: var(--t-xs); cursor: pointer; }
.ist-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ist-versions { margin: 0; padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-1); }
.ist-versions legend { padding: 0 var(--s-1); color: var(--text-2); font-size: var(--t-xs); font-weight: 600; }

.ist-spec-list { display: grid; gap: var(--s-1); }
.ist-spec-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1); align-items: center; padding: var(--s-1); border: 1px solid transparent; border-radius: var(--r-1); }
.ist-spec-item.is-selected { border-color: var(--sel-line); background: var(--sel-bg); }
.ist-spec-pick { display: grid; gap: 2px; min-width: 0; text-align: left; }
.ist-spec-name { overflow-wrap: anywhere; font-weight: 600; }
.ist-spec-target { overflow-wrap: anywhere; font-family: var(--font-mono); font-size: var(--t-caption); }
.ist-spec-item > .badge { grid-column: 1; justify-self: start; }
.ist-spec-actions { grid-column: 1 / -1; display: flex; gap: var(--s-1); justify-content: flex-end; }
.ist-mini { width: 32px; height: 32px; min-width: 32px; padding: 0; font-size: var(--t-body); }

.ist-zone { display: grid; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.ist-zone h4 { font-size: var(--t-body-strong); }
.ist-facet { display: grid; gap: var(--s-3); margin: 0; padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-2); background: var(--bg-2); min-width: 0; }
.ist-facet legend { padding: 0 var(--s-1); font-weight: 600; font-size: var(--t-xs); }
.ist-value { display: grid; gap: var(--s-2); padding: var(--s-2) 0 0; border-top: 1px dashed var(--line); }
.ist-pattern-check { margin: 0; font-size: var(--t-caption); }
.ist-tester [data-match="yes"] { color: var(--ok); }
.ist-tester [data-match="no"] { color: var(--sev-blocking); }
.ist-more summary { cursor: pointer; color: var(--text-2); font-size: var(--t-xs); }
.ist-more[open] { display: grid; gap: var(--s-2); }
.ist-add { align-items: center; }
.ist-add .field { width: auto; min-width: 180px; }

.ist-live-card { border-style: dashed; }
.ist-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--s-4); align-items: start; }
.ist-xml { max-height: 520px; margin: 0; padding: var(--s-3); overflow: auto; border: 1px solid var(--line); border-radius: var(--r-1); background: var(--bg-0); color: var(--text-1); font-family: var(--font-mono); font-size: var(--t-caption); line-height: 1.55; white-space: pre; }
.ist-xml:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ist-x-tag { color: var(--viz-structure); }
.ist-x-attr { color: var(--viz-site); }
.ist-x-val { color: var(--viz-mep); }
.ist-tree, .ist-tree ul { margin: 0; padding-left: var(--s-4); }
.ist-tree li { padding: 2px 0; overflow-wrap: anywhere; }
.ist-tree ul ul > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-2); }
.ist-tree ul ul > li .mono { min-width: 0; overflow-wrap: anywhere; }
.ist-tree > li { padding: var(--s-2) 0; border-bottom: 1px solid var(--line); }
.ist-tree > li > strong, .ist-tree-versions { display: block; }
.ist-issues li { padding: var(--s-1) 0; overflow-wrap: anywhere; }
.ist-jump { display: inline; padding: 0 var(--s-1); }
.ist-action-row { flex-wrap: wrap; }

.ist-drop { display: grid; gap: var(--s-2); justify-items: start; padding: var(--s-4); border: 2px dashed var(--line-2); border-radius: var(--r-2); background: var(--bg-2); }
.shell[data-drop="true"][data-section="studio"] .drop-overlay { display: none; }
.shell[data-drop="true"][data-section="studio"] .ist-drop { border-color: var(--accent); background: var(--sel-bg); }
.ist-chunks summary { cursor: pointer; }
.ist-chunks li { display: grid; gap: var(--s-1); padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.ist-chunk-head { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); align-items: baseline; }
.ist-chunk-path { color: var(--text-3); font-size: var(--t-caption); overflow-wrap: anywhere; }
.ist-chunk-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--t-caption); }
.ist-sources td, .ist-sources th, .ist-drafts td { vertical-align: top; overflow-wrap: break-word; }
.ist-drafts td:nth-child(6) { white-space: nowrap; }

.ist-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: var(--s-4); align-items: start; }
.ist-drafts input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.ist-drafts tr.is-selected { background: var(--sel-bg); }
.ist-drafts tr[data-status="rejected"] { color: var(--text-3); }
.ist-row-actions { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.ist-confidence[data-band="high"] { color: var(--ok); }
.ist-confidence[data-band="medium"] { color: var(--sev-review); }
.ist-confidence[data-band="low"] { color: var(--sev-blocking); }
.ist-side { position: sticky; top: var(--s-2); }
.ist-quote { margin: 0; padding: var(--s-2) var(--s-3); border-left: 3px solid var(--sel-line); background: var(--bg-2); font-style: italic; overflow-wrap: anywhere; }
.ist-context mark { background: var(--sev-review-bg); color: var(--text-1); }

.ist-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: var(--s-4); overflow-y: auto; background: #05070ab3; }
.ist-dialog { width: min(640px, 100%); max-height: calc(100vh - 2 * var(--s-4)); overflow-y: auto; }
.ist-dialog-actions { flex-wrap: wrap; }

.ist-page { max-width: 820px; }
.ist-page-section { display: grid; gap: var(--s-1); }
.ist-page-section h4 { font-size: var(--t-body-strong); }
.ist-page-section p { color: var(--text-2); line-height: 1.55; }

@media (max-width: 900px) {
  .ist-editor, .ist-review { grid-template-columns: minmax(0, 1fr); }
  .ist-side { position: static; }
}
@media (max-width: 700px) {
  /* Narrow screens: each draft / source row becomes a card (no squeezed columns). */
  .ist-drafts thead, .ist-sources thead { display: none; }
  .ist-drafts, .ist-drafts tbody, .ist-sources, .ist-sources tbody { display: block; width: 100%; }
  .ist-drafts tr, .ist-sources tr { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-1); padding: var(--s-3); border-bottom: 1px solid var(--line); }
  .ist-drafts tr { grid-template-columns: 32px minmax(0, 1fr); }
  .ist-drafts td, .ist-sources td, .ist-sources th { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
  .ist-drafts td:first-child { grid-row: span 6; }
  .ist-sources td[data-label]::before { content: attr(data-label) " : "; color: var(--text-3); font-size: var(--t-caption); }
  .ist-drafts td:not(:first-child) { grid-column: 2; }
}
@media (max-width: 480px) {
  .ist-tiles, .ist-templates, .ist-preview-grid { grid-template-columns: minmax(0, 1fr); }
  .ist-add .field { min-width: 0; flex: 1 1 100%; }
  .ist-xml { max-height: 360px; }
}
/* Row headers (document, specification) read as data, not as column titles. */
.ids-studio tbody th { color: var(--text-1); font-size: var(--t-xs); font-weight: 600; letter-spacing: normal; text-transform: none; text-align: left; overflow-wrap: anywhere; }

.ist-api-key {
  display: grid;
  gap: var(--s-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s-3);
  margin-block: var(--s-3);
}
.ist-api-key h4, .ist-api-key p { margin: 0; }
