/* Extracted from index.html. Result preview modal and generic image preview overlay styles. */

.result-preview-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  width: 100%;
  flex: 1;
}

.result-preview-image-cell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.result-preview-image-wrap {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  overflow: hidden;
  background: #f0f0f3;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.result-preview-image-skeleton {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(90deg, #e8e8ec 0%, #f0f0f3 14%, #e8e8ec 28%);
  background-size: 200% 100%;
  animation: result-preview-skeleton-shimmer 1.4s ease-in-out infinite;
  pointer-events: none;
}
.result-preview-image-wrap.result-preview-image-wrap-loaded .result-preview-image-skeleton {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
}
@keyframes result-preview-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.result-preview-image-wrap > .result-preview-pan-layer {
  pointer-events: none;
}

.result-preview-image-wrap.dragging {
  cursor: grabbing;
}

.result-preview-pan-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  will-change: transform;
}

.result-preview-image {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  pointer-events: none;
  object-fit: contain;
  transition: opacity 0.28s ease-out;
}
.result-preview-image.result-preview-image-loading {
  opacity: 0;
}

.result-preview-load-status {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  min-width: 138px;
  min-height: 96px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 12px;
  background: rgba(20, 20, 22, 0.68);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.result-preview-load-status[hidden] {
  display: none;
}

.result-preview-load-percent {
  font-size: 28px;
  line-height: 1;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.result-preview-load-label {
  font-size: 12px;
  line-height: 18px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.96);
}

.result-preview-load-retry {
  height: 28px;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.result-preview-load-retry:hover {
  background: rgba(255, 255, 255, 0.2);
}

.result-zoom-badge {
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #1d1d1f;
  font-size: 12px;
  line-height: 28px;
  padding: 0 8px;
}

.result-zoom-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  height: 38px;
  min-width: 88px;
  border-radius: 10px;
  background: rgba(16, 16, 18, 0.42);
  color: #fff;
  font-size: 16px;
  line-height: 38px;
  text-align: center;
  padding: 0 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.result-zoom-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.result-preview-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.result-preview-arrows {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
}

.result-preview-arrows .result-preview-arrow-btn {
  pointer-events: auto;
}

.result-preview-top-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-preview-person-detection-control {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.result-preview-person-detection-btn {
  position: relative;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  box-shadow: none;
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.65))
    drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform-origin: center center;
  transition: color 0.14s ease, transform 0.14s ease, opacity 0.14s ease;
}

.result-preview-person-detection-btn:hover {
  background: transparent;
  transform: scale(1.08);
}
.result-preview-person-detection-btn:active svg { transform: scale(0.9); }
.result-preview-person-detection-btn[hidden] { display: none; }
.result-preview-person-detection-btn[hidden] + .result-preview-person-detection-text { display: none; }
.result-preview-person-detection-btn svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform-origin: center;
  transition: transform 0.14s ease;
}
.result-preview-person-detection-btn .person-detection-frame {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
}
.result-preview-person-detection-btn .person-detection-head,
.result-preview-person-detection-btn .person-detection-body {
  fill: currentColor;
  stroke: none;
}
.result-preview-person-detection-btn.is-detected {
  color: #ffc106;
  border-color: transparent;
  background: transparent;
}
.result-preview-person-detection-text {
  display: block;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.58);
  transform: translateX(-3px);
  transition: max-width 0.2s ease, margin-left 0.2s ease, opacity 0.14s ease, transform 0.2s ease;
  white-space: nowrap;
}
.result-preview-person-detection-btn.is-detected + .result-preview-person-detection-text {
  max-width: 180px;
  margin-left: 6px;
  opacity: 1;
  transform: translateX(0);
}
.result-preview-person-detection-btn.is-click-animated svg {
  animation: result-preview-person-detection-icon-click 0.18s ease-out;
}
.result-preview-person-detection-btn.is-clear { color: rgba(255, 255, 255, 0.92); }
.result-preview-person-detection-btn.is-error { color: #ff8f87; }
.result-preview-person-detection-btn.is-manual { box-shadow: none; }
.result-preview-person-detection-spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.26);
  border-top-color: #ffc106;
  animation: result-preview-person-detection-spin 0.8s linear infinite;
}
@keyframes result-preview-person-detection-spin { to { transform: rotate(360deg); } }
@keyframes result-preview-person-detection-icon-click {
  0% { transform: scale(1); }
  45% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .result-preview-person-detection-spinner,
  .result-preview-person-detection-btn.is-click-animated svg { animation: none; }
  .result-preview-person-detection-btn,
  .result-preview-person-detection-btn svg,
  .result-preview-person-detection-text { transition: none; }
}

