@import "./editor-toolbar.css";
@import "./embed-configurator.css";
@import "./upload-panel.css";
@import "./models-panel.css";
@import "./gallery.css";
@import "./validation-report.css";
@import "./ground-panel.css";
@import "./event-log.css";
@import "./ai.css";
@import "./admin-panel.css";
@import "./login-panel.css";
@import "./ifc-properties.css";
@import "./viewer-tools.css";
@import "./materials-panel.css";
@import "./assistant.css";
@import "./menu-toolbar.css";
@import "./context-menu.css";

#cboxLoadedContent.iipmooviewer {
  position: absolute;
  overflow: hidden !important;
}

#cboxLoadedContent.iipmooviewer > .cboxPhoto {
  visibility: hidden;
}

.iipmooviewer .navcontainer .navbuttons {
  z-index: 100;
}

.iipmooviewer .canvas {
  width: 100% !important;
  height: 100% !important;
}

a.colorbox {
  position: relative;
  display: block;
}

a.wisski-inline-iip > div#wisski-iip-cont {
  position: relative;
  display: block;
}

a.wisski-inline-iip > div#wisski-iip-cont > img {
  visibility: hidden;
}

.mainContainer, canvas {
  box-sizing: border-box;
}

.mainContainer {
  --viewer-toolbar-max-width: 1080px;
  --viewer-toolbar-height: 58px;
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: block;
  position: relative;
}

.mainContainer.fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9999;
}
.viewer-window-controls {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}
.viewer-window-drag-handle {
  position: absolute;
  top: 0;
  left: 50%;
  width: 96px;
  height: 24px;
  transform: translateX(-50%);
  cursor: move;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 140ms ease;
}
.viewer-window-drag-handle::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 24px;
  height: 8px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 255, 255, .82) 1.5px, transparent 2px) 0 0 / 8px 8px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .55));
}
.viewer-window-controls-enabled:hover .viewer-window-drag-handle,
.viewer-window-drag-handle:hover {
  opacity: .72;
}
.viewer-window-resize-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: auto;
}
.viewer-window-resize-top-left { top: 0; left: 0; cursor: nwse-resize; }
.viewer-window-resize-top-right { top: 0; right: 0; cursor: nesw-resize; }
.viewer-window-resize-bottom-left { bottom: 0; left: 0; cursor: nesw-resize; }
.viewer-window-resize-bottom-right { bottom: 0; right: 0; cursor: nwse-resize; }
.mainContainer.fullscreen .viewer-window-controls {
  display: none;
}

.mainCanvas {
  display: block;
  border-radius: 6px;
}

canvas {
  display: block;
  z-index: 10;
  background: radial-gradient(circle, #ffffff 0%, #999999 100%);
  width: 100%;
  height: 100%;
  position: absolute;
  pointer-events: auto !important;
}

.lil-gui.root {
  position: relative;
}

#handHint {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 48px;
  height: 48px;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  left: 0px;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.9));
}

#viewerNoticeContainer {
  --viewer-notice-safe-bottom: 8px;
  max-width: calc(100% - 88px);
  position: absolute;
  left: 50%;
  bottom: calc(var(--viewer-notice-safe-bottom) + var(--viewer-notice-loading-offset, 0px));
  transform: translateX(-50%);
  transition: bottom 300ms ease;
  /* Above the panel windows (99999) and the upload overlay (100000), so
     errors raised from inside a panel (e.g. plans, account link) stay visible. */
  z-index: 100001;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.mainContainer:has(#viewerEditorToolbar) #viewerNoticeContainer {
  --viewer-notice-safe-bottom: calc(
    14px +
    (var(--viewer-toolbar-height) * clamp(0.75, calc(98vw / var(--viewer-toolbar-max-width)), 1)) +
    10px
  );
}

.viewer-embed-page .mainContainer:has(#viewerEditorToolbar) #viewerNoticeContainer {
  --viewer-notice-safe-bottom: calc(
    12px +
    (var(--viewer-toolbar-height) * clamp(0.62, calc((100vw - 48px) / var(--viewer-toolbar-max-width)), 0.9)) +
    8px
  );
}

/* While the model loads, the percentage badge sits just above the toolbar
   (editor-toolbar.css); lift the notices over it so "model loaded" does not
   cover it. data-loading stays on through the "complete" fade-out. */
.mainContainer:has(#viewerEditorToolbar[data-loading]) #viewerNoticeContainer {
  --viewer-notice-loading-offset: 40px;
}

/* On a phone with the menus (syncNoticeAboveToolbar() in editor-toolbar.js):
   at the top, across the viewer under the logo - the bottom is the tools'. */
#viewerNoticeContainer.viewer-notice-container--top:not(.viewer-notice-container--sandbox):not(.viewer-notice-container--shortcuts) {
  top: var(--viewer-notice-top, 56px);
  bottom: auto;
  left: var(--viewer-notice-left, 12px);
  right: 12px;
  max-width: none;
  transform: none;
  transition: top 300ms ease;
}

#viewerNoticeContainer.viewer-notice-container--sandbox {
  top: 50%;
  bottom: auto;
  max-width: min(520px, calc(100% - 32px));
  transform: translate(-50%, -50%);
}

#viewerNoticeContainer.viewer-notice-container--shortcuts {
  left: auto;
  right: 16px;
  bottom: auto;
  top: 50%;
  max-width: min(380px, calc(100% - 32px));
  transform: translateY(-50%);
}

/* Keep the shortcuts notice off the IFC properties panel (see viewer/ifc-properties.js). */
#viewerNoticeContainer.viewer-notice-container--shortcuts[data-ifc-panel="open"] {
  right: auto;
  left: 16px;
}

#viewerNoticeContainer.viewer-notice-container--shortcuts[data-ifc-panel="crowded"] {
  display: none;
}

.viewer-notice {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--viewer-notice-container-bg);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--viewer-notice-container-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(12, 10, 8, 0.18);
}

.viewer-notice-status {
  position: relative;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: pre-line;
  text-align: center;
  border-radius: 14px;
  line-height: 1.45;
  letter-spacing: 0.015em;
  text-wrap: balance;
  word-break: break-word;
  font-weight: 350;
  min-width: 20vh;
}

.viewer-notice-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.viewer-notice-close:hover {
  opacity: 1;
  background: rgba(127, 127, 127, 0.24);
}

.viewer-notice-status.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.viewer-notice-status.is-hiding {
  opacity: 0;
  transform: translateY(6px) scale(0.98);
}

.viewer-notice-status[data-tone="success"] {
  background: rgba(46, 37, 26, 0.8);
  border-color: rgba(233, 178, 100, 0.42);
}

.viewer-notice-status[data-tone="error"] {
  background: rgba(127, 29, 29, 0.76);
  border-color: rgba(254, 202, 202, 0.28);
}

.viewer-notice-status[data-tone="warning"] {
  background: rgba(120, 53, 15, 0.76);
  border-color: rgba(253, 230, 138, 0.26);
}

