/* The Materials page (admin/composer/materials): a top bar over the gallery, the viewport and the properties.
   It fills the Composer shell's bleed pane and never scrolls; at 1100px and below the areas stack and the page scrolls,
   as the Gold labeller does. Colours come from composer_benchmark_tokens.css. */
.cmat { --side: 300px; flex: 1; min-height: 0; display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--side); grid-template-rows: auto minmax(0, 1fr); color: var(--ink); background: var(--page); }
.cmat h1, .cmat h2, .cmat p { margin: 0; }
.cmat .sub { color: var(--muted); font-size: 0.8rem; }
.cmat-top { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; min-height: 42px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.cmat-top h1 { font-family: var(--display); font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.cmat .btn, .cmat-dialog .btn { border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; font-size: 0.82rem; }
.cmat .btn.primary, .cmat-dialog .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cmat-top .btn { margin-left: auto; align-self: center; }
.cmat-dialog { position: fixed; inset: 0; margin: auto; width: min(420px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); z-index: 10; }
.cmat-dialog::backdrop { background: rgb(16 24 40 / 0.7); }
.cmat-dialog form { display: flex; flex-direction: column; gap: 6px; }
.cmat-dialog h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.cmat-dialog fieldset { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; align-items: center; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.cmat-dialog legend { padding: 0 4px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.cmat-dialog .field_with_errors { display: contents; }
.cmat-dialog label { font-size: 0.84rem; }
.cmat-dialog input[type="number"] { font: inherit; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sunk); color: var(--ink); }
.cmat-dialog input[type="file"] { font-size: 0.78rem; color: var(--muted); min-width: 0; }
.cmat-dialog input[type="color"] { width: 64px; height: 32px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sunk); }
.cmat-error { grid-column: 2; margin: 0; color: var(--warn); font-size: 0.78rem; }
.cmat-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.cmat-side { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; }
.cmat-side h2 { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.cmat-gallery { border-right: 1px solid var(--line); }
.cmat-list { list-style: none; margin: 0 -6px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cmat-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 10px; align-items: center; padding: 5px 6px; border-radius: 8px; }
a.cmat-item { color: inherit; text-decoration: none; }
a.cmat-item:hover { background: var(--paper); }
a.cmat-item[aria-current="true"] { background: var(--accent-soft); }
.cmat-swatch { grid-row: 1 / -1; width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--line-strong); object-fit: cover; display: block; }
.cmat-label, .cmat-family, .cmat-size { grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmat-label { font-size: 0.84rem; font-weight: 600; line-height: 1.2; }
.cmat-family { font-size: 0.72rem; color: var(--muted); }
.cmat-size { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.cmat-folders { margin: 0; }
.cmat-folder { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.cmat-folder:hover { background: var(--sunk); color: var(--ink); }
.cmat-count { font-family: var(--mono); font-size: 0.75rem; }
.cmat-back { font-size: 0.8rem; color: var(--muted); }
.cmat-family-name { margin: 0; font-size: 0.9rem; font-weight: 600; }
.cmat-properties { border-left: 1px solid var(--line); }
.cmat-viewport { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; background: var(--paper); color: var(--muted); font-size: 0.86rem; }
.cmat-viewport canvas { width: 100%; height: 100%; display: block; }
.cmat-maps { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; }
.cmat-map { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.66rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
.cmat-map:hover { border-color: var(--line-strong); }
.cmat-map[data-unsaved]::after { content: "unsaved"; position: absolute; top: -7px; left: -10px; padding: 1px 5px; border-radius: 6px; background: var(--warn); color: var(--page); font-size: 0.6rem; }
.cmat-thumb { width: 44px; height: 44px; border-radius: 6px; border: 1px solid var(--line-strong); object-fit: cover; display: block; }
.cmat-thumb-large { width: 100%; height: auto; aspect-ratio: 1; }
.cmat-dialog[data-map][open] { display: flex; flex-direction: column; gap: 8px; }
.cmat-properties label { font-size: 0.8rem; }
.cmat-properties input, .cmat-properties select { font: inherit; font-size: 0.84rem; }
.cmat-properties form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cmat .btn:disabled { opacity: 0.45; cursor: default; }
.cmat-field { display: flex; align-items: center; gap: 6px; }
.cmat-field > input, .cmat-field > select { flex: 1; min-width: 0; }
.cmat-field > input[type="color"] { flex: none; width: 32px; height: 26px; padding: 1px; }
.cmat-field > input.cmat-strength { flex: none; width: 64px; }
.cmat-field[data-unsaved] > [data-composer-materials--viewer-target="field"] { outline: 2px solid var(--warn); outline-offset: -1px; }
.cmat-revert { flex: none; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.9rem; line-height: 1; cursor: pointer; }
.cmat-revert:hover { background: var(--sunk); }
.cmat-revert[aria-hidden="true"] { visibility: hidden; }

.cmat-views { display: flex; gap: 4px; align-self: center; }
.cmat-views a { padding: 3px 10px; border-radius: 6px; color: var(--muted); font-size: 0.82rem; text-decoration: none; }
.cmat-views a:hover { background: var(--sunk); color: var(--ink); }
.cmat-views a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.cmat-flash { align-self: center; font-size: 0.8rem; color: var(--muted); }
.cmat-flash[data-kind="alert"] { color: var(--warn); }
.cmat-flash[data-kind="notice"] { color: var(--good); }
.cmat-flash[data-kind="warning"] { color: var(--gold); }
.cmat-library { grid-template-columns: 220px minmax(0, 1fr); }
.cmat-tag-nav { border-right: 1px solid var(--line); gap: 4px; }
.cmat-tag-nav h2 { margin-top: 10px; }
.cmat-tag-nav h2:first-child { margin-top: 0; }
.cmat-folder[aria-current="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.cmat-shelf { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 12px 16px; }
.cmat-shelf h2 { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.cmat-group { display: flex; flex-direction: column; gap: 10px; }
.cmat-group h2 .cmat-count { margin-left: 4px; }
.cmat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }
.cmat-entry { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); min-width: 0; }
.cmat-entry-head { display: flex; gap: 12px; align-items: flex-start; }
.cmat-swatch-large { flex: none; width: 56px; height: 56px; border-radius: 8px; }
.cmat-entry-title { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cmat-entry h3 { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 0.9rem; font-weight: 600; }
.cmat-entry h3 a { color: inherit; }
.cmat-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.cmat-chip { display: inline-block; padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 99px; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); text-decoration: none; }
a.cmat-chip:hover { color: var(--ink); background: var(--sunk); }
.cmat-entry details summary { cursor: pointer; font-size: 0.75rem; color: var(--muted); }
.cmat-entry details[open] summary { margin-bottom: 6px; }
.cmat-tags { display: flex; gap: 8px; align-items: center; font-size: 0.8rem; }
.cmat-tags input[type="text"] { flex: 1; min-width: 0; font: inherit; font-family: var(--mono); padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sunk); color: var(--ink); }
.cmat-copies { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cmat-copy { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: center; padding: 8px; border-radius: 8px; background: var(--sunk); }
.cmat-copy .cmat-strip { grid-column: 2; }
.cmat-copy[data-state="superseded"] { opacity: 0.75; }
.cmat-version { width: 2.5em; font-family: var(--mono); font-size: 0.8rem; }
.cmat-strip { display: flex; gap: 4px; }
.cmat-strip .cmat-thumb { width: 36px; height: 36px; }
.cmat-slot { border-style: dashed; }
.cmat-copy-facts { display: flex; flex-direction: column; min-width: 0; }
.cmat-copy-facts > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmat-copy-facts a { color: inherit; }
@media (max-width: 1100px) {
  .cmat { flex: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .cmat-viewport { order: 1; height: 60vh; min-height: 320px; border-bottom: 1px solid var(--line); }
  .cmat-gallery { order: 2; border-right: 0; border-bottom: 1px solid var(--line); }
  .cmat-properties { order: 3; border-left: 0; }
  .cmat-tag-nav { border-right: 0; border-bottom: 1px solid var(--line); }
  .cmat-cards { grid-template-columns: minmax(0, 1fr); }
}
