/* Magpie interface. The images are the content: hairlines, room to breathe, nothing loud but Pip. */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
kbd {
  font: 500 12px/1 var(--font);
  padding: 2px 5px;
  border: var(--hairline);
  border-bottom-width: 2px;
}

/* The pixel face: 8px or 16px only, uppercase labels. */
.pixel {
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0;
}
.pixel-sm {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1;
  text-transform: uppercase;
}
.dim {
  color: var(--ink-dim);
}

/* Stepped 2px corners: the one 16-bit gesture on controls. */
.stepped {
  clip-path: polygon(
    0 4px, 2px 4px, 2px 2px, 4px 2px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 2px, calc(100% - 2px) 2px, calc(100% - 2px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px), calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 2px), 2px calc(100% - 2px), 2px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  background: var(--raised);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
.btn:hover {
  box-shadow: inset 0 0 0 1px var(--ink-dim);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 3px 3px 0 0 var(--shadow);
  margin-right: 3px;
}
.btn-primary:hover {
  box-shadow: 2px 2px 0 0 var(--shadow);
  transform: translate(1px, 1px);
}
.btn-primary:active {
  box-shadow: none;
  transform: translate(3px, 3px);
}
.btn-quiet {
  background: transparent;
  box-shadow: none;
}
.btn-quiet:hover {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-danger {
  color: var(--danger);
}
.btn-danger.btn-solid {
  background: var(--danger);
  color: var(--bg);
  box-shadow: none;
}
.btn-big {
  min-height: 52px;
  width: 100%;
  font-size: 17px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--accent-soft);
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- header and Pip's perch ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: var(--header);
  padding: 0 var(--gutter) 12px calc(var(--gutter) - 8px);
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: var(--hairline);
}
.perch {
  /* Pip stands on the header's bottom hairline. His cell is set from JS (whole device pixels);
     the feet are on row 89 of 96, so the cell hangs 6 art pixels below the perch line. */
  position: relative;
  align-self: flex-end;
  width: var(--pip-cell, 96px);
  height: var(--pip-cell, 96px);
  margin-bottom: calc(-12px - var(--pip-cell, 96px) * 6 / 96);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.perch:focus-visible {
  outline-offset: -8px;
}
#pip {
  display: block;
}
:root[data-pip-edge='1'] #pip {
  /* One art pixel of cream around Pip on dark backgrounds, so his dark outline doesn't sink. */
  filter: drop-shadow(var(--pip-px) 0 0 var(--pip-edge-color)) drop-shadow(calc(var(--pip-px) * -1) 0 0 var(--pip-edge-color))
    drop-shadow(0 var(--pip-px) 0 var(--pip-edge-color)) drop-shadow(0 calc(var(--pip-px) * -1) 0 var(--pip-edge-color));
}
:root {
  --pip-edge-color: rgb(244 235 230 / 0.55);
}
.brand {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  line-height: 40px;
  /* Pip's cell has about 20 art pixels of empty space on his right; pull the wordmark in. */
  margin-left: calc(var(--pip-cell, 96px) * -14 / 96);
}
.status {
  border: 0;
  background: none;
  padding: 0 0 2px;
  color: var(--teal);
  cursor: pointer;
  line-height: 40px;
}
.status:hover {
  color: var(--accent);
}
.spacer {
  flex: 1;
}
.storage-warn {
  color: var(--danger);
  line-height: 40px;
}
.bar .icon-btn {
  margin-bottom: -2px;
}

