body {
  min-height: 100dvh;
  background:
    radial-gradient(980px 560px at 94% -8%, rgba(0, 199, 214, 0.14), transparent 62%),
    radial-gradient(880px 500px at -6% 12%, rgba(44, 39, 118, 0.08), transparent 58%),
    radial-gradient(760px 440px at 50% 106%, rgba(14, 122, 230, 0.09), transparent 60%),
    linear-gradient(180deg, #f7fbff 0%, #eff6fc 100%);
  user-select: none;
  -webkit-user-select: none;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(18px + env(safe-area-inset-right))
    calc(18px + env(safe-area-inset-bottom))
    calc(18px + env(safe-area-inset-left));
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  min-height: calc(100dvh - 34px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* Header & Stepper */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: clamp(44px, 5.5vw, 58px);
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(11, 40, 92, 0.08));
}

.brand-meta {
  padding-left: 14px;
  border-left: 1.5px solid rgba(14, 122, 230, 0.22);
}

.eyebrow {
  margin: 0;
  font-size: 14.5px;
  font-weight: 750;
  letter-spacing: -0.015em;
  color: var(--wave-navy);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(14, 122, 230, 0.16);
  box-shadow: var(--shadow-sm);
}

.step-pill {
  min-height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 650;
}

.step-num {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.78;
}

.step-pill.is-active {
  background: var(--wave-grad-btn);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(14, 122, 230, 0.28);
}

.step-pill.is-done {
  color: var(--wave-indigo);
}

.step-track {
  width: 30px;
  height: 3px;
  border-radius: 999px;
  background: rgba(14, 122, 230, 0.16);
  overflow: hidden;
}

.step-fill {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--wave-grad-bright);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.step-fill.is-complete { transform: scaleX(1); }

/* Stage & Step Heads */
.stage {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(18px, 3vh, 34px) 0;
}

.step-view {
  width: 100%;
  will-change: transform, opacity;
}

.step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.step-kicker {
  margin: 0 0 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wave-azure);
}

h1 {
  margin: 0;
  font-size: clamp(26px, 3.8vw, 40px);
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1.06;
  background: linear-gradient(110deg, #1b1854 0%, #0b285c 45%, #0e7ae6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.step-sub {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.48;
}

/* STEP 1: Open Full-Bleed Signature Canvas (crisp white ink surface, WAVE azure-aqua aura) */
.pad-shell {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.paper {
  position: relative;
  height: clamp(290px, 50dvh, 490px);
  overflow: hidden;
  border-radius: 26px;
  background:
    radial-gradient(rgba(14, 122, 230, 0.085) 1px, transparent 1px),
    linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
  background-size: 24px 24px, 100% 100%;
  border: 1.5px solid rgba(14, 122, 230, 0.18);
  box-shadow:
    0 24px 60px rgba(11, 40, 92, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.28s ease, box-shadow 0.32s ease, transform 0.28s ease;
}

.paper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--wave-grad-bright);
  opacity: 0.45;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.paper.has-ink {
  border-color: rgba(0, 199, 214, 0.55);
  box-shadow:
    0 26px 70px rgba(14, 122, 230, 0.14),
    0 0 0 4px rgba(0, 199, 214, 0.10);
}

.paper.has-ink::before {
  opacity: 1;
}

.paper canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.paper::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 22%;
  border-bottom: 1.5px dashed rgba(14, 122, 230, 0.28);
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.paper.has-ink::after { opacity: 0; }

.corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: rgba(14, 122, 230, 0.34);
  border-style: solid;
  pointer-events: none;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.paper.has-ink .corner {
  border-color: var(--wave-aqua);
  transform: scale(1.1);
}

.corner.tl { top: 16px; left: 16px; border-width: 2px 0 0 2px; border-radius: 5px 0 0 0; }
.corner.tr { top: 16px; right: 16px; border-width: 2px 2px 0 0; border-radius: 0 5px 0 0; }
.corner.bl { bottom: 16px; left: 16px; border-width: 0 0 2px 2px; border-radius: 0 0 0 5px; }
.corner.br { bottom: 16px; right: 16px; border-width: 0 2px 2px 0; border-radius: 0 0 5px 0; }

.hint {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 27%;
  margin: 0;
  color: rgba(11, 40, 92, 0.42);
  font-size: 15px;
  font-weight: 550;
  text-align: center;
  pointer-events: none;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.tool-group {
  display: flex;
  gap: 10px;
}

.tool-group button {
  min-width: 104px;
  padding: 0 18px;
}

.next-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 228px;
  padding: 0 28px;
}

.next-btn .arrow {
  display: inline-block;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.next-btn:hover:not(:disabled) .arrow {
  transform: translateX(5px);
}

/* Signature chip shown beside the photo step */
.sig-chip {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(14, 122, 230, 0.18);
  box-shadow: var(--shadow-sm);
}

.sig-chip img {
  height: 34px;
  max-width: 130px;
  object-fit: contain;
  display: block;
}

.link-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--wave-azure-soft);
  color: var(--wave-navy);
  font-size: 13px;
  font-weight: 650;
}

.link-btn:hover { background: rgba(14, 122, 230, 0.2); }

.camera-stage,
.result-stage {
  width: min(640px, 100%);
  margin: 0 auto;
}

.result-stage {
  width: min(820px, 100%);
}

.card-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 2vw, 22px);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(14, 122, 230, 0.15);
  box-shadow: var(--shadow-md);
}

