/* Contact sheet layout; colors and shared components come from theme.css. */
:root { --tile:180px; }
select, label.ctl { font:inherit; font-size:13px; color:var(--dim); }
select { color:var(--text); background:var(--raised); border:1px solid var(--line); border-radius:6px; padding:4px 8px; }
label.ctl { display:inline-flex; align-items:center; gap:6px; }
input[type=range] { width:90px; accent-color:var(--accent); }

.menu { position:fixed; inset:auto; margin:0; padding:6px; min-width:240px; background:var(--raised); color:var(--text);
        border:1px solid var(--line); border-radius:8px; box-shadow:0 10px 30px #0008; }
.menu button { display:flex; align-items:center; gap:8px; width:100%; background:none; border:0; border-radius:5px; color:var(--text);
               padding:6px 8px 6px 28px; font:inherit; font-size:13px; text-align:left; cursor:pointer; position:relative; }
.menu button:hover { background:#ffffff12; }
.menu button.on::before { content:'✓'; position:absolute; left:9px; color:var(--accent); }
.menu button kbd { margin-left:auto; }
.menu hr { border:0; border-top:1px solid var(--line); margin:5px 0; }
.menu p { margin:6px 8px 2px; color:var(--dim); font-size:11px; line-height:1.8; }
#scopes .meta { gap:8px; }
#scopes .meta .seg button { padding:3px 9px; font-size:12px; }
#scopes .meta button.pick { padding:3px 9px; font-size:12px; }

#seqs { position:sticky; top:49px; z-index:4; display:flex; flex-wrap:wrap; gap:6px; padding:8px 20px; background:rgba(14,15,17,.92);
        backdrop-filter:blur(8px); border-bottom:1px solid var(--line); }
#seqs button { display:inline-flex; align-items:center; gap:6px; background:var(--panel); color:var(--dim); border:1px solid var(--line);
               border-radius:14px; padding:3px 10px 3px 4px; cursor:pointer; font:12px/1.4 inherit; font-family:inherit; }
#seqs button:hover { color:var(--text); border-color:var(--dim); }
#seqs button.on { color:var(--text); border-color:var(--accent); background:#14202f; }
#seqs button i { width:14px; height:14px; border-radius:50%; border:1px solid #0006; }
#seqs button small { color:var(--dim); }
#seqs button.all { padding-left:10px; }

