/* groupwatching UI
   One system: the device's own font for the interface (SF Pro on Apple), Bricolage Grotesque for big titles.
   Radius scale 6 / 8 / 12 / 16. Spacing on a 4px grid. Buttons: one tonal style, one primary
   (accent) style, one icon style; all step 1px up on hover and sink on press. */
* { box-sizing: border-box; }

/* ---------- room themes (picked per room, applied for everyone) ---------- */
:root, [data-theme="classic"] { --bg: #0e0f11; --panel: #16171a; --panel2: #1b1c20; --head: #121316; --head2: #17181b; --input: #1c1d21;
  --border: #25272c; --border2: #33363d; --btn: #212328; --btn-hover: #2b2e34; --text: #ececee; --muted: #8b8f98; --accent: #3ecf8e; --accent2: #3ecf8e; --on-accent: #052116; }
[data-theme="midnight"] { --bg: #0a0e1a; --panel: #0f1526; --panel2: #131b31; --head: #0c1222; --head2: #111a30; --input: #141c33;
  --border: #1d2944; --border2: #2a3a60; --btn: #18223d; --btn-hover: #213050; --text: #e3e9fb; --muted: #8792b3; --accent: #6f98ff; --accent2: #8aacff; --on-accent: #06112e; }
[data-theme="cinema"] { --bg: #0f0909; --panel: #170e0e; --panel2: #1d1212; --head: #130b0b; --head2: #1a1010; --input: #1f1313;
  --border: #2e1c1b; --border2: #472a29; --btn: #251616; --btn-hover: #331f1f; --text: #f4e6cf; --muted: #ad9384; --accent: #e0b24a; --accent2: #e8c26a; --on-accent: #2a1a00; }
[data-theme="forest"] { --bg: #0b120e; --panel: #101a14; --panel2: #14211a; --head: #0d1611; --head2: #121e17; --input: #15231b;
  --border: #1e3227; --border2: #2c4838; --btn: #18291f; --btn-hover: #213729; --text: #e4efe4; --muted: #8ea595; --accent: #7fcf86; --accent2: #98dc9e; --on-accent: #08220e; }
[data-theme="synthwave"] { --bg: #0a0b12; --panel: #10121c; --panel2: #151826; --head: #0d0f18; --head2: #131622; --input: #171a29;
  --border: #22263a; --border2: #323853; --btn: #1b1f2f; --btn-hover: #252a40; --text: #f1f2fa; --muted: #8f94ad; --accent: #ff3d8b; --accent2: #2de2e6; --on-accent: #2b0014; }
[data-theme="cozy"] { --bg: #17120d; --panel: #1f1812; --panel2: #251d15; --head: #1b150f; --head2: #221a13; --input: #2a2018;
  --border: #33281e; --border2: #4b3b2c; --btn: #2c2219; --btn-hover: #382b20; --text: #f5e9d8; --muted: #b09b84; --accent: #f0a656; --accent2: #f5b977; --on-accent: #2e1700; }
[data-theme="light"] { --bg: #f2f2ef; --panel: #ffffff; --panel2: #f7f7f4; --head: #fbfbf9; --head2: #f5f5f2; --input: #ffffff;
  --border: #e3e3de; --border2: #cfcfc8; --btn: #eeeeea; --btn-hover: #e3e3de; --text: #18181b; --muted: #6b6b72; --accent: #15803d; --accent2: #15803d; --on-accent: #ffffff; }

:root {
  --ui: -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --display: 'Bricolage Grotesque', var(--ui);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --r-sm: 6px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
}
* { --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); --tint: color-mix(in srgb, var(--accent) 16%, transparent); }

html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 var(--ui); -webkit-font-smoothing: antialiased; transition: background .3s, color .3s; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons: tonal (default), .pri (accent), .icon (square, quiet) ---------- */
button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  font: 500 13px/1 var(--ui); color: var(--text); background: var(--btn); border: 1px solid var(--border); border-radius: var(--r);
  cursor: pointer; white-space: nowrap; transition: background 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease), opacity 150ms; }
@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) { background: var(--btn-hover); transform: translateY(-1px); }
}
button:active:not(:disabled) { transform: translateY(1px) scale(.985); transition-duration: 90ms; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .45; cursor: default; }
button.pri, button.on { background: var(--accent); border-color: transparent; color: var(--on-accent); }
@media (hover: hover) and (pointer: fine) {
  button.pri:hover:not(:disabled), button.on:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--text)); }
}
button.icon { width: 32px; padding: 0; background: transparent; border-color: transparent; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { button.icon:hover:not(:disabled) { background: var(--btn); color: var(--text); } }
/* toggles (Chat / Call): tinted when on, quiet when off */
button.tog { background: transparent; border-color: var(--border); color: var(--muted); }
button.tog.on { background: var(--tint); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--accent2); }
@media (hover: hover) and (pointer: fine) { button.tog.on:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 24%, transparent); } }
button.icon.tog { border-color: transparent; }