.card-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--wave-grad-bright);
  opacity: 0.72;
}

.panel-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--wave-navy);
}

.panel-meta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--wave-azure);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--wave-azure-soft);
}

.photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 440px;
  max-height: 44dvh;
  margin: 0 auto;
  aspect-ratio: 397 / 323;
  overflow: hidden;
  border-radius: 20px;
  background: linear-gradient(155deg, #f3f9ff 0%, #e6f3fd 100%);
  border: 1.5px solid rgba(14, 122, 230, 0.18);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.photo-frame.is-live {
  border-color: var(--wave-aqua);
  box-shadow: 0 0 0 4px rgba(0, 199, 214, 0.14);
}

.photo-frame img,
.photo-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame video { transform: scaleX(-1); }

.shutter-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}

.photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.camera-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--wave-grad-btn);
  display: grid;
  place-items: center;
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(14, 122, 230, 0.28);
  margin-bottom: 4px;
  animation: iconFloat 3.6s ease-in-out infinite;
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.photo-empty p {
  margin: 0;
  color: var(--wave-navy);
  font-weight: 680;
  font-size: 15px;
}

.photo-empty span { font-size: 13px; }

.vf {
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: rgba(14, 122, 230, 0.42);
  border-style: solid;
  pointer-events: none;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.photo-frame.is-live .vf {
  border-color: var(--wave-aqua);
  transform: scale(1.08);
}

.vf.tl { top: 14px; left: 14px; border-width: 2px 0 0 2px; border-radius: 5px 0 0 0; }
.vf.tr { top: 14px; right: 14px; border-width: 2px 2px 0 0; border-radius: 0 5px 0 0; }
.vf.bl { bottom: 14px; left: 14px; border-width: 0 0 2px 2px; border-radius: 0 0 0 5px; }
.vf.br { bottom: 14px; right: 14px; border-width: 0 2px 2px 0; border-radius: 0 0 5px 0; }

.camera-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.camera-controls button { flex: 1 1 140px; }

.card-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1024 / 682;
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(155deg, #f3f9ff 0%, #e7f4fd 100%);
  border: 1.5px solid rgba(14, 122, 230, 0.18);
}

.card-empty {
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
}

.card-empty p { margin: 0; max-width: 30ch; }

.card-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.card-sheen {
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), rgba(0, 199, 214, 0.25), transparent);
  transform: translateX(-160%) skewX(-22deg);
  pointer-events: none;
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.row button { flex: 1 1 130px; }

/* WAVE Gradient Buttons with Subtle Sheen Sweep */
button.primary {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: var(--wave-grad-btn);
  background-size: 150% 100%;
  color: #ffffff;
  font-weight: 680;
  letter-spacing: -0.01em;
  padding: 0 20px;
  box-shadow: 0 10px 24px rgba(14, 122, 230, 0.26);
}

button.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-140%) skewX(-22deg);
  pointer-events: none;
}

button.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  background-position: 100% 50%;
  box-shadow: 0 14px 30px rgba(0, 199, 214, 0.30);
}

button.primary:hover:not(:disabled)::after {
  animation: sheenSweep 0.75s ease forwards;
}

button.primary.is-sent {
  background: var(--wave-grad-ok);
  box-shadow: 0 10px 26px rgba(13, 148, 136, 0.30);
}

button.secondary,
button.quiet {
  border: 1px solid rgba(14, 122, 230, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--wave-navy);
  font-weight: 600;
  padding: 0 18px;
}

button.secondary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--surface-subtle);
  border-color: rgba(14, 122, 230, 0.42);
  box-shadow: 0 6px 16px rgba(11, 40, 92, 0.08);
}

button.quiet {
  color: var(--danger);
  border-color: rgba(198, 40, 40, 0.25);
}

button.quiet:hover:not(:disabled) {
  background: rgba(198, 40, 40, 0.06);
  transform: translateY(-1px);
}

button.ghost {
  border: 1.5px dashed rgba(14, 122, 230, 0.32);
  border-radius: 14px;
  background: transparent;
  color: var(--wave-mid);
  font-weight: 650;
  padding: 0 18px;
}

button.ghost:hover { background: var(--wave-azure-soft); }

button:active:not(:disabled) { transform: scale(0.975); }

.status {
  min-height: 1.35em;
  margin: 10px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--wave-mid);
  text-align: center;
}