.viewer-notice-status[data-tone="info"] {
  background: var(--viewer-notice-container-bg);
  border-color: rgba(217, 195, 160, 0.22);
}

.viewer-notice-status[data-variant="sandbox"] {
  padding: 14px 20px;
  width: min(380px, calc(100vw - 48px));
  max-width: 100%;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 450;
  white-space: normal;
  background: rgba(22, 19, 16, 0.64);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 18px 56px rgba(12, 10, 8, 0.28);
  box-shadow: 0 0 0 0 rgba(233, 178, 100, 0.0),
              0 18px 56px rgba(12, 10, 8, 0.28);

  animation: sandbox-outline 2.4s ease-in-out infinite;
}

.viewer-notice-status[data-variant="sandbox"] .viewer-notice-message,
.viewer-notice-status[data-variant="sandbox"] .viewer-notice-detail {
  display: block;
}

.viewer-notice-message {
  padding-bottom: 10px;
}

.viewer-notice-status[data-variant="sandbox"] .viewer-notice-detail {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 400;
  opacity: 0.9;
}

@keyframes sandbox-outline {
  0% {
    box-shadow: 0 0 0 0 rgba(233, 178, 100, 0.0),
                0 18px 56px rgba(12, 10, 8, 0.28);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(233, 178, 100, 0.43),
                0 18px 56px rgba(12, 10, 8, 0.28);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(233, 178, 100, 0.0),
                0 18px 56px rgba(12, 10, 8, 0.28);
  }
}

.viewer-notice-status[data-variant="shortcuts"] {
  padding: 12px 16px;
  width: min(380px, calc(100vw - 48px));
  max-width: 100%;
  text-align: left;
  white-space: normal;
}

.viewer-notice-status[data-variant="shortcuts"] .viewer-notice-message {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  padding-bottom: 8px;
}

.viewer-notice-status[data-variant="shortcuts"] .viewer-notice-detail {
  display: block;
  padding: 3px 0;
}

.viewer-shortcut-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.viewer-shortcut-row svg {
  flex: none;
  margin-top: 1px;
  opacity: 0.85;
}

@keyframes fadeIn {
  to {
    opacity: 0.6;
  }
}

.hand-drag-animate {
  animation: fadeIn 2.5s ease forwards;
  transform: translateX(var(--hand-x));
  will-change: transform;
}

#guiContainer {
  position: absolute;
  top: 0px;
  left: auto;
  z-index: 100;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.lil-gui.root>.title {
  background: var(--viewer-gui-title-hover-bg);
  opacity: 1.0;
}

#guiContainer > .lil-gui.root > .children > .lil-gui.viewer-gui-main-folder > .title {
  background: var(--viewer-gui-title-hover-bg);
  opacity: 1;
}

@media (hover: hover) {
    body:not(.lil-gui-dragging) .lil-gui .title:hover {
        background: var(--viewer-gui-title-hover-bg);
        opacity: 1.0;
    }
}

#guiContainer > .lil-gui.root {
  margin: 0;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  --background-color: var(--viewer-gui-bg);
  --title-background-color: var(--viewer-gui-title-bg);
  --title-text-color: var(--viewer-panel-text);
  --text-color: var(--viewer-panel-text);
  --widget-color: var(--viewer-gui-widget-bg);
  --hover-color: var(--viewer-gui-widget-hover-bg);
  --focus-color: var(--viewer-gui-widget-focus-bg);
  --number-color: var(--viewer-brand-blue);
  --string-color: var(--viewer-brand-gold);
  --color: var(--viewer-panel-text);
  background: var(--viewer-gui-bg);
  border-radius: 6px;
}

#guiContainer > .lil-gui.root,
#guiContainer > .lil-gui.root .title,
#guiContainer > .lil-gui.root .name,
#guiContainer > .lil-gui.root .controller,
#guiContainer > .lil-gui.root .children,
#guiContainer > .lil-gui.root button,
#guiContainer > .lil-gui.root input,
#guiContainer > .lil-gui.root select {
  color: var(--viewer-panel-text);
}

#guiContainer > .lil-gui.root button,
#guiContainer > .lil-gui.root input,
#guiContainer > .lil-gui.root select,
#guiContainer > .lil-gui.root .display,
#guiContainer > .lil-gui.root .slider {
  background: var(--viewer-gui-widget-bg);
  color: var(--viewer-panel-text);
}

#guiContainer > .lil-gui.root button:hover,
#guiContainer > .lil-gui.root .display:hover,
#guiContainer > .lil-gui.root .slider:hover,
#guiContainer > .lil-gui.root input:hover,
#guiContainer > .lil-gui.root select:hover {
  background: var(--viewer-gui-widget-hover-bg);
}

#guiContainer > .lil-gui.root button:active,
#guiContainer > .lil-gui.root button:focus,
#guiContainer > .lil-gui.root input:focus,
#guiContainer > .lil-gui.root select:focus {
  background: var(--viewer-gui-widget-focus-bg);
  color: #ffffff;
}

#guiContainer > .lil-gui.root input[type="checkbox"] {
  border: 1px solid color-mix(in srgb, var(--viewer-panel-text) 18%, transparent);
  background: var(--viewer-gui-widget-bg);
}

#guiContainer > .lil-gui.root input[type="checkbox"]:checked {
  background: var(--viewer-gui-slider-fill);
}

#guiContainer > .lil-gui.root input[type="checkbox"]:checked::before {
  color: var(--viewer-gui-checkbox-tick);
}

#guiContainer > .lil-gui.root .slider .fill {
  background: var(--viewer-gui-slider-fill);
}

/* Model loading (loading-status.js). With the editor toolbar on screen the
   progress is a thin ring around it plus a small percentage above it
   (editor-toolbar.css), and this card is only kept for screen readers
   (data-on-toolbar). Without the toolbar: a hairline along the top edge of
   the viewer and the percentage in its corner. */
#spinnerContainer {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  pointer-events: none;
}

.model-loader {
  --model-loader-progress: 0;
  position: relative;
  display: block;
  color: var(--viewer-panel-text, rgba(255, 255, 255, 0.92));
  font-family: -apple-system, BlinkMacSystemFont, "Lucida Grande", "Segoe UI", Roboto, Arial, sans-serif;
  opacity: 1;
  transition: opacity 600ms ease;
}

.model-loader[hidden] {
  display: none !important;
}

.model-loader[data-complete="true"] {
  opacity: 0;
  transition: opacity 900ms ease 500ms;
}

.model-loader[data-on-toolbar] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.model-loader__track {
  height: 3px;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.model-loader__bar {
  width: 0;
  height: 100%;
  background: var(--viewer-loader-accent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--viewer-loader-accent) 60%, transparent);
  transition: width 300ms ease;
}

.model-loader__ring {
  position: absolute;
  top: 8px;
  right: max(12px, env(safe-area-inset-right));
}

