/* Telegram for iOS (dark) on an iPhone 16. Numbers in px = iOS points at 1x.
   Colors from Telegram-iOS DefaultDarkPresentationTheme.swift; geometry 393x852 pt, status bar 54 pt, bottom inset 34 pt. */
@import url("https://fonts.googleapis.com/css2?family=Noto+Color+Emoji&display=swap");
:root {
  --bg: #000;
  --nav: rgba(29,29,29,.9);
  --panel: #1d1d1d;
  --panel-2: #2c2c2e;
  --in: #1d1d1d;
  --out-a: #61bcf9; --out-b: #0088ff;
  --text: #fff;
  --muted: #98989e;
  --accent: #3e88f7;
  --link: #6ab3f3;
  --green: #34c759;
  --red: #ff453a;
  --font: -apple-system, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --status-h: 54px;
  --home-h: 34px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.3; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--link); }
.app { position: relative; height: 100%; overflow: hidden;
  background-color: #000;
  background-image: radial-gradient(circle at 20% 15%, rgba(62,136,247,.10), transparent 45%), radial-gradient(circle at 85% 80%, rgba(120,90,220,.10), transparent 45%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='1.2'%3E%3Ccircle cx='20' cy='24' r='6'/%3E%3Cpath d='M70 18l6 6-6 6-6-6z'/%3E%3Cpath d='M100 60c0-6 8-6 8 0s-8 6-8 0'/%3E%3Cpath d='M30 80l10 0M35 75l0 10'/%3E%3Ccircle cx='75' cy='95' r='5'/%3E%3Cpath d='M15 105l8-8'/%3E%3C/g%3E%3C/svg%3E"); }
/* standalone on a wide screen: draw the device itself */
body.framed { display: grid; place-items: center; background: #111; }
body.framed .app { width: 393px; height: 852px; border-radius: 56px; border: 9px solid #0b0b0b; box-shadow: 0 0 0 2px #3a3a3c, 0 40px 80px rgba(0,0,0,.6); }

/* ---- status bar & Dynamic Island (estimated geometry: 126x37 pt, top 11 pt) ---- */
.status { position: absolute; top: 0; left: 0; right: 0; height: var(--status-h); z-index: 30; display: flex; align-items: center; justify-content: space-between; padding: 12px 28px 0 34px; font-weight: 600; font-size: 16px; pointer-events: none; }
.status__left { display: flex; align-items: center; gap: 5px; }
.status__focus { width: 18px; height: 18px; opacity: .9; }
.island { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: 126px; height: 37px; border-radius: 20px; background: #000; }
.status__right { display: flex; align-items: center; gap: 7px; }
.status__cell { width: 19px; height: 12px; }
.status__wifi { width: 17px; height: 12px; }
.status__batt { width: 27px; height: 13px; border: 1.5px solid rgba(255,255,255,.55); border-radius: 4px; position: relative; padding: 1.5px; }
.status__batt::after { content: ""; position: absolute; right: -4px; top: 3.5px; width: 2px; height: 4px; background: rgba(255,255,255,.55); border-radius: 0 1px 1px 0; }
.status__batt i { display: block; height: 100%; width: 78%; background: #fff; border-radius: 2px; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* ---- navigation bar ---- */
.nav { position: relative; z-index: 20; display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; padding: calc(var(--status-h) + 2px) 8px 8px; background: var(--nav); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: .5px solid rgba(255,255,255,.12); }
.nav--list { grid-template-columns: 1fr; }
.nav__back { display: flex; align-items: center; gap: 2px; color: var(--accent); justify-self: start; }
.nav__back svg { width: 12px; height: 20px; }
.nav__count { background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; border-radius: 10px; padding: 1px 6px; min-width: 20px; text-align: center; }
.nav__count[hidden] { display: none; }
.nav__center { text-align: center; min-width: 0; }
.nav__title { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__avatar { justify-self: end; }
.nav__avatar .avatar { width: 37px; height: 37px; }
.nav__close { color: var(--accent); font-size: 20px; justify-self: start; padding: 0 6px; }
.nav__spacer { width: 1px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; background: linear-gradient(135deg, #5a9bf5, #7d6cf0); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--emoji { font-size: 18px; }

/* ---- chat list ---- */
.chatlist { overflow-y: auto; background: var(--bg); flex: 1; padding-bottom: var(--home-h); }
.chatrow { display: flex; align-items: center; gap: 12px; padding: 9px 12px; width: 100%; text-align: left; }
.chatrow__text { flex: 1; min-width: 0; border-bottom: .5px solid rgba(255,255,255,.12); padding: 6px 0 10px; }
.chatrow:hover { background: var(--panel); }
.chatrow .avatar { width: 58px; height: 58px; }
.chatrow .avatar--emoji { font-size: 28px; }
.chatrow__name { font-weight: 600; font-size: 17px; }
.chatrow__last { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatrow__badge { font-size: 13px; font-weight: 600; color: #fff; background: var(--accent); border-radius: 12px; padding: 2px 7px; min-width: 22px; text-align: center; }

/* ---- hint (demo only) ---- */
.hint { margin: 8px 12px 0; padding: 8px 12px; background: rgba(0,0,0,.45); backdrop-filter: blur(8px); border-radius: 12px; font-size: 13px; color: #d1d1d6; text-align: center; }
.hint[hidden] { display: none; }

/* ---- messages ---- */
.messages { flex: 1; overflow-y: auto; padding: 8px 8px 6px; display: flex; flex-direction: column; gap: 3px; }
.msg { max-width: 82%; display: flex; flex-direction: column; align-self: flex-start; animation: pop .18s ease-out; }
.msg.out { align-self: flex-end; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.bubble { position: relative; background: var(--in); border-radius: 18px; padding: 6px 11px 6px; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 17px; line-height: 1.28; }
.msg:not(.out) .bubble { border-bottom-left-radius: 6px; }
.msg.out .bubble { background: linear-gradient(160deg, var(--out-a), var(--out-b)); border-bottom-right-radius: 6px; }
.bubble .meta { float: right; margin: 8px 0 0 8px; font-size: 11px; color: var(--muted); }
.msg.out .bubble .meta { color: rgba(255,255,255,.8); }
.msg.out .bubble .meta::after { content: " ✓✓"; letter-spacing: -.2em; margin-right: .2em; }
.bubble b, .bubble strong { font-weight: 600; }
.bubble code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: rgba(0,0,0,.25); border-radius: 4px; padding: 1px 4px; }
.bubble pre { margin: 4px 0; padding: 8px; background: rgba(0,0,0,.3); border-radius: 8px; overflow-x: auto; font-size: 14px; }
.bubble blockquote { margin: 4px 0; padding: 4px 8px; border-left: 3px solid var(--accent); background: rgba(255,255,255,.06); border-radius: 4px; }
.bubble tg-spoiler, .bubble .tg-spoiler { background: #444; color: transparent; border-radius: 3px; cursor: pointer; }
.bubble tg-spoiler.show, .bubble .tg-spoiler.show { background: transparent; color: inherit; }
.bubble img.photo { display: block; max-width: 100%; border-radius: 14px; margin: -3px -8px 6px; width: calc(100% + 16px); }
.bubble .doc { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.bubble .doc i { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 16px; }
.bubble .doc small { color: var(--muted); display: block; font-size: 13px; }
.bubble .sticker { font-size: 72px; line-height: 1; }
.svc { align-self: center; font-size: 13px; color: #fff; background: rgba(0,0,0,.35); border-radius: 12px; padding: 4px 11px; margin: 4px 0; text-align: center; max-width: 90%; }

/* ---- inline keyboard (iOS) ---- */
.ikb { display: grid; gap: 4px; margin-top: 4px; width: 100%; }
.ikb__row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.ikb button { background: rgba(255,255,255,.16); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 12px; height: 42px; padding: 0 10px; font-size: 16px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .12s; }
.ikb button:hover { background: rgba(255,255,255,.24); }
.ikb button:active { background: rgba(255,255,255,.32); }
.ikb button.busy { opacity: .6; }
.ikb button .ico { font-size: 12px; margin-left: 4px; opacity: .8; }
.ikb button.ikb--primary { background: #5b6cf0; color: #fff; }
.ikb button.ikb--success { background: #34c759; color: #fff; }
.ikb button.ikb--danger { background: #ff453a; color: #fff; }

/* ---- typing ---- */
.typing { display: flex; gap: 4px; padding: 0 16px 6px; height: 18px; }
.typing[hidden] { display: none; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }

/* ---- reply keyboard ---- */
.replykb { background: #1c1c1e; padding: 6px 6px 2px; display: grid; gap: 6px; border-top: .5px solid rgba(255,255,255,.12); max-height: 45%; overflow-y: auto; }
.replykb[hidden] { display: none; }
.replykb__row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.replykb button { background: #3a3a3c; border-radius: 8px; padding: 11px 6px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 0 rgba(0,0,0,.5); }
.replykb button:hover { background: #48484a; }

/* ---- composer (iOS bot chat) ---- */
.composer { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--nav); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: .5px solid rgba(255,255,255,.12); position: relative; }
.composer__menu { display: flex; align-items: center; gap: 5px; background: #5b6cf0; color: #fff; border-radius: 19px; height: 38px; padding: 0 12px 0 10px; font-size: 16px; font-weight: 500; }
.composer__menu svg { width: 18px; height: 18px; }
.composer__attach { color: var(--muted); width: 26px; height: 26px; }
.composer__attach svg { width: 26px; height: 26px; }
.composer__field { flex: 1; position: relative; min-width: 0; }
.composer__input { width: 100%; background: #000; border: .5px solid rgba(255,255,255,.2); border-radius: 19px; height: 38px; padding: 0 38px 0 14px; color: var(--text); outline: none; font-size: 16px; }
.composer__input::placeholder { color: var(--muted); }
.composer__sticker { position: absolute; right: 9px; top: 7px; width: 24px; height: 24px; color: var(--muted); }
.composer__clear { position: absolute; right: 8px; top: 8px; width: 22px; height: 22px; padding: 0; border: 0; background: none; color: #8e99a4; cursor: pointer; }
.composer__clear svg { display: block; width: 22px; height: 22px; }
.composer__clear[hidden], .composer__sticker[hidden] { display: none; }
.composer__mic, .composer__send { width: 32px; height: 32px; color: var(--muted); display: grid; place-items: center; }
.composer__mic svg { width: 24px; height: 24px; }
.composer__send { color: var(--accent); }
.composer__send svg { width: 32px; height: 32px; }
.composer__send[hidden], .composer__mic[hidden] { display: none; }
.composer__kb { color: var(--muted); width: 26px; height: 26px; }
.composer__kb svg { width: 26px; height: 26px; }
.composer__kb[hidden] { display: none; }
.startbar { display: block; width: 100%; padding: 14px; background: var(--nav); color: var(--accent); font-weight: 600; font-size: 17px; text-transform: uppercase; letter-spacing: .01em; border-top: .5px solid rgba(255,255,255,.12); }
.startbar[hidden] { display: none; }
.home { height: var(--home-h); background: var(--nav); position: relative; }
.home::after { content: ""; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: 134px; height: 5px; border-radius: 3px; background: #fff; }
.home--light { background: #000; }

/* menus */
.cmdmenu { position: absolute; left: 8px; right: 8px; bottom: calc(var(--home-h) + 56px); background: var(--panel); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); overflow: hidden; max-height: 50%; overflow-y: auto; z-index: 25; }
.cmdmenu[hidden] { display: none; }
.cmdmenu button { display: flex; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-bottom: .5px solid rgba(255,255,255,.1); font-size: 16px; }
.cmdmenu button:hover { background: var(--panel-2); }
.cmdmenu button b { color: var(--accent); font-weight: 600; min-width: 96px; }
.cmdmenu button span { color: var(--muted); font-size: 14px; }
.menu { position: absolute; right: 10px; top: calc(var(--status-h) + 52px); background: rgba(44,44,46,.96); backdrop-filter: blur(20px); border-radius: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5); overflow: hidden; z-index: 26; min-width: 220px; }
.menu[hidden] { display: none; }
.menu button { display: block; width: 100%; text-align: left; padding: 11px 16px; font-size: 16px; border-bottom: .5px solid rgba(255,255,255,.1); }
.menu button:hover { background: var(--panel-2); }

/* ---- Mini App ---- */
.webapp { position: absolute; inset: 0; display: flex; flex-direction: column; background: #000; z-index: 28; }
.webapp[hidden] { display: none; }
.webapp iframe { flex: 1; border: 0; width: 100%; background: #000; }

/* ---- toast / modal / offline ---- */
.toast { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 14px; max-width: 86%; z-index: 40; text-align: center; }
.toast[hidden] { display: none; }
.modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); z-index: 41; }
.modal[hidden] { display: none; }
.modal__box { background: rgba(44,44,46,.98); border-radius: 14px; padding: 20px 18px 0; width: 270px; text-align: center; font-size: 15px; }
.modal__box button { display: block; width: 100%; margin-top: 16px; padding: 12px; color: var(--accent); border-top: .5px solid rgba(255,255,255,.15); font-weight: 600; font-size: 17px; }
.offline { position: absolute; top: calc(var(--status-h) + 60px); left: 50%; transform: translateX(-50%); background: #7a2e2e; color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 8px; z-index: 40; }
.offline[hidden] { display: none; }

/* ---- custom emoji ---- */
.cemoji { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.22em; line-height: 1; }
.cemoji img, .cemoji video, .cemoji svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.cemoji--repaint svg *[fill]:not([fill="none"]) { fill: currentColor !important; }
.cemoji--repaint svg *[stroke]:not([stroke="none"]) { stroke: currentColor !important; }
.cemoji--repaint img { filter: brightness(0) invert(1); }

/* ---- simulators / invoice ---- */
.sims { background: var(--nav); border-top: .5px solid rgba(255,255,255,.12); padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.sims[hidden] { display: none; }
.sims__title { width: 100%; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sims button { background: var(--panel-2); border-radius: 10px; padding: 8px 11px; font-size: 14px; }
.sims button:hover { background: #3a3a3c; }
.invoice { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.invoice__amount { font-weight: 600; }
.invoice__pay { background: var(--accent); color: #fff; border-radius: 10px; padding: 7px 14px; font-weight: 600; }

/* ---- bottom sheet: choose channel / confirm admin rights ---- */
.sheet { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 35; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.sheet__box { width: 100%; background: #1c1c1e; border-radius: 22px 22px 0 0; padding: 18px 16px calc(var(--home-h) + 6px); animation: slideup .22s ease-out; max-height: 80%; overflow-y: auto; }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
.sheet__title { font-weight: 600; font-size: 18px; }
.sheet__sub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.sheet__row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 6px; border-radius: 12px; }
.sheet__row:hover { background: var(--panel-2); }
.sheet__row b { display: block; font-weight: 600; }
.sheet__row small { color: var(--muted); font-size: 13px; }
.sheet__row .avatar { width: 46px; height: 46px; font-size: 22px; }
.sheet__empty { color: var(--muted); font-size: 14px; padding: 8px 6px 14px; }
.sheet__rights { display: grid; gap: 10px; padding: 6px 6px 16px; }
.sheet__rights div { display: flex; gap: 12px; align-items: center; font-size: 16px; }
.sheet__check { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.sheet__ok { display: block; width: 100%; padding: 14px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; }
.sheet__cancel { display: block; width: 100%; padding: 13px; margin-top: 6px; border-radius: 12px; color: var(--accent); font-weight: 600; font-size: 17px; }
.sheet__cancel:hover { background: var(--panel-2); }

/* ---- inline mode results (above the composer) ---- */
.inline { background: var(--panel); border-top: .5px solid rgba(255,255,255,.12); max-height: 46%; overflow-y: auto; }
.inline[hidden] { display: none; }
.inline__loading { padding: 12px 14px; color: var(--muted); font-size: 14px; }
.inline__row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 12px; border-bottom: .5px solid rgba(255,255,255,.08); }
.inline__row:hover { background: var(--panel-2); }
.inline__row img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; background: #000; }
.inline__text { min-width: 0; }
.inline__text b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline__text small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
