*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e1e2e;
  line-height: 1.5;
}

/* ── Full-screen viewport ── */

#viewport {
  position: fixed;
  inset: 0;
  background:
    repeating-conic-gradient(#e0e0e0 0% 25%, #ececec 0% 50%)
    50% / 20px 20px;
  overflow: hidden;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

#viewport.has-image { cursor: grab; }
#viewport.has-image.dragging { cursor: grabbing; }

#demo-image {
  position: absolute;
  left: 0; top: 0;
  transform-origin: 0 0;
  display: none;
  pointer-events: none;
  transition: transform 0.12s ease-out;
}

#viewport.dragging #demo-image { transition: none; }

#viewport.has-image #demo-image { display: block; }
#viewport.has-image .placeholder { display: none; }

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0b0b0;
  font-size: 1rem;
  pointer-events: none;
}

/* Viewport drop hint */
#viewport.drag-over::after {
  content: "Drop image here";
  position: absolute;
  inset: 0.75rem;
  border: 3px dashed rgba(79, 70, 229, 0.4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 600;
  color: rgba(79, 70, 229, 0.5);
  background: rgba(79, 70, 229, 0.04);
  pointer-events: none;
  z-index: 1;
}

/* ── Floating panels (frosted glass) ── */

.float-panel {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 10px;
  padding: 0.85rem 1.05rem;
  box-shadow:
    0 2px 16px rgba(0, 0, 0, 0.10),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  font-size: 0.84rem;
}

.float-panel h2 {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 0.5rem;
}

/* Left stack */
.panel-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: 400px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Progress */
#panel-progress {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  min-width: 300px;
  max-width: 520px;
  width: 40vw;
}

/* Zoom */
#panel-zoom {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.65rem;
}

/* ── Drop zone ── */

.drop-zone {
  border: 2px dashed transparent;
  border-radius: 8px;
  padding: 0.3rem;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.drag-over {
  border-color: #4f46e5;
  background: rgba(79, 70, 229, 0.07);
}

/* ── Upload ── */

.file-btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: #eef;
  border: 1px solid #c7c7e8;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #4f46e5;
  cursor: pointer;
  transition: background 0.15s;
}

.file-btn:hover { background: #e0e0ff; }

.file-btn input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.file-info {
  font-size: 0.78rem;
  color: #777;
  margin-top: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Controls ── */

.control-row {
  display: grid;
  grid-template-columns: 80px 1fr 105px;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.control-row label {
  font-size: 0.82rem;
  font-weight: 500;
}

.control-row output {
  font-size: 0.78rem;
  color: #555;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: #4f46e5;
}

.speed-line {
  font-size: 0.78rem;
  color: #777;
  margin-top: 0.3rem;
  margin-bottom: 0.6rem;
}

.speed-line strong { color: #4f46e5; }

/* ── Buttons ── */

.actions { display: flex; gap: 0.4rem; }

button {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

#start-btn { background: #4f46e5; color: #fff; }
#start-btn:hover:not(:disabled) { background: #4338ca; }
#start-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Zoom buttons */
.zoom-btn {
  padding: 0.25rem 0.55rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d0d0d8;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #444;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.zoom-btn:hover { background: #eef; color: #4f46e5; border-color: #c7c7e8; }

.zoom-btn.active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.zoom-btn.active:hover {
  background: #4338ca;
  border-color: #4338ca;
}

.zoom-level {
  font-size: 0.72rem;
  font-weight: 600;
  color: #555;
  font-variant-numeric: tabular-nums;
  min-width: 3.2em;
  text-align: right;
}

/* ── Progress ── */

.progress-track {
  height: 5px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  border-radius: 3px;
  transition: width 80ms linear, background 0.4s;
}

.progress-fill.complete {
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.progress-fill.capped {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.progress-text {
  font-size: 0.78rem;
  color: #666;
  font-variant-numeric: tabular-nums;
}

/* ── SW overlay ── */

#sw-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 245, 247, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s, visibility 0s 0s;
}

#sw-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0s 0.3s;
}

#sw-overlay-text {
  font-size: 0.95rem;
  color: #666;
}

#sw-overlay.error #sw-overlay-text {
  color: #dc2626;
}