.model-loader__percent {
  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--viewer-loader-accent, #e9b264) 45%, transparent);
  border-radius: 999px;
  color: currentColor;
  background: color-mix(in srgb, var(--viewer-panel-bg, rgba(22, 19, 16, 0.82)) 88%, transparent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* The phase messages stay readable for screen readers only. */
.model-loader__phase-viewport {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .model-loader,
  .model-loader__bar {
    transition: none;
  }
}

#loading-log {
  position: fixed;
  left: 0px;
  bottom: 0px;
  z-index: 90;
  width: min(260px, calc(100% - 32px));
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.78);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 10px;
  line-height: 1.3;
  pointer-events: auto;
  background: rgba(8, 7, 5, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
  transform: translateX(8px) translateY(50vh) scale(var(--viewer-toolbar-scale));
}

#loading-log[hidden] {
  display: block;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
}

.loading-log__collapsed-toggle {
  display: none;
}

.loading-log__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  min-height: 18px;
  padding: 0 16px 0 0;
  border: 0;
  color: rgba(238, 237, 231, 0.82);
  font: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.loading-log__header::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid rgba(255, 255, 255, 0.62);
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.62);
  transform: translateY(-60%) rotate(45deg);
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 0.8;
}

.loading-log__header:hover::after,
.loading-log__header:focus-visible::after {
  opacity: 1;
}

.loading-log__header:focus-visible {
  outline: 0;
}

.loading-log__title {
  font-weight: 600;
  font-size: 11px;
}

.loading-log__summary {
  min-width: 0;
  color: rgba(255, 255, 255, 0.58);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading-log__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease, opacity 220ms ease;
  opacity: 0.96;
}

.loading-log__body > * {
  min-height: 0;
  overflow: hidden;
}

#loading-log[data-expanded="true"] .loading-log__header::after {
  transform: translateY(-30%) rotate(225deg);
}

#loading-log[data-expanded="true"] .loading-log__body {
  grid-template-rows: 1fr;
  opacity: 1;
}

#loading-log[data-expanded="true"] {
  padding: 8px 10px;
  background: rgba(8, 7, 5, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

#loading-log:not([data-expanded="true"]) .loading-log__messages {
  display: none;
}

#loading-log:not([data-expanded="true"]) .loading-log__body {
  grid-template-rows: 1fr;
  opacity: 1;
}

#loading-log:not([data-expanded="true"]) .loading-log__summary {
  display: none;
}

.loading-log__messages {
  min-height: 48px;
  display: grid;
  align-content: end;
  gap: 3px;
  padding-top: 8px;
}

.loading-log__message {
  opacity: 0.46;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading-log__message--active {
  color: rgba(255, 255, 255, 0.92);
  opacity: 1;
}

.loading-log__message--done {
  color: rgba(210, 255, 233, 0.82);
  opacity: 0.82;
}

.loading-log__message--done::before {
  content: "✓";
  display: inline-block;
  width: 10px;
  color: rgba(114, 224, 184, 0.9);
}

.loading-log__progress {
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

#loading-log:not([data-expanded="true"]) .loading-log__progress {
  height: 2px;
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

@media (max-width: 520px) {
  #loading-log {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

.loading-log__progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, rgba(110, 168, 254, 0.82), rgba(114, 224, 184, 0.9));
  border-radius: inherit;
  transition: width 220ms ease;
}

.loading-log--done .loading-log__progress-bar {
  background: rgba(114, 224, 184, 0.92);
}

.loading-log--error {
  border-color: rgba(255, 93, 93, 0.35);
}

.loading-log__header {
  margin-bottom: 0;
}

.toastify {
  padding: 12px 20px;
  color: #ffffff;
  display: inline-block;
  box-shadow:
    0 3px 6px -1px rgba(0, 0, 0, 0.12),
    0 10px 36px -4px rgba(74, 61, 44, 0.3);
  background: -webkit-linear-gradient(315deg, #a68b64, #4a3d2c);
  background: linear-gradient(135deg, #a68b64, #4a3d2c);
  position: fixed;
  right: 15px;
  opacity: 0;
  transition: all 1.4s cubic-bezier(0.215, 0.61, 0.355, 1);
  border-radius: 2px;
  cursor: pointer;
  z-index: 15;
}

.toastify.on {
  opacity: 1;
}

.toast-close {
  border: none;
  background: none;
  padding-left: 8px;
}

.hierarchy {
  max-height: 500px;
  overflow-x: hidden;
  overflow-y: scroll;
}

.hierarchy::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  background-color: #f5f5f5;
}

.hierarchy::-webkit-scrollbar {
  width: 6px;
  background-color: #f5f5f5;
}

.hierarchy::-webkit-scrollbar-thumb {
  border-radius: 6px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
  background-color: #555;
}

.closed {
  overflow: hidden;
}

#TextCanvas {
  position: absolute;
  z-index: 8;
  pointer-events: none;
  --font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  color: #000000;
  font-family: var(--font-family);
  font-size: 14px;
  font-style: normal;
  font-weight: 350;
  padding: 10px 0 0 15px;
  max-width: 70%;
  width: 70%;
}

/* Museum palette: the app icon's gold with a sand beige, over near-black
   umber neutrals (panels) and parchment (light theme), for the viewer's
   accents (active buttons, selection, focus, sliders, loading, documented
   timeline events). The "blue" names stay for the stylesheets using them.
   --viewer-brand-blue-strong, a dark coffee brown, fills behind white text
   (11:1); the light theme has darker tones, for contrast on its panels.
   On :root, so panels outside .viewer-wrapper (manifest form) have them. */
:root {
  --viewer-brand-blue: #d9c3a0;
  --viewer-brand-blue-strong: #4a3d2c;
  --viewer-brand-gold: #e9b264;
}

html[data-viewer-theme="light"],
.viewer-wrapper[data-viewer-theme="light"],
#form-manifesto[data-viewer-theme="light"] {
  --viewer-brand-blue: #4a3d2c;
  --viewer-brand-blue-strong: #4a3d2c;
  --viewer-brand-gold: #a8701f;
}