/* ---------- wall ---------- */
main {
  padding: var(--gap) var(--gutter) 120px;
}
.wall {
  position: relative;
  min-height: 1px;
}
.tile {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: zoom-in;
  overflow: hidden;
  contain: strict;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  opacity: 0;
  transition: opacity 0.25s;
}
.tile img.loaded {
  opacity: 1;
}
.tile:hover {
  box-shadow: 0 0 0 1px var(--ink-dim);
}
.tile:focus-visible {
  outline-offset: 3px;
}
.tile .badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 4px 5px 3px;
  background: var(--bg);
  color: var(--teal);
  box-shadow: 0 0 0 1px var(--line);
}
.tile .fav {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 20px;
  background: var(--bg);
  color: var(--accent);
}
.tile.pending {
  cursor: progress;
}
.tile.pending::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--progress, 0.1));
  transition: transform 0.2s;
}
.tile.failed {
  box-shadow: 0 0 0 2px var(--danger);
}

.empty {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--ink-dim);
}
.empty .pixel {
  color: var(--ink);
  margin-bottom: 14px;
}

/* ---------- drop frame ---------- */
.drop-frame {
  position: fixed;
  inset: 10px;
  z-index: 60;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  pointer-events: none;
  color: var(--accent);
}

/* ---------- phone add button ---------- */
.fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  width: 60px;
  height: 60px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 3px 3px 0 0 var(--shadow);
  cursor: pointer;
}
@media (max-width: 720px), (pointer: coarse) {
  .fab {
    display: grid;
    place-items: center;
  }
  body:has(#quicktag:not([hidden])) .fab {
    display: none;
  }
  .add-desktop {
    display: none;
  }
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 721px) {
  /* Bottom left on desktop, clear of the quick-tag drawer's buttons. */
  .toasts {
    left: var(--gutter);
    transform: none;
  }
}
.toast {
  padding: 12px 14px;
  background: var(--ink);
  color: var(--bg);
  pointer-events: auto;
  display: flex;
  gap: 12px;
  align-items: center;
}
.toast.error {
  background: var(--danger);
  color: var(--bg);
}
.toast .link-btn {
  color: inherit;
  margin-left: auto;
}

/* ---------- dialogs ---------- */
dialog {
  color: var(--ink);
  background: var(--surface);
  border: 0;
  padding: 0;
}
dialog::backdrop {
  background: var(--scrim);
}
.sheet {
  margin: auto auto 0;
  width: 100%;
  max-width: 480px;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 0 var(--line);
}
.sheet-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}
.confirm {
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 0 0 1px var(--line-strong), 4px 4px 0 0 var(--shadow);
}
.confirm form {
  padding: 22px;
  display: grid;
  gap: 14px;
}
.confirm h2 {
  margin: 0;
  font-size: 18px;
}
.confirm p {
  margin: 0;
  color: var(--ink-dim);
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
}
.row.end.actions {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* ---------- form fields ---------- */
.field {
  display: grid;
  gap: 6px;
}
.label {
  /* Silkscreen at 16px: two CSS pixels per font pixel, crisp at every screen density. */
  font: 400 16px/1 var(--pixel);
  text-transform: uppercase;
  color: var(--ink-dim);
}
.facet-group .label {
  font: 500 12px/1.2 var(--font);
  text-transform: none;
  color: var(--ink-faint);
}
input[type='text'],
input[type='url'],
input[type='search'],
input[type='number'],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink);
}
textarea {
  min-height: 72px;
  resize: vertical;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* ---------- chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
}
.chip:hover {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chip .facet {
  color: var(--ink-faint);
  font-size: 12px;
}
.chip .key {
  font: 400 8px/1 var(--pixel);
  color: var(--ink-faint);
}
.chip.on {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chip.partial {
  background: var(--raised);
  box-shadow: inset 0 0 0 1px dashed var(--accent);
}
.chip .x {
  color: var(--ink-dim);
  font-size: 16px;
  line-height: 1;
}
.chip.replaced {
  animation: flash 0.8s;
}
@keyframes flash {
  from {
    background: var(--accent);
    color: var(--accent-ink);
  }
}

/* ---------- tag field (type-ahead) ---------- */
.tagfield {
  position: relative;
}
.suggest {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--line-strong), 3px 3px 0 0 var(--shadow);
  max-height: 260px;
  overflow: auto;
}
.suggest li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.suggest li[aria-selected='true'] {
  background: var(--accent-soft);
}
.suggest .facet {
  color: var(--ink-faint);
  font-size: 13px;
}
.suggest .create {
  color: var(--accent);
}
.facet-pick {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--accent-soft);
}
.facet-pick p {
  margin: 0;
  font-size: 14px;
}

