/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* ── Midnight Arcade tokens ── */
:root {
  --bg:         #0B0520;
  --ink:        #F3E6FF;
  --muted:      rgba(243,230,255,.6);
  --faint:      rgba(255,255,255,.07);
  --card:       rgba(22,10,46,.55);
  --card-border:rgba(255,43,214,.35);
  --accent:     #FF2BD6;
  --accent2:    #7B5CFF;
  --accent3:    #2BE1E1;
  --cta:        linear-gradient(135deg,#FF2BD6 0%,#7B5CFF 55%,#2BE1E1 100%);
  --cta-shadow: 0 0 24px rgba(255,43,214,.5), 0 0 48px rgba(43,225,225,.3);
  --radius:     24px;
  --radius-sm:  16px;
}

/* ── Base ── */
html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  background: #0B0520;
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Background ── */
.bg-base {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 100% 0%, #2B0B5A 0%, transparent 55%),
    radial-gradient(100% 80% at 0% 100%, #062033 0%, transparent 55%),
    #0B0520;
}

.bg-dots {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(43,225,225,.25) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent);
}

.bg-scanlines {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .06;
  background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 3px);
}

/* ── Scroll container ── */
.app-scroll {
  position: relative; z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 32px;
  min-height: 100vh;
}

/* ── Header ── */
.app-header {
  padding: 44px 4px 28px;
  text-align: center;
}

.logo-glow {
  display: inline-block;
  filter:
    drop-shadow(0 0 18px rgba(255,43,214,.6))
    drop-shadow(0 0 38px rgba(43,225,225,.4));
}

.logo-img {
  height: 72px;
  width: auto;
  display: block;
  image-rendering: pixelated;
}

.tagline {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: .1px;
}

/* ── View tabs ── */
.view-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--faint);
  border-radius: 999px;
}

.view-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}

.view-tab:hover {
  color: var(--ink);
}

.view-tab.active {
  background: var(--cta);
  color: #0B0520;
  box-shadow: 0 0 16px rgba(255,43,214,.35);
}

/* ── History view ── */
.history-header {
  padding: 4px 4px 16px;
}

.history-title {
  font-family: 'Archivo Black', system-ui, sans-serif;
  font-size: 20px;
  letter-spacing: .2px;
}

.history-hint {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.history-card {
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-card-video-wrap {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
}

.history-card-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-card-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.history-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,43,214,.18);
  color: #FF7FE6;
  white-space: nowrap;
}

.history-date {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-title {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-download-btn {
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}

.history-download-btn:hover {
  background: rgba(255,255,255,.14);
}

.history-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.history-empty-emoji {
  font-size: 40px;
  margin-bottom: 12px;
}

.history-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

@media (min-width: 600px) {
  .history-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Glass card ── */
.glass-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 0 30px rgba(123,92,255,.15);
  margin-bottom: 16px;
}

/* ── Section label ── */
.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 14px;
}

.step-badge {
  width: 26px; height: 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FF2BD6, #7B5CFF);
  box-shadow: 0 0 0 2px rgba(255,43,214,.25), 0 0 14px rgba(255,43,214,.5);
  display: flex; align-items: center; justify-content: center;
  font-family: 'VT323', monospace;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.section-title {
  font-family: 'VT323', monospace;
  font-size: 20px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.1;
}

/* ── Drop zone ── */
.drop-zone {
  border: 1.5px dashed var(--card-border);
  border-radius: var(--radius-sm);
  padding: 34px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(255,43,214,.07);
}

.drop-icon-ring {
  width: 56px; height: 56px;
  border-radius: 999px;
  background: var(--cta);
  box-shadow: var(--cta-shadow);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

.drop-title {
  font-family: 'VT323', monospace;
  font-size: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: 10px;
}

.drop-or { opacity: .5; }

.drop-link {
  background: var(--cta);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  cursor: pointer;
}

.drop-hint {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
  line-height: 1.3;
}

/* ── Photo grid & slots ── */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-slot {
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  border: 1.5px dashed var(--card-border);
  overflow: hidden;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: border-color .2s, box-shadow .2s;
}

.photo-slot.has-photo {
  border: none;
  box-shadow: 0 0 0 1.5px rgba(255,43,214,.6), 0 0 24px rgba(255,43,214,.25);
  cursor: default;
}

.photo-slot.has-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.slot-remove-btn {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; border-radius: 999px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; line-height: 1;
}

.slot-pill {
  position: absolute; left: 8px; bottom: 8px;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 10px; letter-spacing: .5px;
  color: #fff; font-family: 'Space Grotesk', system-ui;
  font-weight: 700; text-transform: uppercase;
}

.slot-empty-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  color: var(--muted);
  pointer-events: none;
}

.slot-plus {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--faint);
  display: flex; align-items: center; justify-content: center;
}

.slot-label-text {
  font-size: 12px; font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase;
}

/* ── Photo dots indicator ── */
.photo-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--faint);
  transition: background .2s, box-shadow .2s;
}

.dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.dot-status {
  font-size: 11px; color: var(--muted);
  margin-left: 6px;
  font-family: 'Space Grotesk', system-ui;
  letter-spacing: .3px;
}

/* ── Template cards ── */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tpl-card {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 10px;
  border-radius: 20px;
  border: 1.5px solid var(--faint);
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui;
  transition: border-color .15s, box-shadow .15s, background .15s;
  width: 100%;
}

.tpl-card:hover {
  border-color: rgba(255,43,214,.4);
  background: rgba(255,43,214,.04);
}

.tpl-card.selected {
  border-color: var(--accent);
  background: rgba(255,43,214,.08);
  box-shadow: 0 0 24px rgba(255,43,214,.3), inset 0 0 0 1px rgba(255,43,214,.35);
}

.tpl-thumb {
  width: 88px;
  height: 108px;
  border-radius: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.tpl-duration-pill {
  position: absolute; left: 6px; bottom: 6px;
  padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  font-size: 10px; color: #fff;
  letter-spacing: .4px; font-weight: 600;
}

.tpl-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

.tpl-play-circle {
  width: 28px; height: 28px; border-radius: 999px;
  background: rgba(255,255,255,.85);
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
}

.tpl-play-triangle {
  width: 0; height: 0;
  border-left: 8px solid #000;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  margin-left: 2px;
}

.tpl-tag {
  position: absolute; left: 6px; top: 6px;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 9px; letter-spacing: .6px;
  font-weight: 700; text-transform: uppercase;
  transition: background .15s;
}

.tpl-card.selected .tpl-tag {
  background: var(--accent);
}

.tpl-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 0;
  min-width: 0;
}

.tpl-title {
  font-size: 15px; font-weight: 700;
  line-height: 1.2; color: var(--ink);
}

.tpl-subtitle {
  font-size: 12px; color: var(--muted);
  margin-top: 6px; line-height: 1.3;
}

.tpl-selector {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
}

.tpl-radio {
  width: 16px; height: 16px; border-radius: 999px;
  border: 1.5px solid var(--muted);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}

.tpl-card.selected .tpl-radio {
  border-color: var(--accent);
  background: var(--accent);
}

.tpl-selector-text {
  font-size: 11px; color: var(--muted);
  font-weight: 600; letter-spacing: .3px;
  transition: color .15s;
}

.tpl-card.selected .tpl-selector-text {
  color: var(--ink);
}

/* ── Spacer ── */
.cta-spacer { height: 100px; }

/* ── Bottom CTA ── */
.cta-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 10px 16px 32px;
  background: linear-gradient(180deg, transparent 0%, rgba(6,2,22,.82) 40%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; justify-content: center;
}

.cta-btn {
  max-width: 448px; width: 100%;
  padding: 16px 20px;
  border-radius: 18px; border: none;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  font-family: 'VT323', monospace;
  font-size: 24px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: not-allowed;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: all .15s;
}

.cta-btn:not(:disabled) {
  background: var(--cta);
  color: #0B0520;
  box-shadow: var(--cta-shadow);
  cursor: pointer;
}

.cta-btn:not(:disabled):hover {
  filter: brightness(1.08);
}

.cta-btn:not(:disabled):active {
  transform: scale(.98);
}

/* ── Overlay base ── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(6,2,22,.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 24px;
}

/* ── Generating overlay ── */
.gen-body {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  color: #fff; width: 100%; max-width: 320px;
}

.ring-container {
  position: relative; width: 160px; height: 160px; flex-shrink: 0;
}

