:root {
  --color-brand-primary: #7b5dd6;
  --color-brand-primary-deep: #6046b0;
  --color-brand-primary-soft: #d9caff;
  --color-brand-primary-haze: #f2ebff;
  --color-accent-pink: #ff9ab8;
  --color-accent-sun: #ffd665;
  --color-accent-sky: #bfe6f8;
  --color-bg-cream: #fff8f1;
  --color-text-main: #625556;
  --color-text-muted: #928587;
  --shadow-card: 0 16px 34px rgba(104, 82, 139, .14);
  --shadow-soft: 0 10px 24px rgba(104, 82, 139, .12);
  --radius-button: 999px;
  --radius-control: 18px;

  --purple: var(--color-brand-primary);
  --purple-deep: var(--color-brand-primary-deep);
  --purple-soft: var(--color-brand-primary-soft);
  --purple-haze: var(--color-brand-primary-haze);
  --pink: var(--color-accent-pink);
  --sun: var(--color-accent-sun);
  --sky: var(--color-accent-sky);
  --cream: var(--color-bg-cream);
  --ink: var(--color-text-main);
  --muted: var(--color-text-muted);
  --shadow: var(--shadow-card);
  --soft-shadow: var(--shadow-soft);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body,
button,
input,
textarea {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

.km-body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 246, 239, .96) 0%, rgba(255, 251, 248, .94) 61%, rgba(221, 247, 215, .98) 100%),
    radial-gradient(circle at 18% 18%, rgba(255, 214, 225, .5) 0 6rem, transparent 6.2rem),
    radial-gradient(circle at 88% 72%, rgba(199, 232, 250, .48) 0 7rem, transparent 7.2rem);
  overflow-x: hidden;
}

.km-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 31rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1.2rem max(8.8rem, env(safe-area-inset-bottom));
  isolation: isolate;
}

.km-skyline,
.km-skyline span {
  position: absolute;
  pointer-events: none;
}