.viewer-wrapper {
  position: relative;
  --viewer-shell-bg: linear-gradient(180deg, #0f0d0b 0%, #171411 100%);
  --viewer-panel-bg: rgba(22, 19, 16, 0.82);
  --viewer-panel-bg-hover: rgba(22, 19, 16, 0.92);
  --viewer-panel-border: rgba(255, 255, 255, 0.12);
  --viewer-panel-shadow: 0 12px 30px rgba(12, 10, 8, 0.28);
  --viewer-panel-text: rgba(255, 255, 255, 0.94);
  --viewer-loader-accent: var(--viewer-brand-gold);
  --viewer-gui-bg: rgba(38, 34, 29, 0.9);
  --viewer-gui-title-bg: rgba(38, 34, 29, 0.9);
  --viewer-gui-title-hover-bg: rgba(24, 21, 18, 0.9);
  --viewer-gui-widget-bg: rgba(255, 255, 255, 0.14);
  --viewer-gui-widget-hover-bg: rgba(255, 255, 255, 0.2);
  --viewer-gui-widget-focus-bg: var(--viewer-brand-blue-strong);
  --viewer-gui-slider-fill: var(--viewer-brand-blue);
  --viewer-gui-checkbox-tick: rgba(255, 255, 255, 0.96);
  --metadata-border: rgba(255, 255, 255, 0.12);
  --metadata-shadow: 0 12px 30px rgba(12, 10, 8, 0.28);
  --metadata-label-color: rgba(255, 255, 255, 0.62);
  --metadata-value-color: rgba(255, 255, 255, 0.94);
  --metadata-accent: rgba(255, 255, 255, 0.82);
  --metadata-card-bg: rgba(22, 19, 16, 0.82);
  --metadata-card-bg-hover: rgba(22, 19, 16, 0.92);
  --metadata-card-bg-open: rgba(22, 19, 16, 0.88);
  --metadata-row-bg: rgba(255, 255, 255, 0.12);
  --metadata-row-bg-hover: rgba(255, 255, 255, 0.18);
  --metadata-row-bg-first: rgba(255, 255, 255, 0.16);
  --metadata-row-bg-pinned: rgba(255, 255, 255, 0.2);
  --metadata-row-border: rgba(176, 160, 138, 0.28);
  --metadata-row-border-strong: rgba(176, 160, 138, 0.34);
  --metadata-row-border-pinned: rgba(176, 160, 138, 0.38);
  --metadata-fade: linear-gradient(
    to bottom,
    rgba(22, 19, 16, 0),
    rgba(22, 19, 16, 0.56) 58%,
    rgba(22, 19, 16, 0.82)
  );
  --viewer-notice-container-bg: rgba(22, 19, 16, 0.9);
  --viewer-notice-container-text: rgba(255, 255, 255, 0.94);
  --viewer-panel-embed-bg: rgba(22, 19, 16, 0.92);
  --viewer-panel-bg-embed-hover: rgba(22, 19, 16, 1.0);
  background: var(--viewer-shell-bg);
}

.viewer-wrapper[data-viewer-theme="light"] {
  --viewer-shell-bg: linear-gradient(180deg, #f7f5f1 0%, #ebe7df 100%);
  --viewer-panel-bg: rgba(252, 250, 246, 0.94);
  --viewer-panel-bg-hover: rgba(255, 253, 249, 0.98);
  --viewer-panel-border: rgba(164, 151, 132, 0.28);
  --viewer-panel-shadow: 0 14px 30px rgba(129, 116, 96, 0.16);
  --viewer-panel-text: rgba(37, 33, 28, 0.92);
  --viewer-loader-accent: var(--viewer-brand-gold);
  --viewer-gui-bg: rgba(249, 246, 240, 0.96);
  --viewer-gui-title-bg: rgba(243, 238, 230, 0.98);
  --viewer-gui-title-hover-bg: rgba(236, 230, 220, 0.98);
  --viewer-gui-widget-bg: rgba(236, 230, 220, 0.9);
  --viewer-gui-widget-hover-bg: rgba(228, 221, 210, 0.96);
  --viewer-gui-widget-focus-bg: var(--viewer-brand-blue-strong);
  --viewer-gui-slider-fill: var(--viewer-brand-gold);
  --viewer-gui-checkbox-tick: rgba(37, 33, 28, 0.92);
  --metadata-border: rgba(164, 151, 132, 0.24);
  --metadata-shadow: 0 14px 30px rgba(129, 116, 96, 0.16);
  --metadata-label-color: rgba(96, 82, 66, 0.82);
  --metadata-value-color: rgba(37, 33, 28, 0.94);
  --metadata-accent: rgba(66, 56, 45, 0.74);
  --metadata-card-bg: rgba(250, 247, 242, 0.94);
  --metadata-card-bg-hover: rgba(255, 252, 247, 0.98);
  --metadata-card-bg-open: rgba(252, 249, 244, 0.97);
  --metadata-row-bg: rgba(245, 241, 234, 0.94);
  --metadata-row-bg-hover: rgba(241, 236, 228, 0.98);
  --metadata-row-bg-first: rgba(252, 249, 244, 0.98);
  --metadata-row-bg-pinned: rgba(255, 252, 247, 1);
  --metadata-row-border: rgba(164, 151, 132, 0.2);
  --metadata-row-border-strong: rgba(136, 122, 102, 0.28);
  --metadata-row-border-pinned: rgba(136, 122, 102, 0.34);
  --metadata-fade: linear-gradient(
    to bottom,
    rgba(250, 247, 242, 0),
    rgba(244, 239, 231, 0.88) 58%,
    rgba(236, 230, 220, 0.98)
  );
  --viewer-notice-container-bg: rgba(236, 230, 220, 0.9);
  --viewer-notice-container-text: rgba(22, 19, 16, 0.92);
}

#metadata-container {
  width: auto;
  min-width: 0;
  /* No max-width here: it's just a full-size, pointer-events:none
     positioning shell for #metadata-card (see main.js's resize handler,
     which keeps this at 100%x100% of the viewer) - #metadata-card's own
     max-width) below) governs its default width. Capping this container
     itself would put a hard ceiling under #metadata-card's own resize
     handle, defeating manual resizing past the old 320px default. */
  position: absolute;
  left: 0px;

  pointer-events: none;
  z-index: 999;

  font-family: -apple-system, BlinkMacSystemFont, "Lucida Grande",
             "Segoe UI", Roboto, Arial, sans-serif;
}

#metadata-container::before {
  content: "";
  position: absolute;
  left: 6px;
  width: 1px;
  height: auto;
  bottom: 0;
}

/* Model details: the file and a one-line summary; open, the counts as tiles
   and the entity's metadata as a flat list. */
#metadata-card {
  position: relative;
  padding: 12px 14px;
  border-radius: 6px;
  width: min(260px, 26vw);
  max-width: 100%;
  min-width: 180px;
  min-height: 46px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--metadata-card-bg) 84%, transparent);
  border: 1px solid var(--metadata-border);
  box-shadow: var(--metadata-shadow);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  /* Draggable via .metadata-drag-handle (startMetadataDrag() in
     metadata.js); it is the button of #metadata-window below. */
  transform: translate3d(var(--drag-x, 0px), var(--drag-y, 0px), 0);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  resize: none;
  overflow: hidden;
  transition:
    width 700ms cubic-bezier(0.23, 1, 0.32, 1),
    background 760ms ease,
    border-color 760ms ease,
    box-shadow 760ms ease;
}

#metadata-card:hover {
  background: var(--metadata-card-bg-hover);
  border-color: var(--metadata-row-border-strong);
  box-shadow: var(--metadata-shadow);
}