/* ---------- quick-tag drawer ---------- */
.drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -1px 0 0 var(--line-strong), -4px 0 0 0 color-mix(in srgb, var(--shadow) 12%, transparent);
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 12px;
}
.drawer-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  flex: 1;
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 0 18px 18px;
  display: grid;
  align-content: start;
  gap: 18px;
}
.drawer-foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: var(--hairline);
}
.drawer-foot .btn {
  flex: 1;
}
.strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 3px 3px 6px;
}
.strip button {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 0;
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  opacity: 0.4;
}
.strip button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}
.strip button[aria-pressed='true'] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent);
}
.strip .state {
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
}
@media (max-width: 720px) {
  .drawer {
    top: auto;
    width: 100%;
    max-height: 82dvh;
    box-shadow: 0 -1px 0 var(--line-strong);
    animation-name: slide-up;
  }
  @keyframes slide-up {
    from {
      transform: translateY(24px);
      opacity: 0;
    }
  }
  .chip {
    min-height: 40px;
    font-size: 15px;
  }
}
details summary {
  cursor: pointer;
  color: var(--ink-dim);
  list-style: none;
}
details summary::before {
  content: '+ ';
  font-family: var(--pixel);
  font-size: 8px;
}
details[open] summary::before {
  content: '- ';
}
details .field {
  margin-top: 10px;
}

/* ---------- detail view ---------- */
.detail {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  background: var(--bg);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: 100%;
}
.detail-stage {
  position: relative;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-in;
  background: var(--surface);
  overscroll-behavior: contain;
}
.detail-stage img {
  max-width: 100%;
  max-height: calc(100dvh - 48px);
  box-shadow: 0 0 0 1px var(--line);
  display: block;
}
.detail-stage.zoomed {
  place-items: start center;
  cursor: zoom-out;
}
.detail-stage.zoomed img {
  max-width: none;
  max-height: none;
}
.detail-side {
  overflow: auto;
  padding: 18px 20px 28px;
  display: grid;
  align-content: start;
  gap: 18px;
  border-left: var(--hairline);
}
.detail-top {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: -6px -8px 0;
}
.detail-top .meta {
  flex: 1;
  padding-left: 8px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-dim);
}
.swatches {
  display: flex;
  height: 32px;
  box-shadow: 0 0 0 1px var(--line);
}
.swatches button {
  border: 0;
  padding: 0;
  cursor: copy;
  min-width: 6px;
}
.swatches button:focus-visible {
  outline-offset: -3px;
}
.facet-group {
  display: grid;
  gap: 6px;
}
.source {
  word-break: break-all;
  font-size: 14px;
}
.fav-btn[aria-pressed='true'] {
  color: var(--accent);
}
@media (max-width: 860px) {
  .detail-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100%;
  }
  .detail {
    overflow: auto;
  }
  .detail-stage {
    padding: 0;
    max-height: none;
  }
  .detail-stage img {
    max-height: 70dvh;
  }
  .detail-stage.zoomed {
    max-height: 80dvh;
  }
  .detail-side {
    border-left: 0;
    border-top: var(--hairline);
  }
}