.km-skyline {
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.km-trail {
  top: .45rem;
  left: -2.2rem;
  width: 9.7rem;
  height: 6.8rem;
  border-top: .18rem dashed rgba(123, 207, 221, .82);
  border-right: .18rem dashed rgba(123, 207, 221, .82);
  border-radius: 0 7rem 0 0;
  transform: rotate(5deg);
}

.km-cloud {
  top: 3.8rem;
  right: .7rem;
  width: 6.9rem;
  height: 4.3rem;
  background:
    radial-gradient(circle at 25% 67%, var(--sky) 0 1.6rem, transparent 1.65rem),
    radial-gradient(circle at 50% 52%, var(--sky) 0 2.1rem, transparent 2.16rem),
    radial-gradient(circle at 75% 67%, var(--sky) 0 1.55rem, transparent 1.6rem);
  opacity: .88;
}

.km-star {
  width: 2rem;
  height: 2rem;
  background: var(--sun);
  clip-path: polygon(50% 0, 62% 36%, 99% 36%, 69% 57%, 81% 94%, 50% 72%, 19% 94%, 31% 57%, 1% 36%, 38% 36%);
  filter: drop-shadow(0 .18rem 0 rgba(232, 172, 45, .42));
}

.km-star-a {
  top: 2.2rem;
  right: 8.2rem;
  transform: rotate(16deg);
}

.km-flower {
  width: 2.3rem;
  height: 2.3rem;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 .32rem, transparent .34rem),
    radial-gradient(circle at 50% 17%, #ff9fb9 0 .48rem, transparent .5rem),
    radial-gradient(circle at 83% 50%, #ff9fb9 0 .48rem, transparent .5rem),
    radial-gradient(circle at 50% 83%, #ff9fb9 0 .48rem, transparent .5rem),
    radial-gradient(circle at 17% 50%, #ff9fb9 0 .48rem, transparent .5rem);
}

.km-flower-a {
  top: 6.2rem;
  left: 2.6rem;
  transform: rotate(-14deg);
}

.km-logo {
  color: var(--purple);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 1.05;
  text-align: center;
  text-shadow:
    0 .16rem 0 #fff,
    .1rem .14rem 0 rgba(255, 255, 255, .9),
    -.1rem .14rem 0 rgba(255, 255, 255, .9),
    0 .32rem .7rem rgba(105, 60, 164, .16);
}

.km-logo-large {
  margin: 0;
  font-size: clamp(1.55rem, 7vw, 2.85rem);
  white-space: nowrap;
}

.km-invite-page {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: space-between;
  gap: clamp(1.1rem, 4.5vw, 1.8rem);
  padding-top: max(5.4rem, env(safe-area-inset-top));
}

.km-invite-brand {
  text-align: center;
}

.km-invite-brand p {
  margin: .82rem 0 0;
  color: var(--ink);
  font-size: clamp(.98rem, 3.9vw, 1.16rem);
  font-weight: 780;
  line-height: 1.45;
}

.km-invite-brand p span {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  margin: 0 1rem;
  border-radius: 50%;
  background: var(--pink);
  vertical-align: middle;
}

.km-hero-book {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(15.4rem, 52svh, 23rem);
}

.km-hero-book::before {
  content: "";
  position: absolute;
  inset: 12% 3% 4%;
  z-index: -1;
  border-radius: 2.2rem;
  background:
    radial-gradient(circle at 22% 22%, rgba(255, 227, 236, .62), transparent 42%),
    radial-gradient(circle at 76% 74%, rgba(191, 230, 248, .38), transparent 46%),
    rgba(255, 255, 255, .2);
  filter: blur(.15rem);
}

.km-hero-art {
  display: block;
  width: min(96%, 27.5rem);
  height: auto;
  aspect-ratio: 1400 / 783;
  object-fit: contain;
  filter: drop-shadow(0 .95rem 1.35rem rgba(118, 75, 170, .1));
}

.km-invite-form {
  display: grid;
  gap: .85rem;
  padding: 0 .45rem 1.35rem;
}

.km-invite-form .km-primary {
  min-height: 6.4rem;
}

.km-pill-input {
  display: grid;
  grid-template-columns: 3.6rem minmax(0, 1fr);
  align-items: center;
  min-height: 4.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: inset 0 0 0 .12rem rgba(219, 202, 235, .55), var(--soft-shadow);
}

.km-input-icon {
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.45rem;
  margin-left: .68rem;
  border-radius: 50%;
  color: var(--purple);
  background: var(--purple-haze);
  font-weight: 950;
  font-size: 1.2rem;
}

.km-pill-input input,
.km-voice-card textarea {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-size: 1.08rem;
  font-weight: 850;
}

.km-pill-input input::placeholder,
.km-voice-card textarea::placeholder {
  color: #b3a8ad;
}

.km-primary,
.km-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .72rem;
  min-height: 4.3rem;
  padding: 0 1.45rem;
  border-radius: var(--radius-button);
  font-size: clamp(1.22rem, 5vw, 1.56rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0;
  text-decoration: none;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.km-primary {
  border: .18rem solid rgba(255, 255, 255, .96);
  color: #fff;
  background: linear-gradient(180deg, #9478ee 0%, var(--purple) 54%, var(--purple-deep) 100%);
  box-shadow:
    0 .7rem 1.35rem rgba(96, 70, 176, .22),
    inset 0 .08rem 0 rgba(255, 255, 255, .28);
  text-shadow: 0 .08rem .18rem rgba(61, 43, 116, .18);
}

.km-primary:hover,
.km-primary:focus-visible {
  filter: brightness(1.025) saturate(1.02);
  box-shadow:
    0 .82rem 1.55rem rgba(96, 70, 176, .24),
    inset 0 .08rem 0 rgba(255, 255, 255, .34);
}

.km-primary:disabled {
  cursor: not-allowed;
  opacity: .64;
  filter: saturate(.75);
  box-shadow: 0 .45rem .9rem rgba(96, 70, 176, .14);
}

.km-primary:active,
.km-secondary:active,
.km-exit:active,
.km-icon-button:active,
.km-mic-button:active,
.km-link-button:active,
.km-delete-photo:active {
  transform: translateY(.1rem) scale(.985);
}

.km-btn-spark {
  color: #ffe98a;
}

.km-secondary {
  border: .12rem solid rgba(217, 202, 255, .92);
  color: var(--purple-deep);
  background: rgba(255, 255, 255, .9);
  box-shadow:
    0 .55rem 1.2rem rgba(104, 82, 139, .1),
    inset 0 .08rem 0 rgba(255, 255, 255, .74);
}

.km-secondary:hover,
.km-secondary:focus-visible {
  border-color: rgba(123, 93, 214, .34);
  background: rgba(255, 255, 255, .96);
  box-shadow:
    0 .68rem 1.35rem rgba(104, 82, 139, .12),
    inset 0 .08rem 0 rgba(255, 255, 255, .82);
}

.km-secondary:disabled,
.km-exit:disabled,
.km-icon-button:disabled,
.km-mic-button:disabled,
.km-link-button:disabled,
.km-next-photo:disabled,
.km-delete-photo:disabled {
  cursor: not-allowed;
  opacity: .58;
  filter: saturate(.75);
}

.km-help,
.km-link-button {
  min-height: 2.75rem;
  border: 0;
  color: var(--purple);
  background: transparent;
  font-weight: 850;
  font-size: 1rem;
}

.km-help {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 760;
}

.km-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: 0 .95rem;
  border-radius: var(--radius-button);
  line-height: 1.1;
  transition: transform .16s ease, color .16s ease, background .16s ease;
}

.km-link-button:hover,
.km-link-button:focus-visible {
  color: var(--purple-deep);
  background: rgba(255, 255, 255, .56);
}

.km-error,
.km-status {
  min-height: 1.45rem;
  text-align: center;
  font-weight: 850;
}

.km-error {
  color: #c94e77;
}

.km-status {
  color: var(--ink);
}

.km-flow-hint {
  min-height: 1.35rem;
  margin: -.05rem 0;
  color: var(--muted);
  font-size: clamp(.84rem, 3.45vw, .98rem);
  line-height: 1.35;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.km-workshop-page {
  display: grid;
  align-content: start;
  gap: 1.15rem;
  padding-top: max(4.5rem, env(safe-area-inset-top));
}

.km-gallery-page,
.km-create-page,
.km-gallery-action-bar {
  --km-page-lift: 1.2rem;
}

.km-gallery-page,
.km-create-page {
  --km-compact-page-top: 2.1rem;
  padding-top: max(var(--km-compact-page-top), env(safe-area-inset-top));
  transform: translateY(calc(-1 * var(--km-page-lift)));
}

.km-gallery-page .km-trail,
.km-create-page .km-trail {
  top: -.65rem;
}

.km-gallery-page .km-cloud,
.km-create-page .km-cloud {
  top: 2.6rem;
}

.km-gallery-page .km-star-a,
.km-create-page .km-star-a {
  display: none;
}

.km-gallery-page .km-flower-a,
.km-create-page .km-flower-a {
  top: 5rem;
}

.km-home-status-pill {
  --km-home-status-width: auto;
  position: relative;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38rem;
  width: var(--km-home-status-width);
  max-width: 100%;
  min-height: 2.45rem;
  margin: -.18rem auto .18rem;
  padding: 0 1rem;
  overflow: hidden;
  border: .15rem solid rgba(174, 160, 181, .48);
  border-radius: 999px;
  color: #675b61;
  background: rgba(255, 255, 255, .58);
  box-shadow:
    0 .42rem .95rem rgba(104, 82, 139, .11),
    inset 0 .08rem 0 rgba(255, 255, 255, .72);
  backdrop-filter: blur(.42rem);
  -webkit-backdrop-filter: blur(.42rem);
  font-size: clamp(.78rem, 3.35vw, .96rem);
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  transition: width .3s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.km-home-status-pill::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(105deg, transparent 0 28%, rgba(255, 255, 255, .72) 42%, transparent 58% 100%);
  transform: translateX(-105%);
}

.km-home-status-text,
.km-home-status-suffix {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.km-home-status-suffix {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.km-home-status-pill.is-welcome .km-home-status-suffix,
.km-home-status-pill.is-complete .km-home-status-suffix {
  animation: kmStatusTwinkle 1.8s ease-in-out infinite;
}

.km-home-status-pill.is-generating {
  border-color: rgba(157, 123, 232, .5);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .68), rgba(248, 242, 255, .58)),
    rgba(255, 255, 255, .54);
  box-shadow:
    0 .5rem 1.15rem rgba(123, 93, 214, .15),
    0 0 0 .22rem rgba(217, 202, 255, .22),
    inset 0 .08rem 0 rgba(255, 255, 255, .78);
  animation: kmStatusPulse 1.5s ease-in-out infinite;
}

.km-home-status-pill.is-generating::before {
  opacity: .86;
  animation: kmStatusShimmer 1.25s ease-in-out infinite;
}

.km-scan-page {
  display: grid;
  align-content: start;
  gap: 1.35rem;
  padding-top: max(3.4rem, env(safe-area-inset-top));
}

.km-scan-header {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) 3.25rem;
  align-items: center;
  gap: .65rem;
}

.km-scan-header .km-logo {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  font-size: clamp(1rem, 4.2vw, 1.42rem);
  text-overflow: clip;
  white-space: nowrap;
}

.km-scan-card {
  position: relative;
  display: grid;
  gap: .95rem;
  padding: .95rem .95rem 1.1rem;
  border: .18rem solid rgba(217, 202, 255, .78);
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .94), rgba(255, 253, 250, .86)),
    radial-gradient(circle at 94% 100%, rgba(224, 249, 232, .54), transparent 46%);
  box-shadow: var(--shadow-soft);
}

.km-scan-guide-art {
  position: absolute;
  right: -.55rem;
  bottom: -1.05rem;
  z-index: 0;
  width: min(31%, 7.1rem);
  height: auto;
  pointer-events: none;
  opacity: .24;
}

.km-scan-card > :not(.km-scan-guide-art) {
  position: relative;
  z-index: 1;
}

.km-scan-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: .28rem solid rgba(217, 202, 255, .88);
  border-radius: 1.45rem;
  background: #242034;
  box-shadow: inset 0 0 0 .08rem rgba(255, 255, 255, .32);
}

.km-scan-viewfinder video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.km-scan-frame {
  position: absolute;
  inset: 18%;
  border: .22rem solid rgba(255, 255, 255, .92);
  border-radius: 1.2rem;
  box-shadow:
    0 0 0 999px rgba(28, 23, 48, .24),
    0 .55rem 1.2rem rgba(20, 16, 38, .18);
}

.km-scan-frame::before,
.km-scan-frame::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  height: .16rem;
  border-radius: 999px;
  background: rgba(111, 202, 122, .88);
}

.km-scan-frame::before {
  top: 50%;
}

.km-scan-frame::after {
  top: 51%;
  opacity: .35;
}

.km-activate-error-page {
  display: grid;
  align-content: center;
  gap: 1.2rem;
  min-height: 100svh;
}

.km-topbar {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) 4.75rem;
  align-items: center;
  gap: .65rem;
}

