/* nobloat/call on top of ui.css: the start page, prejoin, the call (dark in both themes), panels, menus, stats. */
/* --brand comes from the page (Brand.Color in web.go) */
:root { --stage: #121315; --tile: #26282c; --tile-fg: #e5e5e4; }
[data-design="paper"] { --stage: #1a1916; --tile: #2a2824; --tile-fg: #e8e3d6; }
.mark text { fill: var(--accent); }

/* ---- start page and error page -------------------------------------------------------------- */
body.center:has(#start) { max-width: 40rem; }
.tagline { text-align: center; margin: 0 0 1.4rem; }
.start { display: grid; justify-items: center; gap: .9rem; }
.start .link { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: var(--r); padding: .3rem .3rem .3rem .7rem; max-width: 100%; flex-wrap: wrap; justify-content: center; }
.start .link span { overflow-wrap: anywhere; }
.start #join { min-width: 12rem; justify-content: center; }
.start .room { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .9em; }
.start .room input { width: 15rem; }
.start .warn { color: var(--yellow); background: none; display: block; padding: 0; border: 0; }
.start .warn::before { display: none; }
body.center > main + .foot, main .foot { margin-top: 3rem; padding-top: .6rem; border-top: 1px solid var(--line); font-size: .78em; color: var(--muted); display: flex; flex-wrap: wrap; gap: .3rem .8rem; justify-content: center; align-items: center; }
.end { text-align: center; display: grid; gap: .6rem; }

/* ---- the room page fills the window ---------------------------------------------------------- */
body.callpage { max-width: none; padding: 0; margin: 0; height: 100dvh; }
.callpage .logo { text-decoration: none; font-weight: bold; }
.callpage .logo .g { color: var(--grey); } .callpage .logo .c { color: var(--accent); }
.nojs { padding: 2rem; text-align: center; }

/* prejoin */
.pre { max-width: 64rem; margin: 0 auto; padding: 1rem 16px 2rem; }
.pre header { gap: .6rem; margin-bottom: 1rem; }
.pre header h1 { font-weight: bold; }
.pre-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.pre .form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; }
.pre .form > * { grid-column: 1; margin: 0; }
.pre .form label { display: grid; gap: .25rem; color: var(--muted); font-size: .9em; }
.pre .form .row { display: flex; gap: .4rem; align-items: center; }
.pre .form input, .pre .form select { flex: 1; min-width: 0; color: var(--fg); }
.pre #go { min-width: 10rem; }
.cam { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); background: var(--tile); overflow: hidden; color: var(--tile-fg); }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam .ctl { position: absolute; bottom: .7rem; left: 50%; translate: -50%; display: flex; gap: .6rem; }
.mirror { transform: scaleX(-1); }
.lvl { display: flex; gap: 2px; align-items: end; height: 1.1rem; width: 1.6rem; flex: none !important; }
.lvl i { flex: 1; height: 15%; background: var(--green); border-radius: 1px; transition: height .12s; }
.av { position: absolute; inset: 0; margin: auto; width: 4rem; height: 4rem; border-radius: 50%; display: grid; place-items: center; font-weight: bold; font-size: 1.3rem; color: #fff; background: #6b7280; }

/* round controls on the dark stage */
.round.tgl, .round.leave { width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 1px solid #ffffff30; background: #ffffff14; color: #fff; font-size: 1.15rem; position: relative; }
.round.tgl:hover { background: #ffffff26; color: #fff; }
.round.tgl.off { background: var(--red); border-color: var(--red); }
.round.tgl[aria-pressed="true"]:is(#b-share, #b-chat, #b-people) { background: var(--tile-fg); color: var(--stage); }
.round.leave { background: var(--red); border-color: var(--red); width: 3.6rem; border-radius: 1.4rem; }
.round.leave:hover { filter: brightness(1.1); color: #fff; }
.cam .round.tgl { background: #00000066; }

/* ---- the call --------------------------------------------------------------------------------- */
.call { position: relative; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; background: var(--stage); color: var(--tile-fg); color-scheme: dark; }
.lostbar { background: color-mix(in srgb, var(--yellow) 25%, var(--stage)); padding: .3rem .8rem; font-size: .85em; text-align: center; }
.bar-top { display: flex; align-items: center; gap: .6rem; padding: .45rem .8rem; font-size: .9em; border-bottom: 1px solid #ffffff14; grid-row: 2; }
.bar-top .sp { flex: 1; }
.ghost { background: transparent; color: var(--tile-fg); border: 1px solid #ffffff30; border-radius: var(--r); padding: .15rem .6rem; display: inline-flex; gap: .4rem; align-items: center; }
.body { grid-row: 3; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); min-height: 0; }
.body.with-side { grid-template-columns: minmax(0, 1fr) 19rem; }
.body.staged { grid-template-rows: minmax(0, 1fr) 6.5rem; }
.body.staged.with-side { grid-template-columns: minmax(0, 1fr) 19rem; }
.stage { grid-column: 1; grid-row: 1; padding: .5rem .5rem 0; min-height: 0; display: grid; }
.stage > .vtile { height: 100%; }
.stage .selfshare { display: grid; place-items: center; align-content: center; gap: .5rem; border: 1px dashed #ffffff30; border-radius: var(--r-lg); color: #c9c9c9; }
.stage .selfshare button { background: none; color: inherit; border: 1px solid #ffffff40; }
.vtiles { grid-column: 1; display: grid; gap: .5rem; padding: .5rem; min-height: 0; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.body.staged .vtiles { grid-row: 2; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 9.5rem; grid-template-rows: minmax(0, 1fr); overflow-x: auto; }
.vtile .wait { display: none; position: absolute; left: 50%; top: .6rem; translate: -50%; background: #000000a0; border-radius: 4px; padding: .1rem .5rem; font-size: .85em; white-space: nowrap; }
.vtiles.alone .vtile.self .wait { display: block; }
.vtile { position: relative; border-radius: var(--r-lg); background: var(--tile); overflow: hidden; min-height: 0; outline: 2px solid transparent; outline-offset: -2px; cursor: pointer; }
.vtile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile.scr video, .stage .vtile video { object-fit: contain; background: #000; }
.vtile .av { display: none; }
.vtile.nocam .av { display: grid; }
.vtile.nocam video { opacity: 0; }
.vtile.speak { outline-color: var(--accent); }
.vtile .nm { position: absolute; left: .4rem; bottom: .4rem; background: #000000a0; border-radius: 4px; padding: 0 .4rem; font-size: .8em; display: flex; gap: .3rem; align-items: center; max-width: calc(100% - .8rem); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vtile .nm i { color: var(--red); }
.vtile .sig { position: absolute; left: .4rem; top: .4rem; background: #000000a0; border: 0; border-radius: 4px; padding: .1rem .35rem; color: #fff; display: flex; gap: .3rem; align-items: center; font-size: .75em; min-height: 0; }
.vtile .sig.weak { color: var(--yellow); } .vtile .sig.bad { color: var(--red); }
.vtile .more { position: absolute; right: .4rem; top: .4rem; background: #000000a0; border: 0; border-radius: 4px; padding: .1rem .35rem; color: #fff; opacity: 0; min-height: 0; }
.vtile:hover .more, .vtile .more:focus-visible { opacity: 1; }
.vtile .nerd { display: none; position: absolute; left: 2.6rem; top: .4rem; right: 2.4rem; background: #000000b0; border-radius: 4px; padding: .1rem .4rem; font-size: .72em; }
.call.nerd .vtile:not(.self):not(.scr) .nerd:not(:empty) { display: block; }
.vtile .lost { display: none; position: absolute; right: .4rem; bottom: .4rem; background: #000000a0; border-radius: 4px; padding: 0 .4rem; font-size: .75em; }
.vtile.failed .lost { display: block; }
.vtile .lost button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; min-height: 0; }

.bar-bot { grid-row: 4; display: flex; justify-content: center; gap: .6rem; padding: .55rem; border-top: 1px solid #ffffff14; position: relative; }
.bar-bot .keyhint { position: absolute; right: .8rem; top: 50%; translate: 0 -50%; font-size: .72rem; color: #9c9da0; }
.badge { position: absolute; top: -.3rem; right: -.3rem; background: var(--accent); color: #fff; border-radius: 999px; font-size: .65rem; padding: 0 .35rem; line-height: 1.4; }
@media (hover: none) { .bar-bot .keyhint, .callpage kbd { display: none; } }

/* side panel: chat, people (light/dark like the rest of the app) */
.side { grid-column: 2; grid-row: 1 / -1; background: var(--bg); color: var(--fg); color-scheme: light dark; border-left: 1px solid var(--line); min-height: 0; display: grid; }
.side > div { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }
#people-panel { grid-template-rows: auto auto minmax(0, 1fr); }
.side h2 { margin: 0; padding: .5rem .7rem; font-size: .9rem; color: var(--fg); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .3rem; }
.side h2 .x { margin-left: auto; background: none; border: 0; color: var(--muted); padding: 0 .2rem; min-height: 0; }
.msgs { padding: .5rem .7rem; overflow: auto; display: grid; gap: .6rem; align-content: start; font-size: .88em; }
.msg .from { font-weight: bold; } .msg .t { color: var(--muted); font-size: .85em; }
.msg .tx { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg a { color: var(--accent); }
.compose { display: flex; gap: .3rem; padding: .5rem; border-top: 1px solid var(--line); align-items: end; }
.compose textarea { flex: 1; resize: none; min-height: 2.2rem; max-height: 8rem; field-sizing: content; }
.side .pad { padding: .5rem .7rem .2rem; margin: 0; }
.side .pad button { width: 100%; justify-content: center; }
.people { list-style: none; margin: 0; padding: .3rem .4rem; overflow: auto; font-size: .88em; }
.people li { display: flex; align-items: center; gap: .4rem; padding: .25rem .4rem; border-radius: 5px; }
.people li:hover { background: var(--chip); }
.people .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .state { color: var(--muted); display: flex; gap: .45rem; margin-right: .3rem; } .people .state .mut { color: var(--red); }
.people input { flex: 1; min-width: 0; }

/* person menu and connection details float over the call */
.pop, .stats { position: absolute; z-index: 20; background: var(--surface, var(--bg)); color: var(--fg); color-scheme: light dark; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 8px 28px rgb(0 0 0 / .4); }
.pop { padding: .3rem; display: grid; min-width: 13rem; font-size: .88em; }
.pop button { background: none; border: 0; text-align: left; justify-content: flex-start; padding: .35rem .6rem; color: inherit; display: flex; gap: .5rem; align-items: center; border-radius: 5px; min-height: 0; }
.pop button:hover, .pop button:focus-visible { background: var(--chip); }
.pop .del { color: var(--red); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: .2rem 0; width: 100%; }
.stats { padding: .6rem .8rem; font-size: .8em; width: min(32rem, calc(100vw - 16px)); }
.stats h3 { margin: 0 0 .4rem; font-size: 1em; display: flex; justify-content: space-between; gap: 1rem; font-weight: bold; }
.stats table { border-collapse: collapse; width: 100%; }
.stats th, .stats td { padding: .12rem .4rem .12rem 0; text-align: left; vertical-align: top; font-weight: normal; }
.stats th { color: var(--muted); white-space: nowrap; }
.stats tr.hd th { border-bottom: 1px solid var(--line); padding-top: .4rem; }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--green); margin-right: .3rem; }
.dot.weak { background: var(--yellow); } .dot.bad { background: var(--red); }
#codedlg .code { font-size: 1.6rem; letter-spacing: .08em; text-align: center; margin: .6rem 0; font-variant-numeric: tabular-nums; }

/* left / kicked */
.endpage { min-height: 100dvh; display: grid; place-content: center; text-align: center; gap: .8rem; padding: 1rem; }
.endpage .big { font-size: 2rem; }
.endpage .row { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

/* ---- paper: hand-drawn edges where the app is light; the stage stays calm --------------------- */
[data-design="paper"] :is(.pop, .stats, .cam) { border-radius: var(--sketch-sm); }
[data-design="paper"] .vtile { border-radius: var(--sketch-sm); }
[data-design="paper"] .vtile:nth-child(even) { border-radius: 5px 13px 4px 14px / 13px 4px 12px 5px; }
[data-design="paper"] .round.tgl { border-radius: 50% 46% 52% 48% / 48% 52% 46% 50%; }
[data-design="paper"] .stats tr:nth-child(even) td { background: var(--bar); }

/* ---- phones ----------------------------------------------------------------------------------- */
@media (max-width: 40rem) {
  .pre-grid { grid-template-columns: 1fr; }
  .body:not(.staged) .vtiles { grid-template-columns: 1fr !important; grid-auto-rows: minmax(9rem, 1fr); overflow-y: auto; }
  .body.staged .vtiles { grid-auto-columns: 7rem; }
  .body.with-side, .body.staged.with-side { grid-template-columns: minmax(0, 1fr); }
  .side { position: absolute; left: 0; right: 0; bottom: 3.8rem; height: 62%; grid-column: 1; border-left: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -6px 20px #0006; z-index: 10; }
  .bar-bot { gap: .4rem; } .round.tgl { width: 2.5rem; height: 2.5rem; }
  .bar-bot .keyhint { display: none; }
  .bar-top .lbl { display: none; }
  .stats { left: 8px !important; right: 8px; width: auto; }
}
