:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #f6f2fa;
  background: #17131e;
  --surface: #231d2d;
  --raised: #31263d;
  --line: #42364f;
  --muted: #beb2ca;
  --pink: #ddc5ff;
  --lime: #d8fa75;
  --danger: #ffc0b9;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden], .symbols { display: none !important; }
body { margin: 0; min-width: 0; }
h1, h2, p { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
svg:not(.symbols) {
  display: block; width: 1.15rem; height: 1.15rem; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.container { width: min(100% - 3rem, 1020px); margin-inline: auto; }
.topbar { height: 67px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 780; font-size: 1.06rem; white-space: nowrap; }
.brand-mark { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; background: var(--lime); border-radius: .7rem; color: #231a2c; }
.brand-mark svg { width: 1.44rem; height: 1.44rem; }
.brand-latin { color: var(--muted); margin-inline-start: .22rem; font-size: .84rem; font-weight: 650; }
.engine-state { display: flex; gap: .42rem; align-items: center; color: var(--muted); padding: .4rem .66rem; background: #231c2a; border: 1px solid var(--line); border-radius: 99px; font-size: .76rem; white-space: nowrap; }
.state-dot { width: .4rem; height: .4rem; border-radius: 50%; background: var(--lime); }
.offline .state-dot { background: #ffc681; }

.hero {
  position: relative; isolation: isolate; display: grid; align-items: center;
  overflow: hidden; min-height: 171px; padding: 1.65rem 2.05rem; margin: .42rem 0 1.05rem;
  border: 1px solid #c8aaff; border-radius: 1.35rem;
  color: #25143a; background: linear-gradient(108deg, #dfc8ff, #ac86fa 85%);
}
.hero-copy { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.8rem); font-weight: 850; letter-spacing: -.085em; line-height: 1.1; }
.hero p { color: #412858; margin-top: .62rem; font-size: 1rem; font-weight: 600; line-height: 1.4; }
.hero-art { position: absolute; inset: 0 0 0 48%; pointer-events: none; }
.hero-art::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(#57377863 1.1px, transparent 1.1px);
  background-size: 13px 13px;
  mask-image: linear-gradient(90deg, transparent 6%, #000 43%);
}
.hero-shot { position: absolute; display: block; width: 128px; height: 139px; top: 49%; border-radius: .9rem; border: 5px solid #f4eaff; background-size: cover; background-position: center 39%; box-shadow: 0 6px 22px #2b104556; }
.hero-shot-first { right: 32%; background-image: url("/assets/demo-selfie.webp"); transform: translateY(-50%) rotate(-12deg); }
.hero-shot-second { right: 12%; background-image: url("/assets/night.webp"); transform: translateY(-49%) rotate(12deg); background-position: center 36%; }
.hero-sticker { position: absolute; display: grid; place-items: center; right: 27%; bottom: 13%; width: 2.7rem; height: 2.7rem; color: #281839; background: var(--lime); border: 1px solid #312142; border-radius: .8rem; transform: rotate(-12deg); }
.hero-sticker svg { width: 1.5rem; height: 1.5rem; }
.hero-sparkle { position: absolute; left: 23%; top: 26%; color: #5e3991; transform: rotate(-14deg); }
.hero-sparkle svg { width: 1.75rem; height: 1.75rem; }

.workflow { display: grid; grid-template-columns: minmax(235px, .83fr) minmax(0, 1.65fr); gap: .85rem; align-items: stretch; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 1.1rem; padding: 1rem; }
.card h2, .dialog-head h2 { font-size: 1.1rem; font-weight: 750; letter-spacing: -.025em; line-height: 1.3; }
.card-head { display: flex; min-height: 2.3rem; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .65rem; }
.photo-card > h2 { min-height: 2.3rem; display: flex; align-items: center; margin-bottom: .65rem; }
.drop-zone {
  width: 100%; min-height: 129px; padding: .6rem .4rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem;
  text-align: center; color: var(--pink); background: #281e34; border: 1px dashed #725889; border-radius: .85rem;
  transition: border-color .16s, background .16s;
}
.drop-zone:hover, .drop-zone.dragging { background: #362643; border-color: #d5b8ff; }
.drop-zone strong { font-size: .94rem; font-weight: 700; }
.drop-zone small, .video-selected small { color: var(--muted); font-size: .81rem; }
.drop-icon { display: grid; place-items: center; flex: 0 0 auto; width: 2.38rem; height: 2.38rem; color: var(--pink); background: #3d2b4f; border: 1px solid #57406e; border-radius: .68rem; }
.drop-icon svg { width: 1.23rem; height: 1.23rem; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .58rem; }
.button {
  display: inline-flex; justify-content: center; align-items: center; gap: .4rem; text-align: center;
  min-height: 2.55rem; padding: .45rem .7rem; border: 1px solid transparent; border-radius: .65rem;
  white-space: nowrap; font-size: .89rem; line-height: 1.25; font-weight: 690;
  transition: background .16s, border-color .16s;
}
.button svg { width: 1rem; height: 1rem; }
.button.soft { background: var(--raised); color: #f2e7ff; border-color: var(--line); }
.button.soft:hover:not(:disabled) { background: #433252; border-color: #745b87; }
.button.primary { background: var(--lime); color: #21192a; border-color: var(--lime); font-weight: 800; }
.button.primary:hover:not(:disabled) { background: #e8ffa3; border-color: #e8ffa3; }
.button:disabled { opacity: .57; }
.photo-selected { height: 129px; position: relative; border-radius: .85rem; overflow: hidden; background: #191322; border: 1px solid #66527c; }
.photo-selected img { width: 100%; height: 100%; display: block; object-fit: contain; }
.ark-portrait { height: 179px; }
.photo-selected > span { position: absolute; inset: auto 0 0; padding: .65rem .55rem .28rem; color: white; background: linear-gradient(transparent, #100b16e8); font-size: .76rem; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.icon-button { display: grid; place-items: center; flex: 0 0 auto; width: 2.1rem; height: 2.1rem; padding: 0; border-radius: .52rem; color: var(--pink); background: #30253d; border: 1px solid #5b486b; }
.icon-button:hover { color: #fff; background: #473652; }
.icon-button svg { width: 1rem; height: 1rem; }
.remove-photo { position: absolute; top: .35rem; right: .35rem; }

#video-source { min-height: 2.23rem; font-size: .81rem; padding: .32rem .56rem; }
.library { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .52rem; }
.clip-option {
  position: relative; min-width: 0; cursor: pointer; padding: .26rem; overflow: hidden;
  color: #eee5f7; background: #2c2236; border: 1px solid #4a395b; border-radius: .75rem;
  transition: background .16s, border-color .16s;
}
.clip-option:hover { background: #3b2b49; border-color: #9876b3; }
.clip-option:has(input:checked) { color: var(--lime); background: #333a25; border-color: var(--lime); }
.clip-option:has(input:focus-visible) { outline: 2px solid var(--lime); outline-offset: 3px; }
.clip-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.clip-art { position: relative; height: 140px; display: block; overflow: hidden; border-radius: .51rem; background: #33234b; }
.clip-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 38%; }
.clip-option strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .5rem .25rem .3rem; text-align: center; font-size: .88rem; font-weight: 750; line-height: 1.15; }
.clip-length { position: absolute; right: .33rem; bottom: .31rem; background: #160e25d9; color: #fcf6ff; border-radius: .31rem; padding: .14rem .32rem; font-size: .67rem; white-space: nowrap; }
.clip-check { display: none; place-items: center; position: absolute; top: .38rem; right: .38rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--lime); color: #21192a; box-shadow: 0 0 0 2px #19102266; }
.clip-check svg { width: .96rem; height: .96rem; stroke-width: 2.6; }
.clip-option:has(input:checked) .clip-check { display: grid; }
.video-card #video-drop, .video-selected { min-height: 179px; }
.video-selected { display: flex; align-items: center; gap: .65rem; background: #2b2138; border: 1px solid #67517f; padding: .8rem; border-radius: .75rem; }
.video-selected > div { flex: 1; min-width: 0; }
.video-selected strong, .video-selected small { overflow: hidden; display: block; white-space: nowrap; text-overflow: ellipsis; }
.video-selected small { margin-top: .28rem; }

.action, .form-error { grid-column: 1/-1; }
.action { display: grid; justify-items: center; padding-block: .16rem .92rem; gap: .55rem; }
#generate { min-height: 3.15rem; width: min(100%, 368px); border-radius: .84rem; font-size: 1.08rem; }
#generate svg { width: 1.25rem; height: 1.25rem; }
.privacy-note { font-size: .77rem; color: var(--muted); display: flex; align-items: center; gap: .32rem; }
.privacy-note svg { width: .9rem; height: .9rem; }
.form-error { padding: .63rem .78rem; border-radius: .56rem; border: 1px solid #855454; background: #3c232c; color: var(--danger); font-size: .86rem; line-height: 1.45; }
.result-card { margin-top: .1rem; margin-bottom: 1.5rem; }
.result-card .card-head { margin-bottom: .68rem; }
.player-stage { display: grid; place-items: center; overflow: hidden; min-height: 140px; border: 1px solid #493758; border-radius: .72rem; background: #191222; }
.player-progress { display: grid; justify-items: center; gap: .4rem; text-align: center; width: 100%; padding: .85rem; }
.player-progress small, .result-note { color: var(--muted); font-size: .83rem; }
.player-progress progress { display: block; width: min(100%, 285px); height: .65rem; accent-color: var(--lime); }
.player-stage video { display: block; width: 100%; height: clamp(230px, 51vh, 430px); object-fit: contain; background: #100c15; }
.result-note { text-align: center; padding-top: .62rem; }

dialog { width: min(100% - 2rem, 450px); max-height: calc(100dvh - 2rem); overflow: auto; padding: 1rem; background: var(--surface); color: inherit; border: 1px solid #66517a; border-radius: .95rem; box-shadow: 0 30px 90px #0009; }
dialog::backdrop { background: #100918ca; backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .45rem; margin-top: .75rem; }
.dialog-text { margin-top: .55rem; color: var(--muted); font-size: .87rem; }
.camera-stage { position: relative; border-radius: .65rem; overflow: hidden; aspect-ratio: 4/3; background: #191222; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-guide { position: absolute; inset: 13% 29%; border: 1px dashed #eed9ffc9; border-radius: 48%; pointer-events: none; }

@media (max-width: 690px) {
  .container { width: calc(100% - 1.5rem); }
  .topbar { height: 55px; }
  .brand { gap: .4rem; }
  .brand-mark { width: 1.95rem; height: 1.95rem; }
  .brand-mark svg { width: 1.28rem; height: 1.28rem; }
  .hero { min-height: 132px; margin: .3rem 0 .7rem; padding: .9rem; border-radius: .95rem; }
  .hero h1 { font-size: clamp(1.76rem, 7.6vw, 2.65rem); }
  .hero p { font-size: .81rem; margin-top: .42rem; }
  .hero-art { inset-inline-start: 53%; }
  .hero-shot { width: 72px; height: 81px; border-width: 3px; border-radius: .55rem; }
  .hero-shot-first { right: 42%; }
  .hero-shot-second { right: 12%; }
  .hero-sticker { width: 1.7rem; height: 1.7rem; right: 35%; bottom: 15%; border-radius: .46rem; }
  .hero-sticker svg { width: .99rem; height: .99rem; }
  .hero-sparkle { display: none; }
  .workflow { grid-template-columns: minmax(0, 1fr); gap: .62rem; }
  .card { padding: .76rem; border-radius: .85rem; }
  .photo-card > h2 { min-height: 1.55rem; margin-bottom: .5rem; }
  .card-head { min-height: 2.08rem; margin-bottom: .47rem; }
  .photo-card .drop-zone, .photo-selected { min-height: 89px; height: 89px; }
  .photo-card .ark-portrait { height: 110px; }
  .photo-actions { margin-top: .45rem; }
  .button { min-height: 2.65rem; }
  .drop-icon { width: 2.08rem; height: 2.08rem; }
  .library { gap: .38rem; }
  .clip-art { height: clamp(80px, 24vw, 128px); }
  .clip-option strong { font-size: .82rem; padding: .39rem .07rem .21rem; }
  .video-card #video-drop, .video-selected { min-height: 126px; }
  .action { padding-top: .13rem; }
  #generate { width: 100%; }
}

@media (max-width: 360px) {
  .hero { padding-inline: .72rem; }
  .hero p { max-width: 10rem; }
  .hero-shot { width: 62px; height: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
