  /* The app's own colours (Theme.swift), as on the call page. */
  :root { --bg: #090d15; --fg: #f2f6fb; --muted: #8d9bb0; --accent: #00d2ff; --accent2: #0284c7;
    --mine: linear-gradient(135deg, #0aa6d8, #0369a1); --theirs: rgba(255,255,255,.08); --rim: rgba(255,255,255,.10);
    --bar: rgba(9,13,21,.82); --end: #f43f5e;
    /* Telegram's full-screen Mini App draws its Close and ⋯ over the page and
       says how far down they reach; both are zero in a full-size Mini App and
       in a browser, where the device's own inset applies (24 October 2026). */
    --inset-top: calc(max(env(safe-area-inset-top), var(--tg-safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
    --inset-bottom: calc(max(env(safe-area-inset-bottom), var(--tg-safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px)); }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden;
    font: 16px/1.35 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
  body { background: radial-gradient(120% 60% at 50% 0%, rgba(0,210,255,.12), transparent 60%), var(--bg); }
  .screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
  .hidden { display: none !important; }
  header { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--inset-top)) 16px 10px;
    background: var(--bar); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--rim); }
  header h1 { margin: 0; font-size: 22px; font-weight: 700; flex: 1; }
  header .who { flex: 1; min-width: 0; }
  header .who b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  header .who small { color: var(--muted); font-size: 13px; }
  .icon { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rim); background: rgba(255,255,255,.06);
    color: var(--fg); display: grid; place-items: center; padding: 0; cursor: pointer; flex: none; }
  .icon:active { transform: scale(.92); }
  .icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .avatar { width: 50px; height: 50px; border-radius: 50%; flex: none; display: grid; place-items: center;
    font-size: 20px; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
  header .avatar { width: 38px; height: 38px; font-size: 16px; }
  .row { display: flex; gap: 12px; align-items: center; padding: 10px 16px; cursor: pointer; }
  .row:active { background: rgba(255,255,255,.05); }
  .row .text { flex: 1; min-width: 0; border-bottom: 1px solid var(--rim); padding-bottom: 10px; }
  .row .top { display: flex; gap: 8px; align-items: baseline; }
  .row .name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .row .time { color: var(--muted); font-size: 13px; flex: none; }
  .row .last { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
  .empty { color: var(--muted); text-align: center; padding: 48px 24px; }
  #messages { padding: 10px 10px 4px; display: flex; flex-direction: column; gap: 4px; }
  .day { align-self: center; color: var(--muted); font-size: 13px; background: rgba(255,255,255,.06); padding: 3px 10px;
    border-radius: 999px; margin: 8px 0; }
  .bubble { max-width: 80%; padding: 7px 11px 6px; border-radius: 18px; background: var(--theirs); align-self: flex-start;
    border: 1px solid var(--rim); word-wrap: break-word; white-space: pre-wrap; position: relative; }
  .bubble.mine { align-self: flex-end; background: var(--mine); border-color: transparent; }
  .bubble .orig { color: var(--muted); font-size: 14px; border-top: 1px solid var(--rim); margin-top: 5px; padding-top: 4px; }
  .bubble.mine .orig { color: rgba(255,255,255,.75); border-color: rgba(255,255,255,.2); }
  .bubble .meta { float: right; font-size: 12px; color: var(--muted); margin: 6px 0 0 10px; }
  .bubble.mine .meta { color: rgba(255,255,255,.75); }
  .bubble .sender { font-size: 13px; font-weight: 600; color: var(--accent); }
  .bubble img { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 4px; }
  .bubble .note { color: var(--muted); font-style: italic; }
  .system { align-self: center; color: var(--muted); font-size: 13px; margin: 4px 0; }
  .voice { display: flex; align-items: center; gap: 10px; min-width: 180px; }
  .voice button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff;
    display: grid; place-items: center; padding: 0; cursor: pointer; flex: none; }
  .voice button svg { width: 16px; height: 16px; fill: currentColor; }
  .voice .bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); overflow: hidden; }
  .voice .bar i { display: block; height: 100%; width: 0; background: var(--accent); }
  .voice small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  footer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + var(--inset-bottom));
    background: var(--bar); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--rim); }
  textarea { flex: 1; resize: none; max-height: 140px; min-height: 40px; padding: 9px 14px; border-radius: 20px;
    border: 1px solid var(--rim); background: rgba(255,255,255,.06); color: var(--fg); font: inherit; outline: none; }
  textarea:focus { border-color: rgba(0,210,255,.5); }
  #send { background: var(--accent); color: var(--bg); border: 0; }
  #send:disabled, #mic:disabled { opacity: .4; }
  #mic.on { background: var(--end); border-color: transparent; color: #fff; }
  #recording { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 14px; color: var(--fg);
    font-variant-numeric: tabular-nums; }
  #recording i { width: 10px; height: 10px; border-radius: 50%; background: var(--end); animation: blink 1s infinite; }
  @keyframes blink { 50% { opacity: .2; } }
  .toast { position: fixed; left: 50%; top: calc(64px + var(--inset-top)); transform: translateX(-50%);
    background: rgba(9,13,21,.9); border: 1px solid var(--rim); padding: 8px 14px; border-radius: 999px;
    font-size: 14px; z-index: 5; transition: opacity .3s; max-width: 90vw; text-align: center; }
  .toast:empty { opacity: 0; }
