/* =========================================================================
   The record drawer (feature-drawer.js and the drawers of the other pages):
   header context, tabs, sections, dynamic forms, files as rows and as
   tiles, the palette section, the lightbox. Tokens only.
   ========================================================================= */

/* ---- Header context, tabs, sticky footer ----------------------------------- */
.feature-head { margin-bottom: 14px; }
.feature-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.inspector-footer-spacer { flex: 1; }
.inspector-footer .btn-icon { flex: none; }
/* A context block under the title: a line of words and a row of badges. */
.drawer-context { padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.drawer-context-line { color: var(--fg-mute); font-size: 12.5px; }
.drawer-context-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
/* Tabs between the header and the body: one per section; a dot marks errors or unsaved edits. */
.drawer-tabs {
  flex: 0 0 auto; display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); background: var(--bg-1);
}
.drawer-tab {
  position: relative; padding: 10px 10px 9px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--fg-mute); font: 600 12.5px/1.2 var(--f-sans); letter-spacing: 0.01em; white-space: nowrap; cursor: pointer;
}
.drawer-tab:hover { color: var(--fg); }
.drawer-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--amber); }
.drawer-tab:focus-visible { outline: 2px solid var(--amber-line); outline-offset: -2px; }
.drawer-tab .tab-dot { position: absolute; top: 7px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.drawer-tab.has-error .tab-dot { background: var(--err); }
.drawer-pane[hidden] { display: none; }

/* ---- Sections (the stacked kind, kept for drawers that are not tabbed) ----- */
.drawer-section { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 12px; background: var(--bg-1); }
.drawer-section-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  background: var(--bg-2); border: none; border-bottom: 1px solid var(--line); color: var(--fg); text-align: left;
  font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; cursor: pointer;
}
.drawer-section.collapsed .drawer-section-head { border-bottom: none; }
.drawer-section.collapsed .drawer-section-caret { transform: rotate(-90deg); }
.drawer-section-caret { transition: transform var(--t-fast); color: var(--fg-dim); }
.drawer-section-body { padding: 14px 14px 4px; }
.drawer-section.collapsed .drawer-section-body { display: none; }

