/* Image Library — styles
   Light table palette: cool grey surface so photos read true, one accent for actions. */

:root {
  --accent: #3346d3;
  --accent-ink: #ffffff;
  --accent-text: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);

  --surface: #e9ecef;
  --panel: #f7f8f9;
  --raised: #ffffff;
  --stage: #dde1e6;
  --ink: #18202b;
  --ink-2: #566070;
  --ink-3: #848d9a;
  --line: #d2d7de;
  --hover: color-mix(in srgb, var(--ink) 6%, transparent);
  --hover-strong: color-mix(in srgb, var(--ink) 10%, transparent);
  --checker-a: #f3f4f6;
  --checker-b: #dfe2e7;
  --danger: #b42323;
  --ok: #18794e;
  --shadow: 0 24px 60px -16px rgb(15 22 35 / 0.35);

  --row-h: 220px;
  --gap: 10px;
  --top-h: 60px;
  --side-w: 232px;

  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-text: color-mix(in srgb, var(--accent) 60%, white);
    --accent-soft: color-mix(in srgb, var(--accent) 24%, transparent);
    --surface: #1c1e22;
    --panel: #24272c;
    --raised: #2b2f35;
    --stage: #202227;
    --ink: #e8eaed;
    --ink-2: #a3abb6;
    --ink-3: #7b8490;
    --line: #383c43;
    --checker-a: #34373d;
    --checker-b: #2a2d32;
    --danger: #f07a7a;
    --ok: #5fd39a;
    --shadow: 0 24px 60px -16px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-text: color-mix(in srgb, var(--accent) 60%, white);
  --accent-soft: color-mix(in srgb, var(--accent) 24%, transparent);
  --surface: #1c1e22;
  --panel: #24272c;
  --raised: #2b2f35;
  --stage: #202227;
  --ink: #e8eaed;
  --ink-2: #a3abb6;
  --ink-3: #7b8490;
  --line: #383c43;
  --checker-a: #34373d;
  --checker-b: #2a2d32;
  --danger: #f07a7a;
  --ok: #5fd39a;
  --shadow: 0 24px 60px -16px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
code { font-family: var(--mono); font-size: 0.92em; }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.only-narrow { display: none !important; }
.noscript { padding: 24px; text-align: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--raised); color: var(--ink);
  font-weight: 550; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 28%, var(--line)); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 86%, black); border-color: color-mix(in srgb, var(--accent) 86%, black); }
.btn-lg { height: 46px; width: 100%; font-size: 15px; }
.btn-quiet-danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn-quiet-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: transparent; }
.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { width: 30px; height: 30px; }
.linklike {
  border: 0; background: none; padding: 0;
  color: var(--accent-text); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  width: calc(var(--side-w) - 30px); min-width: 0;
  color: var(--ink); text-decoration: none;
  font-size: 16px; font-weight: 650; letter-spacing: -0.01em;
}
.brand-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 22px; height: 22px; flex: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
}
.brand-mark i { border-radius: 2px; background: var(--accent); }
.brand-mark i:nth-child(2) { opacity: .55; }
.brand-mark i:nth-child(3) { opacity: .3; }
.brand-mark i:nth-child(4) { opacity: .8; }