.km-topbar .km-logo {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(.92rem, 4vw, 1.42rem);
  text-overflow: clip;
  white-space: nowrap;
}

.km-back.hidden + .km-logo {
  grid-column: 1 / 3;
}

.km-icon-button,
.km-exit,
.km-floating-action,
.km-mic-button {
  border: 0;
  color: var(--purple);
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--soft-shadow);
}

.km-icon-button {
  display: inline-grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.65rem;
  font-weight: 950;
  line-height: 1;
  box-shadow:
    0 .45rem 1rem rgba(104, 82, 139, .11),
    inset 0 .08rem 0 rgba(255, 255, 255, .8);
  transition: transform .16s ease, color .16s ease, box-shadow .16s ease, background .16s ease;
}

.km-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .28rem;
  width: 4.75rem;
  min-height: 2.55rem;
  padding: 0 .48rem;
  border: .0625rem solid rgba(217, 202, 255, .72);
  border-radius: var(--radius-button);
  color: var(--purple-deep);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(.35rem);
  font-size: .86rem;
  font-weight: 850;
  line-height: 1;
  box-shadow:
    0 .28rem .72rem rgba(104, 82, 139, .08),
    inset 0 .08rem 0 rgba(255, 255, 255, .62);
  transition: transform .16s ease, color .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.km-exit span[aria-hidden="true"] {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  color: var(--purple);
  background: rgba(242, 235, 255, .84);
  font-size: .82rem;
  font-weight: 900;
  line-height: 1;
}