/* ---- Dynamic forms: two columns, wide fields span both -------------------- */
.dyn-form { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
.dyn-field-wide { grid-column: 1 / -1; }
.dyn-field-switch { display: flex; flex-direction: column; gap: 6px; }
.dyn-field-switch > span:first-child { margin-bottom: 0; }

/* ---- Files as rows (files-section.js) --------------------------------------- */
.files-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.files-upload { cursor: pointer; }
.files-list { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--bg-0); }
.file-thumb { width: 56px; height: 56px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--bg-2); overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--fg-dim); }
.file-meta { min-width: 0; flex: 1; }
.file-name { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tools { display: flex; gap: 2px; flex: none; }
.files-empty { margin: 4px 0 8px; }

/* ---- Files as tiles (ui/file-tiles.js) -------------------------------------- */
arc-file-tiles { display: block; border-radius: var(--r-md); }
arc-file-tiles.is-drop { outline: 2px dashed var(--amber); outline-offset: 4px; background: var(--amber-soft); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.tile.is-dragging { opacity: 0.4; }
.tile.is-over { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.tile-thumb {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; width: 100%; padding: 0;
  background: var(--bg-2); border: 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; overflow: hidden;
}
.tile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* A document's preview is a page: whole, on white — a PDF thumbnail with a transparent background read as a dark
   page on the dark tile (Eric, 2026-11-04). An image keeps the dark box and fills it. */
.tile[data-kind="document"] .tile-thumb { background: #fff; }
.tile[data-kind="document"] .tile-thumb img { object-fit: contain; }
.tile-thumb:hover img { opacity: 0.9; }
.tile-ext { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--fg-dim); font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.12em; }
.tile-body { padding: 8px 10px 9px; min-width: 0; }
.tile-name { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--fg); }
.tile-name:hover { color: var(--amber); }
.tile-caption { margin-top: 2px; font-size: 12px; color: var(--fg-mute); min-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-caption.is-empty { color: var(--fg-faint); font-style: italic; }
arc-file-tiles[data-can-edit] .tile-caption, .tile[draggable] .tile-caption { cursor: text; }
.tile-caption-input { width: 100%; padding: 2px 6px; font-size: 12px; }
.tile-meta { margin-top: 3px; font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--fg-dim); }
.tile-grip { position: absolute; top: 6px; left: 6px; display: none; padding: 2px; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line-bold); border-radius: var(--r-xs); cursor: grab; }
.tile-menu { position: absolute; top: 4px; right: 4px; display: none; background: var(--bg-2); border-color: var(--line-bold); }
.tile:hover .tile-grip, .tile:hover .tile-menu, .tile:focus-within .tile-menu { display: inline-flex; }
.tile-drop { border-style: dashed; border-color: var(--line-bold); background: transparent; align-items: stretch; }
.tile-drop-btn {
  flex: 1 1 auto; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: 0; color: var(--fg-mute); font: 600 12.5px var(--f-sans); cursor: pointer;
}
.tile-drop-btn small { font-weight: 400; font-size: 11px; color: var(--fg-dim); }
.tile-drop-btn:hover { color: var(--amber); background: var(--bg-1); }
.tiles-empty { margin: 8px 0 0; }

/* ---- The lightbox ------------------------------------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 3600; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 24px;
  background: var(--scrim); backdrop-filter: blur(4px);
}
.lightbox-figure { margin: 0; max-width: calc(100% - 120px); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox-figure img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border: 1px solid var(--line-bold); border-radius: var(--r-sm); background: var(--bg-1); }
.lightbox-figure figcaption { color: var(--fg-mute); font-size: 13px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; justify-content: center; }
.lightbox-figure figcaption strong { color: var(--fg); }
.lightbox-count { font-family: var(--f-mono); font-size: 11px; color: var(--fg-dim); }
.lightbox-close { position: absolute; top: 16px; right: 16px; }
.lightbox-nav { flex: none; }
.lightbox .btn-ghost { color: var(--fg); background: var(--bg-2); border-color: var(--line-bold); }
@media (max-width: 760px) { .lightbox { padding: 12px; gap: 4px; } .lightbox-figure { max-width: calc(100% - 70px); } }

/* ---- The palette section: a swatch beside each colour ---------------------- */
.palette-scheme { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; align-items: end; }
.palette-fill { grid-column: 1 / -1; margin: -4px 0 14px; }
.palette-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.palette-color { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 8px; align-items: end; }
.palette-color .form-field { margin-bottom: 14px; min-width: 0; }
.palette-swatch { width: 36px; height: 36px; margin-bottom: 14px; border: 1px solid var(--line-bold); border-radius: var(--r-sm); background: var(--bg-2) center / cover no-repeat; }
.palette-swatch.has-value { border-color: var(--line-hover); }
.palette-swatch[data-zoom], .preview-chip-swatch[data-zoom] { cursor: zoom-in; }
/* The blown-up swatch beside a palette swatch (palette-section.js #showZoom): fixed, on the page, above the drawer. */
.swatch-zoom { position: fixed; z-index: 1200; width: 262px; background: var(--bg-2); border: 1px solid var(--line-bold); border-radius: var(--r-md); box-shadow: var(--shadow-md); overflow: hidden; pointer-events: none; }
.swatch-zoom img { display: block; width: 260px; height: 260px; object-fit: cover; }
.swatch-zoom-cap { padding: 6px 10px; font-size: 12px; color: var(--fg); }

@media (max-width: 900px) {
  .dyn-form, .palette-colors { grid-template-columns: 1fr; }
  .palette-scheme { grid-template-columns: 1fr; }
}

/* ---- The lot drawer (feature-drawer.js, U3) ------------------------------- */
.inspector-lot .inspector-header { padding: 10px 12px 10px 18px; align-items: flex-start; }
.lot-head { display: flex; align-items: flex-start; gap: 8px; width: 100%; min-width: 0; }
.lot-head-main { flex: 1 1 auto; min-width: 0; }
.lot-title { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lot-title::first-letter { color: var(--amber); }
.lot-context { margin-top: 1px; font-size: 12px; color: var(--fg-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lot-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lot-approved-by { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--fg-dim); }
.lot-head-tools { display: inline-flex; align-items: center; gap: 6px; flex: none; }
/* The tools read as buttons (Eric: the faint glyphs did not say "click me"): bordered, a hover, a focus ring; the close is a circle. */
.drawer-tool {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  background: var(--bg-2); color: var(--fg-mute); border: 1px solid var(--line-bold); border-radius: 6px; cursor: pointer; font-size: inherit; line-height: 1;
}
.drawer-tool:hover:not(:disabled) { color: var(--fg); background: var(--bg-3); border-color: var(--fg-faint); }
.drawer-tool:focus-visible { outline: 2px solid var(--amber-line); outline-offset: 1px; }
.drawer-tool:disabled { opacity: 0.4; cursor: default; }
.drawer-tool.drawer-close { border-radius: 50%; margin-left: 4px; }
.drawer-tool.drawer-close:hover { color: var(--bg-1); background: var(--amber); border-color: var(--amber); }
#inspector-dock.inspector-docked { overflow: visible; }   /* the back tab hangs off the drawer's edge */
.lot-note { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 8px 10px; font-size: 12.5px; color: var(--amber); background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: var(--r-sm); }
.lot-dirty-note { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); margin-right: 4px; }
.inspector-lot .inspector-body { padding: 16px 18px; }
.files-block { margin-bottom: 18px; }
.files-count { font-family: var(--f-mono); font-size: 11px; color: var(--fg-dim); }
.files-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.files-head .section-label { margin: 0; }

/* Dynamic form fields (dyn-form.js): switch rows, required marks, dependent hints, bulk toggles. */
.dyn-label { display: block; font-family: var(--label-font); font-size: var(--label-size); font-weight: var(--label-weight); text-transform: var(--label-case); letter-spacing: var(--label-tracking); color: var(--fg-mute); margin-bottom: 6px; }
.dyn-req { color: var(--amber); font-weight: 600; }
.dyn-field-switch { display: block; }
.dyn-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 0 0 0 2px; cursor: pointer; }
.dyn-switch-row .dyn-label { margin: 0; }
.dyn-switch-row .switch { flex: none; }
/* Under a field, in running text — not the label style core gives a .form-field's spans. */
.dyn-form .form-field > .dyn-dep, .dyn-form .form-field > .dyn-hint { display: flex; align-items: center; gap: 4px; margin: 4px 0 8px; font-family: var(--font-body, inherit); font-size: 11.5px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--fg-dim); }
.dyn-dep .icon { color: var(--fg-dim); }
.dyn-field.is-loading .dyn-label::after { content: ''; display: inline-block; width: 9px; height: 9px; margin-left: 8px; vertical-align: -1px; border-radius: 50%; border: 1.5px solid var(--line-bold); border-top-color: var(--amber); animation: spin 700ms linear infinite; }
.dyn-form-toggles .dyn-field { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 0 12px; align-items: start; }
.dyn-form-toggles .dyn-field > label, .dyn-form-toggles .dyn-switch-row { grid-column: 2; min-width: 0; }
.dyn-form-toggles .dyn-dep, .dyn-form-toggles .dyn-hint { grid-column: 2; }
.dyn-form-toggles .dyn-set { margin-top: 22px; }
.dyn-form-toggles .dyn-field:not(.is-set) > label { opacity: 0.55; }
.dyn-form-toggles .dyn-field-switch .dyn-set { margin-top: 7px; }
.bulk-preview { margin: 4px 0 0; padding: 10px 12px; background: var(--bg-2); border-left: 2px solid var(--amber); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 13px; color: var(--fg); }

