/* Layout: the page IS a group chat. Phone: Caesar's real avatar full width, his profile, then the thread
   with a sticky header and a sticky "add" bar. Desktop: thread in the middle, profile pinned on the right.
   Palette lifted from the avatar: Samarkand night sky, turquoise domes, the gold pixel logo. */
:root {
  --wall: none;
  --bg: #0A1230; --panel: #111A3A; --bubble: #18244B; --raised: #1F2D5A; --line: #26346A;
  --svc: rgba(5, 9, 26, 0.6); --tint: rgba(255, 255, 255, 0.06);
  --fg: #EEF1FA; --muted: #8C98C4; --link: #5FD0DD;
  --gold: #F2C14E; --gold-hover: #F7D06F; --on-gold: #0A1230;
  --c-sardor: #F0A35E; --c-jasur: #7FD18B; --c-malika: #E880B5; --c-dilnoza: #B79CF2; --c-caesar: var(--gold);
  --font: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --pixel: "Pixelify Sans", var(--mono);
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
[hidden] { display: none !important; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--panel); }
h1, p, figure { margin: 0; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
code { font-family: var(--mono); font-size: 0.875em; }
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }
.skip { position: fixed; left: 16px; top: 16px; z-index: 20; padding: 8px 12px; border-radius: 8px; background: var(--gold); color: var(--on-gold); font-weight: 600; transform: translateY(-200%); transition: transform 300ms var(--ease); }
.skip:focus-visible { transform: none; }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 20px; border-radius: 12px; background: var(--gold); color: var(--on-gold); font-weight: 700; font-size: 16px; text-decoration: none; transition: background-color 200ms var(--ease), transform 200ms var(--ease); }
.btn:hover { background: var(--gold-hover); }
.btn:active { transform: scale(0.98); }

.app { display: grid; grid-template-areas: "profile" "chat"; }
@media (min-width: 1080px) { .app { grid-template-areas: "chat profile"; grid-template-columns: minmax(0, 760px) 380px; justify-content: center; } }

/* Profile: the hero on phones, a chat info panel on desktop */
.profile { --gut-l: max(20px, env(safe-area-inset-left, 0px)); --gut-r: max(20px, env(safe-area-inset-right, 0px)); grid-area: profile; display: grid; gap: 18px; align-content: start; background: var(--panel); padding-block: 0 28px; padding-left: var(--gut-l); padding-right: var(--gut-r); }
.cover { margin-left: calc(-1 * var(--gut-l)); margin-right: calc(-1 * var(--gut-r)); }
.cover img { display: block; width: 100%; height: auto; aspect-ratio: 1; image-rendering: auto; }
.idrow { display: flex; align-items: center; gap: 10px; }
.name { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; }
.handle { margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 20px; }
.presence { color: var(--fg); }
.live-dot { display: inline-block; width: 8px; height: 8px; margin: 0 5px 1px 3px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); animation: pulse 2s var(--ease) infinite; }
.presence.off { color: var(--muted); }
.presence.off .live-dot { background: var(--muted); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); } 70%, 100% { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); } }
.bump { animation: bump 800ms var(--ease); }
@keyframes bump { 0%, 35% { color: var(--gold); } 100% { color: inherit; } }
.cta-row { position: relative; display: flex; gap: 8px; }
.cta-row .btn { flex: 1; }
.qr-btn { display: none; width: 52px; flex: none; place-items: center; border: 0; border-radius: 12px; background: var(--bubble); color: var(--fg); cursor: pointer; transition: background-color 200ms var(--ease); }
.qr-btn:hover, .qr-btn[aria-expanded="true"] { background: var(--raised); }
.qr-btn svg { width: 22px; height: 22px; }
.qr-pop { position: absolute; right: 0; bottom: calc(100% + 10px); z-index: 6; display: grid; justify-items: center; gap: 8px; width: 224px; padding: 14px; border-radius: 14px; background: #FFFFFF; color: var(--on-gold); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); font-size: 14px; line-height: 18px; text-align: center; }
.qr-pop img { display: block; width: 196px; height: 196px; image-rendering: pixelated; }
@media (min-width: 1080px) { .qr-btn { display: grid; } }
.badge, .tag, .stats b { font-family: var(--pixel); font-weight: 500; }
.badge { padding: 2px 8px; border-radius: 6px; background: var(--tint); color: var(--gold); font-size: 14px; line-height: 18px; }
.pitch { max-width: 40ch; font-size: 17px; line-height: 1.5; text-wrap: pretty; }
.pitch b { color: var(--gold); font-weight: 600; }
/* Four numbers in a 2 by 2 grid; the 1px gaps let the line colour show through as dividers */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border-radius: 12px; overflow: hidden; background: var(--line); }
.stats > div { padding: 10px 14px; background: var(--bubble); }
.stats b { display: block; font-size: 22px; line-height: 28px; font-variant-numeric: tabular-nums; }
.stats > div > span { display: block; color: var(--muted); font-size: 13px; line-height: 18px; }
.fine { color: var(--muted); font-size: 13px; line-height: 18px; }
@media (min-width: 640px) {
  .profile { padding-block: 32px 28px; }
  .profile > * { width: 100%; max-width: 440px; justify-self: center; }
  .cover { margin: 0; }
  .cover img { border-radius: 20px; }
}
/* Desktop: the panel is exactly one screen tall and never scrolls; the avatar gives up height first */
@media (min-width: 1080px) {
  .profile { position: sticky; top: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; gap: 14px; padding: 24px; box-shadow: inset 1px 0 0 var(--line); }
  .profile > * { flex: none; max-width: none; }
  .profile > .cover { flex: 0 1 332px; min-height: 120px; display: flex; justify-content: center; }
  .cover img { width: auto; height: 100%; max-width: 100%; object-fit: contain; border-radius: 16px; }
  .pitch { font-size: 16px; }
}
@media (min-width: 1080px) and (max-height: 700px) {
  .fine { display: none; }
  .profile { gap: 10px; padding-block: 16px; }
  .profile > .cover { min-height: 96px; }
  .name { font-size: 28px; }
  .pitch { font-size: 15px; line-height: 1.45; }
  .stats > div { padding: 6px 12px; }
}

