#work-dialog {
  width: min(1100px, calc(100% - 40px));
  height: min(660px, calc(100dvh - 36px));
  overflow: hidden;
}
#work-dialog[open] {
  display: grid;
  grid-template-rows: max-content minmax(0, 1fr);
}
.detail-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 45px;
}
#back-collection {
  justify-self: start;
}
.detail-bar .paging {
  grid-column: -2 / -1;
  justify-self: end;
}
#board-picker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font: 11px/1.35 var(--mono);
}
#board-picker select {
  color: var(--ink);
  background: var(--panel);
  padding: 4px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
}
#board-picker[hidden] {
  display: none;
}
#work-body {
  display: grid;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  grid-template-columns: minmax(225px, 29%) minmax(0, 1fr);
  grid-template-areas: 'head display' 'caption display';
  grid-template-rows: auto minmax(0, 1fr);
  align-items: start;
  gap: 14px clamp(24px, 3.5vw, 48px);
  padding: clamp(18px, 2.1vw, 28px);
}
.work-caption,
.work-display {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.work-caption {
  grid-area: caption;
  align-self: stretch;
}
.work-display {
  grid-area: display;
}
.work-locations {
  grid-area: map;
  width: 100%;
  min-width: 0;
  margin-block-start: auto;
}
.work-head {
  grid-area: head;
  min-width: 0;
  overflow-wrap: anywhere;
  display: grid;
  justify-content: start;
  margin: 0;
  gap: 4px;
}
.work-head h2 {
  margin: 0;
  font-size: clamp(36px, 3.4vw, 50px);
  text-wrap: balance;
}
.work-head .creator-link {
  justify-self: start;
  font-size: clamp(13px, 1.2vw, 16px);
  font-style: italic;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.work-visual {
  grid-area: art;
  min-width: 0;
}
.work-visual .mount {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
}
.work-visual .mount img {
  display: block;
  position: static;
  width: 100%;
  height: auto;
  max-height: clamp(165px, calc(100dvh - 234px), 555px);
  object-fit: contain;
}
.mount.rotatable {
  overflow: clip;
  touch-action: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.mount.rotatable.turning {
  cursor: grabbing;
}
.mount.rotatable img {
  margin: auto;
  pointer-events: none;
  transition: none;
}
.mount.rotatable:not(.model-ready) img {
  opacity: 0;
}
.mount.rotatable.pointer-rotate:focus-visible {
  outline: none;
}
.sticker-model {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.rotation-control {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--rim);
  border-radius: 2px;
  color: var(--mint);
  font: 600 12px/1.2 DM, sans-serif;
}
.rotation-control:hover:enabled {
  color: var(--ink);
  background: var(--panel);
}
.rotation-control:disabled {
  color: var(--muted);
  border-color: var(--line);
  opacity: 0.75;
}
.info-grid {
  grid-area: meta;
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}
.info-grid .work-meta {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: baseline;
  gap: 6px;
}
.info-grid h3 {
  font-size: 9px;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.07em;
}
.work-meta .tags,
.work-meta .work-colors {
  gap: 2px 7px;
}
.tag,
.color-name {
  font:
    400 12px/1.45 DM,
    sans-serif;
  color: var(--ink);
  padding: 0;
}
.tag:not(:last-child)::after {
  content: '·';
  margin-left: 6px;
  color: var(--rim);
}
.color-name {
  gap: 4px;
}
.color-name::before {
  width: 8px;
  height: 8px;
}
.artist-note {
  font-size: 12px;
  color: var(--muted);
}
.artist-note summary {
  cursor: pointer;
  width: fit-content;
}
.artist-note p {
  margin: 5px 0 0;
}
.proof-controls {
  grid-area: 2 / 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 18px;
  min-height: 44px;
}
.proof-controls .work-meta h3 {
  margin: 0;
  font-size: 9px;
  text-align: center;
  color: var(--muted);
}
.variant-strip {
  justify-content: center;
  gap: 3px;
  margin-top: 3px;
}
.variant {
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 52px;
  font-size: 11px;
}
.variant img {
  width: 44px;
  height: 22px;
}
.sighting-map {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--deep);
}
.map-surface {
  position: relative;
  display: grid;
  justify-items: center;
  overflow: hidden;
  isolation: isolate;
  background: #425f63;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.map-surface.panning {
  cursor: grabbing;
}
.map-surface:focus-visible {
  outline-offset: -2px;
}
.heat-controls {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  border: 1px solid var(--rim);
  border-radius: 2px;
  background: var(--deep);
  color: var(--ink);
}
.heat-controls button {
  display: grid;
  place-items: center;
  min-width: 26px;
  min-height: 26px;
  padding: 0 5px;
  font: 600 16px/1 var(--mono);
}
.heat-controls button + button {
  border-left: 1px solid var(--line);
}
.heat-controls button:last-child {
  font-size: 11px;
}
.heat-controls button:hover:enabled {
  background: var(--panel);
}
.heat-controls button:focus-visible {
  outline-offset: -2px;
}
.map-frame {
  position: relative;
  width: min(100%, var(--map-frame-width, 220px));
  container-type: inline-size;
}
.heat-layer,
.city-geography {
  position: absolute;
}
.heat-geography,
.heat-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.heat-geography {
  transform-origin: 0 0;
}
@media (pointer: coarse) {
  .heat-controls button {
    min-width: 30px;
    min-height: 30px;
  }
}
.city-geography,
.heat-layer {
  inset: 0;
  width: 100%;
  height: 100%;
}
.heat-layer {
  mask-image: var(--land);
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
}
.heat-label {
  --offset: 0.45em;
  position: absolute;
  transform: translate(-50%, var(--offset));
  max-width: 46%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #fcf3db;
  text-shadow:
    0 1px 2px #182a22,
    0 0 3px #25382b,
    0 0 2px #25382b;
  font:
    600 clamp(8px, 3.4cqw, 11px)/1.2 DM,
    sans-serif;
  pointer-events: none;
}
.heat-label[data-short] {
  --offset: -50%;
}
@container (max-width: 165px) {
  .heat-label[data-short] {
    font-size: 0;
  }
  .heat-label[data-short]::after {
    content: attr(data-short);
    font-size: 8px;
  }
}

.sighting-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2px 6px;
  padding: 4px 7px;
  color: var(--muted);
  font-size: 10px;
}
.density-key {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 9px/1 var(--mono);
}
.density-key i {
  width: 23px;
  height: 4px;
  background: linear-gradient(90deg, #ffdc76, #f15c3a, #7f1c42);
}

[data-detail='lightbox'] .work-display {
  align-self: stretch;
  display: grid;
  grid-template: 'art' minmax(0, 1fr) / minmax(0, 1fr);
  min-height: 0;
}
[data-detail='lightbox'] .info-grid {
  gap: 3px;
}
#work-dialog .work-visual {
  align-self: stretch;
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(105px, 1fr) auto;
  gap: 10px;
  align-items: center;
}
#work-dialog .work-visual .mount {
  grid-area: 1 / 1;
  height: 100%;
  min-height: 0;
}
#work-dialog .work-visual .mount img {
  position: absolute;
  inset: 0;
  height: 100%;
  max-height: 100%;
}
[data-detail='lightbox'] .work-head h2 {
  font-size: clamp(33px, 3vw, 41px);
}