.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-family: 'VT323', monospace;
  font-size: 44px; font-weight: 400;
  color: #fff; line-height: 1;
}

.ring-pct-sign {
  font-size: 18px; opacity: .7; margin-top: -4px;
}

.gen-step-text {
  font-family: 'VT323', monospace;
  font-size: 22px; letter-spacing: 1px;
  color: #fff; text-transform: uppercase;
  text-align: center;
}

.gen-time-text {
  font-size: 13px; opacity: .6;
  font-family: 'Space Grotesk', system-ui;
  text-align: center;
}

.gen-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  font-family: 'Space Grotesk', system-ui;
  font-size: 12px; color: rgba(255,255,255,.8);
}

.gen-chip-thumb {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
}

/* ── Result overlay ── */
.overlay--result {
  background: #06021A;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
}

.result-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 56px 18px 12px;
  flex-shrink: 0;
}

.result-back-btn {
  width: 40px; height: 40px; border-radius: 999px;
  background: rgba(255,255,255,.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}

.result-title-text {
  font-family: 'VT323', monospace;
  font-size: 18px; letter-spacing: 1.2px; text-transform: uppercase;
  color: #fff;
}

.result-video-area {
  flex: 1;
  margin: 8px 16px 12px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  background: #000;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}

.result-video-area video {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
}

.result-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 0 16px 8px;
  flex-shrink: 0;
}

.result-expire-note {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,.35);
  font-family: 'Space Grotesk', system-ui;
  padding: 0 16px 28px;
  flex-shrink: 0;
}

.result-action-btn {
  padding: 14px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-family: 'Space Grotesk', system-ui;
  font-size: 13px; font-weight: 600; letter-spacing: .3px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
  transition: background .15s;
}

.result-action-btn:hover {
  background: rgba(255,255,255,.14);
}

.result-action-btn:disabled {
  opacity: .35; cursor: not-allowed;
}

/* ── Error overlay ── */
.overlay--error {
  background: rgba(6,2,22,.88);
}

.error-body {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  text-align: center; max-width: 320px;
}

.error-emoji { font-size: 44px; }

.error-msg {
  color: #FF6B6B;
  font-size: 15px;
  line-height: 1.5;
  font-family: 'Space Grotesk', system-ui;
}

.retry-btn {
  padding: 12px 28px;
  border-radius: 14px;
  background: var(--cta);
  border: none;
  color: #0B0520;
  font-family: 'VT323', monospace;
  font-size: 20px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--cta-shadow);
}

/* ── Source sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
}

.source-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  background: rgba(22,10,46,.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 28px 28px 0 0;
  border: 1px solid var(--card-border);
  border-bottom: none;
}

.sheet-handle {
  width: 40px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.25);
  margin: 0 auto 16px;
}

.sheet-title {
  font-family: 'VT323', monospace;
  font-size: 20px; letter-spacing: 1.2px; text-transform: uppercase;
  text-align: center; color: var(--ink); margin-bottom: 14px;
}

.sheet-opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 14px;
  border-radius: 16px; margin-bottom: 6px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: #fff; cursor: pointer;
  text-align: left; font-family: 'Space Grotesk', system-ui;
  transition: background .15s;
}

.sheet-opt:hover { background: rgba(255,255,255,.1); }

.sheet-opt-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sheet-opt-icon--primary {
  background: linear-gradient(135deg, #FF2BD6, #7B5CFF);
}

.sheet-opt-info { flex: 1; }

.sheet-opt-name { font-size: 15px; font-weight: 600; }
.sheet-opt-desc { font-size: 12px; opacity: .65; margin-top: 2px; }

.sheet-cancel {
  width: 100%; margin-top: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.6);
  font-family: 'Space Grotesk', system-ui;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.sheet-cancel:hover { background: rgba(255,255,255,.08); }

/* ── Responsive fine-tuning ── */
@media (max-width: 400px) {
  .app-scroll { padding: 0 12px 32px; }
  .logo-img { height: 58px; }
  .section-title { font-size: 17px; }
  .tpl-thumb { width: 76px; height: 94px; }
  .tpl-title { font-size: 14px; }
}

@media (min-width: 600px) {
  .logo-img { height: 82px; }
}

/* ── Scrollbar hide ── */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ── Selection color ── */
::selection { background: #FF2BD6; color: #fff; }