.km-icon-button:hover,
.km-icon-button:focus-visible,
.km-mic-button:hover,
.km-mic-button:focus-visible {
  color: var(--purple-deep);
  background: rgba(255, 255, 255, .98);
  box-shadow:
    0 .58rem 1.15rem rgba(104, 82, 139, .14),
    inset 0 .08rem 0 rgba(255, 255, 255, .88);
}

.km-exit:hover,
.km-exit:focus-visible {
  color: var(--purple-deep);
  border-color: rgba(123, 93, 214, .3);
  background: rgba(255, 255, 255, .88);
  box-shadow:
    0 .36rem .82rem rgba(104, 82, 139, .1),
    inset 0 .08rem 0 rgba(255, 255, 255, .74);
}

.km-primary:focus-visible,
.km-secondary:focus-visible,
.km-icon-button:focus-visible,
.km-exit:focus-visible,
.km-mic-button:focus-visible,
.km-link-button:focus-visible,
.km-next-photo:focus-visible,
.km-delete-photo:focus-visible {
  outline: .16rem solid rgba(123, 93, 214, .26);
  outline-offset: .16rem;
}

.km-state {
  display: grid;
  gap: 1.1rem;
}

.km-capture-state {
  gap: .5rem;
}

.km-capture-state .km-error:empty {
  display: none;
}

