:root {
  --bg: radial-gradient(circle at top left, #ffe7d3 0%, #f4d0ff 45%, #c1d4ff 100%);
  --panel: rgba(255, 255, 255, 0.82);
  --text: #191825;
  --muted: #5d5a6f;
  --accent: #7a4bff;
  --accent-strong: #5630d8;
  --danger: #ff647c;
  --frame-bg: #0f0b1c;
  --frame-border: rgba(255, 255, 255, 0.6);
  font-family: 'Inter', 'Space Grotesk', 'IBM Plex Sans', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-image: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px clamp(16px, 4vw, 48px);
}

.app-shell {
  width: min(1100px, 100%);
  display: grid;
  gap: 32px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.panel {
  background: var(--panel);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 40px);
  backdrop-filter: blur(20px);
  box-shadow: 0 25px 60px rgba(20, 10, 60, 0.25);
}

.panel.intro h1 {
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1.1;
  margin: 12px 0 18px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
}

.intro-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.intro-top .eyebrow {
  margin: 0;
}

.eyebrow-link {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.eyebrow-link:hover {
  text-decoration: underline;
}

.lede {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 460px;
}

.upload-card {
  margin-top: 32px;
  border: 2px dashed rgba(122, 75, 255, 0.5);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border 0.2s, transform 0.2s, background 0.2s;
  background: rgba(122, 75, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.upload-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  background: rgba(122, 75, 255, 0.12);
}

.upload-card.dragging {
  border-color: var(--accent-strong);
  background: rgba(122, 75, 255, 0.18);
  transform: translateY(-2px) scale(1.01);
}

.upload-card input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-card strong {
  color: var(--accent-strong);
}

.hint,
.status {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 16px;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.frame-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
  width: min(100%, 520px);
  margin: 0 auto;
}

#frameCanvas {
  width: 100%;
  height: 100%;
  border-radius: 32px;
  background: var(--frame-bg);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
  cursor: grab;
  position: relative;
  z-index: 1;
}

#frameCanvas.dragging {
  cursor: grabbing;
}

.frame-overlay {
  --hole-x: 50.94%;
  --hole-y: 49.06%;
  --hole-r: 31.27%;
  pointer-events: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  -webkit-mask-image: radial-gradient(
    circle at var(--hole-x) var(--hole-y),
    transparent 0 calc(var(--hole-r) - 0.2%),
    black calc(var(--hole-r) + 0.2%)
  );
  mask-image: radial-gradient(
    circle at var(--hole-x) var(--hole-y),
    transparent 0 calc(var(--hole-r) - 0.2%),
    black calc(var(--hole-r) + 0.2%)
  );
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 500;
}

.control-row.toggle {
  justify-content: space-between;
}

.control-row.toggle input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.control-row.badge-scale[aria-disabled='true'] {
  opacity: 0.55;
}

.control-row.badge-scale[hidden] {
  display: none;
}

.control-row input[type='range'] {
  flex: 1;
}

.actions {
  justify-content: space-between;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  color: white;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
}

button:not([disabled]):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(122, 75, 255, 0.3);
}

#resetBtn {
  background: rgba(122, 75, 255, 0.15);
  color: var(--accent-strong);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 10, 30, 0.55);
  backdrop-filter: blur(6px);
  z-index: 0;
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(780px, 100%);
  max-height: min(90vh, 900px);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(20, 10, 60, 0.35);
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-close {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(122, 75, 255, 0.12);
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.modal-close:hover {
  box-shadow: none;
}

.modal-body {
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  padding: 10px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  border-radius: 14px;
  background: white;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
    gap: 12px;
  }

  button {
    width: 100%;
    text-align: center;
  }
}
