.fap-viewer { width: 100%; min-width: 0; }
.fap-viewer, .fap-viewer * { box-sizing: border-box; }
.fap-viewer [hidden] { display: none !important; }
.fap-viewer .fap-preview { width: 100%; padding: 16px; }
.fap-viewer .fap-original { display: block; width: 100%; max-width: 100%; height: auto; margin: 0; border: 0; }
.fap-viewer .fap-controls {
  display: block; min-width: 0; width: 100%; margin: 14px 0 0; padding: 0; border: 0;
  font: inherit; font-size: 16px; line-height: 1.5; color: #292724; text-align: center;
}
.fap-viewer .fap-controls legend { float: none; width: auto; margin: 0 auto 8px; padding: 0; font: inherit; font-size: 17px; line-height: 1.4; font-weight: 600; color: inherit; }
.fap-viewer .fap-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fap-viewer .fap-frame {
  appearance: none; display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  flex: 0 1 auto; min-width: 0; max-width: 100%; min-height: 44px; margin: 0; padding: 8px 12px;
  border: 1px solid #b9b4ab; border-radius: 7px; background: #fff; color: #35312b;
  font: inherit; font-size: 16px; font-weight: 500; line-height: 1.35; letter-spacing: normal; text-transform: none;
  text-align: start; text-decoration: none; white-space: normal; box-shadow: none; cursor: pointer;
}
.fap-viewer .fap-frame[aria-pressed='true'] { border-color: #35312b; background: #f3f0e9; box-shadow: inset 0 0 0 1px #35312b; }
.fap-viewer .fap-frame:hover:not(:disabled) { border-color: #35312b; background: #f3f0e9; }
.fap-viewer .fap-frame:focus-visible { outline: 3px solid #225d91; outline-offset: 3px; }
.fap-viewer .fap-frame:disabled { opacity: .5; cursor: not-allowed; }
.fap-viewer .fap-swatch { display: inline-block; flex: 0 0 20px; width: 20px; height: 20px; border-radius: 3px; border: 1px solid rgb(0 0 0 / 20%); }
.fap-viewer .fap-swatch--original { background: #f6f3eb; }
.fap-viewer .fap-swatch--black-matte { background: #292827; }
.fap-viewer .fap-swatch--natural-oak { background: #c0a277 url("frames/natural-oak/top.png") center / auto 100%; }
.fap-viewer .fap-swatch--matte-white { background: linear-gradient(110deg, #f4f3ee, #e1e0dc); }
.fap-viewer .fap-disclaimer { margin: 10px 0 0; padding: 0; font: inherit; font-size: 15px; line-height: 1.5; color: #615c54; }
@media (forced-colors: active) {
  .fap-viewer .fap-frame[aria-pressed='true'] { outline: 2px solid Highlight; outline-offset: -4px; }
}
.fap-viewer .fap-status { font-size: 14px; line-height: 1.5; text-align: center; }
.fap-viewer .fap-status:empty { display: none; }
/* Scope theme resets to the shared renderer; preserve its validated geometry. */
.fap-viewer .art-frame, .fap-viewer .art-frame div { margin: 0; padding: 0; border: 0; max-width: none; }
.fap-viewer .art-frame__paper img { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; object-fit: contain; }
.fap-viewer .art-frame__opening { background: var(--fap-mat-color, #eeeade); }
/* Never expose the lab's debug outline to customers. JS falls back to the original. */
.fap-viewer .art-frame[data-image-ratio] { outline: none; }
/* Proportional mode reserves the same area for every format/finish and the bare original. */
.fap-viewer--proportional .fap-stage {
  width: 100%; max-height: none;
  position: relative; padding: 0; border: 0;
}
.fap-viewer--proportional .fap-composition {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  min-width: 0; min-height: 0;
}
.fap-viewer--proportional .fap-original { width: 100%; height: 100%; object-fit: contain; }
.fap-viewer--proportional .fap-status,
.fap-viewer--proportional .fap-status:empty { display: block; height: 3em; line-height: 1.5; overflow: auto; }
/* The overlay leaves original image dimensions and proportional geometry untouched. */
.fap-viewer .fap-composition { position: relative; }
.fap-viewer--proportional .fap-composition { position: absolute; }
.fap-viewer .fap-zoom-open {
  appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; min-height: 44px;
  margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; cursor: zoom-in;
}
.fap-viewer .fap-zoom-open span {
  position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid #aaa; border-radius: 50%; background: rgb(255 255 255 / 90%); color: #222; font: 24px/1 Arial, sans-serif;
}
.fap-viewer .fap-zoom-open:focus-visible { outline: 3px solid #225d91; outline-offset: 3px; }
/* Dialog is mounted under body, outside builder transforms and overflow clipping. */
dialog.fap-lightbox {
  --fap-lb-text: #f5f5f5; --fap-lb-control: #292929; --fap-lb-border: #888; --fap-lb-focus: #9acbff;
  box-sizing: border-box; position: fixed; inset: 0; width: calc(100% - 24px); max-width: none;
  height: calc(100% - 24px); max-height: none; margin: auto; padding: 12px; border: 0;
  border-radius: 0; box-shadow: none; background: transparent; color: var(--fap-lb-text); font: 16px/1.4 Arial, sans-serif; overflow: hidden;
}
dialog.fap-lightbox.fap-lightbox--light {
  --fap-lb-text: #202020; --fap-lb-control: #fff; --fap-lb-border: #737373; --fap-lb-focus: #225d91;
  color-scheme: light;
}
dialog.fap-lightbox.fap-lightbox--dark { color-scheme: dark; }
dialog.fap-lightbox[open] { display: flex; flex-direction: column; gap: 12px; }
dialog.fap-lightbox::backdrop { background: rgb(32 32 32 / 85%); }
dialog.fap-lightbox.fap-lightbox--light::backdrop { background: rgb(255 255 255 / 90%); }
dialog.fap-lightbox * { box-sizing: border-box; }
dialog.fap-lightbox [hidden] { display: none !important; }
dialog.fap-lightbox .fap-lightbox__header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; flex: none;
}
dialog.fap-lightbox h2 { min-width: 0; margin: 0; padding: 0; color: var(--fap-lb-text); font: 600 16px/1.25 Arial, sans-serif; }
dialog.fap-lightbox p { margin: 0; padding: 0; color: var(--fap-lb-text); font: 14px/1.4 Arial, sans-serif; }
dialog.fap-lightbox .fap-lightbox__visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap;
}
dialog.fap-lightbox .fap-lightbox__toolbar { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
dialog.fap-lightbox button {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  min-width: 44px; min-height: 44px; width: auto; height: 44px;
  margin: 0; padding: 0 12px; border: 1px solid var(--fap-lb-border); border-radius: 6px;
  background: var(--fap-lb-control); color: var(--fap-lb-text);
  font: 14px/1 Arial, sans-serif; letter-spacing: normal; text-transform: none; text-align: center; text-decoration: none; box-shadow: none; cursor: pointer;
}
dialog.fap-lightbox .fap-lightbox__zoom { width: 44px; padding: 0; }
dialog.fap-lightbox .fap-lightbox__zoom svg { display: block; flex: none; width: 24px; height: 24px; margin: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
dialog.fap-lightbox .fap-lightbox__close { justify-self: end; }
dialog.fap-lightbox button:disabled { opacity: .45; cursor: default; }
dialog.fap-lightbox button:focus-visible, dialog.fap-lightbox .fap-lightbox__viewport:focus-visible { outline: 3px solid var(--fap-lb-focus); outline-offset: -3px; }
dialog.fap-lightbox output { display: block; min-width: 52px; color: var(--fap-lb-text); font: 500 15px/1.4 Arial, sans-serif; font-variant-numeric: tabular-nums; text-align: center; }
@media (max-width: 640px) {
  dialog.fap-lightbox .fap-lightbox__header { grid-template-columns: minmax(0, 1fr) auto; }
  dialog.fap-lightbox .fap-lightbox__toolbar { grid-row: 2; grid-column: 1 / -1; }
  dialog.fap-lightbox .fap-lightbox__close { grid-row: 1; grid-column: 2; }
}
dialog.fap-lightbox .fap-lightbox__status:empty { display: none; }
dialog.fap-lightbox .fap-lightbox__viewport {
  position: relative; display: flex; align-items: center; justify-content: center; flex: 1; min-height: 0; min-width: 0;
  overflow: hidden; touch-action: none; overscroll-behavior: contain; user-select: none;
}
dialog.fap-lightbox .fap-lightbox__viewport--zoomed { cursor: grab; }
dialog.fap-lightbox .fap-lightbox__viewport--zoomed:active { cursor: grabbing; }
dialog.fap-lightbox img {
  display: block; flex: none; max-width: none; max-height: none; min-width: 0; margin: 0; padding: 0; border: 0;
  border-radius: 0; object-fit: contain; transform-origin: center; pointer-events: none;
}
