.demo {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
  aspect-ratio: 1.1 / 1;
  container-type: inline-size;
  isolation: isolate;
}

.demo::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 6% -8% -7% 8%;
  background: radial-gradient(closest-side, rgb(255 77 31 / 13%), transparent 72%);
  pointer-events: none;
}

/* Browser window */
.demo__browser {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 3%;
  width: 70%;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--ink);
  border-radius: 2.2cqw;
  box-shadow: var(--shadow-float);
}

.browser__bar {
  display: flex;
  align-items: center;
  gap: 1.4cqw;
  padding: 1.5cqw 2cqw;
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

.browser__dots {
  display: flex;
  gap: 0.65cqw;
  flex: none;
}

.browser__dot {
  width: 1.05cqw;
  height: 1.05cqw;
  border-radius: 50%;
  background: var(--line-strong);
}

.browser__url {
  flex: 1;
  min-width: 0;
  padding: 0.45cqw 1.4cqw;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 1.4cqw;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browser__page {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 54cqw;
  padding: 3cqw 3.2cqw 3.2cqw;
  overflow: hidden;
}

.browser__page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgb(21 20 15 / 14%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}

.fp__kicker {
  font-family: var(--mono);
  font-size: 1.3cqw;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal-deep);
}

.fp__title {
  margin-top: 0.9cqw;
  font-family: var(--display);
  font-size: 4.4cqw;
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
}

.fp__desc {
  margin-top: 1.1cqw;
  max-width: 84%;
  font-size: 1.7cqw;
  line-height: 1.45;
  color: var(--muted);
}

.fp__wave {
  margin-top: 2.1cqw;
  height: 7.4cqw;
}

.fp__wave svg {
  width: 100%;
  height: 100%;
}

.fp__bar {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
  margin-top: auto;
  padding-top: 2cqw;
  font-family: var(--mono);
  font-size: 1.3cqw;
  color: var(--muted);
}

.fp__play {
  display: grid;
  place-items: center;
  width: 4.8cqw;
  height: 4.8cqw;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  flex: none;
}

.fp__play svg {
  width: 1.5cqw;
  height: 1.5cqw;
  transform: translateX(0.15cqw);
}

.fp__save {
  display: inline-flex;
  align-items: center;
  gap: 0.7cqw;
  margin-left: auto;
  padding: 1.15cqw 1.7cqw;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--signal);
  color: var(--ink);
  font-size: 1.45cqw;
  font-weight: 650;
  box-shadow: 0 0.35cqw 0 var(--ink);
  flex: none;
}

.fp__save svg {
  width: 1.5cqw;
  height: 1.5cqw;
}

/* Sliding sidebar */
.demo__sidebar {
  position: absolute;
  z-index: 3;
  inset-block: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: 62%;
  padding: 2.1cqw;
  border-left: 1px solid var(--line-strong);
  background: var(--card);
  box-shadow: -2cqw 0 3cqw -2.4cqw rgb(21 20 15 / 32%);
  transform: translateX(101%);
  transition: transform 0.72s var(--ease-out);
  overflow-y: auto;
}

.sb__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1cqw;
}