/* ---------- settings panel ---------- */
.panel {
  width: min(720px, 100vw);
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  box-shadow: -1px 0 0 var(--line-strong);
}
.panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: var(--hairline);
}
.panel-head h2 {
  margin: 0;
  flex: 1;
  font-size: 18px;
  font-weight: 500;
}
.panel-body {
  padding: 20px 20px 60px;
  display: grid;
  gap: 32px;
}
.panel section {
  display: grid;
  gap: 12px;
}
.panel h3 {
  margin: 0;
}
.meter {
  height: 12px;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  position: relative;
}
.meter span {
  position: absolute;
  inset: 2px auto 2px 2px;
  background: var(--teal);
  max-width: calc(100% - 4px);
}
.meter.warn span {
  background: var(--danger);
}
.segmented {
  display: inline-flex;
  justify-self: start;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.segmented button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  background: none;
  cursor: pointer;
}
.segmented button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* taxonomy editor */
.facet-card {
  box-shadow: 0 0 0 1px var(--line);
  background: var(--raised);
}
.facet-card > header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 14px;
  border-bottom: var(--hairline);
}
.facet-card > header .name {
  font-weight: 500;
  font-size: 16px;
  flex: 1;
  min-width: 120px;
}
.facet-card .opts {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-dim);
  min-height: 32px;
  padding: 0 6px;
  cursor: pointer;
}
.toggle input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.terms {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}
.terms li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 14px;
  min-height: 40px;
}
.terms li:hover {
  background: var(--surface);
}
.terms .tname {
  flex: 1;
}
.terms .count {
  color: var(--ink-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}
.mini {
  min-height: 32px;
  min-width: 32px;
  padding: 0 8px;
  font-size: 13px;
  border: 0;
  background: none;
  color: var(--ink-dim);
  cursor: pointer;
}
.mini:hover {
  color: var(--ink);
  background: var(--accent-soft);
}
.mini.danger:hover {
  color: var(--danger);
}
.add-term {
  display: flex;
  gap: 6px;
  padding: 8px 10px 12px 14px;
}
.inline-edit {
  min-height: 32px !important;
  padding: 4px 8px !important;
}
.warn-line {
  color: var(--danger);
  font-size: 13px;
  padding: 0 14px 8px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- filter bar ---------- */
.filterbar {
  margin-bottom: var(--gap);
  display: grid;
  gap: 10px;
}
.fb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.search {
  position: relative;
  flex: 0 1 300px;
  min-width: 180px;
}
.search input {
  padding-right: 34px;
}
.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}
.search input:focus + kbd,
.search input:not(:placeholder-shown) + kbd {
  display: none;
}
.fb-drop {
  min-height: 40px;
}
.fb-drop .caret {
  font-size: 10px;
  color: var(--ink-faint);
}
.fb-row .count {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.fb-active {
  align-items: center;
}
.fb-active .link-btn {
  font-size: 14px;
  margin-left: 4px;
}
.collection-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 4px;
  border-top: var(--hairline);
}
.collection-head h2 {
  margin: 6px 0 0;
  font-size: 24px;
  font-weight: 700;
}
.collection-head p {
  margin: 4px 0 0;
  max-width: 60ch;
}
@media (max-width: 720px) {
  .search {
    flex: 1 1 100%;
  }
}

/* popovers: anchored menus on desktop, bottom sheets on phones */
.pop {
  position: fixed;
  z-index: 45;
  width: 280px;
  max-height: min(70vh, 520px);
  overflow: auto;
  padding: 6px;
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--line-strong), 4px 4px 0 0 color-mix(in srgb, var(--shadow) 25%, transparent);
}
.pop.wide {
  width: min(560px, calc(100vw - 24px));
  padding: 14px;
  display: grid;
  gap: 16px;
}
@media (max-width: 720px) {
  .pop,
  .pop.wide {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 75dvh;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -1px 0 var(--line-strong), 0 -12px 40px rgb(0 0 0 / 0.25);
  }
}
.pop-close {
  display: none;
}
@media (max-width: 720px) {
  .pop-close {
    display: flex;
    width: 100%;
    margin-top: 8px;
    min-height: 48px;
  }
}
.opts-list {
  display: grid;
}
.opts-list.inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.opt:hover {
  background: var(--accent-soft);
}
.opt .lbl {
  flex: 1;
}
.opt .n {
  color: var(--ink-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.opt .box {
  width: 14px;
  height: 14px;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
  color: var(--accent);
}
.opt .sw {
  width: 14px;
  height: 14px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent);
}
.opt.on {
  color: var(--accent);
}
.opt.on .box {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.opt.zero {
  color: var(--ink-faint);
}
.opts-list.inline .opt {
  box-shadow: inset 0 0 0 1px var(--line);
  min-height: 34px;
}
.opts-list.inline .opt.on {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.refine-sec {
  display: grid;
  gap: 8px;
}
.pad {
  padding: 8px 10px;
  margin: 0;
}

/* ---------- selection ---------- */
.tile .check {
  display: none;
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  background: var(--bg);
  box-shadow: inset 0 0 0 2px var(--ink-dim);
}
.wall.selecting .tile .check {
  display: block;
}
.wall.selecting .tile {
  cursor: pointer;
}
.tile.selected {
  box-shadow: 0 0 0 3px var(--accent);
}
.tile.selected .check {
  display: block;
  background: var(--accent);
  box-shadow: none;
}
.tile.selected .check::after {
  content: '';
  position: absolute;
  inset: 5px;
  background: var(--accent-ink);
  clip-path: polygon(0 50%, 25% 50%, 25% 75%, 37.5% 75%, 37.5% 62.5%, 100% 0, 100% 25%, 37.5% 100%, 25% 100%, 0 75%);
}
.tile.selected img {
  opacity: 0.85;
}
.bulkbar {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  background: var(--raised);
  box-shadow: 0 0 0 1px var(--line-strong), 4px 4px 0 0 var(--shadow);
}
.bulk-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sel-count {
  font-weight: 500;
  white-space: nowrap;
}
body.is-selecting .fab {
  display: none;
}
@media (max-width: 720px) {
  .bulkbar {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: auto;
    max-width: none;
    flex-wrap: wrap;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -1px 0 var(--line-strong);
  }
  .bulk-actions {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .sel-count {
    flex: 1;
  }
}

/* ---------- tool dialog ---------- */
.tool.wide {
  width: min(640px, calc(100vw - 32px));
}
.tool-body {
  display: grid;
  gap: 12px;
}
.tool-body > .row input {
  flex: 1;
}

/* ---------- compare ---------- */
.compare {
  display: none;
  grid-template-rows: auto 1fr;
}
.compare[open] {
  display: grid;
}
.cmp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--gutter);
  border-bottom: var(--hairline);
}
.cmp-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}
.cmp-stage {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  padding: var(--gap) var(--gutter);
  min-height: 0;
}
.cmp-col {
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  min-height: 0;
}
.cmp-img {
  overflow: auto;
  min-height: 0;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}
.cmp-img img {
  width: 100%;
  height: auto;
  display: block;
}
.cmp-col figcaption {
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.cmp-col figcaption p {
  margin: 0;
  color: var(--ink-dim);
}
.swatches.small {
  height: 12px;
}
.swatches.small span {
  min-width: 4px;
}
@media (max-width: 720px) {
  .cmp-stage {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 86%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
  }
  .cmp-col {
    scroll-snap-align: center;
  }
  .cmp-head .btn {
    padding: 0 10px;
  }
}

/* ---------- untagged view ---------- */
.inbox-stage {
  cursor: default;
}
.inbox-stage img {
  max-height: calc(100dvh - 48px);
}
.inbox-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.inbox-actions .btn-big {
  flex: 1;
}
.inbox-actions .btn-quiet {
  min-height: 52px;
  width: 52px;
  padding: 0;
}
.keys {
  margin: 0;
  font-size: 13px;
}
.chips.big .chip {
  min-height: 40px;
}
.inbox-empty {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
  padding: 40px;
}
@media (max-width: 860px) {
  .inbox-stage img {
    max-height: 45dvh;
  }
  .keys {
    display: none;
  }
  .inbox-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  }
}
@media (pointer: coarse) {
  .keys {
    display: none;
  }
}
.detail-side .spacer {
  flex: 1;
}