/* Thread */
.chat { grid-area: chat; min-width: 0; display: flex; flex-direction: column; background-color: var(--bg); background-image: var(--wall); background-size: 360px 360px; }
.chat:focus { outline: none; }
.head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--panel); box-shadow: 0 1px 0 var(--line); }
.head-main { display: flex; align-items: center; gap: 12px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
/* Group photo: Telegram's default look for a group without a photo, initials on the domes' turquoise */
.grp { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(160deg, #6FDCE6, #2A8C9C); color: #FFFFFF; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
.head-title { font-weight: 600; line-height: 1.25; }
.head-sub { color: var(--muted); font-size: 13px; line-height: 18px; transition: color 200ms var(--ease); }
.head-sub.typing { color: var(--link); }
.tag { margin-left: auto; padding: 3px 10px; border-radius: 999px; background: var(--tint); color: var(--muted); font-size: 13px; line-height: 16px; white-space: nowrap; }
.pin { display: flex; gap: 10px; padding: 8px 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); box-shadow: inset 0 1px 0 var(--line); color: inherit; text-decoration: none; font-size: 14px; line-height: 19px; }
.pin::before { content: ""; width: 2px; border-radius: 2px; background: var(--link); flex: none; }
.pin b { display: block; color: var(--link); font-weight: 500; }
.pin span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin > div { min-width: 0; }

.msgs { display: flex; flex-direction: column; gap: 4px; padding-block: 16px 24px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
.svc { align-self: center; max-width: 90%; margin-block: 8px; padding: 3px 10px; border-radius: 999px; background: var(--svc); font-size: 13px; line-height: 18px; text-align: center; }
.m { display: flex; align-items: flex-end; gap: 8px; max-width: min(560px, 92%); scroll-margin-top: 120px; }
.m:not(.cont) + .m { margin-top: 8px; }
.m.cont .ava { visibility: hidden; }
.ava { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--c); color: var(--on-gold); font-size: 15px; font-weight: 700; }
.ava.caesar { background: url(caesar.jpg) center / cover; }
.bub { position: relative; min-width: 0; padding: 7px 12px 6px; border-radius: 14px; background: var(--bubble); }
.m:not(.cont) .bub.tail { border-bottom-left-radius: 0; }
.m:not(.cont) .bub.tail::before { content: ""; position: absolute; left: -8px; bottom: 0; width: 8px; height: 14px; background: var(--bubble); -webkit-mask: radial-gradient(circle at 0 0, transparent 8px, #000 8.5px); mask: radial-gradient(circle at 0 0, transparent 8px, #000 8.5px); }
.nm { color: var(--c); font-size: 14px; line-height: 20px; font-weight: 600; }
.bub p + p, .bub p + .code, .bub .code + p { margin-top: 6px; }
.meta { float: right; margin: 6px 0 -2px 14px; color: var(--muted); font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.rep { display: block; margin: 2px 0 6px; padding: 4px 8px 4px 10px; border-radius: 6px; background: var(--tint); box-shadow: inset 3px 0 0 var(--c-from); font-size: 14px; line-height: 18px; }
.rep b { display: block; color: var(--c-from); font-weight: 600; }
.rep span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.lines { white-space: pre-line; }
.code { border-radius: 8px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.code-h { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 0 12px; color: var(--muted); font-size: 12px; }
.code-h button { padding: 2px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--link); font: inherit; cursor: pointer; transition: background-color 200ms var(--ease); }
.code-h button:hover { background: var(--tint); }
.code pre { margin: 0; padding: 4px 12px 10px; overflow-x: auto; font-family: var(--mono); font-size: 14px; }
.lp { display: grid; margin-top: 8px; padding: 6px 10px; border-radius: 6px; background: rgba(95, 208, 221, 0.08); box-shadow: inset 3px 0 0 var(--link); color: var(--fg); font-size: 14px; line-height: 19px; text-decoration: none; transition: background-color 200ms var(--ease); }
.lp:hover { background: rgba(95, 208, 221, 0.14); }
.lp b { color: var(--link); font-weight: 600; }
.lp span { color: var(--muted); }
.media { margin: 4px -8px 8px; border-radius: 10px; overflow: hidden; }
.shot { margin: 0; padding: 12px 14px; background: #05081A; color: #C9D4EE; font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre; overflow-x: auto; }
.shot .err { color: #FF7B72; }
.photo { display: block; width: 100%; max-width: 300px; height: auto; }
.foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 6px; }
.foot .meta { float: none; margin: 0; }
.reacts { display: flex; flex-wrap: wrap; gap: 6px; }
.reacts span { padding: 1px 8px; border-radius: 999px; background: rgba(95, 208, 221, 0.14); font-size: 13px; line-height: 22px; font-variant-numeric: tabular-nums; }
.stk { position: relative; display: grid; gap: 6px; }
.stk img { display: block; width: 210px; height: auto; }
.stk .meta { position: absolute; right: 4px; top: 76px; float: none; margin: 0; padding: 0 6px; border-radius: 999px; background: var(--svc); color: var(--fg); }
.mwrap { display: grid; gap: 4px; min-width: 0; }
.keys a { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--gold); color: var(--on-gold); font-weight: 700; font-size: 15px; text-decoration: none; transition: background-color 200ms var(--ease), transform 200ms var(--ease); }
.keys a:hover { background: var(--gold-hover); }
.keys a:active { transform: scale(0.98); }

/* Status line: shown only after the script marks a message as thinking */
.st { display: none; align-items: center; gap: 8px; color: var(--muted); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: blink 1100ms var(--ease) infinite; }
.dots i:nth-child(2) { animation-delay: 180ms; }
.dots i:nth-child(3) { animation-delay: 360ms; }
@keyframes blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.m.thinking .st { display: flex; }
.m.thinking .ans { display: none; }
.m.done .ans { animation: arrive 360ms var(--ease); }
@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }
.m, .svc { transition: opacity 420ms var(--ease), transform 420ms var(--ease); }
.m.pending, .svc.pending { opacity: 0; transform: translateY(16px); }

.note { padding: 0 16px 24px; color: var(--muted); font-size: 13px; line-height: 18px; text-align: center; text-wrap: balance; }
.join { position: sticky; bottom: 0; z-index: 5; margin-top: auto; display: grid; padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); background: var(--panel); box-shadow: 0 -1px 0 var(--line); }
@media (min-width: 640px) { .msgs, .join { padding-inline: 24px; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dots i { animation: none; opacity: 0.6; }
  .m, .svc, .btn, .keys a, .skip { transition: none; }
}