.status.error { color: var(--danger); }

.qr-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.qr-dialog[hidden] { display: none; }

.qr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 29, 66, 0.46);
}

.qr-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 24px 22px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.qr-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--wave-navy);
}

.qr-card p {
  margin: 0 auto 16px;
  max-width: 34ch;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.qr-card img {
  width: min(280px, 72vw);
  height: auto;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: #ffffff;
}

.qr-card button { min-width: 140px; }

/* Burst particles for celebratory Send to LED Wall */
.wave-burst-dot {
  position: fixed;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 90;
}

/* Responsive Breakpoints — iPad & Tablet Portrait + Landscape */

/* Tablet Portrait (iPad Mini 744x1133, iPad Air 820x1180, iPad Pro 834x1194 & 1024x1366, Android tablets) */
@media (orientation: portrait) and (min-width: 600px) {
  body {
    padding:
      calc(22px + env(safe-area-inset-top))
      calc(28px + env(safe-area-inset-right))
      calc(24px + env(safe-area-inset-bottom))
      calc(28px + env(safe-area-inset-left));
  }

  .shell {
    max-width: 820px;
    min-height: calc(100dvh - 46px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .stage {
    padding: clamp(18px, 2.8vh, 32px) 0;
  }

  .paper {
    height: clamp(340px, 46dvh, 560px);
  }

  .camera-stage {
    width: min(560px, 100%);
  }

  .photo-frame {
    width: 100%;
    max-width: min(440px, calc(30dvh * 397 / 323));
    max-height: none;
  }

  .card-slot {
    width: 100%;
    max-width: min(100%, calc(35dvh * 1024 / 682));
    margin: 0 auto;
  }
}

/* Tablet & Desktop Landscape (iPad Mini 1024x768, iPad Air 1180x820, iPad Pro 1194x834 / 1366x1024, Galaxy Tab) */
@media (orientation: landscape) and (min-width: 740px), (min-width: 1120px) {
  body {
    padding:
      calc(14px + env(safe-area-inset-top))
      calc(26px + env(safe-area-inset-right))
      calc(14px + env(safe-area-inset-bottom))
      calc(26px + env(safe-area-inset-left));
  }

  .shell {
    min-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .topbar {
    flex-wrap: nowrap;
    padding-bottom: 12px;
  }

  .brand-logo {
    height: clamp(40px, 5.2dvh, 52px);
  }

  .stage {
    padding: clamp(10px, 2dvh, 22px) 0;
  }

  .step-head {
    margin-bottom: 12px;
  }

  h1 {
    font-size: clamp(24px, 3.1vw, 36px);
  }

  .paper {
    height: clamp(230px, 50dvh, 470px);
  }

  .action-bar {
    margin-top: 12px;
  }

  .camera-stage {
    width: min(520px, 100%);
  }

  .result-stage {
    width: min(860px, 100%);
  }

  .camera-controls {
    margin-top: auto;
    padding-top: 12px;
  }

  .export-actions {
    margin-top: auto;
    padding-top: 12px;
  }
}

/* Compact-height Tablet Landscape (e.g., iPad Mini/Air in Safari landscape ~640–780px usable height) */
@media (orientation: landscape) and (max-height: 820px) and (min-width: 740px) {
  .topbar {
    padding-bottom: 8px;
  }

  .brand-logo {
    height: 40px;
  }

  .step-head {
    margin-bottom: 10px;
  }

  .step-kicker {
    margin-bottom: 2px;
    font-size: 10.5px;
  }

  h1 {
    font-size: clamp(22px, 2.6vw, 30px);
  }

  .paper {
    height: clamp(210px, 49dvh, 390px);
    border-radius: 22px;
  }

  .card-panel {
    padding: 14px 16px;
    border-radius: 20px;
  }

  .panel-label {
    margin-bottom: 10px;
    font-size: 13.5px;
  }

  .photo-frame {
    width: 100%;
    max-width: min(100%, calc(38dvh * 397 / 323));
    max-height: none;
    border-radius: 16px;
  }

  .card-slot {
    width: 100%;
    max-width: min(100%, calc(38dvh * 1024 / 682));
    margin: 0 auto;
    border-radius: 14px;
  }

  .export-actions {
    gap: 8px;
  }

  .export-actions button,
  .camera-controls button {
    min-height: 44px;
  }

  .status {
    margin-top: 6px;
    font-size: 12.5px;
  }
}

/* Narrow Phones */
@media (max-width: 599px) {
  .stepper {
    width: 100%;
    justify-content: space-between;
  }

  .step-track { width: 16px; }

  .step-pill {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
    font-size: 12.5px;
    gap: 4px;
  }

  .action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-group {
    width: 100%;
  }

  .tool-group button { flex: 1; }

  .next-btn { width: 100%; }

  .sig-chip {
    width: 100%;
    justify-content: space-between;
  }
}