.km-viewer-wrap {
  position: relative;
  margin-top: .1rem;
}

.km-viewer,
.km-result-viewer {
  width: 100%;
  border: .22rem solid rgba(217, 202, 255, .84);
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 252, 249, .9));
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.km-viewer {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  min-height: 0;
}

.km-viewer video,
.km-viewer img,
.km-result-viewer video {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  background: #1c1730;
}

.km-viewer video,
.km-viewer img {
  object-fit: cover;
}

.km-viewer img {
  object-fit: contain;
  background: #fbf7ff;
}

.km-result-viewer video {
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.km-photo-grid {
  width: 100%;
  min-height: 18rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: .55rem;
  padding: .6rem;
  background: #fbf7ff;
}

.km-viewer .km-photo-grid img {
  width: 100%;
  height: 100%;
  min-height: 8rem;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 1rem;
  background: #fff;
}

.km-empty-preview {
  height: 100%;
  display: grid;
  place-items: center;
  width: 100%;
  color: var(--muted);
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 255, 255, .72) 0 4.8rem, transparent 4.95rem),
    linear-gradient(145deg, rgba(255, 227, 236, .64), rgba(228, 255, 241, .7) 54%, rgba(239, 224, 255, .62));
  font-weight: 900;
  text-align: center;
  padding: 0;
}

.km-capture-placeholder-art {
  display: block;
  width: 100%;
  max-height: none;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: transparent;
  pointer-events: none;
  filter: none;
}

.km-viewer .km-capture-placeholder-art {
  object-fit: cover;
  background: transparent;
}

.km-floating-action {
  position: absolute;
  top: 1.1rem;
  width: 3.9rem;
  height: 3.9rem;
  border-radius: 1.05rem;
  font-size: 1.62rem;
  font-weight: 950;
}

.km-camera {
  left: 1.15rem;
}

