/* Shared modal styles */
.funes-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
}
.funes-modal-panel {
  background: #111;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  width: min(92vw, 1400px);
  max-width: 100vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.funes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.funes-modal-title {
  font-size: 14px;
  opacity: 0.9;
}
.funes-modal-close {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
}
.funes-modal-body {
  flex: 1 1 auto;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  position: relative;
}

.funes-modal-body--column {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 24px;
  background: #111;
  color: #fff;
  text-align: left;
  overflow-y: auto;
  gap: 16px;
}

/* Wireframe modal: enforce a definite body height so the stacked images can fill it */
.ld-modal .funes-modal-body { height: 60vh; }
.funes-modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.funes-modal-img {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Buttons */
.funes-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.funes-btn-primary { background: #049ef4; color: #fff; }
.funes-btn-secondary { background: #333; color: #fff; }

/* Layered preview */
.funes-img-wrap { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; height: auto; max-height: 72vh; overflow: hidden; }
/* In wireframe modal, make the wrapper fill the body so children using % heights have a base */
.ld-modal .funes-img-wrap { height: 100%; }
.funes-img-stack { position: relative; display: inline-block; overflow: hidden; }
.funes-img-base,
.funes-img-linedraw {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: auto;
}
.funes-img-base { opacity: 1; }
.funes-img-linedraw { pointer-events: none; opacity: 0.9; }

/* Layer button & menu */
.funes-layer-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #222;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.funes-layer-menu {
  position: absolute;
  right: 60px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 220px;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 10px 10px;
}
.funes-layer-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; margin: 8px 0; }
.funes-layer-label { font-size: 12px; opacity: 0.9; }

/* Spinner */
@keyframes funes-spin { from { transform: rotate(0) } to { transform: rotate(360deg) } }
.funes-spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: funes-spin 1s linear infinite; }

/* Loading (linedraw generation) */
.funes-loading-card {
  background: rgba(17, 17, 17, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  padding: 22px 26px;
  min-width: 280px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
}
.funes-loading-spinner { width: 36px; height: 36px; border-width: 3px; }
.funes-loading-status { font-size: 14px; line-height: 20px; opacity: 0.95; min-height: 20px; }
.funes-loading-line { white-space: nowrap; }

.download-license-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.download-license-content ul {
  margin: 0;
  padding-left: 20px;
}

.download-license-list li {
  margin-bottom: 6px;
}

.download-license-note {
  opacity: 0.85;
}

.download-license-attribution {
  font-weight: 600;
  font-size: 14px;
}

.download-license-error {
  width: 100%;
  background: rgba(255, 77, 79, 0.18);
  border: 1px solid rgba(255, 77, 79, 0.5);
  color: #ffabab;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

@keyframes funes-fade-in-out {
  0% { opacity: 0; transform: translateY(6px); }
  10% { opacity: 1; transform: translateY(0); }
  90% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}
@keyframes funes-fade-in-stay {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
.funes-fade-in-out { animation: funes-fade-in-out 5s ease-in-out both; }
.funes-fade-in-stay { animation: funes-fade-in-stay 600ms ease-in-out both; }