.result-preview-edit-btn {
  min-width: 62px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.result-preview-edit-btn:hover { background: rgba(0, 0, 0, 0.66); }
.result-preview-edit-btn[hidden] { display: none; }

.result-preview-compare-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  cursor: pointer;
  touch-action: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.result-preview-compare-btn:hover,
.result-preview-compare-btn.active {
  background: rgba(0, 0, 0, 0.72);
}

.result-preview-compare-btn:disabled {
  cursor: wait;
  opacity: 0.42;
}

.result-preview-compare-btn[hidden] { display: none; }

.result-preview-compare-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.result-preview-compare-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  transition: none;
}

.result-preview-compare-image.active {
  opacity: 1;
  visibility: visible;
}

.result-preview-arrow-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.result-preview-arrow-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.5);
}

.result-preview-arrow-btn svg {
  width: 20px;
  height: 20px;
}

.result-preview-side {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 4px 0 0;
  margin-top: -5px;
}

.result-preview-side .crop-actions,
.result-preview-side .result-choice-group {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.result-side-btn {
  height: 32px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 9px;
  background: #fff;
  color: #3a3a3c;
  font: inherit;
  font-size: 12px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.result-preview-side .result-side-btn {
  width: auto;
  min-width: 88px;
}

.result-side-btn.active {
  background: var(--blue);
  border-color: transparent;
  color: #1d1d1f;
}

.result-side-btn svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-choice-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.result-choice-btn {
  height: 32px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  background: #fff;
  color: #3a3a3c;
  font: inherit;
  font-size: 12px;
  padding: 0 10px;
  cursor: pointer;
}

.result-choice-btn.active {
  background: #F0EEE9;
  border-color: rgba(29, 29, 31, 0.18);
  color: #1d1d1f;
}

.result-choice-btn.disabled {
  opacity: 0.7;
  cursor: default;
}

.tool-modal-card.result-preview-card {
  width: min(92vw, 660px);
  min-height: 0;
  height: min(86vh, 750px);
  padding: 12px;
}

.tool-modal-card.result-preview-card .tool-modal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  z-index: 31000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-modal.show {
  display: flex;
}
.preview-modal.case-image-preview {
  overflow: hidden;
}
.preview-modal.case-image-preview img {
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center center;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.preview-modal.case-image-preview.is-zoomed img {
  cursor: grab;
}
.preview-modal.case-image-preview.is-dragging img {
  cursor: grabbing;
  transition: none;
}
.preview-modal.preview-modal--growth {
  animation: growth-preview-fade-in 0.22s ease;
}
.preview-modal.preview-modal--growth.is-closing {
  animation: growth-preview-fade-out 0.18s ease forwards;
}
.preview-modal.preview-modal--growth img {
  width: min(var(--growth-center-inner-width), 92vw);
  max-width: min(var(--growth-center-inner-width), 92vw);
  max-height: 78vh;
  object-fit: contain;
  animation: growth-preview-zoom-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center center;
}
.preview-modal.preview-modal--growth.is-closing img {
  animation: growth-preview-zoom-out 0.18s ease forwards;
}
@keyframes growth-preview-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes growth-preview-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes growth-preview-zoom-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes growth-preview-zoom-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.96); }
}

.preview-modal img {
  max-width: min(62vw, 734px);
  max-height: 59vh;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  background: #fff;
}

html.theme-dark .preview-modal img {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

html.theme-dark .result-preview-image-wrap {
  border-color: rgba(255, 255, 255, 0.08);
  background: var(--surface);
}
html.theme-dark .result-preview-image-skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.1) 14%, rgba(255,255,255,0.06) 28%);
  background-size: 200% 100%;
}

html.theme-dark .result-preview-image {
  background: var(--surface);
}