.km-photo-index {
  right: 1.15rem;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.km-next-photo {
  display: inline-grid;
  place-items: center;
  position: absolute;
  top: 50%;
  right: .75rem;
  width: 3.2rem;
  height: 4.4rem;
  border: .16rem solid rgba(255, 255, 255, .9);
  border-radius: 1.2rem;
  color: #7f43ee;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--soft-shadow);
  transform: translateY(-50%);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  transition: transform .16s ease, color .16s ease, box-shadow .16s ease, background .16s ease;
}

.km-next-photo:hover,
.km-next-photo:focus-visible {
  color: var(--purple-deep);
  background: rgba(255, 255, 255, .98);
  box-shadow:
    0 .58rem 1.15rem rgba(104, 82, 139, .14),
    inset 0 .08rem 0 rgba(255, 255, 255, .88);
}

.km-next-photo:active {
  transform: translateY(calc(-50% + .1rem)) scale(.985);
}

.km-delete-photo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 1.15rem;
  bottom: 1.15rem;
  min-width: 4.2rem;
  min-height: 2.75rem;
  padding: 0 .9rem;
  border: 0;
  border-radius: var(--radius-control);
  color: #fff;
  background: rgba(201, 78, 119, .94);
  box-shadow: var(--soft-shadow);
  font-size: .95rem;
  font-weight: 900;
  line-height: 1;
  transition: transform .16s ease, filter .16s ease, box-shadow .16s ease;
}

.km-delete-photo:hover,
.km-delete-photo:focus-visible {
  filter: brightness(1.03);
  box-shadow: 0 .58rem 1.15rem rgba(159, 55, 91, .16);
}

.km-voice-card {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: .85rem;
  align-items: center;
  min-height: 6.65rem;
  border: .16rem solid #cda8ff;
  border-radius: 2.1rem;
  padding: .78rem;
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--soft-shadow);
}

.km-mic-button {
  display: inline-grid;
  place-items: center;
  width: 4.45rem;
  height: 4.45rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
  background:
    radial-gradient(circle at 50% 45%, rgba(123, 93, 214, .14) 0 55%, transparent 56%),
    rgba(255, 255, 255, .97);
  transition: transform .16s ease, color .16s ease, box-shadow .16s ease, background .16s ease;
}

.km-mic-button.recording {
  color: #fff;
  background: linear-gradient(180deg, #ff7da6, #d93f78);
  box-shadow:
    0 .7rem 1.35rem rgba(217, 63, 120, .24),
    0 0 0 .22rem rgba(255, 125, 166, .16);
}

.km-voice-card textarea {
  min-height: 4.8rem;
  resize: none;
  line-height: 1.45;
  padding: .45rem .25rem;
}

.km-stage-title {
  padding: 1.75rem .5rem .45rem;
  text-align: center;
}

.km-stage-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.25rem, 10.5vw, 3.45rem);
  line-height: 1.08;
  font-weight: 950;
  text-shadow:
    0 .16rem 0 rgba(255, 255, 255, .9),
    0 .46rem .9rem rgba(116, 69, 171, .11);
}

.km-stage-title p {
  margin: .82rem auto 0;
  max-width: 24rem;
  color: var(--ink);
  font-size: clamp(.98rem, 4vw, 1.18rem);
  font-weight: 780;
  line-height: 1.45;
}

.km-dots {
  display: flex;
  justify-content: center;
  gap: .58rem;
  margin-top: 1rem;
}

.km-dots span {
  width: .62rem;
  height: .62rem;
  border-radius: 50%;
  background: var(--pink);
  animation: kmDot 1.1s ease-in-out infinite;
}

.km-dots span:nth-child(2) {
  background: #dda7ff;
  animation-delay: .16s;
}

.km-dots span:nth-child(3) {
  background: var(--purple-soft);
  animation-delay: .32s;
}

@keyframes kmDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .65; }
  40% { transform: translateY(-.35rem); opacity: 1; }
}

@keyframes kmStatusTwinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: .82; }
  45% { transform: scale(1.18) rotate(8deg); opacity: 1; }
}