#metadata-card.metadata-open {
  background: var(--metadata-card-bg-open);
  border-color: var(--metadata-row-border-strong);
}

/* The model's details, opened from the card (metadata.js): a window that
   grows out of it, moved by its header, resized by its corner, kept inside
   the viewer and off the toolbar (getMetadataWindowBounds()). */
#metadata-window {
  position: absolute;
  left: var(--window-x, 8px);
  top: var(--window-y, 64px);
  width: min(340px, calc(100% - 16px));
  min-width: 200px;
  min-height: 120px;
  max-height: min(72vh, 640px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 0 14px 12px;
  border-radius: 10px;
  background: var(--metadata-card-bg-open);
  border: 1px solid var(--metadata-row-border-strong);
  box-shadow: var(--metadata-shadow);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  pointer-events: auto;
  resize: both;
  overflow: hidden;
  transform-origin: var(--window-origin-x, 0px) var(--window-origin-y, 0px);
  animation: metadata-window-in 360ms cubic-bezier(0.2, 0.9, 0.25, 1);
}

#metadata-window[hidden] {
  display: none;
}

#metadata-window.metadata-window-closing {
  animation: metadata-window-out 220ms cubic-bezier(0.4, 0, 0.8, 0.4) forwards;
  pointer-events: none;
}

@keyframes metadata-window-in {
  from { opacity: 0; transform: scale(0.12); }
  to { opacity: 1; transform: none; }
}

@keyframes metadata-window-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.12); }
}

@media (prefers-reduced-motion: reduce) {
  #metadata-window,
  #metadata-window.metadata-window-closing {
    animation: none;
  }
}

.metadata-window-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0 -14px;
  padding: 0 6px 0 14px;
  border-bottom: 1px solid var(--metadata-border);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#metadata-window.metadata-dragging .metadata-window-header {
  cursor: grabbing;
}

.metadata-window-title {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--metadata-value-color);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metadata-window-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--metadata-label-color);
  cursor: pointer;
}

.metadata-window-close:hover {
  color: var(--metadata-value-color);
  background: color-mix(in srgb, var(--metadata-value-color) 10%, transparent);
}

.metadata-window-close:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--metadata-value-color) 40%, transparent);
  outline-offset: 1px;
}

.metadata-window-close svg {
  width: 18px;
  height: 18px;
}

.metadata-drag-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  border-radius: 6px 6px 0 0;
  z-index: 1;
}

/* Shown only while the card is hovered. */
.metadata-drag-handle::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--metadata-label-color);
  opacity: 0;
  transition: opacity 0.2s ease;
}

#metadata-card:hover .metadata-drag-handle::before {
  opacity: 0.45;
}

.metadata-drag-handle:hover::before,
#metadata-card:hover .metadata-drag-handle:hover::before {
  opacity: 0.8;
}

#metadata-card.metadata-dragging,
#metadata-card.metadata-dragging .metadata-drag-handle {
  cursor: grabbing;
}

#metadata-content {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  padding-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.metadata-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.metadata-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--metadata-value-color) 7%, transparent);
}

.metadata-stat-value {
  color: var(--metadata-value-color);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metadata-stat-label {
  color: var(--metadata-label-color);
  font-size: 11px;
}

.metadata-row {
  pointer-events: auto !important;
  display: grid;
  grid-template-columns: minmax(80px, 36%) minmax(0, 1fr);
  column-gap: 10px;
  font-size: 12px;
  line-height: 1.35;
  align-items: baseline;
  position: relative;
  padding: 7px 2px;
  border-bottom: 1px solid var(--metadata-border);
  transition: background 0.2s ease;
}

.metadata-row:last-child {
  border-bottom: 0;
}

.metadata-label {
  color: var(--metadata-label-color);
  font-size: 12px;
  font-weight: 400;
  display: inline;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.metadata-value {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  color: var(--metadata-value-color);
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Lucida Grande",
             "Segoe UI", Roboto, Arial, sans-serif;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.metadata-row.metadata-row-expandable {
  cursor: pointer;
}

.metadata-row.metadata-row-expandable:hover .metadata-value {
  color: color-mix(in srgb, var(--metadata-value-color) 80%, var(--metadata-label-color));
}

.metadata-row.metadata-row-pinned .metadata-value {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

.metadata-row.metadata-row-pinned {
  z-index: 2;
}

.metadataSeparator {
  height: 1px;
}

#metadata-window.metadata-window-overflowing #metadata-content::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  /*height: 54px;*/
  pointer-events: none;
  background: var(--metadata-fade);
}

#metadata-collapse {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0;
  color: var(--viewer-panel-text);
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  background: transparent;
  border: 0;
  text-align: left;
  appearance: none;
}

#metadata-collapse:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--metadata-value-color) 40%, transparent);
  outline-offset: 4px;
  border-radius: 6px;
}

.metadata-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.metadata-toggle-title {
  color: var(--metadata-value-color);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metadata-toggle-summary {
  color: var(--metadata-label-color);
  font-size: 11px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The IIIF drag-and-drop icon (metadata.js), left of the chevron; the title
   stops short of it. */
.metadata-iiif {
  position: absolute;
  top: 20px;
  right: 40px;
  display: block;
  line-height: 0;
  border-radius: 4px;
  z-index: 2;
}
.metadata-iiif img { width: 22px; height: 20px; display: block; }
.metadata-iiif:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--metadata-value-color) 40%, transparent);
  outline-offset: 3px;
}
#metadata-card.metadata-has-iiif .metadata-toggle-copy { padding-right: 30px; }

.metadata-toggle-chevron {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.metadata-toggle-chevron::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 5px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid rgba(255, 255, 255, 0.78);
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.78);
  transform: rotate(45deg);
  transition: transform .18s ease;
}

.viewer-wrapper[data-viewer-theme="light"] .metadata-toggle-chevron::before {
  border-right-color: rgba(66, 56, 45, 0.74);
  border-bottom-color: rgba(66, 56, 45, 0.74);
}

.viewer-wrapper[data-viewer-theme="light"] .embed-icon {
  background-color: rgba(66, 56, 45, 0.82);
}

.viewer-wrapper[data-viewer-theme="light"] .share-view-icon {
  background-color: rgba(66, 56, 45, 0.82);
}

#metadata-collapse.metadata-collapsed .metadata-toggle-chevron::before {
  transform: rotate(-45deg);
}

.viewer-wrapper[data-viewer-theme="dark"] #metadata-container::before {
  background: linear-gradient(
    to bottom,
    rgba(255,255,255,.4),
    rgba(255,255,255,.15),
    transparent
  );
}

#viewerActionMenu {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 999999;
  line-height: 0;
}

.viewer-stats {
  position: absolute !important;
  top: 0px !important;
  right: -90px !important;
  max-height: 120px;
  max-width: 90px;
  z-index: 2;
  visibility: hidden;
}

#annotationDialog[hidden] {
  display: none !important;
}

