/* Telegram-style chat used by every bot simulator */
.tg {
  --tg-bg: #0e1621;
  --tg-head: #17212b;
  --tg-in: #182533;
  --tg-out: #2b5278;
  --tg-text: #f5f5f5;
  --tg-meta: #6d8299;
  --tg-link: #6ab3f3;
  --tg-btn: #22303f;
  --tg-btn-text: #e9eef4;
  --tg-input: #17212b;
  --tg-pattern: rgba(255, 255, 255, .025);
  position: relative;
  display: flex; flex-direction: column;
  height: 100%;
  border-radius: 44px; overflow: hidden;
  background: var(--tg-bg);
  color: var(--tg-text);
  font: 400 15px/1.42 -apple-system, "Segoe UI", Roboto, "Onest", system-ui, sans-serif;
  isolation: isolate;
}

/* ---- real phone shell (desktop / tablet) ---- */
.tg-device {
  --dev-h: min(82vh, 780px);
  position: relative;
  height: var(--dev-h); min-height: 560px;
  aspect-ratio: 392 / 832;            /* modern 19.5:9 phone incl. bezel */
  max-width: 100%;
  margin: 0 auto;
  padding: 11px;
  border-radius: 55px;
  background: #050506;
  box-shadow:
    0 0 0 1.5px #5d6168,               /* polished metal rim */
    0 0 0 3.5px #24262a,
    0 0 0 4.5px #6e737b,
    inset 0 0 0 1px #1c1d20,
    0 50px 90px -35px rgba(0, 0, 0, .75),
    0 18px 40px -20px rgba(0, 0, 0, .5);
}
.tg-device::before, .tg-device::after {   /* side buttons */
  content: ""; position: absolute; width: 4px; border-radius: 2px;
  background: linear-gradient(90deg, #3b3e44, #6e737b 50%, #3b3e44);
}
.tg-device::before { left: -8px; top: 18%; height: 7%; box-shadow: 0 calc(var(--dev-h) * .1) 0 #4d5157; }  /* volume up + down */
.tg-device::after  { right: -8px; top: 26%; height: 10%; }                                                   /* power */

.tg-status {
  position: relative; z-index: 3; flex: none;
  height: 46px; padding: 0 30px 0 34px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--tg-head); color: var(--tg-text);
  font: 600 15px/1 -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  letter-spacing: -.01em;
}
.tg-island { position: absolute; left: 50%; top: 11px; transform: translateX(-50%); width: 31%; max-width: 118px; height: 30px; border-radius: 20px; background: #000; }
.tg-island::after { content: ""; position: absolute; right: 11px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #2a3a55 0 25%, #0b0f18 60%); }
.tg-sicons { display: flex; align-items: center; gap: 5px; }
.tg-sicons svg { height: 11px; width: auto; fill: currentColor; }
.tg-batt { position: relative; width: 24px; height: 11.5px; border-radius: 3.5px; border: 1.3px solid currentColor; opacity: .9; }
.tg-batt::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; border-radius: 0 1px 1px 0; background: currentColor; }
.tg-batt i { position: absolute; inset: 1.5px; right: 22%; border-radius: 1.5px; background: currentColor; }
.tg-homebar { position: absolute; z-index: 4; left: 50%; bottom: 7px; transform: translateX(-50%); width: 36%; height: 5px; border-radius: 3px; background: var(--tg-text); opacity: .55; pointer-events: none; }
.tg .tg-bottom { padding-bottom: 18px; }

/* on a real phone the page itself is the phone: drop the shell, use the full width */
@media (max-width: 600px) {
  .tg-device { height: min(80svh, 720px); min-height: 480px; aspect-ratio: auto; width: 100%; padding: 0; border-radius: 18px; background: none; box-shadow: 0 20px 50px -30px rgba(0, 0, 0, .6); }
  .tg-device::before, .tg-device::after, .tg-status, .tg-homebar { display: none; }
  .tg { border-radius: 18px; border: 1px solid var(--line); }
  .tg .tg-bottom { padding-bottom: 0; }
}
:root[data-theme="light"] .tg {
  --tg-bg: #c9dcb4;
  --tg-head: #ffffff;
  --tg-in: #ffffff;
  --tg-out: #e1fec6;
  --tg-text: #111111;
  --tg-meta: #6b8a5f;
  --tg-link: #2a7ab9;
  --tg-btn: rgba(46, 86, 30, .28);
  --tg-btn-text: #ffffff;
  --tg-input: #ffffff;
  --tg-pattern: rgba(40, 80, 30, .07);
  box-shadow: 0 30px 80px -50px rgba(20, 40, 60, .5);
}
.tg-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--tg-head); border-bottom: 1px solid rgba(0, 0, 0, .25); z-index: 2; }
.tg-ava { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; background: linear-gradient(140deg, #5aa7e6, #2b6aa8); color: #fff; flex: none; }
.tg-title { min-width: 0; flex: 1; }
.tg-title b { display: block; font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-title small { display: block; color: var(--tg-meta); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-theme="light"] .tg-title small { color: #7a8a99; }
.tg-reset { border: 0; background: none; color: var(--tg-meta); cursor: pointer; padding: 6px; border-radius: 50%; }
.tg-reset:hover { color: var(--tg-text); }
.tg-reset svg { width: 20px; height: 20px; display: block; }
.tg-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 10px 8px;
  display: flex; flex-direction: column; gap: 6px;
  background-color: var(--tg-bg);
  background-image: radial-gradient(var(--tg-pattern) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
  scrollbar-width: thin;
}
.tg-msg { display: flex; flex-direction: column; max-width: 88%; animation: tgIn .22s ease-out; }
.tg-msg.bot { align-self: flex-start; }
.tg-msg.me { align-self: flex-end; align-items: flex-end; }
@keyframes tgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tg-bubble {
  position: relative; padding: 7px 11px 6px; border-radius: 14px; background: var(--tg-in);
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}
.tg-msg.bot .tg-bubble { border-bottom-left-radius: 5px; }
.tg-msg.me .tg-bubble { background: var(--tg-out); border-bottom-right-radius: 5px; }
.tg-bubble a { color: var(--tg-link); }
.tg-bubble code { font-family: var(--mono); font-size: 13px; background: rgba(0, 0, 0, .18); padding: 1px 4px; border-radius: 4px; }
:root[data-theme="light"] .tg-bubble code { background: rgba(0, 0, 0, .06); }
.tg-bubble pre { margin: 4px 0; white-space: pre-wrap; font-size: 13px; }
.tg-bubble u { text-decoration-thickness: 1px; }
.tg-time { float: right; margin: 6px 0 -4px 10px; font-size: 11.5px; color: var(--tg-meta); user-select: none; }
.tg-msg.me .tg-time { color: #7fa4c8; }
:root[data-theme="light"] .tg-msg.me .tg-time { color: #5aa553; }
.tg-react { position: absolute; bottom: -10px; left: 8px; background: var(--tg-in); border: 2px solid var(--tg-bg); border-radius: 999px; font-size: 13px; padding: 0 5px; line-height: 20px; }
.tg-msg.me .tg-react { left: auto; right: 8px; background: var(--tg-out); }
.tg-msg.has-react { margin-bottom: 10px; }
.tg-ikb { display: grid; gap: 4px; margin-top: 4px; width: 100%; min-width: 220px; }
.tg-ikb-row { display: grid; gap: 4px; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tg-ikb button, .tg-ikb a {
  border: 0; border-radius: 8px; background: var(--tg-btn); color: var(--tg-btn-text);
  padding: 8px 6px; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; text-align: center;
  backdrop-filter: blur(6px); line-height: 1.25;
}
.tg-ikb button:hover:not(:disabled), .tg-ikb a:hover { filter: brightness(1.18); }
.tg-ikb button:disabled { opacity: .55; cursor: default; }
.tg-note { align-self: center; background: rgba(0, 0, 0, .3); color: #fff; border-radius: 999px; padding: 3px 12px; font-size: 13px; margin: 6px 0; text-align: center; max-width: 92%; }
:root[data-theme="light"] .tg-note { background: rgba(60, 90, 50, .45); }
.tg-typing .tg-bubble { padding: 10px 14px; }
.tg-dots { display: inline-flex; gap: 4px; }
.tg-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tg-meta); animation: tgDot 1.1s infinite; }
.tg-dots i:nth-child(2) { animation-delay: .15s; }
.tg-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes tgDot { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.tg-media { display: block; border-radius: 10px; margin: -3px -7px 6px; max-width: calc(100% + 14px); width: 280px; background: rgba(0, 0, 0, .2); }
.tg-loc { width: 240px; max-width: calc(100% + 14px); height: 130px; border-radius: 10px; margin: -3px -7px 6px; position: relative; overflow: hidden;
  background-color: #e6eadf;
  background-image: linear-gradient(90deg, transparent 47%, #fff 47%, #fff 53%, transparent 53%), linear-gradient(0deg, transparent 30%, #fff 30%, #fff 35%, transparent 35%), linear-gradient(28deg, transparent 62%, #f6d78a 62%, #f6d78a 66%, transparent 66%), radial-gradient(circle at 78% 26%, #b9d8a4 0 22px, transparent 23px);
}
.tg-loc::after { content: "📍"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -85%); font-size: 30px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.tg-doc { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.tg-doc-ico { width: 42px; height: 42px; border-radius: 50%; background: #4fae4e; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.tg-doc small { display: block; color: var(--tg-meta); }
.tg-bottom { background: var(--tg-input); z-index: 2; }
.tg-rkb { display: grid; gap: 5px; padding: 6px; background: var(--tg-head); border-top: 1px solid rgba(0, 0, 0, .2); max-height: 42%; overflow: auto; }
.tg-rkb[hidden] { display: none; }
.tg-rkb-row { display: grid; gap: 5px; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tg-rkb button { border: 0; border-radius: 8px; padding: 10px 6px; background: var(--tg-btn); color: var(--tg-btn-text); cursor: pointer; font-size: 14px; line-height: 1.2; }
:root[data-theme="light"] .tg-rkb button { background: #f1f3f5; color: #222; box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.tg-rkb button:hover { filter: brightness(1.15); }
.tg-form { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-top: 1px solid rgba(0, 0, 0, .25); }
.tg-form input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--tg-text); padding: 8px 4px; outline: none; font-size: 15px; }
.tg-form input::placeholder { color: var(--tg-meta); }
.tg-form button { border: 0; background: none; color: #5ca8eb; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.tg-form button:hover { background: rgba(92, 168, 235, .12); }
.tg-form button svg { width: 22px; height: 22px; }
.tg-form .tg-kbtoggle { color: var(--tg-meta); }
.tg-toast {
  position: absolute; left: 50%; top: 70px; transform: translate(-50%, -10px); opacity: 0; pointer-events: none;
  background: rgba(20, 28, 38, .94); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: 86%; text-align: center; transition: opacity .2s, transform .2s; z-index: 5;
}
.tg-toast.show { opacity: 1; transform: translate(-50%, 0); }
.tg-bubble.flash { animation: tgFlash 1s ease-out; }
@keyframes tgFlash { 0% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: 0 1px 1px rgba(0,0,0,.18); } }

/* multi-role simulators: tabs on phones, side-by-side on wide screens */
.roles-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.roles-tabs button { position: relative; flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 9px 12px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.roles-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.roles-tabs .badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; border-radius: 999px; background: var(--gold); color: #1d1300; font-size: 12px; display: grid; place-items: center; padding: 0 5px; }
.roles-tabs .badge[hidden] { display: none; }
.roles-panes > [data-pane] { display: none; }
.roles-panes > [data-pane].active { display: block; }
.pane-label { display: none; font-weight: 600; margin: 0 0 8px 4px; color: var(--muted); font-size: 14px; }
@media (min-width: 1120px) {
  .roles-wide .roles-tabs { display: none; }
  .roles-wide .roles-panes { display: grid; grid-template-columns: repeat(var(--panes, 2), minmax(0, 1fr)); gap: 18px; }
  .roles-wide .roles-panes > [data-pane] { display: block; }
  .roles-wide .pane-label { display: block; }
  .roles-wide .tg-device { --dev-h: min(78vh, 700px); }
}
.tg-form .tg-kbtoggle[hidden] { display: none; }
/* real phones hide the scrollbar */
@media (min-width: 601px) {
  .tg-device .tg-log { scrollbar-width: none; }
  .tg-device .tg-log::-webkit-scrollbar { display: none; }
}
