/* PEXEFY: keep the picture on the worktable, controls on its edges. */
.pxf-entry {
  display: flex;
  align-items: center;
  gap: 20px;
  width: min(760px, 100%);
  margin: 20px auto 12px;
  padding: 18px 24px;
  border: 1px solid #b89950;
  border-radius: 22px;
  background:
    linear-gradient(
      120deg,
      #103e55,
      #166563);
  color: #fff5d5;
  text-align: left;
  box-shadow: 0 5px 15px #39534930;
}
.pxf-entry > svg {
  width: 56px;
  height: 56px;
  flex: none;
  color: #f8d58a;
  filter: drop-shadow(0 3px 0 #082f42);
}
.pxf-entry > span {
  flex: 1;
}
.pxf-entry strong {
  display: block;
  font: 700 27px Georgia;
  letter-spacing: 2px;
}
.pxf-entry small {
  display: block;
  margin-top: 4px;
  font: 14px/1.4 system-ui;
}
.pxf-entry > b {
  font: 34px Georgia;
}
.pxf-gallery-entry {
  display: block;
  min-height: 44px;
  padding: 6px 16px;
  margin: 5px 0 10px auto;
  border: 1px solid #b8a16c;
  border-radius: 22px;
  background: #145769;
  color: #fff8de;
  font: 700 14px system-ui;
}
#pexefy {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #faf5e8;
  color: #153e50;
  box-shadow: none;
  overflow: hidden;
  font: 15px/1.4 system-ui, sans-serif;
}
#pexefy[open] {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr)28px;
}
#pexefy::backdrop {
  background: #08273de8;
}
#pexefy * {
  box-sizing: border-box;
}
#pexefy [hidden] {
  display: none !important;
}
#pexefy button {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  color: inherit;
  touch-action: manipulation;
}
#pexefy button:disabled {
  opacity: .4;
  cursor: default;
}
#pexefy button:focus-visible,
#pexefy [tabindex]:focus-visible {
  outline: 3px solid #18a7a5;
  outline-offset: 3px;
}
#pexefy p {
  color: inherit;
  line-height: 1.5;
}
#pexefy h2,
#pexefy h3 {
  font-family: Georgia, serif;
  color: #173f52;
}
#pexefy h2 {
  font-size: 32px;
  margin: 0 0 8px;
}
#pexefy h3 {
  font-size: 23px;
  margin: 18px 0 12px;
}
.pxf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 20px;
  background: #0e354c;
  color: #fff5d9;
  border-bottom: 2px solid #c6a864;
}
.pxf-header button {
  border: 1px solid #547885;
  border-radius: 12px;
  background: #153f56;
  padding: 5px 14px;
}
.pxf-header .pxf-close {
  font-size: 28px;
  width: 44px;
  padding: 0;
}
.pxf-brand {
  text-align: center;
}
.pxf-brand span {
  font-size: 9px;
  letter-spacing: 3px;
  color: #b6d8d7;
}
.pxf-brand h1 {
  font: 700 26px/1 Georgia;
  margin: 2px;
  letter-spacing: 4px;
}
.pxf-content {
  min-height: 0;
  overflow: auto;
  padding: 26px max(20px, calc((100vw - 1120px)/2));
  overscroll-behavior: contain;
}
.pxf-heading {
  text-align: center;
  margin-bottom: 24px;
}
.pxf-heading p {
  margin: 0;
  color: #58767d !important;
}
.pxf-status {
  margin: 0 !important;
  padding: 4px 12px;
  background: #e8e8d9;
  text-align: center;
  font-size: 12px;
  overflow: auto;
  white-space: nowrap;
}
.pxf-source-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}
.pxf-upload,
.pxf-resume,
#pexefy .pxf-primary {
  padding: 13px 25px;
  border: 1px solid #ba9950;
  border-radius: 14px;
  background: linear-gradient(#ffe8ad, #ecc56e);
  font-weight: 700;
  box-shadow: 0 3px 0 #b6934c30;
}
.pxf-resume,
#pexefy .pxf-secondary {
  background: #175669;
  color: #fff8df;
  border: 1px solid #327587;
  border-radius: 14px;
  padding: 10px 18px;
  font-weight: 600;
}
.pxf-private {
  text-align: center;
  font-size: 12px;
  color: #607c7d !important;
  margin: 12px 0;
}
.pxf-album-title {
  text-align: center;
}
.pxf-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.pxf-art {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d7c9a5;
  border-radius: 16px;
  background: #fffdf8;
  box-shadow: 0 4px 10px #78613d12;
}
.pxf-art img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: contain;
}
.pxf-art span {
  font-size: 11px;
  letter-spacing: 1px;
  color: #638080;
}
.pxf-art:hover {
  border-color: #1b8b89;
  box-shadow: 0 5px 14px #17596622;
}
.pxf-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 25px;
  border: 1px dashed #c3c3a7;
  border-radius: 16px;
}
.pxf-more-sources {
  display: block;
  margin: 16px auto;
  background: #fff;
  border: 1px solid #c3c3a7;
  border-radius: 10px;
  padding: 8px 20px;
}
.pxf-loading {
  text-align: center;
  padding: 40px;
}
.pxf-setup {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 1fr);
  align-items: center;
  gap: 50px;
  min-height: 100%;
}
.pxf-source-preview {
  padding: 14px;
  background: #fffdf7;
  border: 1px solid #cfbd91;
  border-radius: 12px;
  box-shadow: 0 12px 32px #4c655426;
  transform: rotate(-1deg);
}
.pxf-source-preview img {
  display: block;
  width: 100%;
  height: min(60dvh, 570px);
  object-fit: contain;
}
.pxf-options .pxf-heading {
  text-align: left;
}
.pxf-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 26px 0 12px;
}
.pxf-counts button {
  min-height: 64px !important;
  font: 700 26px Georgia !important;
  border: 1px solid #c6b991;
  background: #fffdf6;
  border-radius: 14px;
}
.pxf-counts button[aria-pressed=true] {
  color: #fff5d5 !important;
  background: #165e6b;
  border-color: #165e6b;
  box-shadow: 0 0 0 3px #a2d4c5;
}
.pxf-hint {
  font-size: 13px;
  color: #607c7d !important;
}
.pxf-options > .pxf-primary {
  width: 100%;
  margin-top: 16px;
}
.pxf-confirm {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 8;
  width: min(440px, calc(100% - 24px));
  padding: 24px;
  border: 2px solid #c5a265;
  border-radius: 20px;
  background: #fff9e9;
  box-shadow: 0 0 0 100vmax #05263d99, 0 10px 45px #001c3a44;
  text-align: center;
}
.pxf-confirm button {
  margin: 5px;
}
#pexefy[data-screen=play] .pxf-content {
  padding: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr)40px;
  overflow: hidden;
  background: #e3e9df;
}
.pxf-play-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px;
  background: #f9f6eb;
  border-bottom: 1px solid #cdd6c5;
}
.pxf-play-toolbar > button {
  padding: 5px 14px;
  border: 1px solid #bdc8b7;
  border-radius: 10px;
  background: #fffdf4;
}
.pxf-play-toolbar button[aria-pressed=true] {
  background: #176774;
  color: #fff8df !important;
}
.pxf-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.pxf-progress strong {
  min-width: 60px;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
}
.pxf-progress progress {
  width: 100px;
  height: 9px;
  accent-color: #1b8d84;
}
.pxf-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr)280px;
  min-height: 0;
}
.pxf-board-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  background-color: #d8e3d8;
  background-image: radial-gradient(#73948a24 1px, transparent 1px);
  background-size: 12px 12px;
}
.pxf-board-wrap {
  position: relative;
  margin: 0 auto;
  box-shadow: 0 4px 18px #153c4d24;
  border-radius: 4px;
  flex-shrink: 0;
}
.pxf-board {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.pxf-board g[aria-disabled=false] {
  cursor: crosshair;
}
.pxf-board g:focus {
  filter: drop-shadow(0 0 4px #067782);
}
.pxf-reference-image {
  transition: opacity .15s;
}
.pxf-tray {
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr)44px;
  gap: 8px;
  min-height: 0;
  padding: 10px 12px;
  background: #103b51;
  color: #fff6db;
  border-left: 1px solid #56807f;
}
.pxf-tray-top {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}
.pxf-tray-top h2 {
  font: 700 17px Georgia !important;
  color: #fff6db !important;
  margin: 0 !important;
}
.pxf-tray-top button {
  font-size: 12px !important;
  border: 1px solid #537c88;
  border-radius: 10px;
  padding: 4px 10px;
  background: #184e62;
  color: #fff6db !important;
}
.pxf-pieces {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
}
.pxf-piece {
  padding: 6px;
  border: 1px solid #78939155;
  border-radius: 13px;
  background: #ffffff0b;
  min-width: 0;
  min-height: 0 !important;
  touch-action: none !important;
  user-select: none;
}
.pxf-piece svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(1px 3px 2px #001c2b66);
}
.pxf-piece:hover {
  background: #ffffff17;
}
.pxf-piece[aria-pressed=true] {
  background: #366b72;
  box-shadow: inset 0 0 0 2px #ffdb80;
  border-color: #ffdb80;
}
.pxf-paging {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.pxf-paging button {
  width: 44px;
  border: 1px solid #537c88;
  border-radius: 10px;
  background: #184e62;
  color: #fff6db !important;
  font-size: 25px !important;
}
.pxf-drag {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 7px 5px #06223377);
}
.pxf-drag svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.pxf-play-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  background: #f9f6eb;
  font-size: 12px;
}
.pxf-save {
  border: 0;
  background: none;
  font-size: 11px !important;
  color: #39766b !important;
  min-height: 32px !important;
}
.pxf-save[data-error=true] {
  color: #a23b24 !important;
  text-decoration: underline;
}
.pxf-win {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: min(400px, calc(100vw - 28px));
  padding: 24px;
  text-align: center;
  background: #fff8e5;
  border: 2px solid #c8a354;
  border-radius: 25px;
  box-shadow: 0 12px 80px #163e5577;
}
.pxf-win h2 {
  font-size: 36px !important;
}
.pxf-win button {
  display: block;
  width: 100%;
  margin: 10px 0 0;
}
.pxf-star {
  display: block;
  font-size: 60px;
  line-height: 1.2;
  color: #d6a147;
}
.pxf-miss {
  animation: pxf-miss .25s ease-in-out;
}
@keyframes pxf-miss {
  50% {
    filter: sepia(.3);
  }
}
@media (max-width: 1000px) {
  .pxf-workspace {
    grid-template-columns: minmax(0, 1fr)220px;
  }
  .pxf-content {
    padding: 22px;
  }
  .pxf-setup {
    gap: 24px;
  }
  .pxf-gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .pxf-play-foot {
    font-size: 10px;
  }
}
@media (max-width: 700px) {
  #pexefy[open] {
    grid-template-rows: 54px minmax(0, 1fr)26px;
  }
  .pxf-header {
    padding: 3px 8px;
  }
  .pxf-brand h1 {
    font-size: 22px;
  }
  .pxf-content {
    padding: 18px 14px;
  }
  .pxf-heading {
    margin-bottom: 18px;
  }
  #pexefy h2 {
    font-size: 26px;
  }
  .pxf-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .pxf-art img {
    height: 150px;
  }
  .pxf-source-actions {
    gap: 8px;
  }
  .pxf-source-actions button {
    width: 100%;
  }
  .pxf-setup {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .pxf-source-preview {
    width: 100%;
  }
  .pxf-source-preview img {
    height: 25dvh;
  }
  .pxf-options {
    width: 100%;
  }
  .pxf-options .pxf-heading {
    text-align: center;
  }
  .pxf-counts {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    margin: 14px 0;
  }
  .pxf-counts button {
    font-size: 21px !important;
    min-height: 52px !important;
  }
  .pxf-hint {
    font-size: 12px;
  }
  .pxf-options > .pxf-primary {
    margin-top: 8px;
  }
  .pxf-play-toolbar {
    gap: 5px;
    padding: 4px 8px;
  }
  .pxf-play-toolbar > button {
    padding: 5px 8px;
    font-size: 11px !important;
  }
  .pxf-progress {
    gap: 0;
  }
  .pxf-progress strong {
    font-size: 14px;
    min-width: 48px;
  }
  .pxf-progress progress {
    display: none;
  }
  .pxf-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr)174px;
  }
  .pxf-tray {
    grid-template-rows: 32px minmax(0, 1fr)34px;
    padding: 4px 10px;
    gap: 4px;
    border-left: 0;
    border-top: 1px solid #56807f;
  }
  .pxf-tray-top h2 {
    font-size: 15px !important;
  }
  .pxf-tray-top button {
    min-height: 30px !important;
  }
  .pxf-pieces {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    gap: 5px;
  }
  .pxf-piece {
    padding: 2px;
    border-radius: 7px;
  }
  .pxf-paging {
    justify-content: center;
  }
  .pxf-paging button {
    min-height: 32px !important;
    height: 32px;
    width: 52px;
    font-size: 22px !important;
  }
  .pxf-board-scroll {
    padding: 12px;
  }
  .pxf-play-foot {
    padding: 2px 8px;
    gap: 4px;
    line-height: 1.2;
  }
  .pxf-help {
    max-width: 65%;
  }
  .pxf-save {
    max-width: 35%;
    text-align: right;
  }
  .pxf-entry {
    gap: 12px;
    padding: 14px 18px;
  }
  .pxf-entry strong {
    font-size: 23px;
  }
  .pxf-entry small {
    font-size: 12px;
  }
  .pxf-entry > svg {
    width: 42px;
    height: 42px;
  }
  .pxf-status {
    font-size: 10px;
  }
}
@media (max-height: 550px) and (min-width: 701px) {
  #pexefy[open] {
    grid-template-rows: 48px minmax(0, 1fr)22px;
  }
  #pexefy[data-screen=play] .pxf-content {
    grid-template-rows: 48px minmax(0, 1fr)32px;
  }
  .pxf-workspace {
    grid-template-columns: minmax(0, 1fr)290px;
  }
  .pxf-pieces {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .pxf-tray {
    grid-template-rows: 36px minmax(0, 1fr)36px;
    gap: 4px;
    padding: 5px 8px;
  }
  .pxf-paging button {
    height: 34px;
    min-height: 34px !important;
  }
  .pxf-tray-top button {
    min-height: 34px !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pxf-miss {
    animation: none;
  }
  .pxf-reference-image {
    transition: none;
  }
}
#pexefy .pxf-win-close {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: 25px;
}

/* Keep the source visible while assembling; the same button toggles the large reference. */
.pxf-play-toolbar > .pxf-reference{display:flex;align-items:center;gap:7px;padding:3px 8px;flex-shrink:0}
.pxf-reference-thumb{display:block;width:64px;height:36px;object-fit:contain;background:#fffdf6;border:1px solid #c4baa2;border-radius:4px}
.pxf-reference-label{font-size:12px}
@media(max-width:700px){
 .pxf-play-toolbar > .pxf-reference{padding:3px 4px}
 .pxf-reference-thumb{width:50px;height:34px}
 .pxf-reference-label{display:none}
}
