.viewer-dialog {
  --viewer-bg: #14151b;
  --viewer-panel: #1d1d26;
  --viewer-text: #ede9ee;
  --viewer-muted: #aaa5b3;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--viewer-text);
  background: var(--viewer-bg);
  font-family: inherit;
  overscroll-behavior: contain;
  overflow: hidden;
  color-scheme: dark;
}
.viewer-dialog::backdrop { background: #101016ed; }
.viewer-dialog [hidden] { display: none !important; }
.viewer-dialog * { box-sizing: border-box; }
.viewer-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; height: 100%; }
.viewer-header { display: flex; align-items: center; gap: 20px; min-height: 82px; padding: max(12px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left)); border-bottom: 1px solid #ffffff13; }
.viewer-heading { flex: 1; min-width: 0; }
.viewer-heading h2 { font-family: var(--serif, 'Songti SC', serif); margin: 0; font-size: 19px; font-weight: 500; line-height: 1.4; letter-spacing: .04em; color: var(--viewer-text); }
.viewer-position { margin: 4px 0 0; font-size: 12px; color: var(--viewer-muted); letter-spacing: .08em; }
.viewer-dialog button, .viewer-dialog select, .viewer-dialog a { font: inherit; }
.viewer-button, .viewer-icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; flex-shrink: 0; min-height: 42px; border: 1px solid #ffffff1d; border-radius: 5px; padding: 9px 13px; color: var(--viewer-text); background: transparent; font-size: 12px !important; line-height: 1.4; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.viewer-button:hover, .viewer-icon-button:hover { background: #ffffff0d; border-color: #ffffff4a; }
.viewer-button:focus-visible, .viewer-icon-button:focus-visible, .viewer-version:focus-visible, .viewer-references a:focus-visible { outline: 2px solid #cbb6e6; outline-offset: 3px; }
.viewer-button:disabled, .viewer-icon-button:disabled { opacity: .28; cursor: default; }
.viewer-icon-button { width: 44px; padding: 5px; font-size: 21px !important; }
.viewer-return { border-color: transparent; padding-left: 0; color: var(--viewer-muted); }
.viewer-return > span:first-child { font-size: 22px; }
.viewer-close { margin-left: 2px; border-color: transparent; font-size: 30px !important; }
.viewer-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; min-height: 0; }
.viewer-body.viewer-info-hidden { grid-template-columns: minmax(0, 1fr); }
.viewer-picture-area { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.viewer-stage { display: flex; position: relative; align-items: center; justify-content: center; min-height: 0; overflow: hidden; isolation: isolate; touch-action: none; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.viewer-stage.viewer-is-zoomed { cursor: grab; }
.viewer-stage.viewer-is-dragging { cursor: grabbing; }
.viewer-image { display: block; flex-shrink: 0; max-width: none; max-height: none; object-fit: contain; transform-origin: center center; will-change: transform; pointer-events: none; user-select: none; }
.viewer-loading { display: flex; position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); align-items: center; justify-content: center; gap: 12px; max-width: calc(100% - 32px); border: 1px solid #ffffff13; border-radius: 5px; padding: 9px 14px; color: #ddd7e4; background: #17151ee6; font-size: 12px; cursor: default; text-align: center; }
.viewer-loading.viewer-loading-blocking { top: 50%; bottom: auto; transform: translate(-50%, -50%); }
.viewer-retry { min-height: 36px; }
.viewer-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; min-height: 70px; padding: 12px 22px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid #ffffff13; background: var(--viewer-bg); }
.viewer-navigation, .viewer-zoom-controls { display: inline-flex; align-items: center; gap: 6px; }
.viewer-zoom-label { display: inline-block; width: 37px; color: var(--viewer-muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.viewer-info { min-height: 0; overflow-y: auto; border-left: 1px solid #ffffff13; background: var(--viewer-panel); scrollbar-width: thin; scrollbar-color: #61556c transparent; touch-action: pan-y; }
.viewer-info-content { padding: 34px 25px 30px; }
.viewer-kicker { margin: 0 0 20px; color: #bfa6cf; font-size: 12px; letter-spacing: .2em; }
.viewer-line { margin: 0 0 19px; font-family: var(--sans, system-ui, sans-serif); font-size: 16px; font-weight: 400; line-height: 1.9; }
.viewer-observation { margin: 0 0 22px; color: #c8c0d0; font-size: 14px; line-height: 1.9; }
.viewer-tags { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 25px 0 16px; color: #bbaacb; font-size: 12px; line-height: 1.6; }
.viewer-dimensions { margin: 0 0 16px; color: #afa6ba; font-size: 12px; font-variant-numeric: tabular-nums; }
.viewer-gesture-hint { margin: 0 0 24px; color: #b7adbf; font-size: 12px; line-height: 1.9; }
.viewer-download { width: 100%; font-size: 12px !important; }
.viewer-references { margin-top: 30px; padding-top: 23px; border-top: 1px solid #ffffff15; }
.viewer-references h3 { margin: 0 0 12px; font-size: 12px; font-weight: 400; letter-spacing: .12em; color: var(--viewer-muted); }
.viewer-references ul { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.viewer-references a { display: block; color: #c6b2d5; font-size: 12px; line-height: 1.8; text-decoration-color: #c6b2d540; text-underline-offset: 4px; overflow-wrap: anywhere; }
.viewer-version-label { display: flex; align-items: center; gap: 8px; color: var(--viewer-muted); font-size: 12px; }
.viewer-version { width: 165px; min-height: 38px; padding: 7px; border: 1px solid #ffffff25; border-radius: 4px; color: var(--viewer-text); background: var(--viewer-panel); font-size: 12px !important; }
@media (max-width: 1000px) {
  .viewer-body { grid-template-columns: minmax(0, 1fr) 245px; }
  .viewer-header { gap: 12px; padding-right: 16px; padding-left: 16px; }
  .viewer-return-label { display: none; }
  .viewer-info-content { padding: 26px 20px; }
  .viewer-toolbar { padding-right: 12px; padding-left: 12px; }
  .viewer-native { display: none; }
}
@media (max-width: 700px) {
  .viewer-header { min-height: 75px; gap: 8px; padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left)); }
  .viewer-heading h2 { font-size: 15px; letter-spacing: .02em; }
  .viewer-position { margin-top: 4px; font-size: 12px; }
  .viewer-return { min-width: 32px; padding: 4px; }
  .viewer-close { width: 40px; }
  .viewer-body { display: flex; flex-direction: column; }
  .viewer-picture-area { flex: 1; width: 100%; }
  .viewer-body:not(.viewer-info-hidden) .viewer-picture-area { display: flex; flex-direction: column; flex: 0 0 auto; }
  .viewer-body:not(.viewer-info-hidden) .viewer-stage { flex: 0 0 auto; height: min(calc((100vw - 16px) * var(--viewer-ratio, .563) + 16px), calc(100dvh - 230px)); min-height: 140px; }
  .viewer-info { flex: 1 1 auto; width: 100%; border-left: 0; border-top: 1px solid #ffffff17; }
  .viewer-info-content { padding: 23px 23px max(25px, env(safe-area-inset-bottom)); }
  .viewer-kicker { margin-bottom: 10px; }
  .viewer-line { font-size: 16px; margin-bottom: 12px; }
  .viewer-observation { font-size: 14px; margin-bottom: 18px; }
  .viewer-tags { margin-top: 18px; }
  .viewer-toolbar { min-height: 63px; gap: 3px; flex-wrap: nowrap; padding: 9px 7px max(9px, env(safe-area-inset-bottom)); }
  .viewer-icon-button { width: 38px; min-height: 42px; }
  .viewer-navigation, .viewer-zoom-controls { gap: 1px; }
  .viewer-button { min-height: 42px; padding: 8px; font-size: 12px !important; }
  .viewer-zoom-label { width: 30px; font-size: 12px; }
  .viewer-info-toggle { padding-left: 8px; padding-right: 8px; }
  .viewer-version-label > span { display: none; }
  .viewer-version { width: 112px; min-height: 40px; font-size: 12px !important; }
  .viewer-loading { flex-direction: column; width: max-content; gap: 6px; font-size: 12px; }
}
@media (max-width: 370px) {
  .viewer-icon-button { width: 33px; }
  .viewer-zoom-label { width: 24px; }
  .viewer-info-toggle { padding: 6px; }
  .viewer-version { width: 98px; }
  .viewer-heading h2 { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .viewer-dialog *, .viewer-dialog *::before, .viewer-dialog *::after { scroll-behavior: auto !important; }
}

/* The close view remains connected to the visual relationships of the exhibition. */
.viewer-connections { margin: 22px 0; padding-top: 17px; border-top: 1px solid #ffffff1a; }
.viewer-connections h3 { margin: 0 0 10px; font-size: 12px; font-weight: 400; color: #cbb6dc; }
.viewer-connections > div { display: grid; gap: 8px; }
.viewer-connections a { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 11px; min-height: 60px; padding: 7px 0; color: var(--viewer-text); text-decoration: none; }
.viewer-connections a:hover { background: #ffffff08; }
.viewer-connections a:focus-visible { outline: 2px solid #cbb6e6; outline-offset: 3px; }
.viewer-connections img { width: 60px; height: 49px; object-fit: contain; }
.viewer-connections span { font-size: 12px; line-height: 1.7; }
.viewer-connections small { display: block; margin-top: 4px; color: var(--viewer-muted); font-size: 12px; }

.viewer-compare { margin: 0 0 8px; width: 100%; }

/* State feedback is brief; the picture transform stays immediate for gestures. */
.viewer-save-controls { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; min-height: 42px; }
.viewer-save { flex: 1 1 auto; min-width: 0; margin: 0; }
.viewer-save[aria-pressed="true"] { color: #e2c9f0; border-color: #b394ca66; background: #c5a4db12; }
.viewer-open-enter { animation: viewer-reveal 180ms ease-out both; }
.viewer-image-arrive { animation: viewer-picture-ready 200ms ease-out both; }
.save-confirmed { animation: save-response 180ms ease-out; }
@keyframes viewer-reveal { from { opacity: 0; } to { opacity: 1; } }
@keyframes viewer-picture-ready { from { opacity: .72; } to { opacity: 1; } }
@keyframes save-response { 0%,100% { scale: 1; } 45% { scale: 1.1; } }
.save-feedback {
  position: fixed; z-index: 1000; right: max(18px,env(safe-area-inset-right)); bottom: max(18px,env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 18px; max-width: min(420px,calc(100vw - 36px));
  padding: 9px 12px 9px 17px; border: 1px solid #bda5cf52; border-radius: 4px;
  color: #f0e9f4; background: #292330; box-shadow: 0 7px 24px #100b1d38;
  font: 12px/1.65 var(--sans,system-ui,sans-serif);
}
.save-feedback[hidden] { display: none; }
.save-feedback > span { min-width: 0; overflow-wrap: anywhere; }
.save-feedback > button { flex-shrink: 0; min-width: 44px; min-height: 36px; padding: 5px 8px; border: 0; color: #e1c4f2; background: transparent; font-size: 12px !important; }
.viewer-dialog .save-feedback { position: static; inset: auto; flex: 0 0 auto; width: auto; max-width: none; margin: 0; padding: 0; gap: 0; border: 0; background: transparent; box-shadow: none; }
.viewer-dialog .save-feedback > span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.viewer-dialog .save-feedback > button { min-height: 42px; padding: 8px; }
.viewer-dialog .save-feedback[hidden] { display: none !important; }
.save-feedback-arrive { animation: viewer-reveal 180ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .viewer-open-enter, .viewer-image-arrive, .save-confirmed, .save-feedback-arrive { animation: none !important; }
}