input, select { height: 34px; font: 14px var(--ui); color: var(--text); background: var(--input); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 0 10px; transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease); }
input::placeholder { color: var(--muted); }
input:focus { border-color: var(--accent); outline: none; }
select { padding: 0 28px 0 10px; appearance: none; cursor: pointer;
  background: var(--input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 8px center/14px no-repeat; }

/* sliders: thin track, filled to --p (set by app.js) */
input[type=range] { -webkit-appearance: none; appearance: none; height: 20px; padding: 0; border: none; background: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px;
  background: linear-gradient(var(--accent2), var(--accent2)) 0 0 / var(--p, 0%) 100% no-repeat, color-mix(in srgb, var(--text) 18%, transparent); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--text) 18%, transparent); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px #0006; transition: transform 150ms var(--ease); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: #fff; }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.25); }
input[type=range]:focus-visible { box-shadow: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }

/* ---------- join ---------- */
#join { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; overflow-y: auto;
  background: radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%), var(--bg); }
#joinForm { display: grid; gap: 16px; width: min(400px, 100%); padding: 32px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: 0 24px 60px -20px #0008; }
.joinHead { display: grid; gap: 6px; margin-bottom: 4px; }
.kicker { font: 500 12px var(--ui); letter-spacing: .02em; color: var(--muted); }
#joinTitle { margin: 0; font: 800 48px/1 var(--display); font-optical-sizing: auto; letter-spacing: -.03em; overflow-wrap: anywhere; }
#joinForm label { display: grid; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
#joinForm label input { font-size: 15px; height: 40px; }
#joinForm .note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
#joinForm .note:empty { display: none; }
#joinForm .note b { color: var(--text); font-weight: 600; }
#joinForm button[type=submit] { height: 42px; font-size: 14px; margin-top: 4px; }

/* theme picker: each swatch is a tiny preview drawn from its own theme's variables */
.themePick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.themePick button { display: grid; gap: 6px; justify-items: stretch; justify-content: stretch; align-content: start; height: auto; padding: 6px 6px 7px; border-radius: var(--r);
  font-size: 11.5px; color: var(--text); background: var(--panel); border: 1px solid var(--border2); }
@media (hover: hover) and (pointer: fine) { .themePick button:hover:not(:disabled) { background: var(--panel2); } }
.themePick .sw { height: 30px; border-radius: 4px;
  background: linear-gradient(var(--accent), var(--accent)) 6px 64% / 38% 4px no-repeat,
              linear-gradient(var(--muted), var(--muted)) 6px 34% / 22% 3px no-repeat,
              linear-gradient(var(--panel2), var(--panel2)) right / 30% 100% no-repeat, var(--bg); }
.themePick button.sel { box-shadow: 0 0 0 2px var(--accent); border-color: transparent; }