#annotationDialog {
  position: fixed;
  inset: auto;
  width: 0;
  height: 0;
  z-index: 999999;
  overflow: hidden;
}

.annotation-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 22, 0.56);
  backdrop-filter: blur(1.5px);
}

.annotation-dialog__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(820px, calc(100% - 28px));
  max-width: calc(100% - 28px);
  max-height: min(82%, 700px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--viewer-panel-border);
  background: var(--viewer-panel-bg);
  color: var(--viewer-panel-text);
  box-shadow: var(--viewer-panel-shadow);
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Lucida Grande",
            "Segoe UI", Roboto, Arial, sans-serif;
}

.annotation-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.annotation-dialog__header h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.annotation-dialog__close,
.annotation-dialog__actions button {
  border: 1px solid var(--viewer-panel-border);
  border-radius: 6px;
  background: var(--viewer-panel-bg);
  color: var(--viewer-panel-text);
  font: inherit;
  padding: 6px 10px;
  cursor: pointer;
}

.annotation-dialog__close {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.annotation-dialog__close:hover,
.annotation-dialog__actions button:hover {
  background: var(--viewer-panel-bg-hover);
}

.annotation-dialog__form {
  display: grid;
  gap: 10px;
}

.annotation-dialog__form label {
  display: grid;
  gap: 5px;
  font-weight: 600;
}

.annotation-dialog__form input,
.annotation-dialog__form textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--viewer-panel-border);
  border-radius: 6px;
  background: var(--viewer-panel-bg);
  color: var(--viewer-panel-text);
  font: inherit;
  padding: 7px 9px;
}

.annotation-dialog__form textarea {
  resize: vertical;
  min-height: 120px;
}

.annotation-dialog__form .annotation-dialog__checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.annotation-dialog__form .annotation-dialog__checkbox input {
  width: auto;
  margin: 0;
}

.annotation-dialog__form select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--viewer-panel-border);
  border-radius: 6px;
  background: var(--viewer-panel-bg);
  color: var(--viewer-panel-text);
  font: inherit;
  font-weight: 400;
  padding: 7px 9px;
}

/* Level of Certainty and what it applies to, side by side. */
.annotation-dialog__certainty {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 8px;
}

.annotation-dialog__certainty[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .annotation-dialog__certainty {
    grid-template-columns: 1fr;
  }
}

/* Level of Certainty legend (editor/certainty.js). Each level reads by its
   colour, its code and its symbol. */
.certainty-legend {
  box-sizing: border-box;
  width: 300px;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--viewer-panel-border);
  border-radius: 8px;
  background: var(--viewer-panel-bg);
  color: var(--viewer-panel-text);
  box-shadow: var(--viewer-panel-shadow);
  font: 13px/1.3 system-ui, sans-serif;
}

.certainty-legend__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.certainty-legend__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.certainty-legend__close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.certainty-legend__close:hover {
  background: var(--viewer-panel-bg-hover);
}

.certainty-legend__select-all {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--viewer-panel-border);
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.certainty-legend__select-all:hover {
  background: var(--viewer-panel-bg-hover);
}

.certainty-legend__select-all:focus-visible {
  outline: 2px solid var(--viewer-panel-text);
  outline-offset: 2px;
}

.certainty-legend__levels {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.certainty-legend__row {
  display: grid;
  grid-template-columns: 22px 16px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}

.certainty-legend__swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: box-shadow 0.12s ease, transform 0.12s ease;
}

.certainty-legend__swatch:hover {
  transform: scale(1.08);
}

.certainty-legend__swatch:focus-visible {
  outline: 2px solid var(--viewer-panel-text);
  outline-offset: 2px;
}

/* Picked in the filter: a ring in the panel's text colour. */
.certainty-legend__swatch.is-active {
  box-shadow:
    0 0 0 2px var(--viewer-panel-bg),
    0 0 0 4px var(--viewer-panel-text);
}

.certainty-legend__row.is-filtered-out > :not(.certainty-legend__swatch) {
  opacity: 0.4;
}

.certainty-legend__code {
  font-weight: 700;
}

.certainty-legend__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.certainty-legend__range,
.certainty-legend__count {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.certainty-legend__count {
  min-width: 1.5em;
  text-align: right;
}

.certainty-legend__opacity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 3.2em;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--viewer-panel-border);
}

.certainty-legend__opacity input {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.certainty-legend__opacity output {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.certainty-legend__row--unassessed {
  grid-template-columns: 22px 16px minmax(0, 1fr);
  opacity: 0.85;
}

/* Kept in view at the bottom of the scrolling panel, so Save stays tappable
   on phones while the keyboard is open. */
.annotation-dialog__actions {
  position: sticky;
  bottom: -14px;
  z-index: 1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0 -14px -14px;
  padding: 10px 14px 14px;
  background: var(--viewer-panel-bg);
  border-top: 1px solid var(--viewer-panel-border);
}

@media (pointer: coarse) {
  .annotation-dialog__actions button {
    min-height: 40px;
    padding: 8px 14px;
  }
}

/* Bug report form (bug-report.js); the panel and form reuse the annotation
   dialog's styles. */
#bugReportDialog[hidden] {
  display: none !important;
}

#bugReportDialog {
  position: fixed;
  inset: 0;
  z-index: 999999;
}

#bugReportDialog .annotation-dialog__panel {
  width: min(480px, calc(100% - 28px));
}

.bug-report-dialog__privacy {
  margin: 0;
  font-size: 12px;
  opacity: 0.75;
}

#annotationPOITooltip[hidden] {
  display: none !important;
}

/* Appended to <body>, outside .viewer-wrapper and its theme variables:
   it carries its own, following the theme set on <body>. */
#annotationPOITooltip {
  --annotation-poi-tooltip-bg: rgba(22, 19, 16, 0.92);
  --annotation-poi-tooltip-border: rgba(255, 255, 255, 0.12);
  --annotation-poi-tooltip-text: rgba(255, 255, 255, 0.94);
  --annotation-poi-tooltip-shadow: 0 12px 30px rgba(12, 10, 8, 0.28);
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 14px));
  z-index: 999998;
  pointer-events: none;
}

body[data-viewer-theme="light"] #annotationPOITooltip {
  --annotation-poi-tooltip-bg: rgba(252, 250, 246, 0.96);
  --annotation-poi-tooltip-border: rgba(164, 151, 132, 0.28);
  --annotation-poi-tooltip-text: rgba(37, 33, 28, 0.92);
  --annotation-poi-tooltip-shadow: 0 14px 30px rgba(129, 116, 96, 0.16);
}

.annotation-poi-tooltip__panel {
  position: relative;
  min-width: 120px;
  max-width: min(320px, calc(100vw - 32px));
  border: 1px solid var(--annotation-poi-tooltip-border);
  border-radius: 8px;
  background: var(--annotation-poi-tooltip-bg);
  color: var(--annotation-poi-tooltip-text);
  box-shadow: var(--annotation-poi-tooltip-shadow);
  font-family: system-ui, sans-serif;
  padding: 7px 10px;
  box-sizing: border-box;
  overflow-wrap: break-word;
}