main { display:grid; grid-template-columns:minmax(0,1fr) 420px; gap:20px; padding:20px; align-items:start; }
@media (max-width:1100px) { main { grid-template-columns:1fr; } #scopes { position:static !important; max-height:none !important; } }
#left { min-width:0; }

/* The timeline stays pinned under the sequence bar while the grid scrolls beneath it; the shadows paint the
   page background into the gaps above and below so tiles don't show through. */
#tl-card { position:sticky; top:var(--sticky, 105px); z-index:3; margin-bottom:20px; box-shadow:0 -20px 0 var(--bg), 0 20px 0 var(--bg); }
#tl-card .meta span { overflow:hidden; text-overflow:ellipsis; }
#timeline { display:block; width:100%; height:236px; cursor:crosshair; touch-action:none; }

#scopes { position:sticky; top:calc(var(--sticky, 105px) + 12px); max-height:calc(100vh - var(--sticky, 105px) - 24px); overflow:auto; }
#scopes .cells { grid-template-columns:1fr; }
#scopes .cells > div { min-height:0; }
#scope-title { overflow:hidden; text-overflow:ellipsis; min-width:0; }
#summary { padding:10px 14px; font-size:12px; color:var(--dim); display:grid; grid-template-columns:auto 1fr; gap:3px 12px; border-top:1px solid var(--line); }
#summary b { color:var(--text); font-weight:500; font-variant-numeric:tabular-nums; }
#summary .pal { grid-column:1 / -1; display:flex; height:16px; border-radius:4px; overflow:hidden; margin-top:6px; }
#summary .actions { grid-column:1 / -1; display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.hint { margin:0; padding:10px 14px 14px; color:var(--dim); font-size:12px; line-height:1.6; border-top:1px solid var(--line); }

.group { margin-bottom:22px; }
.ghead { display:flex; align-items:center; gap:12px; margin:0 0 8px; padding:6px 2px; cursor:pointer; border-bottom:1px solid var(--line); }
.ghead b { font-size:14px; }
.ghead .name { color:var(--text); text-transform:capitalize; }
.ghead span { color:var(--dim); font-size:12px; white-space:nowrap; }
.ghead .strip { flex:1; display:flex; height:10px; min-width:40px; border-radius:3px; overflow:hidden; }
.ghead .strip i { flex:1; }
.ghead:hover b { color:var(--accent); }

.tiles { display:grid; grid-template-columns:repeat(auto-fill, minmax(var(--tile), 1fr)); gap:8px; }
.tile { scroll-margin:calc(var(--sticky, 105px) + var(--tl-h, 0px) + 28px) 0 8px; position:relative; background:var(--panel); border:1px solid var(--line); border-radius:6px; overflow:hidden; cursor:pointer;
        transition:opacity .12s; user-select:none; }
.tile img { display:block; width:100%; aspect-ratio:2 / 1; object-fit:cover; background:#000; }
.tile .pal { display:flex; height:5px; }
.tile .cap { display:flex; gap:6px; padding:3px 7px; font-size:11px; color:var(--dim); white-space:nowrap; overflow:hidden; }
.tile .cap b { color:var(--text); font-weight:500; }
.tile .cap .sp { flex:1; }
.tile:hover { border-color:var(--dim); }
.tile.sel { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.tile.dim { opacity:.18; }
.tile.flag { border-color:var(--danger); }
.tile.flag::after { content:'!'; position:absolute; top:4px; left:4px; width:16px; height:16px; border-radius:50%; background:var(--danger);
                    color:#000; font:700 11px/16px sans-serif; text-align:center; }
.tile .badge { position:absolute; top:4px; right:4px; background:#000c; color:#ffd24a; border-radius:4px; padding:1px 5px; font:11px ui-monospace,Menlo,monospace; }
.tile.err img { opacity:.2; }
.flat .tiles { margin-top:0; }

#lightbox { position:fixed; inset:0; z-index:40; background:#000; display:flex; flex-direction:column; }
.lb-body { flex:1; min-height:0; display:flex; }
#lb-side:empty { display:none; }
#lb-side { width:420px; flex-shrink:0; border-left:1px solid var(--line); overflow:auto; }
#lb-side #scopes { position:static; max-height:none; border:0; border-radius:0; }
.lb-bar { display:flex; gap:12px; align-items:center; padding:10px 20px; border-bottom:1px solid var(--line); background:var(--panel); }
.lb-bar span { color:var(--dim); font-size:12px; }
.lb-stage { flex:1; min-width:0; min-height:0; display:flex; align-items:center; justify-content:center; padding:16px; }
#lightbox:fullscreen .lb-stage { padding:0; }
#lb-wrap { flex:none; width:auto; }
#lb-img { display:block; width:100%; height:100%; }
#lb-mask { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }

/* looks: body[data-look] filters the images; SVG filters are built in contact.js */
body[data-look=bw] .tile img, body[data-look=bw] #lb-img { filter:url(#look-bw); }
body[data-look=false] .tile img, body[data-look=false] #lb-img { filter:url(#look-false); }
body[data-look=clip] .tile img, body[data-look=clip] #lb-img { filter:url(#look-clip); }
body[data-look=hue] .tile img, body[data-look=hue] #lb-img { filter:url(#look-hue); }
body[data-look=delta] .tile img { filter:url(#look-bw) brightness(1.3); }
.tile .delta, .tile .dtext { display:none; }
body[data-look=delta] .tile .delta { display:block; position:absolute; top:0; left:0; right:0; aspect-ratio:2 / 1; mix-blend-mode:color; pointer-events:none; }
body[data-look=delta] .tile .dtext { display:block; position:absolute; left:4px; top:4px; }
body[data-look=delta] .tile.flag .dtext { left:24px; }
.tile { container-type:inline-size; }
.tile .dtext { max-width:calc(100% - 8px); overflow:hidden; font-size:clamp(8px, 6.5cqw, 11px) !important; background:#000c; border-radius:4px; padding:1px 5px; font:10px/1.4 ui-monospace,Menlo,monospace; color:#ccc; white-space:nowrap; pointer-events:auto; }
.tile .dtext b, #legend b { font-weight:400; }
.tile .dtext b.hi, #legend b.hi { color:var(--danger); }
#legend .note { color:var(--dim); }
body[data-look=sat] .tile img, body[data-look=sat] #lb-img { filter:saturate(3); }
body[data-look=blur] .tile img { filter:blur(calc(var(--tile) / 18)); transform:scale(1.08); }
body[data-look=blur] #lb-img { filter:blur(24px); }
.tile .swatch { display:none; position:absolute; top:0; left:0; right:0; aspect-ratio:2 / 1; }
body[data-look=palette] .tile .swatch { display:flex; }
body[data-look=mean] .tile .swatch { display:block; }
body[data-look=mean] .tile .swatch i { display:none; }
#legend { position:fixed; z-index:45; left:50%; bottom:14px; transform:translateX(-50%); display:flex; gap:3px; align-items:center;
          padding:5px 8px; background:#000d; border:1px solid var(--line); border-radius:8px; font-size:11px; color:#000; backdrop-filter:blur(6px); }
#legend i { font-style:normal; padding:1px 5px; border-radius:3px; white-space:nowrap; }

/* view toggles (body classes set from the View buttons) */
/* Images only: one continuous grid, sequences flow into each other without starting a new row. */
body.clean #grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(var(--tile), 1fr)); gap:2px; }
body.clean .group, body.clean .tiles { display:contents; }
body.clean .tile { border:0; border-radius:0; background:#000; }
body.clean .tile .pal, body.clean .tile .cap, body.clean .ghead { display:none; }
body.clean .tile.sel { box-shadow:none; }
body.clean .tile.sel::before { content:''; position:absolute; inset:0; z-index:1; box-shadow:inset 0 0 0 2px var(--accent); pointer-events:none; }
body.no-timeline #tl-card, body.no-scopes main > #scopes, body.no-seqs #seqs { display:none; }
body.no-scopes main { grid-template-columns:1fr; }
body.focus header, body.focus #seqs, body.focus #tl-card, body.focus main > #scopes { display:none; }
body.focus main { grid-template-columns:1fr; padding:2px; }
#focus-exit { display:none; position:fixed; top:10px; right:10px; z-index:35; opacity:.25; transition:opacity .15s; background:#000c; }
body.focus #focus-exit { display:inline-flex; gap:8px; align-items:center; }
#focus-exit:hover, #focus-exit:focus-visible { opacity:1; }
#lb-side #summary .actions, #lb-side .hint { display:none; }
#scopes .meta .seg, #scopes .meta button, #scope-n { flex-shrink:0; }

/* Update images dialog */
#stills { padding:0; border:1px solid var(--line); border-radius:10px; background:var(--panel); color:var(--text); width:min(460px, 92vw);
          box-shadow:0 20px 60px #000a; }
#stills::backdrop { background:#0009; }
#stills .panel { padding:16px 18px 14px; }
#stills header { position:static; padding:0 0 8px; border:0; background:none; backdrop-filter:none; justify-content:space-between; flex-wrap:nowrap; }
#stills h2 { margin:0; font-size:15px; }
#stills h3 { margin:12px 0 6px; font-size:12px; font-weight:600; color:var(--dim); text-transform:uppercase; letter-spacing:.04em; }
#stills .hint { margin:0; color:var(--dim); font-size:12px; line-height:1.5; }
#stills-tasks { display:grid; grid-template-columns:1fr 1fr; gap:4px 12px; }
#stills-tasks label { display:flex; align-items:center; gap:8px; font-size:13px; padding:3px 0; cursor:pointer; }
#stills-tasks input { accent-color:var(--accent); }
#stills .actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:14px; }
#stills-status { flex-basis:100%; min-height:1.5em; }
#stills-status.error { color:var(--danger); }