/* ---------- top bar ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
#bar { display: flex; gap: 8px; align-items: center; height: 56px; padding: 0 12px 0 16px; background: var(--head); border-bottom: 1px solid var(--border); }
.titleBox { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin-right: 8px; }
#siteTitle { font: 700 22px/1.1 var(--ui); letter-spacing: -.02em; max-width: 30vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#brand { color: var(--muted); font-size: 12px; white-space: nowrap; }
.loadBox { flex: 1; display: flex; align-items: center; gap: 4px; min-width: 120px; max-width: 760px; margin: 0 auto; padding: 3px;
  background: var(--input); border: 1px solid var(--border2); border-radius: 10px; transition: border-color 150ms var(--ease); }
.loadBox:focus-within { border-color: var(--accent); }
.loadBox > svg.i { margin-left: 8px; color: var(--muted); }
.loadBox input { flex: 1; min-width: 60px; height: 30px; border: none; background: none; padding: 0 6px; }
.loadBox input:focus-visible { box-shadow: none; }
.loadBox select { height: 30px; border-color: transparent; background-color: var(--btn); font-size: 13px; }
.loadBox button { height: 30px; border-radius: 7px; }
.barRight { display: flex; gap: 6px; align-items: center; }
.sep { width: 1px; height: 20px; background: var(--border2); margin: 0 4px; }

/* ---------- layout: everything in #main is placed by app.js layout() ---------- */
#main { flex: 1; position: relative; min-height: 0; overflow: hidden; }
#stage, #main .win, .gutter, .tile { position: absolute; }
#stage { display: flex; flex-direction: column; background: #000; z-index: 1; }

/* gutters: wide hit area, 1px line that lights up */
.gutter { z-index: 3; touch-action: none; background: var(--bg); }
.gutter::after { content: ''; position: absolute; background: var(--border); transition: background 150ms var(--ease); }
#gChat { cursor: col-resize; } #gChat::after { top: 0; bottom: 0; left: 50%; width: 1px; }
#gCams { cursor: row-resize; } #gCams::after { left: 0; right: 0; top: 50%; height: 1px; }
.gutter:hover::after, .gutter.drag::after { background: var(--accent2); }
#gChat:hover::after, #gChat.drag::after { width: 2px; }
#gCams:hover::after, #gCams.drag::after { height: 2px; }

.win { display: flex; flex-direction: column; background: var(--panel); overflow: hidden; }
#cams { background: var(--panel2); z-index: 2; }
#chat { z-index: 4; }
#chat.floating { z-index: 20; border: 1px solid var(--border2); border-radius: var(--r-lg); box-shadow: 0 20px 50px -10px #000c; }
#chat.floating .winHead { cursor: move; }
.winHead { display: flex; gap: 4px; align-items: center; height: 36px; flex: none; padding: 0 4px 0 12px; background: var(--head2);
  border-bottom: 1px solid var(--border); user-select: none; touch-action: none; }
.winHead > .wt { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.winHead button { height: 28px; font-size: 12px; padding: 0 10px; }
.winHead button.icon { width: 28px; padding: 0; }
.winHead .hideWin { margin-left: auto; }
#cams .hint { color: var(--muted); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; margin-left: 6px; }
#users { color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
#chat .winHead #users + #compactBtn { margin-left: auto; }
#chat .winHead #chatDock + .hideWin { margin-left: 0; }

/* resize handle (bottom-right corner) for floating things */
.rs { position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; cursor: nwse-resize; z-index: 3; touch-action: none; opacity: .6;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50%, var(--muted) 58%, transparent 58%, transparent 72%, var(--muted) 72%, var(--muted) 80%, transparent 80%); }
#chat:not(.floating) .rs { display: none; }

/* ---------- player ---------- */
#playerBox { flex: 1; position: relative; min-height: 0; }
#video, #ytHolder { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { background: #000; }
#ytHolder iframe { width: 100%; height: 100%; pointer-events: none; } /* our controls only, so nobody desyncs via YT UI */
#empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: #8b8f98; pointer-events: none; text-align: center; padding: 16px; }
#empty b { font: 800 32px/1 var(--display); letter-spacing: -.03em; color: #ececee; }
#empty span { font-size: 13px; }
#overlayStatus { color: #fff; position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px;
  font-size: 13px; background: #000b; backdrop-filter: blur(8px); border: 1px solid #ffffff1a; display: none; }
#overlayStatus.show { display: block; }

#controls { display: flex; gap: 6px; align-items: center; height: 52px; flex: none; padding: 0 10px; background: var(--head); border-top: 1px solid var(--border); color: var(--text); }
#playBtn { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
#playBtn svg.i { fill: currentColor; stroke: none; width: 16px; height: 16px; }
#timeLabel { font: 12px var(--ui); color: var(--muted); min-width: 96px; padding: 0 4px; font-variant-numeric: tabular-nums; }
#seek { flex: 1; min-width: 60px; }
.volBox { display: flex; align-items: center; gap: 4px; color: var(--muted); padding: 0 6px; }
#vol { width: 80px; }
#status { font-size: 12px; color: var(--muted); padding: 0 12px 6px; background: var(--head); flex: none; }
#status:empty { padding: 0; }