@keyframes kmStatusPulse {
  0%, 100% { box-shadow: 0 .5rem 1.15rem rgba(123, 93, 214, .15), 0 0 0 .18rem rgba(217, 202, 255, .18), inset 0 .08rem 0 rgba(255, 255, 255, .78); }
  50% { box-shadow: 0 .55rem 1.25rem rgba(123, 93, 214, .19), 0 0 0 .3rem rgba(217, 202, 255, .28), inset 0 .08rem 0 rgba(255, 255, 255, .82); }
}

@keyframes kmStatusShimmer {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(105%); }
}

.km-magic-card {
  display: grid;
  gap: .95rem;
  padding: .86rem .86rem 1.12rem;
  border: .18rem solid rgba(217, 202, 255, .7);
  border-radius: 2rem;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, .78), rgba(255, 246, 239, .72)),
    radial-gradient(circle at 20% 18%, rgba(225, 198, 255, .46), transparent 42%),
    radial-gradient(circle at 86% 84%, rgba(224, 249, 232, .62), transparent 44%);
  box-shadow: var(--shadow-soft);
}

.km-magic-scene {
  position: relative;
  overflow: hidden;
  border-radius: 1.35rem;
  aspect-ratio: 16 / 9;
  background: rgba(242, 235, 255, .72);
}

.km-magic-scene img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .94;
  filter: saturate(1.05);
}

.km-generation-text {
  text-align: center;
  color: var(--purple-deep);
  font-size: clamp(1rem, 4vw, 1.16rem);
  font-weight: 850;
  line-height: 1.45;
}

.km-result-title {
  padding-top: 1.45rem;
}

.km-result-title h1 {
  font-size: clamp(2.05rem, 9.4vw, 3.15rem);
}

.km-result-viewer {
  margin-top: .2rem;
}

.km-save-link {
  display: grid;
}

.km-gallery-page {
  padding-bottom: max(8.8rem, env(safe-area-inset-bottom));
}

.km-gallery-section {
  display: grid;
  gap: .82rem;
}

.km-collection-section {
  gap: .78rem;
}

.km-gallery-section h1,
.km-gallery-section h2,
.km-gallery-video-card h3 {
  margin: 0;
  color: var(--ink);
  line-height: 1.18;
  text-shadow: 0 .12rem 0 rgba(255, 255, 255, .84);
}

.km-gallery-section h1,
.km-gallery-section h2 {
  font-size: clamp(1.45rem, 6.2vw, 2.05rem);
  font-weight: 900;
}

.km-collection-section h1 {
  font-size: clamp(2rem, 8.6vw, 2.75rem);
  letter-spacing: 0;
}

.km-gallery-video,
.km-gallery-video-card {
  overflow: hidden;
  border: .16rem solid rgba(217, 202, 255, .84);
  border-radius: 1.55rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 252, 249, .9));
  box-shadow: var(--soft-shadow);
}

.km-gallery-video-card {
  display: grid;
  gap: .62rem;
  padding: .72rem;
}

.km-gallery-video-card h3 {
  padding: .08rem .22rem;
  color: #756567;
  font-size: 1.02rem;
  font-weight: 850;
}

.km-gallery-video video,
.km-gallery-video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 1.05rem;
  background: #1c1730;
  object-fit: contain;
}

.km-collection-video {
  border-width: .18rem;
  box-shadow: var(--shadow);
}

.km-gallery-video-compact video,
.km-gallery-video-compact .km-empty-preview {
  min-height: 8rem;
}

.km-gallery-video-compact video {
  aspect-ratio: 16 / 7;
}

.km-intro-section {
  margin-top: .4rem;
}

.km-gallery-page.is-first-round-intro .km-intro-section {
  margin-top: 1.8rem;
  gap: .92rem;
}

.km-gallery-page.is-first-round-intro .km-gallery-video-compact video,
.km-gallery-page.is-first-round-intro .km-gallery-video-compact .km-empty-preview {
  min-height: 18rem;
}