.search { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.search > [data-icon] { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 40px 0 36px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--raised);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search kbd {
  position: absolute; right: 9px;
  padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px;
  font: 500 11px/1.4 var(--mono); color: var(--ink-3);
  pointer-events: none;
}
.search input:not(:placeholder-shown) ~ kbd, .search input:focus ~ kbd { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-upload { margin-right: 4px; }

.deploy-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px; margin-right: 4px;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout + sidebar ---------- */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--top-h);
  height: calc(100dvh - var(--top-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 12px 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.side-section + .side-section { margin-top: 24px; }
.side-h { margin: 0 10px 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.folder-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.folder {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px 6px calc(10px + max(var(--depth, 0) - 1, 0) * 14px);
  border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2);
  text-align: left;
}
.folder:hover { background: var(--hover); color: var(--ink); }
.folder.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder[data-depth="2"] .folder-name::before,
.folder[data-depth="3"] .folder-name::before,
.folder[data-depth="4"] .folder-name::before { content: "/ "; color: var(--ink-3); }
.folder-count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.folder.active .folder-count { color: inherit; }
.folder-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.folder-heading .side-h { margin: 0 0 0 10px; }
.btn-new-folder { height: 30px; padding: 0 8px; gap: 5px; font-size: 12px; }
.btn-new-folder svg { width: 15px; height: 15px; }
.folder-label { display: flex; align-items: center; gap: 7px; min-width: 0; }
.folder-label svg { width: 16px; height: 16px; }
.folder-rename { display: flex; align-items: center; gap: 7px; padding: 7px 10px; margin-top: 8px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); font-size: 12px; }
.folder-rename:hover { background: var(--hover); color: var(--ink); }
.folder-rename svg { width: 15px; height: 15px; }
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
.chip {
  height: 28px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--ink-2);
  font-size: 12px; font-weight: 600;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.scrim { position: fixed; inset: 0; z-index: 45; background: rgb(12 16 22 / .45); }

/* ---------- main + toolbar ---------- */
.main { min-width: 0; padding: 16px 20px 48px; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px;
  margin-bottom: 14px;
}
.count { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.count strong { color: var(--ink); font-weight: 600; margin-right: 8px; }
.tools { display: flex; align-items: center; gap: 10px; }
.selection-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; padding: 12px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 10px; background: var(--accent-soft); }
.selection-bar p { margin: 0; font-weight: 600; }
.selection-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
#selectImagesBtn[aria-pressed="true"] { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.select { position: relative; display: block; }
.select select {
  appearance: none; -webkit-appearance: none;
  height: 34px; padding: 0 32px 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--raised);
}
.select::after {
  content: ""; position: absolute; right: 13px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); }
.seg button {
  width: 32px; height: 28px; border: 0; border-radius: 6px;
  display: grid; place-items: center;
  background: transparent; color: var(--ink-3);
}
.seg button[aria-pressed="true"] { background: var(--hover-strong); color: var(--ink); }
.size { display: flex; align-items: center; }
.size input { width: 110px; accent-color: var(--accent); }

/* ---------- grid ---------- */
.grid { --h: var(--row-h); gap: var(--gap); }
.grid.rows { display: flex; flex-wrap: wrap; }
.grid.rows::after { content: ""; flex-grow: 999999999; }
.grid.rows .tile { flex: var(--r) 1 calc(var(--r) * var(--h)); max-width: calc(var(--r) * var(--h) * 2); }
.grid.rows .tile:only-child { max-width: none; }
.grid.squares { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--h), 1fr)); }