.annotation-poi-tooltip__title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  #metadata-card {
    width: min(220px, calc(100vw - 32px));
    padding: 10px 12px;
  }

  .metadata-row {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }

  .metadata-toggle-title {
    font-size: 13px;
  }

  .metadata-toggle-chevron {
    width: 16px;
    height: 16px;
  }

  .viewer-notice {
    max-width: calc(100% - 88px);
    padding: 6px 9px;
    font-size: 11px;
  }

  /* Hints (picking, clipping) are a sentence long: on one line they ran off
     the screen. */
  .viewer-notice-hint {
    white-space: normal;
    text-align: center;
    text-wrap: balance;
    border-radius: 14px;
  }
}

.widget > select {
  color: #000;
}

.field__items .viewer-wrapper {
  max-width: none !important;
  width: 100%;
  background: none;
}

.field__items .viewer-wrapper > * {
  max-width: none;
}

.field--type-file {
  width: 100%;
}

#spinner .spinnerContainer {
  position: absolute;
  left: 50%;
}

.lv-bars,
.lv-circles,
.lv-determinate_line,
.lv-bordered_line,
.lv-determinate_bordered_line,
.lv-dots,
.lv-squares,
.lv-line,
.lv-spinner,
.lv-determinate_circle,
.lv-dashed {
  font-family: sans-serif;
  font-size: small;
}



html.presentation-mode,
html.presentation-mode body,
html.presentation-mode #DFG_3DViewer,
html.presentation-mode .mainContainer,
html.presentation-mode .mainCanvas,
html.presentation-mode canvas,
.presentation-mode,
.presentation-mode body {
  background: transparent !important;
}

body.presentation-mode {
    margin: 0;
    overflow: hidden;
}

html.presentation-mode,
body.presentation-mode {
    background: transparent !important;
}

/* ==========================================================================
   Phones and touch screens
   ========================================================================== */

/* The standalone viewer page (index.html) on a phone: the picker and the
   gallery take one compact row each and the viewer fills the rest of the
   screen - its toolbar is always on screen, with no empty band below. */
@media (max-width: 640px), (max-height: 520px) and (pointer: coarse) {
  body.viewer-standalone-page {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding:
      env(safe-area-inset-top)
      env(safe-area-inset-right)
      env(safe-area-inset-bottom)
      env(safe-area-inset-left);
    box-sizing: border-box;
  }

  /* Sized by the page, not by its canvas (main.js follows its size). */
  body.viewer-standalone-page > #DFG_3DViewer {
    flex: 1 1 0;
    height: auto !important;
    min-height: 280px;
    overflow: hidden;
  }

  /* Picker and account area share one row. */
  body.viewer-standalone-page > #viewer-page-header {
    margin: 8px;
    flex-wrap: nowrap;
    gap: 8px;
  }

  #viewer-page-header > #example-model-picker {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    gap: 8px;
    padding: 6px 8px;
  }

  #viewer-page-header > #viewer-account-bar {
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 8px;
  }

  #example-model-picker label {
    /* The select says what it is; the label cost three lines. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* (Beats external-sources.css's min-width: 220px, loaded after this.) */
  #viewer-page-header #example-model-picker select,
  #example-model-picker select {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Notices: one short line above the toolbar, not a block over the model.
     Edge to edge (centred inside): with left: 50% the notice could only use
     half of the viewer's width, and wrapped. */
  #viewerNoticeContainer:not(.viewer-notice-container--sandbox):not(.viewer-notice-container--shortcuts) {
    left: 12px;
    right: 12px;
    max-width: none;
    transform: none;
  }

  .viewer-notice-status:not([data-variant]) {
    min-width: 0;
    padding: 6px 12px;
    font-size: 12px;
    line-height: 1.3;
  }
}

/* A phone held sideways: the gallery gives its height to the viewer. */
@media (max-height: 520px) and (pointer: coarse) {
  #image-list,
  .image-list-scroller {
    display: none !important;
  }

  body.viewer-standalone-page > #viewer-page-header {
    margin: 4px 8px;
  }

  #viewer-page-header > #example-model-picker,
  #viewer-page-header > #viewer-account-bar {
    padding: 4px 8px;
  }
}

/* Model details on a phone: a small round "i" in the corner instead of the
   file name card, so it keeps off the model. The name stays in the button's
   aria-label; a tap opens the window out of it. */
@media (max-width: 640px), (max-height: 520px) and (pointer: coarse) {
  #metadata-card {
    width: 40px !important;
    height: 40px !important;
    min-width: 0;
    min-height: 0;
    margin: 8px 0 0 max(8px, env(safe-area-inset-left));
    padding: 0;
    border-radius: 999px;
    transform: none;
    transition: none;
  }

  #metadata-card .metadata-drag-handle,
  #metadata-card .metadata-toggle-copy {
    display: none;
  }

  #metadata-card #metadata-collapse {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 0;
    gap: 0;
  }

  #metadata-card .metadata-toggle-chevron {
    width: 20px;
    height: 20px;
    border-radius: 0;
    background-color: var(--metadata-value-color);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5'/%3E%3Ccircle cx='12' cy='7.75' r='.6' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.5'/%3E%3Ccircle cx='12' cy='7.75' r='.6' fill='black'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  #metadata-card .metadata-toggle-chevron::before {
    display: none;
  }
}

/* The menus on a phone or a tablet on its side (ui/menu-toolbar.js): the
   model's details open from the Model menu; the card would sit under the
   rail. */
.viewer-menus-compact #metadata-card {
  display: none !important;
}

/* Touch: targets of about 40px and more, no resize handles to hit by
   accident, and the viewer's overlays clear of notches and the home bar. */
@media (pointer: coarse) {
  .viewer-window-controls {
    display: none;
  }

  #example-model-picker select {
    min-height: 40px;
  }

  #example-model-picker #uploadModel,
  #example-model-picker #browseModelsButton,
  #example-model-picker #openLocalFileButton,
  #example-model-picker #browseManifestsButton,
  #example-model-picker #planButton,
  #example-model-picker #example-theme-toggle,
  #viewer-account-bar #loginButton,
  #viewer-account-bar #manageUsersButton {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
  }

  #metadata-collapse {
    min-height: 40px;
  }

  /* Above the (unscaled, see editor-toolbar.css) touch toolbar. */
  .mainContainer:has(#viewerEditorToolbar) #viewerNoticeContainer,
  .viewer-embed-page .mainContainer:has(#viewerEditorToolbar) #viewerNoticeContainer {
    --viewer-notice-safe-bottom: calc(14px + var(--viewer-toolbar-height) + 10px + env(safe-area-inset-bottom));
  }

  /* Only a fullscreen viewer reaches the notch/status bar; elsewhere the page
     keeps clear of it (body.viewer-standalone-page padding), and the inset
     would push the card down from the canvas corner. */
  .mainContainer:fullscreen #metadata-container,
  .mainContainer.fullscreen #metadata-container {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    box-sizing: border-box;
  }

  /* Same for the toolbar on the standalone page: the page padding already
     keeps it off the home bar. */
  body.viewer-standalone-page .mainContainer:not(:fullscreen):not(.fullscreen) #viewerEditorToolbar,
  body.viewer-standalone-page > #viewerEditorToolbar {
    margin-left: 0;
    margin-bottom: 0;
  }
}