:is([data-detail='rail'], [data-detail='notes']) :is(.work-caption, .work-display) {
  display: contents;
}
#work-dialog[data-detail='rail'] #work-body {
  grid-template-columns: minmax(210px, 28%) minmax(0, 1fr);
  grid-template-areas: 'head head' 'map art' 'meta art';
  grid-template-rows: auto 1fr auto;
}
#work-dialog[data-detail='notes'] #work-body {
  grid-template-areas: 'head art' 'map art' 'meta art';
  grid-template-rows: auto 1fr auto;
}
@media (max-width: 720px) {
  #work-dialog {
    width: calc(100% - 12px);
    max-width: calc(100% - 12px);
    max-height: calc(100dvh - 12px);
    height: calc(100dvh - 12px);
  }
  .detail-bar {
    padding: 4px 10px;
    gap: 4px;
  }
  .detail-bar button {
    font-size: 12px;
  }
  #board-picker > span {
    display: none;
  }
  #board-picker select {
    font-size: 11px;
  }
  .paging {
    gap: 2px;
  }
  .paging button {
    min-width: 22px;
  }
  .paging span {
    font-size: 10px;
  }
  #work-dialog[data-detail] #work-body {
    grid-template: 'head' max-content 'art' max-content 'map' max-content 'meta' max-content / minmax(0, 1fr);
    align-content: start;
    gap: 16px;
    padding: clamp(12px, 3vw, 20px);
  }
  #work-dialog[data-detail] :is(.work-caption, .work-display) {
    display: contents;
  }
  #work-dialog .work-visual {
    grid-template-rows: auto auto;
    gap: 4px;
  }
  #work-dialog .work-visual .mount {
    height: auto;
    aspect-ratio: 1;
    max-height: min(80svh, 640px);
  }
  .mount.rotatable {
    touch-action: pan-y pinch-zoom;
  }
  .map-frame {
    --map-frame-width: min(70vw, 280px);
  }
  .work-head {
    gap: 3px;
  }
  .work-head h2,
  [data-detail='lightbox'] .work-head h2 {
    font-size: clamp(26px, 5.7vw, 38px);
  }
  .work-visual .mount img {
    max-height: 100%;
  }
  .info-grid .work-meta {
    grid-template-columns: 39px 1fr;
    gap: 3px;
  }
  .variant {
    min-width: 34px;
    padding: 3px;
    font-size: 10px;
  }
  .variant img {
    width: 31px;
    height: 18px;
  }
}

@media (max-width: 480px) {
  .info-grid h3 {
    font-size: 8px;
  }
  .tag,
  .color-name {
    font-size: 11px;
  }
  .work-meta .tags,
  .work-meta .work-colors {
    column-gap: 5px;
  }
  .sighting-footer {
    padding: 3px 5px;
  }
}

@media (min-width: 721px) and (orientation: landscape) and (max-height: 570px) {
  #work-dialog[data-detail='lightbox'] #work-body {
    grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  [data-detail='lightbox'] .work-caption {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    gap: 4px;
  }
  #work-body {
    padding: 10px 16px;
    row-gap: 6px;
  }
  .work-caption,
  .work-display {
    gap: 9px;
  }
  .work-visual .mount img {
    max-height: clamp(94px, calc(100dvh - 207px), 370px);
  }
  #work-dialog .work-head h2 {
    font-size: clamp(23px, 3.2vw, 34px);
  }
  .proof-controls {
    gap: 4px 8px;
    min-height: 30px;
  }
  .map-frame {
    --map-frame-width: clamp(74px, calc(100dvh - 300px), 200px);
  }
  .info-grid .work-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 6px;
  }
  .info-grid :is(.tags, .work-colors) {
    display: contents;
  }
}