/* The palette tab (palette-section.js): preview strip, scheme pickers, colour rows. */
.palette-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; margin-bottom: 16px; background: var(--bg-0); border: 1px solid var(--line); border-radius: var(--r-md); min-height: 54px; align-items: center; }
.preview-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.preview-chip-swatch { width: 30px; height: 30px; border: 1px solid var(--line-bold); border-radius: var(--r-sm); background: var(--bg-2) center / cover no-repeat; }
.preview-chip-type { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-dim); }
.palette-fill { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: -4px 0 14px; }
.palette-fill-hint { margin: 0; }
.palette-rows { display: flex; flex-direction: column; gap: 6px; }
.palette-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 36px; gap: 10px; align-items: center; }
.palette-row-label { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-mute); }
.palette-row .palette-swatch { margin: 0; }
@media (max-width: 760px) { .palette-row { grid-template-columns: 72px minmax(0, 1fr) 30px; } }

/* The bulk bar over the map page (bulk-edit.js). */
.bulk-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 8;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; max-width: calc(100% - 32px);
  background: var(--bg-2); border: 1px solid var(--amber-line); border-radius: var(--r-md); box-shadow: var(--shadow-md); white-space: nowrap;
}
.bulk-bar strong { font-size: 13px; margin-right: 6px; }
.map-page { position: relative; }
.map-page[data-view="list"] .bulk-bar { bottom: 52px; }