/* No network (viewer/connectivity.js) or no repository configured in the app
   (viewer/remote.js): hide controls that need the server. The model browser
   stays in the app without a repository - its address is entered there.
   The app signs in with a session token (remote.js), like a page does with
   its cookie. */
body.viewer-offline #uploadModel,
body.viewer-offline #browseModelsButton,
body.viewer-offline #loginButton,
body.viewer-offline #manageUsersButton,
body.viewer-no-remote #uploadModel,
body.viewer-no-remote #loginButton,
body.viewer-no-remote #manageUsersButton,
body.viewer-app #browseModelsButton,
body.viewer-app #browseManifestsButton,
/* ...and the bar that holds only those two, or its empty frame stays in the
   header's corner. */
body.viewer-offline #viewer-account-bar,
body.viewer-no-remote #viewer-account-bar,
body.viewer-app #viewer-account-bar:not(:has(button:not([hidden]))) {
  display: none !important;
}

/* App, first run (ui/first-run-hints.js): the button to try next pulses.
   Inside its own box - the toolbar clips what sticks out of it. */
.first-run-pulse {
  animation: first-run-pulse-glow 1.2s ease-in-out infinite;
}

.first-run-pulse > span {
  display: inline-block;
  animation: first-run-pulse-icon 1.2s ease-in-out infinite;
}

@keyframes first-run-pulse-glow {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--viewer-brand-blue) 35%, transparent);
  }
  50% {
    box-shadow: inset 0 0 0 2px var(--viewer-brand-blue), inset 0 0 14px color-mix(in srgb, var(--viewer-brand-blue) 55%, transparent);
  }
}

@keyframes first-run-pulse-icon {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .first-run-pulse,
  .first-run-pulse > span {
    animation: none;
  }

  .first-run-pulse {
    box-shadow: inset 0 0 0 2px var(--viewer-brand-blue);
  }
}

/* App on any screen, tablets too (the phone layout above stops at 640px):
   the viewer fills what the header leaves, instead of index.html's 50vh
   with an empty band below it. */
body.viewer-app.viewer-standalone-page {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

body.viewer-app.viewer-standalone-page > #DFG_3DViewer {
  flex: 1 1 0;
  height: auto !important;
  min-height: 280px;
  overflow: hidden;
}

/* Tools and features that are not available (ui/lock-icon.js): a small
   lock - the same icon on the toolbar, in the plans panel and on the
   repository address field. */
:root {
  --plan-lock-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V11a1 1 0 0 1 1-1h1Zm2 0h6V7a3 3 0 0 0-6 0v3Z'/%3E%3C/svg%3E");
  --plan-lock-color: #fbbf24;
}

#viewerEditorToolbar .plan-locked {
  position: relative;
}

#viewerEditorToolbar .plan-locked > .viewer-editor-tool_icon {
  opacity: 0.55;
}

#viewerEditorToolbar .plan-locked::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  background-color: var(--plan-lock-color);
  -webkit-mask: var(--plan-lock-mask) center / contain no-repeat;
  mask: var(--plan-lock-mask) center / contain no-repeat;
  pointer-events: none;
}

.plan-lock-icon {
  display: inline-block;
  flex: none;
  width: 11px;
  height: 11px;
  margin: 0 4px;
  vertical-align: -1px;
  background-color: var(--plan-lock-color);
  -webkit-mask: var(--plan-lock-mask) center / contain no-repeat;
  mask: var(--plan-lock-mask) center / contain no-repeat;
}

/* Page scrollbar, following the viewer theme (applyTheme() in
   ui/localization-theme.js sets data-viewer-theme on <html>). */
html[data-viewer-theme] {
  --page-scroll-thumb: rgba(96, 82, 66, 0.4);
  --page-scroll-thumb-hover: rgba(96, 82, 66, 0.62);
  scrollbar-width: thin;
  scrollbar-color: var(--page-scroll-thumb) transparent;
}

html[data-viewer-theme="dark"] {
  --page-scroll-thumb: rgba(238, 238, 238, 0.3);
  --page-scroll-thumb-hover: rgba(238, 238, 238, 0.5);
}

html[data-viewer-theme]::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html[data-viewer-theme]::-webkit-scrollbar-track,
html[data-viewer-theme]::-webkit-scrollbar-corner {
  background: transparent;
}

html[data-viewer-theme]::-webkit-scrollbar-thumb {
  background: var(--page-scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

html[data-viewer-theme]::-webkit-scrollbar-thumb:hover {
  background: var(--page-scroll-thumb-hover);
  background-clip: padding-box;
}

/* ExPlora4D logo (ui/brand-logo.js), top centre over the canvas - the
   corners hold the metadata card, the panel column, the toolbar and the
   view helper. Not interactive, so it never takes a click from the model.
   Both versions are stacked: on a dark background (.is-on-dark) the
   light-lettered one fades in over the other. */
.viewer-brand-logo {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  display: grid;
  width: clamp(140px, 20%, 220px);
  opacity: 1;
  transition: opacity 1.2s ease;
  pointer-events: none;
  user-select: none;
}

.viewer-brand-logo img {
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
  transition: opacity 1.6s ease;
}

/* The version coming in fades in first, the one going out after it (the
   delay), so the logo never turns see-through half-way. */
.viewer-brand-logo__light {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.55));
}

.viewer-brand-logo__dark {
  opacity: 0;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
  transition-delay: 1s;
}

.viewer-brand-logo.is-on-dark .viewer-brand-logo__light {
  opacity: 0;
  transition-delay: 1s;
}

.viewer-brand-logo.is-on-dark .viewer-brand-logo__dark {
  opacity: 1;
  transition-delay: 0s;
}

/* Fades while the pointer is over the model, back when it leaves the
   canvas. Mice only: a tap would leave it faded on a touch screen - there
   brand-logo.js fades it (.is-faded) while fingers are on the model. */
@media (hover: hover) {
  .mainContainer:has(#MainCanvas:hover) .viewer-brand-logo {
    opacity: 0.35;
  }
}

.viewer-brand-logo.is-faded {
  opacity: 0.35;
  transition-duration: 0.3s;
}

@media (max-width: 640px) {
  .viewer-brand-logo {
    width: 130px;
  }
}
