/* /call/ (T-042). A file, not inline: the page's CSP is style-src 'self' (web/conf/default.conf). Colours as on /u/
   (u.html); the call screen is dark in both themes, like every phone's call screen. */

:root { --fg: #1d1d1f; --muted: #6e6e73; --bg: #fff; --card: #f5f5f7; --line: #d2d2d7; --accent: #2a7de1;
        --on-accent: #fff; --danger: #e5383b; --ok: #34c759; }
@media (prefers-color-scheme: dark) {
  :root { --fg: #f2f2f2; --muted: #a1a1a6; --bg: #111; --card: #1c1c1e; --line: #3a3a3c; --accent: #4c9bff; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg);
       background: var(--bg); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

.page { min-height: 100%; }
.loading { text-align: center; color: var(--muted); padding-top: 30vh; margin: 0; }
.noscript { text-align: center; padding: 30vh 16px 0; color: var(--muted); }

/* --- cards: start, message, ended -------------------------------------------------------------------------- */
.card { max-width: 420px; margin: 0 auto; padding: 8vh 16px 32px; text-align: center; }
.avatar { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; display: flex; align-items: center;
          justify-content: center; font-size: 40px; font-weight: 600; color: var(--on-accent); background: var(--accent);
          user-select: none; }
.avatar.big { width: 120px; height: 120px; font-size: 52px; margin-bottom: 12px; }
.who, .title { font-size: 24px; margin: 0 0 4px; overflow-wrap: anywhere; }
.mxid { color: var(--muted); margin: 0 0 4px; overflow-wrap: anywhere; font-size: 14px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }
.text { margin: 8px 0 16px; overflow-wrap: anywhere; }
.muted { color: var(--muted); margin: 0 0 24px; }
form { text-align: left; margin: 0 0 16px; }
.label { display: block; font-weight: 600; margin: 0 0 6px; }
.input { display: block; width: 100%; padding: 12px 14px; font: inherit; color: var(--fg); background: var(--card);
         border: 1px solid var(--line); border-radius: 12px; outline: none; }
.input:focus { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.btn { display: block; width: 100%; padding: 14px 16px; margin: 0 0 12px; border: 0; border-radius: 12px;
       font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.secondary { background: var(--card); color: var(--fg); }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--danger); font-size: 15px; margin: 4px 0 0; }
.note { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.actions { margin-top: 24px; }

/* --- the call screen ----------------------------------------------------------------------------------------- */
.call { position: fixed; inset: 0; background: #0b0b0c; color: #f2f2f2; overflow: hidden; }
.stage { position: absolute; inset: 0; }
.remote { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
/* T-074: the other side's picture is shown WHOLE (contain) — `cover` cut a 9:16 phone picture into a "super zoom" on a
   landscape screen. The margins are a blurred, darkened copy of the same frame (a second <video> of the same track: no
   second decoding, no external resource); a screen share keeps plain black margins (a blurred document is noise). */
.remote video { position: relative; width: 100%; height: 100%; object-fit: contain; background: #000; }
.remote.camera video { background: transparent; } /* else the picture's own black box hides the backdrop */
.remote video.backdrop { position: absolute; inset: 0; object-fit: cover; background: #000; transform: scale(1.12);
                         filter: blur(28px) brightness(.5); pointer-events: none; }
@media (prefers-reduced-transparency: reduce) { .remote video.backdrop { display: none; } }
.peer { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
        padding: 0 16px 120px; text-align: center; }
.peer-name { font-size: 26px; font-weight: 600; margin: 0 0 4px; overflow-wrap: anywhere; }
.status { color: #a1a1a6; margin: 0; font-variant-numeric: tabular-nums; }
.self { position: absolute; right: 12px; bottom: 112px; width: 28vw; max-width: 200px; aspect-ratio: 3 / 4;
        border-radius: 12px; overflow: hidden; background: #222; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
.self video { width: 100%; height: 100%; object-fit: cover; }
.self.mirror video { transform: scaleX(-1); }
@media (min-width: 700px) { .self { aspect-ratio: 4 / 3; width: 22vw; max-width: 260px; } }

.topbar { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
          padding: max(12px, env(safe-area-inset-top)) 16px 24px;
          background: linear-gradient(rgba(0, 0, 0, .6), rgba(0, 0, 0, 0)); }
.top-name { font-weight: 600; overflow-wrap: anywhere; }
.top-status { color: #c7c7cc; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; color: #c7c7cc; border: 1px solid rgba(255, 255, 255, .25); border-radius: 999px; padding: 1px 8px; }
.call.talking .peer .status { display: none; }
.call.has-video .peer { display: none; }

.banner { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); max-width: calc(100% - 32px);
          display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 12px;
          background: rgba(40, 40, 42, .92); color: #f2f2f2; font-size: 14px; }
.link { border: 0; background: none; color: #4c9bff; font: inherit; font-weight: 600; padding: 0; cursor: pointer; }

.controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 14px;
            padding: 20px 12px max(20px, env(safe-area-inset-bottom));
            background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .65)); }
.round { width: 56px; height: 56px; flex: 0 0 auto; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
         display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .16); color: #fff; }
.round:hover { background: rgba(255, 255, 255, .26); }
.round:disabled { opacity: .4; cursor: default; }
.round svg { width: 26px; height: 26px; fill: currentColor; }
.round svg .stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round svg .slash { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; display: none; }
.round.off { background: #f2f2f2; color: #111; }
.round.off svg .slash { display: inline; }
.round.active { background: var(--accent); }
.round.hangup { background: var(--danger); }
.round.hangup:hover { background: #c92a2d; }
.round.hangup svg { width: 30px; height: 30px; }
@media (max-width: 360px) { .round { width: 50px; height: 50px; } .controls { gap: 10px; } }

/* --- T-108: the bars fade away over video (lib/chrome.mjs decides; /app/ uses this file too) ------------------------ */
/* Shown: visibility flips back at once, so a Tab pressed to bring them back already lands on a button. Hidden: the
   fade first, THEN visibility (it is what keeps hidden buttons out of clicks and of the Tab order); pointer-events at
   once, so a tap on a fading button reaches the video and simply brings the bars back. The self-view stays. */
.call .controls, .call .topbar { transition: opacity .2s ease, visibility 0s linear 0s; }
.call.chrome-hidden .controls, .call.chrome-hidden .topbar { opacity: 0; visibility: hidden; pointer-events: none;
                                                             transition: opacity .2s ease, visibility 0s linear .2s; }
.call.chrome-hidden .stage { cursor: none; }
@media (prefers-reduced-motion: reduce) {
  .call .controls, .call .topbar, .call.chrome-hidden .controls, .call.chrome-hidden .topbar { transition: none; }
}

/* --- T-070: the grid of a call with two or more others (GROUP-CALLS §6) ----------------------------------------- */
/* Two columns; up to six tiles fit without scrolling (3 rows), more scroll. The controls and the top bar float over
   it, as over the full-screen video. */
.top-count { color: #c7c7cc; font-size: 14px; }
.call.grid-mode .peer, .call.grid-mode .remote { display: none; }
.grid { position: absolute; left: 0; right: 0; top: 56px; bottom: 96px; padding: 8px; display: grid; gap: 8px;
        grid-template-columns: 1fr 1fr; overflow-y: auto; align-content: start; }
.grid.n2 { grid-template-columns: 1fr; grid-auto-rows: calc((100% - 8px) / 2); }
.grid.n4 { grid-auto-rows: calc((100% - 8px) / 2); }
.grid.n6, .grid.many { grid-auto-rows: calc((100% - 16px) / 3); }
@media (min-width: 700px) and (orientation: landscape) {
  .grid.n2 { grid-template-columns: 1fr 1fr; grid-auto-rows: 100%; }
  .grid.n6, .grid.many { grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: calc((100% - 8px) / 2); }
}
.tile { position: relative; min-height: 0; border-radius: 14px; overflow: hidden; background: #1f1f22;
        display: flex; align-items: center; justify-content: center; border: 2px solid transparent; }
.tile.speaking { border-color: var(--ok); }
.tile-media { position: absolute; inset: 0; }
/* A tile crops (cover) only when the picture's shape is close to the tile's (≤ 30 % off, group.mjs videoFit): it then
   fills the tile like in Meet/Element Call and loses only a strip at the edges. A phone's 9:16 picture in a wide tile
   would lose most of the face (the T-074 "super zoom") — such a picture, and every screen share, is shown whole. */
.tile-media video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile-media.cover video { object-fit: cover; }
.tile.has-video .tile-avatar, .tile.has-video .tile-status { display: none; }
.tile-avatar { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
               font-size: 28px; font-weight: 600; color: var(--on-accent); background: var(--accent); user-select: none; }
.tile-status { position: absolute; left: 0; right: 0; bottom: 34px; margin: 0; text-align: center; font-size: 13px; color: #a1a1a6; }
.tile-label { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); display: flex; align-items: center; gap: 4px;
              padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .55); font-size: 13px; }
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mic { width: 14px; height: 14px; flex: none; fill: none; stroke: #ff6b6b; stroke-width: 2.2; stroke-linecap: round; }

/* --- T-071: recent calls (lib/calls-view.mjs) — /app/'s "Calls" tab and a remembered guest's list here ---------- */
.cl-list { list-style: none; margin: 0; padding: 0; }
.cl-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; text-align: left; }
.cl-avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
             font-weight: 600; font-size: 18px; color: var(--on-accent); background: var(--accent); user-select: none; }
.cl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-top, .cl-sub-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cl-name { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl-tag { flex: none; font-size: 12px; line-height: 16px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.cl-sub { flex: 1 1 8em; min-width: 0; color: var(--muted); font-size: 14px; line-height: 1.3; overflow-wrap: break-word; }
.cl-time { flex: none; margin-left: auto; padding-left: 6px; font-size: 13px; color: var(--muted); }
.cl-sub-line { align-items: flex-start; flex-wrap: wrap; row-gap: 2px; }
.cl-sub-line .cl-arrow { margin-top: 2px; }
.cl-arrow { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.4; stroke-linecap: round;
            stroke-linejoin: round; }
.cl-row.missed .cl-name, .cl-row.missed .cl-sub { color: var(--danger); }
.cl-row.missed .cl-arrow { stroke: var(--danger); }
.cl-row.gone .cl-avatar { background: var(--muted); }
.cl-actions { display: flex; flex: none; gap: 0; }
.cl-btn { width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; padding: 0; cursor: pointer; display: flex;
          align-items: center; justify-content: center; background: none; color: var(--accent); }
.cl-btn:hover { background: var(--card); }
.cl-btn:disabled { opacity: .35; cursor: default; background: none; }
.cl-btn svg { width: 22px; height: 22px; fill: currentColor; }
@media (max-width: 360px) { .cl-row { gap: 8px; padding: 8px 10px; } .cl-btn { width: 34px; height: 34px; } }

/* --- T-071: the remembered guest — its calls under the start card, the incoming call, the sign-in offer ---------- */
.recent { max-width: 420px; margin: 0 auto; padding: 0 0 32px; }
.recent-title { font-size: 18px; margin: 8px 16px 4px; }
.recent .note { margin: 4px 16px 8px; }
.recent .btn { width: auto; display: inline-block; margin: 8px 16px; padding: 8px 14px; font-size: 14px; }
.offer { margin: 20px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--card); text-align: left; }
.offer .text { margin: 0 0 10px; font-size: 15px; }
.offer .btn { margin: 0; }
.incoming { position: fixed; inset: 0; background: #0b0b0c; color: #f2f2f2; display: flex; flex-direction: column;
            justify-content: space-between; padding: 12vh 16px max(32px, env(safe-area-inset-bottom)); text-align: center; z-index: 10; }
.in-peer .peer-name { font-size: 28px; font-weight: 600; margin: 8px 0 4px; overflow-wrap: anywhere; }
.in-kind { color: #c7c7cc; margin: 0; }
.in-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.pill { min-width: 140px; padding: 16px 24px; border: 0; border-radius: 999px; font: inherit; font-weight: 600; color: #fff;
        cursor: pointer; }
.pill.answer { background: var(--ok); }
.pill.decline { background: var(--danger); }
.in-peer .avatar.big { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 18px rgba(76, 155, 255, .18); } }
@media (prefers-reduced-motion: reduce) { .in-peer .avatar.big { animation: none; } }
