/* A Brainy Chat look (TASK 007, Huy 2026-10-24). Palette + font: abrainychat brainy-spec/brand/README.md
   - outside the call (home, pre-join, left): cream canvas, white cards, hairline borders, navy text
   - in the call: deep navy surfaces so faces stand out, same accent
   Logo navy #2c3479 is for the mark/headings only; buttons use the web accent #3b5cb8. */
:root {
  --navy: #2c3479; --navy-deep: #161b3f; --accent: #3b5cb8; --accent-hover: #34529f;
  --vanilla: #eddfd4; --cream: #faf8f5; --teal: #3db0b7; --gold: #e1b74f;
  --bg: var(--cream); --panel: #ffffff; --tile: #f1f5f9; --line: #e2e8f0;
  --text: #1e293b; --muted: #64748b; --danger: #d64545; --ok: var(--teal);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
#meeting {
  --bg: var(--navy-deep); --panel: #1f2552; --tile: #262d63; --line: #353d78;
  --text: #f4f5fb; --muted: #a9b0d6; --danger: #ef6b6b;
  color-scheme: dark;
  background: var(--bg); color: var(--text); /* inherited colour is body's computed value, so set it here */
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 "Be Vietnam Pro", Roboto, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1 { font-size: 24px; margin: 0 0 16px; color: var(--navy); font-weight: 600; }
h2 { font-size: 18px; margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: 14px; }
.link { color: var(--accent); display: block; text-align: center; margin-top: 12px; }

.screen { min-height: 100%; }
.center { display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(44,52,121,.06); }
.card.wide { max-width: 560px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.brand img { height: 32px; width: auto; }
.brand h1 { margin: 0; }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 12px; border-radius: 12px; font: inherit;
  border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 16px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button {
  font: inherit; color: var(--text); background: var(--tile); border: 0; border-radius: 12px;
  padding: 12px 16px; cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; width: 100%; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* pre-join preview */
.preview { position: relative; aspect-ratio: 16/9; background: var(--navy-deep); border-radius: 12px; overflow: hidden; margin: 8px 0 16px; }
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off { position: absolute; inset: 0; display: grid; place-items: center; color: #a9b0d6; }
.preview-controls { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; gap: 12px; justify-content: center; }
.round { width: 48px; height: 48px; border-radius: 50%; padding: 0; color: #fff; background: rgba(22,27,63,.75); display: grid; place-items: center; }
.round[aria-pressed="false"] { background: var(--danger); }

/* icons (CSS masks keep the page script-free of SVG strings) */
.round::before, .tool .ico { content: ""; width: 22px; height: 22px; background: currentColor; display: block;
  -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
#preMic, #tMic { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 15a3 3 0 0 0 3-3V6a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.9V21h2v-2.1a7 7 0 0 0 6-6.9z'/%3E%3C/svg%3E"); }
#preMic[aria-pressed="false"], #tMic[aria-pressed="false"] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 10.6V6a3 3 0 0 0-5.9-.8zM19 12h-2c0 .7-.2 1.4-.4 2l1.5 1.5c.6-1 .9-2.2.9-3.5zM4.3 3 3 4.3l6 6V12a3 3 0 0 0 4.5 2.6l1.6 1.6A5 5 0 0 1 7 12H5a7 7 0 0 0 6 6.9V21h2v-2.1c1-.1 2-.5 2.8-1l3.9 3.9 1.3-1.3z'/%3E%3C/svg%3E"); }
#preCam, #tCam { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11z'/%3E%3C/svg%3E"); }
#preCam[aria-pressed="false"], #tCam[aria-pressed="false"] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 6.5l-4 4V7a1 1 0 0 0-1-1H9.8L21 17.2zM3.3 2 2 3.3 4.7 6H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12c.2 0 .4-.1.5-.2l3.2 3.2 1.3-1.3z'/%3E%3C/svg%3E"); }
#tShare { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 18a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2H0v2h24v-2zM13 14.2V12c-3 0-5 1-6.5 3 .6-3 2.4-6 6.5-6.6V7l4 3.6z'/%3E%3C/svg%3E"); }
#tInvite { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 12a4 4 0 1 0-4-4 4 4 0 0 0 4 4zm-9-2V7H4v3H1v2h3v3h2v-3h3v-2zm9 4c-2.7 0-8 1.3-8 4v2h16v-2c0-2.7-5.3-4-8-4z'/%3E%3C/svg%3E"); }
#tStats { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9h3v11H5zm5.5-5h3v16h-3zM16 13h3v7h-3z'/%3E%3C/svg%3E"); }
#tLeave { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 9c-1.6 0-3.1.3-4.6.7v3.1c0 .4-.2.7-.6.9-1 .5-1.9 1.1-2.6 1.8-.2.2-.4.3-.7.3s-.5-.1-.7-.3L.3 13.1a1 1 0 0 1 0-1.4C3.3 8.8 7.5 7 12 7s8.7 1.8 11.7 4.7a1 1 0 0 1 0 1.4l-2.5 2.5c-.2.2-.4.3-.7.3s-.5-.1-.7-.3c-.8-.7-1.6-1.3-2.6-1.8a1 1 0 0 1-.6-.9V9.7C15.1 9.3 13.6 9 12 9z'/%3E%3C/svg%3E"); }

/* meeting */
#meeting { position: fixed; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--bg); }
.bar.top { font-size: 14px; }
.code { font-weight: 600; letter-spacing: .5px; }
.status { margin-left: auto; font-size: 13px; color: var(--muted); }
.status.warn { color: #f5a524; }
#grid { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px; place-content: center; }
#stage { flex: 3; min-height: 0; position: relative; background: #000; margin: 8px 8px 0; border-radius: 12px; overflow: hidden; }
#stage video { width: 100%; height: 100%; object-fit: contain; }
#meeting.has-stage #grid { flex: 1; grid-auto-flow: column; }
.tile { position: relative; background: var(--tile); border-radius: 10px; overflow: hidden; border: 2px solid transparent; transition: border-color .15s; }
.tile.speaking { border-color: var(--ok); }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile.fit-contain video { object-fit: contain; background: #000; }
.tile.self video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; }
.tile .avatar span { width: 25%; aspect-ratio: 1; max-width: 72px; min-width: 32px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: clamp(12px, 3vw, 22px); }
.tile.has-video .avatar { display: none; }
.label { position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); background: rgba(22,27,63,.7); border-radius: 6px; padding: 2px 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label .muted-mic { color: var(--danger); margin-left: 4px; }
.tile .info { position: absolute; right: 6px; top: 6px; font: 11px/1.3 ui-monospace, monospace; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 6px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 4px; font-size: 13px; }
.pager button { padding: 4px 14px; }
.bar.bottom { justify-content: center; gap: 4px; padding: 8px 8px calc(8px + var(--safe-b)); flex-wrap: nowrap; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px; min-width: 56px; background: transparent; font-size: 12px; white-space: nowrap; }
.tool:hover { background: var(--tile); }
.tool[aria-pressed="false"] .ico { color: var(--danger); }
.tool.active .ico { color: var(--ok); }
.tool.leave .ico { color: var(--danger); }
#stats { position: absolute; top: 44px; right: 8px; max-width: min(360px, calc(100% - 16px)); background: rgba(22,27,63,.94); border-radius: 10px; padding: 8px 12px; z-index: 5; }
#stats pre { margin: 0; font: 12px/1.45 ui-monospace, monospace; white-space: pre-wrap; }
dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog .row { display: flex; gap: 8px; margin-top: 12px; }
dialog .row button { flex: 1; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--navy); color: #fff; max-width: calc(100% - 32px); text-align: center; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; }

@media (max-width: 420px) {
  .tool { min-width: 0; padding: 6px 2px; font-size: 11px; flex: 1 1 0; }
  .tool span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .bar.top { gap: 8px; font-size: 13px; }
}

/* camera effects picker (pre-join strip + in-call dialog) */
.fx { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: -6px 0 14px; scrollbar-width: none; }
.fx::-webkit-scrollbar { display: none; }
.fx-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; background: none; color: var(--muted); font-size: 12px; border-radius: 10px; }
.fx-thumb { width: 68px; height: 42px; border-radius: 10px; border: 2px solid var(--line); overflow: hidden; display: grid; place-items: center; background: var(--tile); color: var(--text); }
.fx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fx-chip[aria-pressed="true"] { color: var(--text); font-weight: 600; }
.fx-chip[aria-pressed="true"] .fx-thumb { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.fx-thumb { position: relative; font-size: 20px; }
.fx-art { position: absolute; inset: -6px; background: radial-gradient(circle at 22% 32%, #e1b74f 0 13%, transparent 14%), radial-gradient(circle at 80% 26%, #3db0b7 0 11%, transparent 12%), linear-gradient(135deg, #adcee7, #eddfd4); }
.fx-art.light { filter: blur(2px); }
.fx-art.strong { filter: blur(4px); }
.fx-person { position: absolute; inset: 0; background: radial-gradient(ellipse 24% 34% at 50% 100%, #2c3479 0 98%, transparent 100%), radial-gradient(circle at 50% 46%, #2c3479 0 13%, transparent 14%); }
.fx-note { font-size: 12px; color: var(--muted); margin: -8px 0 12px; min-height: 1em; }
#fxDialog { width: min(540px, calc(100% - 32px)); }
#fxDialog .fx { margin: 8px 0 4px; flex-wrap: wrap; overflow: visible; }
#tFx { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a4 4 0 1 0-4-4 4 4 0 0 0 4 4zm0 2c-3.3 0-7 1.7-7 4v2h14v-2c0-2.3-3.7-4-7-4z'/%3E%3Cpath d='M19 2l.9 2.1L22 5l-2.1.9L19 8l-.9-2.1L16 5l2.1-.9zM4 9l.6 1.4L6 11l-1.4.6L4 13l-.6-1.4L2 11l1.4-.6z'/%3E%3C/svg%3E"); }
@media (max-width: 340px) {
  .tool { font-size: 10px; letter-spacing: -.2px; } /* SE: 7 tools x ~45 px */
}
