/* The Gallery window (js/gallery/ui.js, GAL1-GAL3). Colours, rims and text size come from the tokens, so every look and
   the light/dark switch reach it; nothing here is a colour of its own except the picture-free tile ground. */
.panel.gal-panel { width: min(1100px, calc(100% - 48px)); }
.gal { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; font-size: calc(14px * var(--ts)); }

/* the top row: three tabs at most at rest, three small icon buttons */
.gal-bar, .gal-sel, .gal-crumb { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--line); min-height: 52px; }
.gal-bar[hidden], .gal-sel[hidden], .gal-crumb[hidden], .gal-status[hidden], .gal-empty[hidden], .gal-undo[hidden], .gal-pop[hidden], .gal-viewer[hidden] { display: none; }
.gal-tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.gal-tab { flex: none; display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 6px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.gal-tab:hover { background: rgba(var(--tint), .06); }
.gal-tab[aria-selected="true"] { background: rgba(var(--tint), .1); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.gal-tab-c { font-size: .85em; color: var(--muted); font-variant-numeric: tabular-nums; }
.gal-tools { display: flex; gap: 4px; flex: none; }
.gal-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; padding: 0; color: var(--text); }
.gal-icon svg { display: block; }
.gal-tools .gal-icon[aria-expanded="true"] { background: rgba(var(--tint), .12); }
.gal .small { min-height: 44px; font-size: .92em; }

.gal-sel { background: rgba(var(--tint), .06); flex-wrap: wrap; }
.gal-sel-n { flex: 1; min-width: 4em; font-weight: 600; }
.gal-sel button { min-height: 44px; }
.gal-del { color: var(--text); }
.gal-sel .gal-del:hover { color: #ff7a6b; border-color: #ff7a6b; }

.gal-crumb { gap: 10px; }
.gal-crumb-n { font-weight: 650; }
.gal-crumb-note { flex: 1; color: var(--muted); font-size: .92em; }

.gal-status { margin: 0; padding: 6px 14px; display: flex; align-items: center; gap: 10px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: .92em; }
.gal-status span { flex: 1; }

/* the grid: one scroller; cells are placed by transform, so a size change moves them in the same frame */
.gal-main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.gal-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; outline: none; overscroll-behavior: contain; padding: 0; scrollbar-width: thin; }
/* kit/zoom-lock sets touch-action: none on own-zoom regions; one finger must still scroll here, two pinch (we handle it) */
.gal [data-own-zoom], .gal [data-own-zoom] * { touch-action: pan-y; }
.gal-sizer { position: relative; width: 100%; }
.gal-cell { position: absolute; left: 0; top: 0; overflow: hidden; border-radius: 3px; background: rgba(var(--tint), .1); cursor: pointer; contain: strict; -webkit-tap-highlight-color: transparent; user-select: none; }
.gal-px { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; }
.gal-cell.ready .gal-px { opacity: 1; }
.gal-cell.glyph::before { content: var(--glyph); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: clamp(14px, calc(var(--cell, 60px) * .4), 56px); color: var(--muted); }
.gal-cell.glyph::after { content: attr(data-ext); position: absolute; left: 4px; bottom: 3px; font-size: 10px; letter-spacing: .06em; color: var(--muted); }
.gal-cell.broken::before { content: "▫"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.gal-cell.focus { outline: 3px solid var(--accent); outline-offset: -3px; }
.gal-cell.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.gal-cell.selected .gal-px { transform: scale(.88); border-radius: 6px; transition: transform var(--mo-fast, .12s) ease; }
html[data-motion="reduce"] .gal-cell.selected .gal-px { transition: none; }
.gal-badge { position: absolute; right: 4px; bottom: 3px; padding: 1px 6px; border-radius: 99px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; line-height: 1.5; }
.gal-badge:empty { display: none; }
.gal-tick { position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; display: none; align-items: center; justify-content: center; background: rgba(0, 0, 0, .45); color: #fff; border: 2px solid #fff; }
.gal-tick svg { width: 16px; height: 16px; opacity: 0; }
.gal-cell.selecting .gal-tick, .gal-cell:hover .gal-tick { display: flex; }
.gal-cell.selected .gal-tick { background: var(--accent); border-color: #fff; display: flex; }
.gal-cell.selected .gal-tick svg { opacity: 1; stroke: var(--on-accent, #000); }
@media (pointer: coarse) { .gal-cell:not(.selecting):hover .gal-tick { display: none; } }
.gal-scroll[hidden] { display: none; }

/* nothing here yet: one clear first step, the rest quiet */
.gal-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.gal-empty h3 { margin: 0; font-size: 1.25em; font-family: var(--font-head); }
.gal-empty p { margin: 0; max-width: 34em; color: var(--muted); }
.gal-empty-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gal-empty-row button, .gal-add, .gal-pop button { min-height: 44px; }
.gal-fine { color: var(--muted); font-size: .88em; }

/* the Undo line sits in the window, over nothing that can be pressed */
.gal-undo { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); padding: 8px 8px 8px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--rim, var(--line)); box-shadow: 0 8px 28px var(--shadow); }
.gal-undo .solid { min-height: 44px; }

/* the three small menus */
.gal-pop { position: absolute; z-index: 4; overflow-y: auto; padding: 10px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--rim, var(--line)); box-shadow: 0 16px 40px var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.gal-pop h3 { margin: 8px 4px 2px; font-size: .8em; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.gal-row { display: flex; align-items: center; gap: 6px; }
.gal-row-main { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 6px 10px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
button.gal-row-main:hover { background: rgba(var(--tint), .08); }
.gal-row-n { overflow-wrap: anywhere; }
.gal-row-c { color: var(--muted); font-size: .88em; text-align: right; flex: none; }
.gal-src-n { flex-direction: column; align-items: flex-start; gap: 0; }
.gal-src-n .gal-row-c { text-align: left; }
.gal-new { display: flex; gap: 6px; }
.gal-new input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(var(--tint), .06); color: var(--text); font: inherit; }
.gal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gal-field { display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.gal-field > span { color: var(--muted); font-size: .88em; }
.gal-field input[type=range] { width: 100%; min-height: 44px; accent-color: var(--accent); }
.gal-field select { min-height: 44px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(var(--tint), .06); color: var(--text); font: inherit; }
.gal-out { color: var(--muted); font-size: .88em; }

/* one picture: fills the window; the grid under it is kept as it was */
.gal-viewer { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--glass-strong); }
.gal-vhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); min-height: 52px; }
.gal-back { min-height: 44px; display: inline-flex; align-items: center; }
.gal-vname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.gal-vbody { position: relative; flex: 1; min-height: 0; background: #000; }
.gal-vbody .lc { position: absolute; inset: 0; }

@media (max-width: 560px) {
  .panel.gal-panel { width: 100%; height: calc(100% - var(--dock-h)); top: calc(50% - var(--dock-h) / 2); border-radius: 0; }
  .gal-tab { padding: 6px 10px; }
  .gal-bar, .gal-sel, .gal-crumb { padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) { .gal-cell.selected .gal-px { transition: none; } }
