/* Имитация чата Telegram (iOS) для показа виджетов в браузере. */
:root {
  --bg: #fff; --text: #000; --hint: #8a8a8e; --link: #2a7bde; --accent: #3390ec;
  --head: #f7f7f7; --line: #d9d9dd;
  --wall1: #d3e3b6; --wall2: #a9cd9c; --doodle: #7fa36f;
  --in: #fff; --out: #e1fec6; --out-hint: #4fae4e;
  --key: #ffffffcc; --key-text: #1e7ed8;
  --m: #0000a0; --c: #00d7ff; --y: #ffd200;
  --page: #0000a0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17212b; --text: #fff; --hint: #7f91a4; --link: #6ab3f3; --accent: #5eb5f7;
    --head: #17212b; --line: #0d141b;
    --wall1: #0f1a24; --wall2: #16232f; --doodle: #24394a;
    --in: #182533; --out: #2b5278; --out-hint: #7db8e8;
    --key: #2b394866; --key-text: #fff;
  }
}
:root[data-theme="dark"] {
  --bg: #17212b; --text: #fff; --hint: #7f91a4; --link: #6ab3f3; --accent: #5eb5f7;
  --head: #17212b; --line: #0d141b;
  --wall1: #0f1a24; --wall2: #16232f; --doodle: #24394a;
  --in: #182533; --out: #2b5278; --out-hint: #7db8e8;
  --key: #2b394866; --key-text: #fff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  color: var(--text); background: var(--page); -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }

/* Страница: на телефоне — приложение во весь экран, на десктопе — рамка телефона и описание. */
.stage { min-height: 100%; display: flex; align-items: center; justify-content: center; gap: 56px; padding: 0; }
.side { display: none; color: #fff; max-width: 420px; }
.side .kicker { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c); }
.side h1 { font-size: 44px; line-height: 1.02; margin: 12px 0 18px; font-weight: 900; letter-spacing: -.01em; text-transform: uppercase; }
.side p { font-size: 17px; line-height: 1.45; color: #d6dcff; margin: 0 0 14px; }
.side .nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.side .nav a { color: #fff; text-decoration: none; border: 2px solid #ffffff55; border-radius: 12px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.side .nav a.on { border-color: var(--c); color: var(--c); }
.side .nav a:hover { border-color: #fff; }
.side .note { font-size: 12px; color: #9fa8e8; margin-top: 28px; line-height: 1.4; }
.side .restart { margin-top: 10px; background: none; border: 0; color: var(--y); font: 600 14px system-ui; padding: 0; cursor: pointer; }

.phone { position: relative; width: 100%; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
@media (min-width: 900px) and (min-height: 700px) {
  .stage { padding: 32px; }
  .side { display: block; }
  .phone {
    width: 400px; height: min(860px, calc(100dvh - 64px)); border-radius: 54px;
    box-shadow: 0 0 0 12px #111, 0 0 0 14px #3a3a44, 0 40px 80px #00000066;
  }
  .phone::before { content: ""; position: absolute; z-index: 5; top: 10px; left: 50%; width: 120px; height: 32px; margin-left: -60px; background: #000; border-radius: 20px; }
  .status { display: flex !important; }
}
.status { display: none; height: 50px; flex: none; align-items: flex-end; justify-content: space-between; padding: 0 30px 6px 40px; font-size: 15px; font-weight: 600; background: var(--head); }

/* Шапка чата */
.head { flex: none; display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px; background: var(--head); border-bottom: 0.5px solid var(--line); z-index: 2; }
.head .back { color: var(--accent); font-size: 17px; text-decoration: none; display: flex; align-items: center; gap: 2px; min-width: 70px; }
.head .back svg { width: 12px; height: 20px; }
.head .who { flex: 1; text-align: center; line-height: 1.15; }
.head .who b { display: block; font-size: 16px; font-weight: 600; }
.head .who span { font-size: 13px; color: var(--hint); }
.head .who span.typing { color: var(--accent); }
.ava { width: 38px; height: 38px; border-radius: 50%; flex: none; display: block; }
.head .ava { margin-left: 32px; }

/* Лента */
.feed {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px 8px 14px;
  background-color: var(--wall2);
  background-image: var(--doodles), linear-gradient(160deg, var(--wall1), var(--wall2));
  background-size: 260px, cover; background-attachment: local;
  display: flex; flex-direction: column; gap: 6px;
  scroll-behavior: smooth;
}
.day { align-self: center; font-size: 13px; font-weight: 600; color: #fff; background: #0000002e; padding: 3px 10px; border-radius: 12px; margin: 4px 0; }
.intro { align-self: center; margin: auto 12px; max-width: 320px; padding: 16px; border-radius: 18px; background: #0000002e; color: #fff; font-size: 14px; text-align: center; }
.intro b { display: block; font-size: 16px; margin-bottom: 6px; }

.msg { max-width: 86%; display: flex; flex-direction: column; animation: pop .22s ease-out; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.bubble { position: relative; padding: 6px 10px 7px; border-radius: 18px; background: var(--in); box-shadow: 0 1px 1px #0000001a; font-size: 16px; overflow-wrap: anywhere; }
.out .bubble { background: var(--out); }
.in .bubble { border-bottom-left-radius: 6px; }
.out .bubble { border-bottom-right-radius: 6px; }
.bubble .tm { float: right; margin: 8px 0 -4px 10px; font-size: 11px; color: var(--hint); }
.out .bubble .tm { color: var(--out-hint); }
.bubble p { margin: 0 0 6px; }
.bubble p:last-of-type { margin-bottom: 0; }
.bubble b { font-weight: 600; }
.bubble ul { margin: 4px 0; padding-left: 20px; }
.bubble .from { display: block; font-size: 14px; font-weight: 600; color: #2a7bde; margin-bottom: 2px; }

/* Инлайн-клавиатура */
.keys { display: grid; gap: 4px; margin-top: 4px; }
.keys button {
  min-height: 40px; border: 0; border-radius: 12px; background: var(--key); color: var(--key-text);
  font: 600 15px system-ui, sans-serif; padding: 6px 10px; cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  position: relative;
}
.keys button.url::after { content: "↗"; position: absolute; right: 8px; top: 4px; font-size: 12px; }
.keys button:disabled { cursor: default; }
.keys button.picked { background: var(--accent); color: #fff; }
.keys.done button:not(.picked):not(.url) { opacity: .55; }

/* Виджет */
.msg.widget { max-width: 100%; width: min(100%, 420px); }
.wbox { border-radius: 18px; border-bottom-left-radius: 6px; overflow: hidden; background: var(--in); box-shadow: 0 1px 2px #00000026; }
.wbox iframe { display: block; width: 100%; border: 0; background: transparent; }
.wcap { display: flex; justify-content: space-between; padding: 5px 10px 6px; font-size: 12px; color: var(--hint); }

/* Медиа */
.photo { border-radius: 18px; overflow: hidden; background: var(--in); box-shadow: 0 1px 1px #0000001a; width: min(290px, 78vw); }
.photo img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #c7cbe8; }
.photo .cap { padding: 6px 10px 7px; font-size: 15px; }
.photo .cap small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; color: var(--hint); text-transform: uppercase; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.voice .play { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; flex: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.voice .play svg { width: 18px; height: 18px; fill: #fff; }
.voice .wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; }
.voice .wave i { flex: 1; max-width: 3px; border-radius: 2px; background: var(--hint); opacity: .55; }
.voice .wave i.on { background: var(--accent); opacity: 1; }
.voice .meta { font-size: 12px; color: var(--hint); margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.voice .tr { border: 0; background: #3390ec22; color: var(--accent); font: 700 11px system-ui; border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.vtext { margin-top: 6px; font-size: 14.5px; display: none; }
.vtext.on { display: block; }

.circle { position: relative; width: 220px; height: 220px; cursor: pointer; }
.circle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: #c7cbe8; transition: transform 6s ease-out; }
.circle.playing img { transform: scale(1.12); }
.circle svg.ring { position: absolute; inset: -6px; width: 232px; height: 232px; transform: rotate(-90deg); pointer-events: none; }
.circle svg.ring circle { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.circle .pbtn { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: #00000066; display: flex; align-items: center; justify-content: center; }
.circle .pbtn svg { width: 24px; height: 24px; fill: #fff; margin-left: 3px; }
.circle.playing .pbtn { display: none; }
.circle .dur { position: absolute; left: 14px; bottom: 10px; font-size: 12px; color: #fff; background: #00000066; padding: 1px 7px; border-radius: 9px; }
.subs { max-width: 260px; margin-top: 6px; padding: 6px 10px; border-radius: 14px; background: var(--in); font-size: 14.5px; box-shadow: 0 1px 1px #0000001a; }
.subs .from { display: block; font-size: 13px; font-weight: 600; color: #2a7bde; }

.typing-b { display: flex; gap: 4px; padding: 12px 14px; }
.typing-b i { width: 7px; height: 7px; border-radius: 50%; background: var(--hint); animation: blink 1.2s infinite; }
.typing-b i:nth-child(2) { animation-delay: .2s; } .typing-b i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* Низ: кнопка «Запустить» / поле ввода */
.bottom { flex: none; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--head); border-top: 0.5px solid var(--line); }
.startbtn { width: 100%; min-height: 46px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font: 700 16px system-ui; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.input { display: flex; align-items: center; gap: 10px; }
.input .field { flex: 1; min-height: 36px; border-radius: 18px; border: 0.5px solid var(--line); background: var(--bg); color: var(--hint); font-size: 15px; display: flex; align-items: center; padding: 0 14px; }
.input svg { width: 26px; height: 26px; fill: var(--hint); flex: none; }
@media (min-width: 900px) and (min-height: 700px) { .bottom { padding-bottom: 22px; } }

.toast { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); z-index: 9; background: #000000cc; color: #fff; font-size: 14px; padding: 8px 14px; border-radius: 12px; max-width: 86%; text-align: center; pointer-events: none; }
