/* Immersive artwork, then a clear path to the correct local attachment. */
dialog {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 16px 80px var(--shadow);
  overflow: auto;
  animation: appear 0.15s ease-out;
}
dialog::backdrop {
  background: #050709bd;
  backdrop-filter: blur(8px);
}
#detail {
  width: min(1360px, calc(100% - 64px));
  max-width: none;
  max-height: 94dvh;
  overflow: hidden;
  isolation: isolate;
}
#detail-scroll {
  position: relative;
  z-index: 1;
  max-height: 94dvh;
  overflow: auto;
  scrollbar-gutter: stable;
}
.detail-top {
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  pointer-events: none;
}
.detail-top button {
  pointer-events: auto;
  background: var(--panel);
  box-shadow: 0 2px 12px var(--shadow);
}
#close-detail {
  border: 1px solid var(--hairline);
  border-radius: 50%;
}
#detail-back {
  font-size: 11px;
}
.detail-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 53%) minmax(0, 47%);
  align-items: start;
}
.detail-ambience {
  --ambience-veil: color-mix(in srgb, var(--panel) 74%, transparent);
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity .24s ease-out;
}
:root[data-theme="dark"] .detail-ambience {
  --ambience-veil: color-mix(in srgb, var(--panel) 62%, transparent);
}
.detail-ambience.is-ready {
  opacity: 1;
}
.detail-ambience img {
  position: absolute;
  inset: -64px;
  width: calc(100% + 128px);
  height: calc(100% + 128px);
  max-width: none;
  object-fit: cover;
  filter: blur(14px) saturate(1.1);
}
.detail-ambience::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ambience-veil);
}
#gallery {
  position: sticky;
  top: 0;
  align-self: start;
  background: transparent;
  padding: 24px;
  min-width: 0;
  border-right: 1px solid var(--hairline);
}
.gallery-stage {
  height: clamp(350px, 61dvh, 720px);
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg);
}
.gallery-stage .image-host {
  background: var(--bg);
}
#gallery-image {
  width: 100%;
  height: 100%;
}
#gallery-image,
#viewer-image {
  position: relative;
  isolation: isolate;
}
#gallery-image > .image-host,
#viewer-image > .image-host {
  position: absolute;
  inset: 0;
}
.image-host.image-previous {
  z-index: -1;
  pointer-events: none;
}
.image-host.preview-pending {
  opacity: 0;
}
#viewer-image {
  transition:
    width 0.2s ease,
    height 0.2s ease;
}
.tabs button[aria-selected="true"]:after {
  animation: tab-indicator 0.22s ease-out;
  transform-origin: left;
}
@keyframes tab-indicator {
  from {
    transform: scaleX(0.4);
    opacity: 0.4;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}
.gallery-stage img,
.viewer-stage img {
  object-fit: contain;
}
.gallery-stage > button {
  position: absolute;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--hairline);
  z-index: 1;
  box-shadow: 0 2px 12px var(--shadow);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 24px;
}
.gallery-prev {
  top: 46%;
  left: 10px;
}
.gallery-next {
  top: 46%;
  right: 10px;
}
#open-viewer {
  width: auto;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 11px;
  right: 12px;
  bottom: 12px;
}
#image-count {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: var(--panel);
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 11px;
}
.thumbnails {
  display: flex;
  overflow-x: auto;
  gap: 9px;
  margin: 16px 0 0;
  padding: 4px 3px 8px;
  min-width: 0;
}
.thumbnails > button {
  flex-shrink: 0;
  width: 52px;
  height: 60px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  overflow: hidden;
}
.thumbnails > button[aria-pressed="true"] {
  border: 2px solid var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.detail-info {
  min-width: 0;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}
:root[data-theme="dark"] .detail-info {
  background: color-mix(in srgb, var(--panel) 65%, transparent);
}
.detail-title {
  padding: 64px 32px 0;
  overflow-wrap: anywhere;
}
.detail-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}
.favorite-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 80px;
  min-height: 44px;
  cursor: pointer;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 8px 12px;
  background: var(--panel);
}
.favorite-toggle input[type="checkbox"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.favorite-toggle .ui-icon {
  width: 16px;
  height: 16px;
}
.favorite-toggle:has(input:checked) {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.favorite-toggle:has(input:checked) svg {
  fill: currentColor;
}
.favorite-toggle:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.detail-title h2 {
  font-size: 30px;
  letter-spacing: -0.7px;
  line-height: 1.25;
  font-weight: 500;
  margin: 18px 0 10px;
}
.detail-creator {
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 8px;
}
.detail-creator:empty {
  display: none;
}
.original-title {
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
  margin: 0 0 12px;
}
.full-title {
  border: 0 !important;
  font-size: 11px;
  margin: 0 !important;
}
.full-title summary {
  font-size: 11px;
  padding-block: 7px;
  min-height: 36px;
  color: var(--muted);
}
.full-title p {
  color: var(--muted);
  font-size: 12px;
}
.detail-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  font-size: 11px;
  color: var(--muted);
  margin: 16px 0;
}
.detail-facts > span + span:before {
  content: "·";
  margin: 0 10px;
}
#detail-download {
  width: 100%;
  display: flex;
  justify-content: space-between;
  border-radius: 5px;
  min-height: 50px;
  font-size: 13px;
  padding: 12px 16px;
}
.download-hint {
  font-size: 10px;
  color: var(--muted);
  margin: 7px 0 20px;
}
.compatibility {
  margin: 20px 0 8px;
}
.compatibility h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin: 0 0 10px;
}
.compatibility h3 > small {
  margin-left: auto;
  font-size: 10px;
}
.compatibility .chips {
  gap: 6px;
  margin: 0;
}
.role-button {
  background: var(--panel);
  border: 1px solid var(--hairline) !important;
  border-radius: 4px !important;
  padding: 7px 10px !important;
  font-size: 11px !important;
  min-height: 40px !important;
  white-space: normal;
  text-align: left;
}
.role-button:hover {
  border-color: var(--accent) !important;
  background: var(--accent-bg);
}
.compatibility-empty {
  font-size: 11px;
  color: var(--muted);
  margin: 16px 0;
}
.more-roles {
  border: 0;
  margin: 2px 0 !important;
}
.more-roles > summary {
  font-size: 11px;
}
.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 4px 0 12px;
}
.source-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 11px;
  text-decoration: none;
  color: var(--muted);
}
.source-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.detail-lower {
  padding: 0 32px 28px;
  min-width: 0;
}
.tabs {
  display: flex;
  overflow-x: auto;
  gap: 24px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--hairline);
}
.tabs button {
  position: relative;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 12px 0;
  min-height: 50px;
  background: none;
  border: 0;
  border-radius: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.tabs button[aria-selected="true"] {
  color: var(--ink);
}
.tabs button[aria-selected="true"]:after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}
.tabs button > span {
  font-size: 10px;
  margin-left: 4px;
  color: var(--muted);
}
#tab-content {
  min-height: 120px;
  scroll-margin-top: 80px;
}
.detail-loading {
  margin: 30px;
  height: 400px;
  padding: 22px;
}
#detail details {
  border-top: 1px solid var(--hairline);
  margin: 12px 0;
  min-width: 0;
}
#detail summary {
  min-height: 44px;
  padding: 10px 0;
  overflow-wrap: anywhere;
}
#detail details[open] > summary {
  margin-bottom: 8px;
}
.description-section {
  margin: 0 0 18px !important;
  border: 0 !important;
}
.description-section > summary {
  color: var(--muted);
  font-size: 11px;
}
.description {
  font-size: 12px;
  line-height: 1.95;
  color: var(--ink);
}
.description-section[open] > .description {
  padding: 16px 18px;
  background: var(--bg);
  border-radius: 5px;
}
.product {
  padding: 0 0 20px;
}
.product-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 12px;
}
.product-heading h3 {
  font-size: 13px;
  margin: 0;
}
.product-heading a {
  font-size: 11px;
}
#tab-content > details > summary,
.product > details > summary {
  font-size: 12px;
}
.snapshot-label {
  padding: 12px;
  border-radius: 5px;
  background: var(--soft);
  color: var(--muted);
  font-size: 11px;
}
.detail-evidence {
  font-size: 11px;
}
.detail-evidence h4 {
  font-size: 12px;
  margin-top: 18px;
}
.detail-evidence blockquote {
  margin: 12px 0;
  padding: 12px;
  border-left: 2px solid var(--hairline);
  color: var(--muted);
  background: var(--bg);
}
.detail-evidence pre {
  font-size: 11px;
}
.message {
  padding: 20px 0;
  border-top: 1px solid var(--hairline);
}
.message time,
.message a {
  font-size: 11px;
}
.message pre {
  font-size: 12px;
}
.detail-metadata {
  min-width: 0;
  font-size: 12px;
}
.metadata-note {
  color: var(--muted);
  line-height: 1.8;
}
.metadata-product,
.metadata-source {
  padding: 4px 0 20px;
  border-bottom: 1px solid var(--hairline);
  overflow-wrap: anywhere;
}
.metadata-sources > h3 {
  margin-top: 28px;
  font-size: 14px;
}
#detail .metadata-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px 24px;
  margin: 12px 0 20px;
}
.metadata-field {
  min-width: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
#detail .metadata-field dt {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}
#detail .metadata-field dd {
  margin: 0;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  #detail .metadata-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}
.metadata-json {
  font:
    11px/1.85 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 16px;
  margin: 0;
  max-width: 100%;
  tab-size: 2;
}
.attachment {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 16px;
  margin: 10px 0 14px;
  background: var(--panel);
}
.file-type {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 46px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.4px;
}
.attachment-info {
  flex: 1;
  min-width: 0;
}
.attachment h4 {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}
.attachment .file-meta {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
}
.attachment a.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 6px;
  font-size: 11px;
  min-width: 72px;
  min-height: 44px;
  padding: 9px 12px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--bg);
  border-radius: 4px;
  text-decoration: none;
}
.download .ui-icon {
  width: 15px;
  height: 15px;
}
.unavailable {
  font-size: 11px;
  color: var(--muted);
  padding: 10px;
}
.file-information {
  border: 0 !important;
  margin: 4px 0 0 !important;
  font-size: 11px;
}
.file-information > summary {
  font-size: 10px;
  color: var(--muted);
}
#detail dl {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  font-size: 11px;
  gap: 7px;
  margin: 2px 0 14px;
}
#detail dt {
  color: var(--muted);
}
#detail dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.attachment-filters {
  border: 0 !important;
  margin: 0 0 12px !important;
}
.attachment-filters > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  list-style: none;
  width: fit-content;
}
.attachment-filters > summary:after {
  content: "⌄";
  padding-left: 8px;
}
.attachment-filters > summary > .ui-icon {
  width: 14px;
  height: 14px;
}
.file-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 5px;
}
.file-filters label {
  display: grid;
  gap: 4px;
  font-size: 10px;
  flex: 1;
  min-width: 90px;
}
.file-filters select {
  width: 100%;
  font-size: 11px;
  max-width: none;
}
.attachment-group-label,
.unlabelled-files > summary,
.unlabelled-files > p {
  font-size: 11px;
}
.package {
  font-size: 11px;
}
.package-body {
  min-width: 0;
}
.package-body label {
  display: block;
  margin: 10px 0;
  font-size: 11px;
}
.package-body input {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
}
.tree {
  max-height: 420px;
  overflow: auto;
  margin: 12px 0;
  padding: 0 8px;
}
.tree details {
  margin: 0 0 0 14px !important;
  border: 0 !important;
}
.tree-file {
  padding: 3px 0 3px 14px;
  font-size: 11px !important;
  overflow-wrap: anywhere;
}
.tree-file small {
  white-space: nowrap;
}
.package-more {
  font-size: 11px;
}
.attachment-empty {
  padding: 28px 12px;
  background: var(--bg);
  border-radius: 5px;
  margin: 12px 0 22px;
}
.attachment-empty h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}
.attachment-empty p {
  font-size: 12px;
  margin: 0;
}
.detail-secondary {
  margin-top: 24px;
  border-top: 1px solid var(--hairline);
}
.detail-secondary > details {
  margin: 0 !important;
  border: 0 !important;
  border-bottom: 1px solid var(--hairline) !important;
}
.detail-secondary > details > summary {
  font-size: 11px;
  color: var(--muted);
  padding: 14px 0;
  min-height: 48px;
}
.personal > summary > span {
  float: right;
  font-size: 10px;
}
.personal-body {
  padding: 8px 0 18px;
}
.personal label {
  font-size: 11px;
}
.personal textarea {
  margin-top: 6px;
  font-size: 12px;
  border-color: var(--line);
}
.record-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.record-actions button {
  margin: 0;
  font-size: 11px;
}
#save-note {
  background: var(--accent-bg);
  border-color: transparent;
  color: var(--accent);
}
.source-record {
  padding: 12px;
  border: 0;
  border-radius: 5px;
  margin-bottom: 12px;
  font-size: 11px;
}
.source-record p {
  font-size: 10px;
}
.source-record button {
  font-size: 11px;
}
.selected-source {
  background: var(--accent-bg);
}
.status-control {
  border: 0;
  padding: 0;
  margin: 0 0 16px;
  min-width: 0;
}
.status-control legend {
  font-size: 11px;
  color: var(--muted);
  padding: 0;
  margin-bottom: 8px;
}
.status-control > div {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 5px;
  background: var(--soft);
  max-width: 100%;
}
.status-control label {
  position: relative;
  margin: 0;
  cursor: pointer;
}
.status-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.status-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 4px;
  font-size: 11px;
}
.status-control input:checked + span {
  background: var(--panel);
  box-shadow:
    0 1px 3px var(--shadow),
    inset 0 0 0 1px var(--hairline);
  font-weight: 600;
}
.status-control input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#viewer {
  width: 96vw;
  height: 96dvh;
  max-width: none;
  max-height: 96dvh;
  overflow: hidden;
}
.viewer-tools {
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-bottom: 1px solid var(--hairline);
  padding: 8px;
}
.viewer-stage {
  height: calc(100% - 65px);
  width: 100%;
  overflow: auto;
  background: var(--bg);
}
#viewer-image {
  width: 100%;
  height: 100%;
  min-height: 100%;
}
.viewer-stage .image-host {
  background: transparent;
}
.viewer-stage img {
  max-width: none;
}
.original-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 44px;
  padding: 8px 10px;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 4px;
  font-size: 11px;
  background: var(--soft);
}
@media (max-width: 1100px) and (min-width: 761px) {
  #detail {
    width: calc(100% - 32px);
  }
  .detail-hero {
    grid-template-columns: minmax(0, 48%) minmax(0, 52%);
  }
  .detail-title {
    padding: 64px 24px 0;
  }
  .detail-lower {
    padding: 0 24px 24px;
  }
  #gallery {
    padding: 24px 16px;
  }
  .attachment {
    flex-wrap: wrap;
  }
  .attachment a.download {
    margin-left: 52px;
  }
  .attachment-info {
    flex-basis: calc(100% - 52px);
  }
}
@media (max-width: 760px) {
  .detail-ambience img {
    filter: blur(10px);
    opacity: .7;
  }
  #detail {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    scrollbar-gutter: auto;
  }
  #detail-scroll {
    max-height: 100dvh;
    padding-bottom: 72px;
  }
  .detail-top {
    top: 10px;
    right: 10px;
  }
  #detail-back {
    font-size: 10px;
    padding: 8px;
  }
  .detail-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  #gallery {
    position: static;
    padding: 14px 16px 8px;
    border-right: 0;
  }
  .gallery-stage {
    height: clamp(260px, 44dvh, 420px);
  }
  .thumbnails {
    margin-top: 10px;
  }
  .thumbnails > button {
    width: 44px;
    height: 50px;
  }
  .detail-title {
    padding: 18px 20px 0;
  }
  .detail-title h2 {
    font-size: 25px;
    margin: 12px 0 8px;
  }
  .detail-lower {
    padding: 0 20px 24px;
  }
  .detail-facts {
    margin: 12px 0 16px;
  }
  #detail-download {
    position: fixed;
    bottom: 12px;
    left: 16px;
    right: 16px;
    width: calc(100% - 32px);
    z-index: 6;
    box-shadow:
      0 0 0 12px var(--panel),
      0 -10px 25px var(--shadow);
  }
  .download-hint {
    margin-bottom: 12px;
  }
  .compatibility {
    margin-top: 16px;
  }
  .tabs {
    gap: 22px;
    margin-bottom: 16px;
    scroll-margin-top: 12px;
  }
  .tabs button {
    font-size: 12px;
  }
  .attachment {
    padding: 12px;
    gap: 10px;
  }
  .file-type {
    width: 32px;
    min-height: 42px;
    font-size: 8px;
  }
  .attachment a.download {
    min-width: 64px;
    padding: 8px;
    gap: 4px;
  }
  .attachment a.download .ui-icon {
    display: none;
  }
  .detail-secondary {
    margin-top: 20px;
  }
  #viewer {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .viewer-tools {
    gap: 2px;
    padding: 4px;
  }
  .viewer-tools button {
    padding: 7px;
    min-width: 44px;
  }
  .viewer-tools .original-image {
    min-width: 54px;
    padding: 8px 6px;
  }
  #zoom-level {
    font-size: 11px;
  }
}
@media (max-width: 360px) {
  .detail-title {
    padding: 16px 16px 0;
  }
  .detail-lower {
    padding: 0 16px 24px;
  }
  .attachment {
    flex-wrap: wrap;
  }
  .attachment-info {
    flex-basis: calc(100% - 42px);
  }
  .attachment a.download {
    margin-left: 42px;
  }
  .tabs {
    gap: 18px;
  }
  .favorite-toggle {
    min-width: 72px;
    padding: 8px 11px;
  }
  .detail-title h2 {
    font-size: 23px;
  }
  .viewer-tools {
    height: 108px;
    flex-wrap: wrap;
    align-content: center;
    gap: 4px;
  }
  .viewer-stage {
    height: calc(100% - 108px);
  }
}

@media (max-width: 760px) {
  #detail[data-tab="attachments"] #detail-download {
    display: none;
  }
}