.sb__brand {
  display: flex;
  align-items: center;
  gap: 0.9cqw;
  font-family: var(--display);
  font-size: 1.9cqw;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sb__mark {
  width: 3.2cqw;
  height: 3.2cqw;
  flex: none;
}

.sb__close {
  display: grid;
  place-items: center;
  width: 3.4cqw;
  height: 3.4cqw;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.sb__close svg {
  width: 1.5cqw;
  height: 1.5cqw;
}

.sb__user {
  display: flex;
  align-items: center;
  gap: 1cqw;
  margin-top: 1.8cqw;
  padding: 1.1cqw;
  border: 1px solid var(--line);
  border-radius: 1.3cqw;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
}

.sb__avatar {
  display: grid;
  place-items: center;
  width: 3.2cqw;
  height: 3.2cqw;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 1.4cqw;
  flex: none;
}

.sb__email {
  font-size: 1.35cqw;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb__signed {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.95cqw;
  letter-spacing: 0.04em;
  color: var(--green);
  white-space: nowrap;
}

.sb__label {
  margin-top: 1.9cqw;
  font-family: var(--mono);
  font-size: 1.08cqw;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sb__list {
  display: grid;
  gap: 0.6cqw;
  margin-top: 1.1cqw;
}

.sb__item {
  display: flex;
  align-items: center;
  gap: 1cqw;
  padding: 1.05cqw 1.15cqw;
  border: 1px solid var(--line);
  border-radius: 1.1cqw;
  font-size: 1.45cqw;
  color: var(--ink-soft);
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.sb__item--selected {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--ink);
  color: var(--ink);
  font-weight: 550;
}

.sb__mini {
  display: grid;
  place-items: center;
  width: 2.5cqw;
  height: 2.5cqw;
  border-radius: 0.65cqw;
  background: var(--paper-deep);
  flex: none;
}

.sb__mini svg {
  width: 1.5cqw;
  height: 1.5cqw;
}

.sb__badge {
  margin-left: auto;
  padding: 0.3cqw 0.7cqw;
  border-radius: 999px;
  background: var(--paper-deep);
  font-family: var(--mono);
  font-size: 0.9cqw;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.sb__item--new {
  border-style: dashed;
  color: var(--muted);
}

.sb__item--new span:first-child {
  display: grid;
  place-items: center;
  width: 2.5cqw;
  height: 2.5cqw;
  border-radius: 0.65cqw;
  border: 1px dashed var(--line-strong);
  font-size: 1.3cqw;
  line-height: 1;
}

.sb__save {
  width: 100%;
  margin-top: auto;
  padding: 1.25cqw;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--signal);
  color: var(--ink);
  font-size: 1.5cqw;
  font-weight: 650;
  box-shadow: 0 0.35cqw 0 var(--ink);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.sb__note {
  margin-top: 1cqw;
  font-size: 1.08cqw;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

/* Cursor */
.demo__cursor {
  position: absolute;
  z-index: 5;
  left: 76%;
  top: 64%;
  width: 3.2cqw;
  height: 3.2cqw;
  opacity: 0;
  filter: drop-shadow(0 2px 2px rgb(21 20 15 / 28%));
  transform: translate(-50%, -50%) scale(1);
  transition: left 0.75s var(--ease), top 0.75s var(--ease), opacity 0.3s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}

/* Pass card in flight */
.demo__pass {
  position: absolute;
  z-index: 6;
  left: 68%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 0.9cqw;
  width: 13cqw;
  padding: 1.1cqw;
  border-radius: 1.3cqw;
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
}

.demo__pass svg {
  width: 2.8cqw;
  height: 2.8cqw;
  flex: none;
}

.demo__pass-text {
  display: grid;
  gap: 0.1cqw;
  line-height: 1.15;
}

.demo__pass-text strong {
  font-size: 1.25cqw;
  font-weight: 600;
}

.demo__pass-text span {
  font-family: var(--mono);
  font-size: 0.9cqw;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgb(243 238 226 / 60%);
}

/* Phone */
.demo__phone {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: 0;
  width: 32%;
  aspect-ratio: 0.46 / 1;
  padding: 0.85cqw;
  border-radius: 4.6cqw;
  background: var(--ink);
  box-shadow: var(--shadow-float);
  transform: rotate(2.2deg);
}

.phone__screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: 3.9cqw;
  background: var(--card);
  padding: 1.4cqw 1.7cqw 1.8cqw;
}

.phone__island {
  position: absolute;
  z-index: 3;
  top: 1.1cqw;
  left: 50%;
  width: 32%;
  height: 2.2cqw;
  border-radius: 999px;
  background: var(--ink);
  transform: translateX(-50%);
}

.phone__status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 1.15cqw;
  font-weight: 600;
  color: var(--ink);
}

.phone__signal {
  display: flex;
  align-items: center;
  gap: 0.3cqw;
}

.phone__signal i {
  display: block;
  width: 0.4cqw;
  height: 0.4cqw;
  border-radius: 50%;
  background: var(--ink);
}

.phone__head {
  margin-top: 2.6cqw;
}

.phone__kicker {
  font-family: var(--mono);
  font-size: 0.95cqw;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal-deep);
}

.phone__title {
  margin-top: 0.5cqw;
  font-family: var(--display);
  font-size: 3.3cqw;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}

.phone__meta {
  margin-top: 0.5cqw;
  font-family: var(--mono);
  font-size: 0.95cqw;
  color: var(--muted);
}

.phone__cover {
  position: relative;
  display: flex;
  align-items: flex-end;
  margin-top: 1.6cqw;
  aspect-ratio: 1 / 0.72;
  padding: 1.4cqw;
  overflow: hidden;
  border-radius: 1.6cqw;
  background:
    radial-gradient(120% 100% at 15% 0%, rgb(255 77 31 / 88%) 0%, rgb(217 59 16 / 0%) 55%),
    linear-gradient(145deg, #2a2820 0%, #15140f 100%);
}

.phone__cover-wave {
  position: absolute;
  inset: auto 0 0;
  height: 55%;
  opacity: 0.9;
}

.phone__cover-wave svg {
  width: 100%;
  height: 100%;
}

.phone__cover-label {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.55cqw;
  padding: 0.45cqw 0.75cqw;
  border-radius: 999px;
  background: rgb(21 20 15 / 42%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-family: var(--mono);
  font-size: 0.9cqw;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
}

.phone__cover-label svg {
  width: 1.8cqw;
  height: 1.8cqw;
}

.phone__list {
  display: flex;
  flex-direction: column;
  margin-top: 1.5cqw;
}

.phone__ep {
  display: flex;
  align-items: center;
  gap: 0.9cqw;
  width: 100%;
  padding: 1.05cqw 0;
  border-top: 1px solid var(--line);
  text-align: left;
}

.phone__ep-art {
  display: grid;
  place-items: center;
  width: 3.6cqw;
  height: 3.6cqw;
  border-radius: 0.7cqw;
  background: var(--paper-deep);
  flex: none;
}

.phone__ep-art svg {
  width: 2.2cqw;
  height: 2.2cqw;
}

.phone__ep-inner {
  display: flex;
  align-items: center;
  gap: 0.9cqw;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.phone__ep-body {
  display: block;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.phone__ep-title {
  display: block;
  font-size: 1.7cqw;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone__ep-meta {
  display: block;
  font-family: var(--mono);
  font-size: 1.08cqw;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phone__ep--new {
  display: grid;
  grid-template-rows: 0fr;
  padding-block: 0;
  border-top-width: 0;
  opacity: 0;
  transform: translateY(-0.6cqw);
  transition: grid-template-rows 0.55s var(--ease-out), opacity 0.4s var(--ease), transform 0.55s var(--ease-out), padding 0.55s var(--ease-out);
}

.phone__ep--new > * {
  overflow: hidden;
}

.phone__new-badge {
  margin-left: auto;
  padding: 0.28cqw 0.6cqw;
  border-radius: 999px;
  background: var(--signal);
  font-family: var(--mono);
  font-size: 0.78cqw;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
  flex: none;
}

/* Scene direction */
.demo[data-scene="1"] .demo__cursor {
  left: 58%;
  top: 60%;
  opacity: 1;
}

.demo[data-scene="2"] .demo__cursor {
  left: 58%;
  top: 60%;
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.82);
}

.demo[data-scene="3"] .demo__cursor {
  left: 58%;
  top: 60%;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.demo[data-scene="4"] .demo__cursor {
  left: 58%;
  top: 60%;
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.82);
}

.demo[data-scene="5"] .demo__cursor {
  opacity: 0;
}

.demo[data-scene="2"] .demo__sidebar,
.demo[data-scene="3"] .demo__sidebar,
.demo[data-scene="4"] .demo__sidebar,
.demo[data-scene="5"] .demo__sidebar {
  transform: translateX(0);
}

.demo[data-scene="2"] .browser__page::after,
.demo[data-scene="3"] .browser__page::after,
.demo[data-scene="4"] .browser__page::after,
.demo[data-scene="5"] .browser__page::after {
  opacity: 1;
}

.demo[data-scene="4"] .sb__save {
  transform: scale(0.97);
  box-shadow: 0 0.15cqw 0 var(--ink);
}

.demo[data-scene="4"] .demo__pass {
  animation: pass-fly 1.5s var(--ease-out) forwards;
}

.demo[data-scene="5"] .phone__ep--new {
  grid-template-rows: 1fr;
  padding-block: 1.05cqw;
  border-top-width: 1px;
  opacity: 1;
  transform: none;
}

@keyframes pass-fly {
  0% {
    left: 64%;
    top: 50%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.65) rotate(-12deg);
  }
  14% {
    opacity: 1;
  }
  55% {
    left: 71%;
    top: 43%;
    transform: translate(-50%, -50%) scale(1) rotate(4deg);
  }
  82% {
    opacity: 1;
  }
  100% {
    left: 84%;
    top: 58%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.82) rotate(9deg);
  }
}

/* Caption + control */
.demo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 620px;
  margin: 22px auto 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.demo-meta__note {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.demo-meta__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: none;
}

.demo-meta__toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.demo-meta__toggle svg {
  width: 10px;
  height: 10px;
}

@media (max-width: 560px) {
  .demo {
    aspect-ratio: 0.58 / 1;
  }

  .demo__browser {
    width: 100%;
    top: 0;
  }

  .browser__page {
    min-height: 66cqw;
  }

  .demo__sidebar {
    width: 70%;
    padding: 2.6cqw;
  }

  .demo__phone {
    width: 44%;
    right: 2%;
  }

  .fp__title {
    font-size: 5.8cqw;
  }

  .fp__desc {
    display: none;
  }

  .fp__wave {
    height: 9cqw;
    margin-top: 3cqw;
  }

  .fp__bar,
  .fp__kicker {
    font-size: 2.1cqw;
  }

  .fp__save {
    padding: 1.7cqw 2.2cqw;
    font-size: 2.2cqw;
  }

  .sb__brand {
    font-size: 2.3cqw;
  }

  .sb__email {
    font-size: 2.2cqw;
  }

  .sb__signed {
    display: none;
  }

  .sb__label {
    font-size: 1.9cqw;
    margin-top: 2.8cqw;
  }

  .sb__item {
    padding: 1.7cqw;
    font-size: 2.7cqw;
  }

  .sb__item:nth-child(2),
  .sb__item:nth-child(3) {
    display: none;
  }

  .browser__page::after {
    background: rgb(21 20 15 / 22%);
  }

  .sb__save {
    padding: 2cqw;
    font-size: 2.7cqw;
  }

  .sb__note {
    font-size: 1.7cqw;
  }

  .phone__title {
    font-size: 4.3cqw;
  }

  .phone__ep-title {
    font-size: 2.5cqw;
  }

  .phone__ep-meta {
    font-size: 1.7cqw;
  }

  .phone__foot,
  .phone__cover-label {
    font-size: 1.5cqw;
  }

  .demo__pass {
    width: 16cqw;
  }

  .demo[data-scene="1"] .demo__cursor,
  .demo[data-scene="2"] .demo__cursor,
  .demo[data-scene="3"] .demo__cursor,
  .demo[data-scene="4"] .demo__cursor {
    left: 60%;
    top: 39%;
  }

  @keyframes pass-fly {
    0% {
      left: 60%;
      top: 39%;
      opacity: 0;
      transform: translate(-50%, -50%) scale(0.65) rotate(-12deg);
    }
    14% {
      opacity: 1;
    }
    55% {
      left: 66%;
      top: 42%;
      transform: translate(-50%, -50%) scale(1) rotate(4deg);
    }
    82% {
      opacity: 1;
    }
    100% {
      left: 76%;
      top: 54%;
      opacity: 0;
      transform: translate(-50%, -50%) scale(0.82) rotate(9deg);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo__sidebar,
  .demo__cursor,
  .demo__pass,
  .phone__ep--new,
  .browser__page::after,
  .sb__save {
    transition: none;
  }

  .demo[data-scene="4"] .demo__pass {
    animation: none;
    opacity: 0;
  }
}

.phone__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55cqw;
  margin-top: auto;
  padding-top: 1.2cqw;
  font-family: var(--mono);
  font-size: 0.9cqw;
  color: var(--muted);
  white-space: nowrap;
}

.phone__foot svg {
  width: 1.15cqw;
  height: 1.15cqw;
  color: var(--green);
  flex: none;
}