.tile {
  position: relative; min-width: 0;
  border-radius: 6px; overflow: hidden;
  background: var(--tile-bg, var(--stage));
  transition: outline-color .2s;
  outline: 2px solid transparent; outline-offset: 2px;
}
.tile.alpha, #dImg.alpha {
  background-color: var(--checker-a);
  background-image: conic-gradient(var(--checker-b) 25%, transparent 0 50%, var(--checker-b) 0 75%, transparent 0);
  background-size: 16px 16px;
}
.tile-hit {
  display: block; width: 100%; aspect-ratio: var(--r);
  padding: 0; border: 0; background: none;
  cursor: zoom-in;
}
.grid.squares .tile-hit { aspect-ratio: 1; }
.grid.squares .tile.alpha .tile-hit img { padding: 12%; }
.tile-hit img { display: block; width: 100%; height: 100%; object-fit: contain; }
.tile-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 26px 10px 8px;
  background: linear-gradient(to top, rgb(8 12 18 / .7), transparent);
  color: #fff; font-size: 12px;
  opacity: 0; transition: opacity .15s;
  pointer-events: none;
}
.tile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-dim { flex: none; opacity: .8; font-variant-numeric: tabular-nums; }
.tile-copy {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: rgb(255 255 255 / .94); color: #18202b;
  box-shadow: 0 1px 3px rgb(0 0 0 / .25);
  opacity: 0; transition: opacity .15s, background-color .15s;
}
.tile-copy:hover { background: #fff; }
.tile:hover .tile-meta, .tile:focus-within .tile-meta,
.tile:hover .tile-copy, .tile:focus-within .tile-copy { opacity: 1; }
.tile.flash { outline-color: var(--accent); }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile-select { display: none; position: absolute; top: 8px; left: 8px; z-index: 2; width: 32px; height: 32px; align-items: center; justify-content: center; border: 2px solid #9aa3b2; border-radius: 8px; background: rgb(255 255 255 / .96); color: transparent; box-shadow: 0 1px 3px rgb(0 0 0 / .2); }
.grid.selecting .tile-select { display: inline-flex; }
.tile-select[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: white; }
.tile-select[disabled] { opacity: .45; cursor: not-allowed; }
.grid.selecting .tile-meta { opacity: 1; }
.grid.selecting .tile-badge { top: 45px; }
.tile-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 600;
}
.sentinel { height: 1px; }
@media (hover: none) {
  .tile-copy { opacity: .9; width: 30px; height: 30px; }
}

/* ---------- empty + error ---------- */
.empty { max-width: 470px; margin: 12vh auto 0; text-align: center; color: var(--ink-2); }
.empty h2 { margin: 0 0 8px; color: var(--ink); font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.empty p { margin: 0; }
.empty .btn { margin-top: 18px; }

/* ---------- dialogs ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgb(10 14 20 / .55); }
.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: fade .14s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 10px 20px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.foot-status { margin: 0 auto 0 0; font-size: 13px; color: var(--ink-2); }
.foot-left { margin-right: auto; }
.lede { margin: 0 0 16px; color: var(--ink-2); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select, .num {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--raised);
}
.field textarea { resize: vertical; min-height: 60px; line-height: 1.45; }
.field input:focus, .field textarea:focus, .field select:focus, .num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal > form { display: flex; flex-direction: column; min-height: 0; }
.organization-status { margin: 12px 0 0; min-height: 1.4em; color: var(--ink-2); overflow-wrap: anywhere; }
.organization-status.error { color: var(--danger); }
.move-hint { margin-top: 16px; }
.org-connect { margin-bottom: 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.hint { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.set-status { margin: 0; min-height: 1.4em; font-weight: 550; }
.set-status.ok { color: var(--ok); }
.set-status.bad { color: var(--danger); }

.notice { margin-bottom: 4px; padding: 14px 16px; border-radius: 10px; background: var(--accent-soft); }
.notice p { margin: 0 0 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

.drop {
  padding: 26px 16px; text-align: center;
  border: 1.5px dashed color-mix(in srgb, var(--ink) 24%, var(--line)); border-radius: 12px;
  background: var(--raised);
  transition: border-color .12s, background-color .12s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop p { margin: 0; }
.drop p + p { margin-top: 4px; }
.up-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 248px; overflow-y: auto; }
.up-list:empty { display: none; }
.up-item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised);
}
.up-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--stage); }
.up-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-sub { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.up-sub .warn { color: var(--danger); }
.up-state { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.up-state.working, .up-state.sending { color: var(--accent-text); }
.up-state.done { color: var(--ok); }
.up-state.error { color: var(--danger); }
.opts { margin: 16px 0 0; padding: 0; border: 0; display: grid; gap: 9px; }
.opts legend { padding: 0; margin-bottom: 9px; font-size: 13px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 9px; }
.check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.num { width: 82px; padding: 4px 8px; }

/* ---------- detail view ---------- */
.detail {
  width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  background: var(--panel);
}
.detail::backdrop { background: var(--stage); }
.detail[open] { display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.detail-stage {
  position: relative; min-height: 0; overflow: hidden;
  display: grid; place-items: center;
  background: var(--stage);
}
#dImg {
  display: block; max-width: 100%; max-height: 100%;
  border-radius: 3px;
  box-shadow: 0 12px 40px -14px rgb(0 0 0 / .45);
}
#dImg.alpha { box-shadow: none; }
.nav-btn {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--panel); color: var(--ink);
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.nav-btn.prev { left: 20px; }
.nav-btn.next { right: 20px; }
.nav-btn[disabled] { opacity: .3; cursor: default; }
.stage-counter { position: absolute; left: 22px; top: 16px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stage-close { position: absolute; top: 8px; right: 8px; background: var(--panel); }

.detail-side {
  display: flex; flex-direction: column; gap: 18px;
  padding: 14px 20px 28px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.d-name { margin: 6px 0 0; font-size: 18px; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.d-folder {
  align-self: flex-start; margin-top: -10px;
  padding: 4px 11px; border: 0; border-radius: 999px;
  background: var(--hover); color: var(--ink-2);
  font-size: 12.5px; font-weight: 550;
}
.d-folder:hover { background: var(--hover-strong); color: var(--ink); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.facts dt { font-size: 12px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 560; font-variant-numeric: tabular-nums; }

.snippet { border: 1px solid var(--line); border-radius: 11px; background: var(--raised); overflow: hidden; }
.fmt-tabs { display: flex; padding: 0 6px; border-bottom: 1px solid var(--line); }
.fmt-tabs button {
  flex: 1; padding: 10px 4px 9px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--ink-3);
  font-size: 13px; font-weight: 600;
}
.fmt-tabs button:hover { color: var(--ink); }
.fmt-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.code {
  margin: 0; padding: 13px 14px; min-height: 66px; max-height: 150px; overflow: auto;
  font: 12.5px/1.6 var(--mono); color: var(--ink);
  white-space: pre-wrap; word-break: break-all;
}
.snippet .btn-lg { border-radius: 0; border-width: 1px 0 0; }
.meta-save { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -8px; }
.detail-side .field { margin-bottom: -4px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.d-actions .btn { flex: 1; }
#dDelete { align-self: flex-start; margin-top: -6px; padding: 0 10px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; left: 50%; bottom: 22px; z-index: 100;
  translate: -50% 0;
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
}
.toast {
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--panel);
  font-size: 13.5px; font-weight: 560;
  box-shadow: 0 10px 30px -8px rgb(0 0 0 / .4);
  opacity: 0; translate: 0 8px;
  transition: opacity .18s, translate .18s;
}
.toast.in { opacity: 1; translate: 0 0; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .only-narrow { display: grid !important; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .brand { width: auto; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(300px, 84vw); height: 100dvh;
    transform: translateX(-102%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .detail[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56dvh auto; overflow-y: auto; }
  .detail-side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .detail-side .side-head .icon-btn { display: none; }
  .nav-btn { width: 38px; height: 38px; }
  .nav-btn.prev { left: 8px; }
  .nav-btn.next { right: 8px; }
  .stage-counter { left: 14px; top: 14px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-title, .btn-upload .btn-label, .pill-text, .search kbd { display: none; }
  .btn-upload { padding: 0 10px; margin-right: 0; }
  .deploy-pill { padding: 0 9px; }
  .main { padding: 12px 10px 36px; }
  .size { display: none; }
  .grid { --h: calc(var(--row-h) * .62); --gap: 6px; }
  .field-grid { grid-template-columns: 1fr; }
  .tools { flex-wrap: wrap; gap: 7px; }
  .selection-actions { width: 100%; }
  .selection-actions .btn { height: 34px; padding: 0 9px; font-size: 12px; }
  .selection-bar { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
}