/* ---------- chat ---------- */
#msgs { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; font-size: 13.5px; line-height: 1.45; scrollbar-width: thin; }
#msgs .m { margin: 3px 0; overflow-wrap: anywhere; }
#msgs > .m:first-child { margin-top: auto; } /* newest at the bottom, near the input */
#msgs .m b { color: var(--accent2); font-weight: 600; }
#msgs .sys { color: var(--muted); font-size: 12px; text-align: center; margin: 8px 0; }
#chatForm { display: flex; align-items: center; gap: 2px; flex: none; margin: 8px; padding: 3px; background: var(--input); border: 1px solid var(--border2);
  border-radius: 10px; transition: border-color 150ms var(--ease); }
#chatForm:focus-within { border-color: var(--accent); }
#chatIn { flex: 1; min-width: 0; height: 30px; border: none; background: none; padding: 0 4px; }
#chatIn:focus-visible { box-shadow: none; }
#emojiBtn { width: 30px; height: 30px; font-size: 16px; }
#emojiBtn.on { background: var(--btn); color: var(--text); }
#chatForm .send { width: 30px; height: 30px; padding: 0; border-radius: 7px; }
#chatForm .send svg.i { width: 16px; height: 16px; }
#emojiPop { position: absolute; left: 8px; right: 8px; bottom: 54px; max-height: 260px; overflow-y: auto; z-index: 30; padding: 8px;
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r-lg); box-shadow: 0 16px 40px -8px #000b; scrollbar-width: thin; }
#emojiPop .cat { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 6px 4px 4px; }
#emojiPop .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
#emojiPop button { height: 34px; font-size: 20px; padding: 0; background: none; border: none; border-radius: var(--r-sm); }
@media (hover: hover) and (pointer: fine) { #emojiPop button:hover { background: var(--btn-hover); transform: scale(1.1); } }
#msgs .m .big { font-size: 28px; line-height: 1.2; } /* message that's only emoji */

/* ---------- call tiles ---------- */
.tile { z-index: 5; background: #000; border-radius: 10px; overflow: hidden; cursor: grab; touch-action: none; user-select: none;
  transition: box-shadow 180ms var(--ease), opacity 180ms; }
.tile.inchat { z-index: 21; } /* above a floating chat */
.tile.floating { z-index: 15; box-shadow: 0 16px 40px -8px #000d; }
.tile.dragging { cursor: grabbing; opacity: .92; }
.tile .rs { opacity: 0; transition: opacity .15s; --muted: #fff; }
.tile:hover .rs { opacity: .8; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
/* no camera / cam off / not in call: the person's lil guy */
.tile .avatar { position: absolute; inset: 0; display: none; }
.tile .avatar svg { width: 100%; height: 100%; display: block; }
.tile.novid .avatar { display: block; }
.tile.novid video { visibility: hidden; }  /* stays mounted so remote audio keeps playing */
.tile .micOff { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; padding: 4px; border-radius: 50%; background: #e5484d; }
.tile .micOff svg { width: 100%; height: 100%; fill: #fff; }
.tile .micOff::after, .tileCtl .ic.off::after { content: ''; position: absolute; left: 50%; top: 15%; height: 70%; width: 2px; background: #fff; transform: rotate(45deg); }
/* own tile: small mic / cam buttons, only on hover */
.tileCtl { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 6px; opacity: 0; transition: opacity 150ms var(--ease); }
.tile.me:hover .tileCtl, .tileCtl:focus-within { opacity: 1; }
.tileCtl .ic { position: relative; width: 30px; height: 30px; padding: 6px; border-radius: 50%; background: #000a; border: 1px solid #ffffff33; backdrop-filter: blur(6px); }
@media (hover: hover) and (pointer: fine) { .tileCtl .ic:hover:not(:disabled) { background: #000d; } }
.tileCtl .ic svg { width: 100%; height: 100%; fill: #fff; }
.tileCtl .ic.off { background: #e5484d; border-color: transparent; }
.tile.me:hover .lbl { opacity: 0; }
/* outline = the person's color (same as their name in chat and their lil guy) */
.tile:not(.incall) { opacity: .55; border: 2px dashed var(--uc, var(--border2)); }
.tile.incall { border: 2px solid var(--uc, var(--accent2)); }
.tile .lbl { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: #fff; background: #000a; backdrop-filter: blur(6px); padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; transition: opacity 150ms; }

/* ---------- fullscreen: same docked layout (nothing covers the video), top bar hidden ---------- */
body.fs #bar { display: none; }
body.fs #controls, body.fs #status { position: absolute; left: 0; right: 0; z-index: 5; transition: opacity .3s var(--ease); }
body.fs #controls { bottom: 0; height: 68px; padding-top: 16px; border: none; color: #fff; --text: #fff; --muted: #c9c9cf;
  background: linear-gradient(transparent, #000c); }
body.fs #controls button.tog:not(.on), body.fs #controls button.icon { color: #e6e6ea; border-color: transparent; }
body.fs #status { bottom: 68px; background: transparent; color: #ddd; text-shadow: 0 1px 2px #000; }
body.fs.idle #controls, body.fs.idle #status { opacity: 0; }
body.fs.idle { cursor: none; }

/* extension mode: video plays in the viewer's own streaming tab */
#extPanel { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 24px; text-align: center; background: var(--panel); }
#extPanel .msg { white-space: pre-line; max-width: 520px; line-height: 1.6; color: var(--muted); }
#extPanel .msg b { color: var(--text); }
#extPanel .btns { display: flex; gap: 8px; }
#extPanel code { font: 12.5px var(--mono); background: var(--btn); padding: 2px 6px; border-radius: var(--r-sm); }

/* ---------- settings dialog ---------- */
#settings { background: var(--panel); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-xl); padding: 24px; width: min(400px, calc(100vw - 32px));
  box-shadow: 0 30px 80px -20px #000c; }
#settings::backdrop { background: #0009; backdrop-filter: blur(3px); }
#settings h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
#settings .sub { font-weight: 400; font-size: 12px; color: var(--muted); }
#settings hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.roomRow { display: grid; gap: 6px; margin-bottom: 12px; font-size: 12px; font-weight: 500; color: var(--muted); }
#avPreview { width: 132px; height: 132px; margin: 0 auto 16px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); }
#avPreview svg { width: 100%; height: 100%; display: block; }
.avRows div { display: grid; grid-template-columns: 96px 32px 1fr 32px; gap: 6px; align-items: center; margin: 4px 0; }
.avRows span { font-size: 13px; color: var(--muted); }
.avRows button { padding: 0; font-size: 16px; }
.avRows b { text-align: center; font-weight: 500; font-size: 13px; text-transform: capitalize; }
.avBtns { display: flex; gap: 8px; margin-top: 16px; }
.avBtns span { flex: 1; }

/* ---------- narrow screens (phones) ---------- */
@media (max-width: 760px) {
  #bar { flex-wrap: wrap; height: auto; padding: 8px 10px; row-gap: 8px; }
  .titleBox { flex: 1; }
  #siteTitle { max-width: 55vw; font-size: 19px; }
  .loadBox { order: 3; flex-basis: 100%; max-width: none; }
  .loadBox select { max-width: 92px; }
  .barRight .lblTxt { display: none; }
  #cams .hint, .volBox, #timeLabel { display: none; }
  #joinForm { padding: 24px; }
  #joinTitle { font-size: 40px; }
}

/* phone layout (set by app.js layout() when #main is narrow): chat sits under the video */
body.phone #chat:not(.floating) { border-top: 1px solid var(--border); }
body.phone #controls { gap: 2px; padding: 0 6px; }
body.phone #controls button.tog { display: none; }
#overlayStatus { max-width: calc(100% - 24px); text-align: center; border-radius: 14px; }

/* ---------- subtitles ---------- */
#subs { position: absolute; left: 50%; bottom: 7%; transform: translateX(-50%); width: max-content; max-width: 86%; z-index: 4; pointer-events: none;
  text-align: center; white-space: pre-line; color: #fff; font: 600 calc(clamp(15px, 2.6vmin, 30px) * var(--subSize, 1))/1.3 var(--ui);
  text-shadow: 0 0 4px #000, 0 1px 3px #000; }
#subs span { background: #000a; padding: 2px 8px; border-radius: 4px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
#subs:empty { display: none; }
body.fs:not(.idle) #subs { bottom: calc(7% + 50px); }
#ccBtn.on { color: var(--accent2); }

.pop { position: absolute; right: 10px; bottom: 58px; z-index: 30; width: min(400px, calc(100% - 20px)); max-height: calc(100% - 70px); overflow-y: auto;
  display: grid; gap: 10px; padding: 14px; background: var(--panel); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-lg);
  box-shadow: 0 20px 50px -10px #000c; scrollbar-width: thin; }
body.fs .pop { bottom: 76px; }
.pop .popHead { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pop .popHead b { font-size: 14px; }
#subName { color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pop .row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pop .row input:not([type=checkbox]) { flex: 1; min-width: 0; }
.pop .lab { width: 52px; font-size: 12px; color: var(--muted); }
.pop .hintTxt { font-size: 12px; color: var(--muted); }
.pop .grow { flex: 1; }
.pop .chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.pop .chk input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
#subOffLbl { min-width: 48px; text-align: center; font: 12px var(--ui); font-variant-numeric: tabular-nums; }
.pop [data-size].sel { background: var(--tint); color: var(--accent2); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
#osRes { display: grid; gap: 2px; max-height: 220px; overflow-y: auto; scrollbar-width: thin; }
#osRes:empty { display: none; }
#osRes button { display: grid; grid-template-columns: 1fr auto; justify-content: stretch; text-align: left; height: auto; padding: 7px 8px; gap: 2px 8px;
  background: transparent; border-color: transparent; white-space: normal; }
@media (hover: hover) and (pointer: fine) { #osRes button:hover:not(:disabled) { background: var(--btn); transform: none; } }
#osRes .t { font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.35; }
#osRes .d { font-size: 11.5px; color: var(--muted); grid-column: 1 / -1; }
#osRes .n { font: 11px var(--ui); font-variant-numeric: tabular-nums; color: var(--muted); }
#osRes .msg { font-size: 12.5px; color: var(--muted); padding: 4px 2px; line-height: 1.5; }
#osRes code { font: 11.5px var(--mono); background: var(--btn); padding: 1px 5px; border-radius: 4px; }

#dropZone { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(4px); pointer-events: none; }
#dropZone > div { display: grid; justify-items: center; gap: 8px; padding: 40px 56px; border: 2px dashed var(--accent); border-radius: var(--r-xl);
  background: var(--panel); color: var(--text); }
#dropZone svg.i { width: 36px; height: 36px; color: var(--accent2); }
#dropZone b { font: 800 30px/1 var(--display); letter-spacing: -.03em; }
#dropZone span { color: var(--muted); font-size: 13px; }

/* touch screens: 16px inputs (no zoom-on-focus on iOS), app height follows the visible screen */
@media (pointer: coarse) {
  input, select { font-size: 16px; }
  #chatIn, .loadBox input { font-size: 16px; }
}
#app { height: 100dvh; }
@media (max-width: 1000px) {
  .barRight .lblTxt, #brand { display: none; }
  .barRight button:not(.icon) { width: 36px; padding: 0; }
  .loadBox select { max-width: 96px; }
}
@media (max-height: 460px) { #cams .hint { display: none; } }

/* ---------- agreement / report dialogs, legal footer ---------- */
dialog.small { background: var(--panel); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r-xl); padding: 24px;
  width: min(440px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px #000c; }
dialog.small::backdrop { background: #0009; backdrop-filter: blur(3px); }
dialog.small h3 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
dialog.small p { margin: 0 0 12px; color: var(--muted); line-height: 1.5; font-size: 13.5px; }
dialog.small .chk { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; font-weight: 500; line-height: 1.4; cursor: pointer; margin: 4px 0; overflow-wrap: anywhere; }
dialog.small .chk input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
dialog.small .chk code { font: 12px var(--mono); color: var(--muted); }
dialog.small textarea { width: 100%; resize: vertical; font: 14px/1.4 var(--ui); color: var(--text); background: var(--input); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 8px 10px; margin-bottom: 8px; }
dialog.small textarea:focus { outline: none; border-color: var(--accent); }
dialog.small .note { margin: 4px 0 0; font-size: 12.5px; }
dialog.small .note:empty { display: none; }
dialog a, .legal a { color: var(--text); }
.legal { margin: 0; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
#settings .legal { margin-top: 0; }
