/* ============================================================
   Quantum — quant.guloxy.xyz

   The page is a film. One window of the real interface is held on
   screen by a sticky stage and carried through six scenes: it comes
   forward, comes apart, switches to Telegram, takes a call, changes
   its skin, then makes room for the phones.

   Every scene value is a plain 0..1 number written onto .film-stage
   by the controller in app.js. Nothing here reads the scroll itself,
   which is what keeps the choreography in one place.

   Layers, in order:
     1. faces + tokens
     2. page furniture (nav, opening, download, footer)
     3. the film stage and its camera
     4. the interface replica
     5. the scenes
     6. adaptation
   ============================================================ */

@font-face {
  font-family: "Playfair";
  src: url("/fonts/playfair-normal-cyrillic.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Playfair";
  src: url("/fonts/playfair-normal-latin.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122;
}
@font-face {
  font-family: "Playfair";
  src: url("/fonts/playfair-italic-cyrillic.woff2") format("woff2");
  font-weight: 400 900; font-style: italic; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Playfair";
  src: url("/fonts/playfair-italic-latin.woff2") format("woff2");
  font-weight: 400 900; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122;
}
@font-face {
  font-family: "Golos";
  src: url("/fonts/golos-normal-cyrillic.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Golos";
  src: url("/fonts/golos-normal-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2122;
}

:root {
  --ink: #0a0a0b;
  --ink-2: #101011;
  --ink-3: #17171a;
  --line: #232326;
  --line-soft: #19191c;

  --bone: #ece9e4;
  --bone-2: #a6a29c;
  --bone-3: #6f6c68;

  --violet: #6d5efc;

  --shell: 1240px;
  --gut: 32px;

  --serif: "Playfair", "Iowan Old Style", Georgia, serif;
  --sans: "Golos", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.shell { width: 100%; max-width: var(--shell); margin-inline: auto; padding-inline: var(--gut); }

.skip { position: absolute; left: -9999px; top: 10px; z-index: 99; padding: 10px 16px; background: var(--violet); color: #fff; }
.skip:focus { left: 16px; }

::selection { background: var(--violet); color: #fff; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 4px; }

/* ---------- type ---------- */

h1, h2, h3 { margin: 0; font-weight: 400; }

h1 { font-family: var(--serif); font-size: clamp(2.9rem, 7vw, 6rem); line-height: 0.98; letter-spacing: -0.025em; }
h2 { font-family: var(--serif); font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1.03; letter-spacing: -0.02em; }
h3 { font-family: var(--sans); font-size: 1.02rem; font-weight: 600; }

em { font-style: italic; font-weight: 500; }
h1 em, h2 em { color: #fff; }

p { margin: 0; }

.say { max-width: 46ch; color: var(--bone-2); font-size: 1.02rem; line-height: 1.62; }

.meta {
  display: flex; align-items: center; gap: 14px;
  color: var(--bone-3); font-size: 0.76rem; letter-spacing: 0.13em; text-transform: uppercase;
}
.meta .rule { width: 46px; height: 1px; background: var(--line); }

.sec-num {
  font-family: var(--serif); font-size: 0.9rem; color: var(--bone-3);
  padding-bottom: 22px; margin-bottom: 44px; border-bottom: 1px solid var(--line-soft);
}

.fine {
  margin-top: 52px; padding-top: 22px; border-top: 1px solid var(--line-soft);
  max-width: 74ch; color: var(--bone-3); font-size: 0.87rem; line-height: 1.6;
}

/* ---------- actions ---------- */

.cta {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 11px;
  padding: 15px 30px; border-radius: 2px;
  background: var(--violet); color: #fff;
  font-size: 0.94rem; font-weight: 600; text-decoration: none;
  overflow: hidden;
  transition:
    transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 0.28s ease;
}
/* A light wipes across from the left rather than the whole fill
   changing brightness — the button reads as a surface, not a state. */
.cta::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(-101%);
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cta > * { position: relative; z-index: 1; }
.cta:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -12px var(--violet); }
.cta:hover::before { transform: translateX(0); }
.cta:active { transform: translateY(0); }

/* A chevron drawn from two borders — no icon file for one glyph. */
.arw {
  width: 7px; height: 7px;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cta:hover .arw { transform: rotate(45deg) translate(3px, -3px); }

.cta-sm { padding: 9px 18px; font-size: 0.85rem; gap: 9px; }

.ghost {
  position: relative;
  display: inline-flex; align-items: center; padding: 15px 4px;
  color: var(--bone-2); font-size: 0.94rem; text-decoration: none;
  transition: color 0.25s ease;
}
.ghost::after {
  content: "";
  position: absolute; left: 4px; right: 4px; bottom: 12px;
  height: 1px; background: currentColor;
  transform: scaleX(0.3); transform-origin: left;
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.ghost:hover { color: var(--bone); }
.ghost:hover::after { transform: scaleX(1); }

/* ============================================================
   2. PAGE FURNITURE
   ============================================================ */

.nav {
  position: fixed; inset: 0 0 auto; z-index: 60;
  background: linear-gradient(to bottom, var(--ink) 14%, transparent);
}
.nav-in { display: flex; align-items: center; justify-content: space-between; height: 74px; }

.brand { display: flex; align-items: baseline; gap: 11px; text-decoration: none; color: var(--bone); }
.brand-name { font-family: var(--serif); font-size: 1.3rem; }
.brand-team {
  font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--bone-3);
  transition: color 0.3s ease, letter-spacing 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.brand:hover .brand-team { color: var(--bone-2); letter-spacing: 0.24em; }

.open {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding-block: 140px 90px;
  overflow: hidden;
}
.field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.open-in { position: relative; z-index: 2; }
.open h1 { margin: 28px 0 26px; max-width: 15ch; }
.acts { display: flex; align-items: center; gap: 26px; margin-top: 38px; }

.hint { position: absolute; left: 50%; bottom: 26px; z-index: 2; margin: 0; transform: translateX(-50%); }
.hint-line {
  display: block; width: 1px; height: 54px;
  background: linear-gradient(to bottom, transparent, var(--bone-3));
  transform-origin: top;
  animation: drop 2.6s cubic-bezier(0.6, 0, 0.3, 1) infinite;
}
@keyframes drop {
  0% { transform: scaleY(0); opacity: 0; }
  35%, 75% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1) translateY(54px); opacity: 0; }
}

.get { position: relative; z-index: 2; padding-block: 150px 130px; background: var(--ink); }
.get h2 { margin-bottom: 24px; }
.get .say { margin-bottom: 60px; }

.files { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.file {
  position: relative;
  display: grid; gap: 8px; padding: 40px 34px;
  background: var(--ink); color: var(--bone); text-decoration: none;
  overflow: hidden;
}
/* Transform rather than padding: nothing here should cost a reflow. */
.file::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--ink-3);
  transform: translateY(101%);
  transition: transform 0.55s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.file > * { position: relative; z-index: 1; }
.file:hover::before { transform: translateY(0); }

.file-k, .file-n, .file-s {
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.file:hover .file-k { transform: translateX(10px); }
.file:hover .file-n { transform: translateX(10px); transition-delay: 0.03s; }
.file:hover .file-s { transform: translateX(10px); transition-delay: 0.06s; }

.file-k { font-family: var(--serif); font-size: 2rem; line-height: 1; }
.file-n { color: var(--bone-2); font-size: 0.9rem; }
.file-s { margin-top: 14px; color: var(--bone-3); font-size: 0.8rem; letter-spacing: 0.06em; }

.file-arw {
  position: absolute; right: 34px; top: 50%; z-index: 1;
  width: 10px; height: 10px;
  border-right: 2px solid var(--violet);
  border-bottom: 2px solid var(--violet);
  opacity: 0;
  transform: translate(-14px, -50%) rotate(-45deg);
  transition:
    opacity 0.4s ease,
    transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.file:hover .file-arw { opacity: 1; transform: translate(0, -50%) rotate(-45deg); }

.foot { position: relative; z-index: 2; padding-block: 40px; border-top: 1px solid var(--line-soft); background: var(--ink); }
.foot-in { display: flex; align-items: baseline; gap: 16px; }
.foot-mark { font-family: var(--serif); font-size: 1.15rem; }
.foot-team { color: var(--bone-3); font-size: 0.88rem; }
.foot-year { margin-left: auto; color: var(--bone-3); font-size: 0.88rem; }

.rise {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity 0.8s cubic-bezier(0.2, 0.8, 0.3, 1),
    transform 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.rise.seen { opacity: 1; transform: none; }
/* Cards in a row arrive one after the other. */
.files .rise:nth-child(2) { transition-delay: 0.1s; }

/* ============================================================
   3. THE FILM STAGE
   ============================================================ */

.film {
  /* Six scenes, each given a comfortable screen and a bit to breathe. */
  --scenes: 6;
  position: relative;
  height: calc(var(--scenes) * 132vh + 60vh);
  background: var(--ink);
}

.film-stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;

  /* Written every frame by the controller. */
  --dolly: 0; --chat: 0; --split: 0; --tg: 0;
  --call: 0; --skin: 0; --fly: 0; --lite: 0; --prog: 0;
}

/* A vignette keeps the eye on the window rather than the corners. */
.film-stage::after {
  content: "";
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(ellipse 78% 66% at 62% 50%, transparent 42%, var(--ink) 100%);
  opacity: 0.9;
}

.camera {
  position: absolute; inset: 0;
  perspective: 1700px;
  perspective-origin: 62% 48%;
}

.rig {
  position: absolute;
  left: 62%; top: 50%;
  width: 1040px; height: 620px;
  margin: -310px 0 0 -520px;
  transform-style: preserve-3d;
  /*
     The one transform that carries the whole film: far away and turned
     at the start, square to the camera by the end of the first scene,
     then swung aside to make room for the phones.
  */
  transform:
    translate3d(
      calc(var(--fly) * -21%),
      calc(var(--fly) * 1%),
      calc(-1450px * (1 - var(--dolly)) - var(--fly) * 340px)
    )
    rotateX(calc((1 - var(--dolly)) * 24deg + var(--split) * 6deg))
    rotateY(calc((1 - var(--dolly)) * -17deg + var(--fly) * -13deg))
    rotateZ(calc((1 - var(--dolly)) * -2deg));
  will-change: transform;
}

/* ---------- captions ---------- */

.caps {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; justify-content: center;
  pointer-events: none;
}
.cap {
  position: absolute;
  left: var(--gut);
  max-width: 25rem;
  pointer-events: none;
}
/* The number, the heading and the text come in one after another —
   the order they are meant to be read in. */
.cap > * {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.55s cubic-bezier(0.2, 0.8, 0.3, 1),
    transform 0.62s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.cap.on > * { opacity: 1; transform: none; }
.cap.on .cap-n { transition-delay: 0.04s; }
.cap.on h2 { transition-delay: 0.11s; }
.cap.on p { transition-delay: 0.19s; }
.cap-n {
  display: block; margin-bottom: 18px;
  font-family: var(--serif); font-size: 0.86rem; color: var(--bone-3); letter-spacing: 0.06em;
}
.cap h2 { margin-bottom: 16px; }
.cap p { color: var(--bone-2); font-size: 0.98rem; line-height: 1.62; }

/* ---------- progress ---------- */

.progress {
  position: absolute; left: var(--gut); right: var(--gut); bottom: 26px; z-index: 6;
  height: 1px; background: var(--line-soft);
}
.progress span {
  display: block; height: 100%; width: calc(var(--prog) * 100%);
  background: var(--violet);
}

/* ---------- the palette strip ---------- */

.swatches {
  position: absolute; right: var(--gut); top: 50%; z-index: 6;
  display: grid; gap: 10px;
  transform: translateY(-50%);
  opacity: var(--skin);
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.swatches i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition:
    transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 0.4s ease;
}
.swatches i.on {
  transform: scale(1.85);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), 0 0 18px var(--c);
}

/* Which scene of how many, in the corner. */
.scene-mark {
  position: absolute; right: var(--gut); bottom: 22px; z-index: 6;
  display: flex; align-items: baseline; gap: 6px;
  font-family: var(--serif); color: var(--bone-3); font-size: 0.82rem;
}
.scene-mark b { font-weight: 400; color: var(--bone); font-size: 1.05rem; }

/* ============================================================
   4. THE INTERFACE REPLICA

   Colours come from the application's own tokens. `--accent` is
   overwritten by the controller during the theme scene, and `--lite`
   mixes every surface toward a light theme, which is how the window
   changes its skin without a second copy of the markup.
   ============================================================ */

.app {
  --accent: #6d5efc;
  --s-bg: color-mix(in oklab, #0c0b14, #eceaf2 calc(var(--lite) * 100%));
  --s-panel: color-mix(in oklab, #100e1a, #f7f6fa calc(var(--lite) * 100%));
  --s-panel-2: color-mix(in oklab, #16141f, #eeecf3 calc(var(--lite) * 100%));
  --s-elev: color-mix(in oklab, #1c1a27, #ffffff calc(var(--lite) * 100%));
  --s-line: color-mix(in oklab, #262336, #dcd9e4 calc(var(--lite) * 100%));
  --s-text: color-mix(in oklab, #ecebf3, #17151f calc(var(--lite) * 100%));
  --s-dim: color-mix(in oklab, #9a97ab, #5d5a68 calc(var(--lite) * 100%));

  position: absolute; inset: 0;
  transform-style: preserve-3d;
  border: 1px solid var(--s-line);
  border-radius: 16px;
  background: var(--s-panel);
  box-shadow:
    0 70px 140px -50px rgba(0, 0, 0, 0.92),
    0 0 0 1px rgba(255, 255, 255, 0.03);
  overflow: hidden;
  color: var(--s-text);
}

.app-bar {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 16px;
  border-bottom: 1px solid var(--s-line);
  background: var(--s-panel-2);
}
.dots { display: flex; gap: 7px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--s-line); }
.app-title { color: var(--s-dim); font-size: 0.78rem; }

.app-body {
  display: grid; grid-template-columns: 264px 1fr;
  height: calc(100% - 40px);
  transform-style: preserve-3d;
}

.pane { transform-style: preserve-3d; }

/* ---------- the list ---------- */

.side {
  padding: 12px 10px;
  border-right: 1px solid var(--s-line);
  background: var(--s-bg);
  overflow: hidden;
}

.tabs {
  position: relative;
  display: flex; gap: 4px; padding: 3px; margin-bottom: 12px;
  border: 1px solid var(--s-line); border-radius: 9px;
  background: var(--s-panel);
}
/* The pill slides between the two tabs instead of jumping. */
.tabs::before {
  content: "";
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  border-radius: 6px;
  background: var(--s-elev);
  transform: translateX(calc(var(--tg) * 100%));
}
.tab {
  position: relative; z-index: 1;
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 4px; font-size: 0.72rem; font-weight: 500; color: var(--s-dim);
}
.tab-q { color: color-mix(in oklab, var(--s-dim), var(--s-text) calc((1 - var(--tg)) * 100%)); }
.tab-t { color: color-mix(in oklab, var(--s-dim), var(--s-text) calc(var(--tg) * 100%)); }
.tab b {
  padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 0.6rem;
}

.search {
  height: 32px; margin-bottom: 12px; padding: 0 10px;
  display: flex; align-items: center;
  border: 1px solid var(--s-line); border-radius: 8px; background: var(--s-panel);
}
.search i { width: 82px; height: 6px; border-radius: 3px; background: var(--s-line); }

/*
   Both lists share one grid cell. They used to be absolutely positioned
   with no offset, which put the Telegram list at its static position —
   underneath the other one — and the list appeared to break in two.
*/
.lists { display: grid; }
.lists > * { grid-area: 1 / 1; }
.rows { display: flex; flex-direction: column; gap: 2px; align-content: start; }
.rows-q { opacity: calc(1 - var(--tg)); }
.rows-t { opacity: var(--tg); }
/* Each row lags a little more than the one above it. */
.rows-t .row { transform: translateX(calc((1 - var(--tg)) * 18px * var(--k, 1))); }
.rows-t .row:nth-child(1) { --k: 0.6; }
.rows-t .row:nth-child(2) { --k: 1; }
.rows-t .row:nth-child(3) { --k: 1.4; }
.rows-t .row:nth-child(4) { --k: 1.8; }
.rows-t .row:nth-child(5) { --k: 2.2; }

.row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; }
.row.on { background: color-mix(in oklab, transparent, var(--accent) 15%); }
.row span { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.row b { font-size: 0.75rem; font-weight: 550; }
.row em { font-style: normal; font-size: 0.66rem; color: var(--s-dim); }
.row u { text-decoration: none; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.6rem; }
.row.on em { color: color-mix(in oklab, var(--accent), #fff 35%); }

.av { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(140deg, #6d5efc, #3a2f9e); }
.av.big { width: 34px; height: 34px; }
.a2 { background: linear-gradient(140deg, #ec4899, #8d2159); }
.a3 { background: linear-gradient(140deg, #14b8a6, #0b5f57); }
.a4 { background: linear-gradient(140deg, #f59e0b, #8a5906); }
.a5 { background: linear-gradient(140deg, #3b82f6, #1b4b96); }
.t1 { background: linear-gradient(140deg, #37bbfe, #007dbb); }
.t2 { background: linear-gradient(140deg, #e17076, #a13b40); }
.t3 { background: linear-gradient(140deg, #7bc862, #3d7a2b); }
.t4 { background: linear-gradient(140deg, #a695e7, #5b4aa8); }
.t5 { background: linear-gradient(140deg, #faa774, #b2603a); }

/* ---------- the conversation ---------- */

.talk {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--s-panel);
}

.talk-head {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--s-line);
  background: var(--s-panel-2);
}
/* Avatar and name each get one cell holding both states, so the two
   never lay themselves out on top of each other's text. */
.talk-av { display: grid; }
.talk-av > * { grid-area: 1 / 1; }
.head-q { opacity: calc(1 - var(--tg)); }
.head-t { opacity: var(--tg); }

.talk-who { display: grid; }
.talk-who > * { grid-area: 1 / 1; }
.who { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.who b { font-size: 0.82rem; font-weight: 570; }
.who em { font-style: normal; font-size: 0.66rem; color: var(--s-dim); }
.who em.live-on { color: #34d399; }
.who-q { opacity: calc(1 - var(--tg)); }
.who-t { opacity: var(--tg); }
.talk-acts { display: flex; gap: 8px; margin-left: auto; }
.talk-acts i { width: 28px; height: 28px; border-radius: 8px; background: var(--s-elev); }

.stream { position: relative; flex: 1; overflow: hidden; }

/* The two conversations occupy the same box and cross-fade. Each lays
   itself out in normal flow, so bubble heights can change freely. */
.thread {
  position: absolute;
  inset: 20px 18px auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.thread-q {
  opacity: calc(1 - var(--tg));
  transform: translateX(calc(var(--tg) * -38px));
}
.thread-t {
  opacity: var(--tg);
  transform: translateX(calc((1 - var(--tg)) * 38px));
}
/* Telegram's bubbles are dealt out by their own scene, not the chat one. */
.thread-t .msg { --seen: clamp(0, calc(var(--tg) * 6 - var(--n) * 0.86), 1); }

/*
   Messages are laid out in one column per conversation, stacked in the
   same box. Each bubble knows its index, so the scene can deal them out
   one at a time as the scroll advances.
*/
.msg {
  /* Windows overlap (0.86 of a step each), so one bubble is still
     settling as the next begins — a queue rather than a metronome. */
  --seen: clamp(0, calc(var(--chat) * 5.2 - var(--n) * 0.86), 1);
  transform-origin: left bottom;
  display: flex; align-items: center; gap: 9px;
  width: fit-content; max-width: 76%;
  margin-bottom: 9px;
  padding: 9px 13px;
  border-radius: 15px;
  font-size: 0.78rem; line-height: 1.45;
  opacity: var(--seen);
  transform:
    translateY(calc((1 - var(--seen)) * 16px))
    scale(calc(0.955 + 0.045 * var(--seen)));
}
.msg.them { border: 1px solid var(--s-line); border-bottom-left-radius: 5px; background: var(--s-elev); }
.msg.me {
  margin-left: auto;
  transform-origin: right bottom;
  border-bottom-right-radius: 5px;
  background: var(--accent);
  color: #fff;
}

.play { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); position: relative; }
.msg.me .play { background: rgba(255, 255, 255, 0.25); }
.play::after {
  content: ""; position: absolute; left: 9px; top: 7px;
  border-left: 7px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 18px; min-width: 96px; }
.wave i {
  flex: 1; border-radius: 1px;
  background: color-mix(in oklab, var(--s-dim), transparent 45%);
  animation: wave 1.5s ease-in-out infinite;
}
.msg.me .wave i { background: rgba(255, 255, 255, 0.5); }
.wave i:nth-child(-n + 8) { background: var(--accent); }
.msg.me .wave i:nth-child(-n + 8) { background: #fff; }
.wave i:nth-child(2n) { animation-delay: 0.13s; }
.wave i:nth-child(3n) { animation-delay: 0.27s; }
.wave i:nth-child(5n) { animation-delay: 0.41s; }
@keyframes wave { 0%, 100% { height: 32%; } 50% { height: 92%; } }
.dur { font-size: 0.66rem; color: var(--s-dim); }
.msg.me .dur { color: rgba(255, 255, 255, 0.8); }

.fico {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.2); color: #fff;
  font-size: 0.52rem; font-weight: 700; font-style: normal;
}
.ftext { display: flex; flex-direction: column; gap: 2px; }
.ftext b { font-size: 0.73rem; }
.ftext em { font-style: normal; font-size: 0.64rem; opacity: 0.75; }

/* Telegram's own shapes: a round video note and a sticker, both
   without a bubble behind them, exactly as the app draws them. */
.msg.round, .msg.sticker { background: none; border: 0; padding: 0; }
.circle {
  display: block; width: 128px; height: 128px; border-radius: 50%;
  background: linear-gradient(150deg, #2f2a4d, #14121f);
  border: 1px solid var(--s-line);
  position: relative;
}
.circle i {
  position: absolute; inset: 0; margin: auto;
  width: 0; height: 0;
  border-left: 15px solid rgba(255, 255, 255, 0.85);
  border-top: 10px solid transparent; border-bottom: 10px solid transparent;
}
.stick { display: block; font-size: 4.4rem; line-height: 1; }

.composer {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 16px; padding: 12px 14px;
  border: 1px solid var(--s-line); border-radius: 12px;
  background: var(--s-panel-2);
  color: var(--s-dim); font-size: 0.76rem;
}
.composer i { margin-left: auto; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); }

/* ---------- the call ---------- */

.call {
  position: absolute; right: 22px; bottom: 22px;
  width: 300px; padding: 14px;
  border: 1px solid var(--s-line); border-radius: 14px;
  background: color-mix(in oklab, var(--s-elev), transparent 6%);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
  /* Present while the panes are apart, and again during its own scene. */
  opacity: max(var(--split), var(--call));
  transform: translateZ(calc(max(var(--split), var(--call)) * 130px)) scale(calc(1 + var(--call) * 0.06));
}
.call-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--s-dim); font-size: 0.68rem; }
.live { width: 6px; height: 6px; border-radius: 50%; background: #f4495c; }
.call-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.tile { border-radius: 10px; border: 1px solid var(--s-line); height: 88px; display: block; }
.tile.share { background: linear-gradient(150deg, #241f3b, #15121f); padding: 10px; display: grid; gap: 6px; align-content: start; }
.tile.share i { display: block; height: 7px; border-radius: 2px; background: rgba(255, 255, 255, 0.14); }
.tile.share i:nth-child(2) { width: 70%; }
.tile.share i:nth-child(3) { width: 45%; }
.tile.cam { background: linear-gradient(150deg, #3b2f6b, #1d1840); }
.call-bar { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.call-bar i { width: 30px; height: 30px; border-radius: 50%; background: var(--s-elev); border: 1px solid var(--s-line); }
.call-bar i.hang { background: #f4495c; border-color: #f4495c; }

/* ---------- labels while the window is apart ---------- */

.tags { position: absolute; inset: 0; pointer-events: none; transform-style: preserve-3d; }
.tag {
  position: absolute;
  padding: 5px 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(10, 10, 11, 0.82);
  color: var(--bone-2); font-size: 0.72rem; white-space: nowrap;
  opacity: var(--split);
  transition: opacity 0.3s ease;
}
.tag-1 { left: -96px; top: 32%; transform: translateZ(-150px); }
.tag-2 { left: 44%; top: -30px; transform: translateZ(-30px); }
.tag-3 { right: -70px; bottom: 22%; transform: translateZ(140px); }

/* ---------- the phones ---------- */

.phone {
  position: absolute;
  width: 208px; height: 430px;
  border: 1px solid var(--s-line, #262336);
  border-radius: 26px;
  background: #100e1a;
  box-shadow: 0 50px 90px -34px rgba(0, 0, 0, 0.95);
  overflow: hidden;
  /* Waiting behind the window until the last scene brings them in. */
  opacity: var(--fly);
  transform-style: preserve-3d;
}
.phone-l {
  right: -300px; top: 40px;
  transform: translate3d(calc((1 - var(--fly)) * 260px), 0, calc(-700px + var(--fly) * 620px)) rotateY(-16deg);
}
.phone-r {
  right: -560px; top: 130px;
  transform: translate3d(calc((1 - var(--fly)) * 420px), 0, calc(-900px + var(--fly) * 700px)) rotateY(-22deg);
}
.ph-top { height: 34px; border-bottom: 1px solid #262336; background: #16141f; }
.ph-rows { padding: 10px; display: grid; gap: 6px; }
.ph-row { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; background: #16141f; }
.ph-row span { flex: 1; height: 7px; border-radius: 3px; background: #262336; }
.ph-chat { padding: 12px; display: grid; gap: 8px; }
.ph-b { display: block; height: 26px; border-radius: 12px; width: 72%; background: #1c1a27; }
.ph-b.me { margin-left: auto; background: var(--violet); }
.ph-b.short { width: 48%; }

/* ============================================================
   6. ADAPTATION
   ============================================================ */

@media (max-width: 1100px) {
  .camera { perspective-origin: 50% 46%; }
  .rig { left: 50%; top: 56%; transform-origin: 50% 50%; }
  .caps { justify-content: flex-start; padding-top: 96px; }
  .cap { max-width: none; right: var(--gut); }
  .swatches { display: none; }
}

@media (max-width: 780px) {
  :root { --gut: 20px; }
  body { font-size: 16px; }

  /*
     The window is 1040px wide by design. Rather than reflow the replica
     — which would stop being a replica — the whole rig is scaled down
     to fit, so it stays truthful on a phone.
  */
  .film { --scenes: 6; height: calc(var(--scenes) * 118vh + 40vh); }
  .rig { transform-origin: 50% 50%; scale: 0.46; top: 62%; }
  .caps { padding-top: 88px; }
  .cap h2 { font-size: 1.9rem; }
  .cap p { font-size: 0.92rem; }
  .phone { display: none; }
  .tag { display: none; }
  .files { grid-template-columns: 1fr; }
  .file { padding: 30px 24px; }
  .acts { flex-wrap: wrap; gap: 14px 22px; }
  .cta { width: 100%; }
  .hint { display: none; }
  .open { padding-block: 120px 80px; }
}

@media (max-width: 480px) {
  .rig { scale: 0.33; top: 66%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .rise { opacity: 1; transform: none; }
  .hint { display: none; }
  /*
     Without motion the film cannot tell its story, so it stops being a
     film: the window sits square and finished, and every caption is
     readable in the flow of the page.
  */
  .film { height: auto; }
  .film-stage {
    position: static; height: auto; padding-block: 80px;
    --dolly: 1; --chat: 1; --split: 0; --tg: 0; --call: 1; --skin: 0; --fly: 0;
  }
  .film-stage::after { display: none; }
  .camera { position: relative; inset: auto; height: 700px; }
  .rig { transform: none; }
  .caps { position: static; display: grid; gap: 48px; padding-block: 60px; }
  .cap { position: static; opacity: 1; transform: none; max-width: 46ch; }
  .progress, .swatches, .phone, .tags, .scene-mark { display: none; }
  .cap > * { opacity: 1; transform: none; }
}