.km-gallery-page.is-first-round-intro .km-gallery-video-compact video {
  aspect-ratio: 16 / 13;
}

.km-video-list {
  display: grid;
  gap: .92rem;
}

.km-gallery-empty {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: .78rem;
  padding: 1.05rem 1.2rem 1.18rem;
  border: .14rem solid rgba(217, 202, 255, .5);
  border-radius: 1.35rem;
  color: var(--muted);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .86), rgba(255, 253, 250, .78));
  box-shadow: 0 .55rem 1.1rem rgba(104, 82, 139, .07);
  text-align: center;
  font-weight: 780;
  line-height: 1.45;
}

.km-empty-state-art {
  display: block;
  width: min(68%, 15rem);
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 .65rem 1rem rgba(104, 82, 139, .09));
}

.km-fixed-action-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(100%, 31rem);
  padding: .8rem 1.2rem max(.8rem, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 253, 251, 0), rgba(255, 253, 251, .94) 24%);
  transform: translateX(-50%);
}

.km-gallery-action-bar {
  transform: translate(-50%, calc(-1 * var(--km-page-lift)));
}

.km-fixed-action-bar .km-primary {
  width: 100%;
}

.km-capture-actions {
  display: grid;
  gap: .82rem;
  margin-top: .05rem;
}

.km-capture-actions .km-primary,
.km-capture-actions .km-secondary {
  width: 100%;
}

#recordBtn.recording {
  border-color: rgba(255, 255, 255, .98);
  color: #fff;
  background: linear-gradient(180deg, #ff7da6, #d93f78);
  box-shadow:
    0 .7rem 1.35rem rgba(217, 63, 120, .24),
    0 0 0 .22rem rgba(255, 125, 166, .16),
    inset 0 .08rem 0 rgba(255, 255, 255, .28);
}

.km-result-state .km-empty-preview {
  min-height: 12rem;
}

@media (min-width: 680px) {
  .km-shell {
    width: min(100%, 45rem);
    padding-inline: 2.2rem;
  }

  .km-invite-page {
    grid-template-rows: auto auto auto;
    gap: 1.55rem;
    padding-top: max(5.8rem, env(safe-area-inset-top));
  }

  .km-hero-book {
    min-height: 24rem;
  }

  .km-hero-art {
    width: min(82%, 33rem);
  }

  .km-scan-card,
  .km-magic-card {
    width: min(100%, 36rem);
    justify-self: center;
  }

  .km-scan-viewfinder {
    aspect-ratio: 4 / 5;
  }

  .km-viewer video,
  .km-viewer img {
    aspect-ratio: 4 / 3;
  }

  .km-state {
    gap: 1.25rem;
  }

  .km-voice-card {
    grid-template-columns: 6rem minmax(0, 1fr);
    min-height: 7.25rem;
  }

  .km-mic-button {
    width: 5.25rem;
    height: 5.25rem;
  }

  .km-fixed-action-bar {
    width: min(100%, 45rem);
    padding-inline: 2.2rem;
  }

  .km-video-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.05rem;
  }

  .km-gallery-empty {
    padding-block: 1.25rem 1.35rem;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .km-shell {
    width: min(100%, 58rem);
    padding-bottom: 2rem;
  }

  .km-invite-page {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    align-items: center;
    padding-top: 1.4rem;
  }

  .km-invite-brand {
    grid-column: 1 / -1;
  }

  .km-hero-book {
    min-height: 12rem;
  }

  .km-invite-form {
    padding-bottom: 0;
  }

  .km-viewer {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }

  .km-dots span {
    animation: none;
    opacity: .85;
    transform: none;
  }

  .km-home-status-pill,
  .km-home-status-pill::before,
  .km-home-status-suffix {
    animation: none !important;
    transform: none !important;
  }

  .km-primary:active,
  .km-secondary:active,
  .km-exit:active,
  .km-icon-button:active,
  .km-mic-button:active,
  .km-link-button:active,
  .km-delete-photo:active,
  .km-next-photo:active {
    transform: none;
  }
}
