/* OptiTide Meet — one stylesheet, no build step. */

/* Poppins is OptiTide's typeface, served from here rather than from Google:
   one less third party, and it still works on a box with no outbound internet. */
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/brand/poppins-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/brand/poppins-600.woff2') format('woff2');
}

/* OptiTide's own tokens, taken from optitide.io: navy #0D1530 / #1A223F and
   orange #FF6A00 → #FF8C3A. The app stays dark because it is wrapped around
   video, which is what the brand's own hero does too. */
:root {
  --navy: #0d1530;
  --navy-2: #1a223f;

  --bg: #0d1530;
  --bg-2: #1a223f;
  --bg-3: #232c4e;
  --line: #2b345a;
  --text: #eef1f7;
  --text-dim: #a3aec6;

  --accent: #ff6a00;
  --accent-bright: #ff8c3a;
  --accent-dark: #e85f00;
  --accent-soft: #ffe7d3;
  --accent-gradient: linear-gradient(120deg, #ff6a00 0%, #ff8c3a 100%);
  --accent-ink: #ffffff;

  /* Status colours stay status colours — they mean something, and amber sitting
     next to the brand orange would be read as branding rather than a warning. */
  --good: #37c98b;
  --warn: #ffcf5c;
  --bad: #f2604f;
  --hand: #ffcf5c;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(5, 9, 24, 0.55);
  --sidebar-w: 340px;
  --font: 'Poppins', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The app toggles visibility with the `hidden` attribute throughout. Component
   rules set `display`, which would otherwise win over the UA sheet's
   `[hidden] { display: none }` and leave chips and badges stuck on screen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
.muted { color: var(--text-dim); font-weight: 400; }
.hint { color: var(--text-dim); font-size: .8rem; line-height: 1.45; margin: .5rem 0 0; }
.field-error { color: var(--bad); font-size: .85rem; margin: .5rem 0 0; }

/* ─── buttons ─────────────────────────────────────────────────────────── */
.btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .6rem .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #2c365c; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .ctrl:focus-visible, .tool:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .tab:focus-visible, .side-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary { background: var(--accent-gradient); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn-small { padding: .35rem .6rem; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .55rem .7rem;
  margin-bottom: .5rem;
}
textarea { resize: vertical; }
label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: .25rem; }

/* ─── landing ─────────────────────────────────────────────────────────── */
body.landing {
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(1100px 600px at 50% -15%, #24305c, var(--bg));
}
.landing-card {
  width: min(460px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}
.landing-card h1 { font-size: 1.7rem; }
.tagline { color: var(--text-dim); margin: 0 0 1.5rem; line-height: 1.5; font-size: .93rem; }
.tabs { display: flex; gap: .25rem; background: var(--bg); padding: .25rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; }
.tab {
  flex: 1; background: transparent; border: 0; color: var(--text-dim);
  padding: .55rem; border-radius: 6px; cursor: pointer;
}
.tab.is-active { background: var(--bg-3); color: var(--text); font-weight: 600; }
.panel { display: none; }
.panel.is-active { display: block; }
.code-input { text-transform: uppercase; letter-spacing: .18em; font-size: 1.25rem; text-align: center; font-weight: 600; }
.feature-strip {
  list-style: none; padding: 0; margin: 1.75rem 0 0;
  display: flex; flex-wrap: wrap; gap: .4rem;
}
.feature-strip li {
  font-size: .75rem; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: .25rem .6rem;
}
.rooms-known { margin-top: 1.25rem; font-size: .85rem; color: var(--text-dim); }
.rooms-known ul { padding-left: 1rem; }
.rooms-known a { color: var(--accent); }

/* ─── preflight ───────────────────────────────────────────────────────── */
.preflight {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(8, 12, 30, .93); backdrop-filter: blur(6px);
}
.preflight[hidden] { display: none; }
.preflight-card {
  width: min(440px, 100%); max-height: 92dvh; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 1.5rem; box-shadow: var(--shadow);
}
.preview-wrap { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
#preview { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.level-meter { position: absolute; left: .6rem; right: .6rem; bottom: .6rem; height: 6px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; }
.level-meter span { display: block; height: 100%; width: 0%; background: var(--good); transition: width .08s linear; }
.device-row { margin-bottom: .5rem; }
.preflight-toggles { display: flex; gap: .5rem; margin: .75rem 0; }
.chip {
  flex: 1; border: 1px solid var(--line); background: var(--bg-3);
  border-radius: 999px; padding: .5rem; cursor: pointer; font-size: .85rem;
}
.chip[aria-pressed="false"] { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ─── room layout ─────────────────────────────────────────────────────── */
body.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  grid-template-rows: 52px minmax(0, 1fr) auto 72px;
  grid-template-areas:
    "top   top"
    "stage side"
    "film  side"
    "ctrl  ctrl";
  height: 100dvh;
  overflow: hidden;
}
body.room.sidebar-hidden { --sidebar-w: 0px; }
body.room.sidebar-hidden .sidebar { display: none; }

/* ─── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 .9rem; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.class-title { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.code-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: .25rem .7rem; cursor: pointer;
  font-weight: 600; letter-spacing: .08em; font-size: .82rem;
}
.code-pill:hover { border-color: var(--accent); }
.view-switch { display: flex; gap: .2rem; background: var(--bg); padding: .2rem; border-radius: 999px; }
.vs { border: 0; background: transparent; color: var(--text-dim); padding: .3rem .8rem; border-radius: 999px; cursor: pointer; font-size: .82rem; }
.vs.is-active { background: var(--bg-3); color: var(--text); font-weight: 600; }
.net-chip, .timer-chip, .rec-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; padding: .25rem .6rem; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line);
}
.net-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.net-chip.good .dot { background: var(--good); }
.net-chip.ok .dot { background: var(--warn); }
.net-chip.bad .dot { background: var(--bad); }
.timer-chip { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer-chip.urgent { background: var(--bad); border-color: var(--bad); color: #fff; }
.rec-chip { color: var(--bad); font-weight: 700; }

/* ─── stage ───────────────────────────────────────────────────────────── */
.stage { grid-area: stage; position: relative; min-height: 0; padding: .6rem; }

/* Tiles share the stage evenly rather than sitting at a fixed 16:9 — a class
   of three should not leave two thirds of the screen empty. */
.grid {
  display: grid; gap: .6rem; height: 100%;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
}

.tile {
  position: relative; background: #05070a; border-radius: var(--radius);
  overflow: hidden; min-height: 0; min-width: 0;
  border: 2px solid transparent; transition: border-color .2s;
}
.tile.speaking { border-color: var(--good); }
.tile.hand-up { border-color: var(--hand); }
.tile.picked { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(76,141,255,.3); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #05070a; }
.tile.mirror video { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; background: #000; }
.tile-avatar {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(160deg, #24314a, #161b23);
}
.tile-avatar span {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 1.9rem; font-weight: 700;
}
.tile-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: .4rem; padding: .4rem .55rem;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); font-size: .8rem;
}
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-badges { margin-left: auto; display: flex; gap: .3rem; }
.tile-badges span { font-size: .78rem; }
.tile-role { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; background: var(--accent); padding: .05rem .35rem; border-radius: 4px; }
.tile-hand { position: absolute; top: .5rem; left: .5rem; font-size: 1.3rem; animation: wave 1.4s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(12deg); } }
.tile-pin { position: absolute; top: .4rem; right: .4rem; background: rgba(0,0,0,.55); border: 0; border-radius: 6px; padding: .2rem .4rem; cursor: pointer; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-pin { opacity: 1; }
.tile.pinned .tile-pin { opacity: 1; color: var(--accent); }

/* Focus view: one big tile, everyone else drops to the filmstrip below. */
.stage.focus .grid { grid-template-columns: 1fr; grid-template-rows: 1fr; }

/* ─── whiteboard ──────────────────────────────────────────────────────── */
.board-wrap { position: absolute; inset: .6rem; display: flex; flex-direction: column; gap: .5rem; }
.board-wrap[hidden] { display: none; }
.board-tools {
  display: flex; align-items: center; gap: .25rem; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .3rem .5rem;
}
.tool {
  border: 0; background: transparent; color: var(--text);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: .95rem;
  display: grid; place-items: center;
}
.tool:hover { background: var(--bg-3); }
.tool.is-active { background: var(--accent); color: #fff; }
.tool[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tool-sep { width: 1px; height: 20px; background: var(--line); margin: 0 .3rem; }
.swatches { display: flex; gap: .2rem; }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.is-active { border-color: #fff; }
#board-width { width: 80px; margin: 0; }
.board-canvas-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
#board { background: #fbfbf8; border-radius: var(--radius); box-shadow: var(--shadow); touch-action: none; cursor: crosshair; max-width: 100%; max-height: 100%; }
.board-locked-note {
  position: absolute; top: .6rem; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.7); padding: .3rem .8rem; border-radius: 999px; font-size: .8rem;
}

/* ─── filmstrip ───────────────────────────────────────────────────────── */
.filmstrip {
  grid-area: film; display: flex; gap: .5rem; padding: 0 .6rem .6rem;
  overflow-x: auto; scrollbar-width: thin;
}
.filmstrip .tile { width: 168px; flex: 0 0 auto; aspect-ratio: 16/9; }

/* ─── flashcard ───────────────────────────────────────────────────────── */
.flashcard-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(8, 10, 14, .82); backdrop-filter: blur(4px);
}
.flashcard-overlay[hidden] { display: none; }
.flashcard {
  position: relative; width: min(560px, 100%); max-height: 100%; overflow: auto;
  background: #fffdf7; color: #1b1f27; border-radius: 20px;
  padding: 2rem; text-align: center; box-shadow: var(--shadow);
}
.fc-close { position: absolute; top: .6rem; right: .6rem; border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: #667; }
.fc-image img { max-width: 100%; max-height: 220px; border-radius: 12px; margin-bottom: 1rem; }
.fc-word { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 0 .25rem; letter-spacing: -.01em; }
.fc-ipa { color: #6b7280; font-size: 1.1rem; margin: 0 0 1rem; }
.fc-say { border-color: #d8d2c4; color: #1b1f27; }
.fc-say:hover { background: #f0ece1; }
.fc-back { margin-top: 1.25rem; border-top: 1px solid #e7e2d6; padding-top: 1.25rem; }
.fc-meaning { font-size: 1.15rem; margin: 0 0 .5rem; }
.fc-example { color: #4b5563; font-style: italic; margin: 0; }
.fc-flip { margin-top: 1rem; border-color: #d8d2c4; color: #1b1f27; }
.fc-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.fc-nav .btn { border-color: #d8d2c4; color: #1b1f27; }
.fc-count { color: #6b7280; font-size: .85rem; }

/* ─── cold call ───────────────────────────────────────────────────────── */
.picked-overlay {
  position: absolute; inset: 0; z-index: 25; display: grid; place-content: center; text-align: center;
  background: rgba(8,10,14,.75); animation: pop .35s ease-out;
}
.picked-overlay[hidden] { display: none; }
.picked-overlay span { font-size: clamp(2.2rem, 8vw, 4.5rem); font-weight: 800; color: var(--accent); }
.picked-overlay small { display: block; color: var(--text-dim); margin-top: .5rem; font-size: 1rem; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ─── captions ────────────────────────────────────────────────────────── */
.caption-bar {
  position: absolute; left: 50%; bottom: .8rem; transform: translateX(-50%);
  z-index: 28; max-width: min(900px, 92%);
  background: rgba(6, 8, 12, .88); border: 1px solid var(--line);
  border-radius: 10px; padding: .5rem .9rem;
  font-size: clamp(1rem, 2.2vw, 1.35rem); line-height: 1.35; text-align: center;
}
.caption-bar[hidden] { display: none; }
#caption-who { color: var(--accent); font-weight: 700; margin-right: .5rem; }

/* ─── reactions & toasts ──────────────────────────────────────────────── */
.reactions { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.reaction { position: absolute; bottom: 0; font-size: 2rem; animation: float-up 2.8s ease-out forwards; }
@keyframes float-up {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { transform: translateY(-70vh) scale(1); opacity: 0; }
}
.toasts { position: absolute; top: .8rem; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20,25,33,.95); border: 1px solid var(--line);
  padding: .45rem .9rem; border-radius: 999px; font-size: .85rem;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ─── sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  grid-area: side; display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2); border-left: 1px solid var(--line);
}
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.side-tab {
  flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-dim); padding: .75rem .3rem; cursor: pointer; font-size: .84rem;
}
.side-tab.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 .3rem; border-radius: 999px;
  background: var(--bg-3); font-size: .7rem; color: var(--text-dim);
}
.side-tab.is-active .badge { background: var(--accent); color: #fff; }
.side-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: .85rem; }
.side-panel.is-active { display: flex; flex-direction: column; }

/* roster */
.mod-bar { display: flex; gap: .4rem; margin-bottom: .75rem; }
.roster { list-style: none; margin: 0 0 1rem; padding: 0; }
.roster li {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .3rem; border-radius: var(--radius-sm); font-size: .88rem;
}
.roster li:hover { background: var(--bg-3); }
.roster .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: #fff; flex: 0 0 auto;
}
.roster .group-tag { font-size: .68rem; color: var(--text-dim); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25rem; }
.roster .acts { display: flex; gap: .2rem; opacity: 0; }
.roster li:hover .acts { opacity: 1; }
.roster .acts button { border: 0; background: transparent; cursor: pointer; padding: .15rem; border-radius: 4px; }
.roster .acts button:hover { background: var(--bg); }

.breakout-box { border-top: 1px solid var(--line); padding-top: .85rem; }
.breakout-box h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.breakout-controls { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.breakout-controls input { width: 60px; margin: 0; }
.breakout-controls label { margin: 0; }
.breakout-list { font-size: .82rem; color: var(--text-dim); }
.breakout-list .bo-group { margin-bottom: .35rem; }
.breakout-list .bo-group strong { color: var(--text); }

/* chat */
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; padding-right: .2rem; }
.msg { font-size: .88rem; line-height: 1.45; }
.msg .meta { display: flex; align-items: baseline; gap: .4rem; margin-bottom: .1rem; }
.msg .who { font-weight: 600; font-size: .82rem; }
.msg .who.teacher { color: var(--accent); }
.msg .time { color: var(--text-dim); font-size: .7rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg .body a { color: var(--accent); }
.msg.correction {
  background: rgba(55, 201, 139, .12); border-left: 3px solid var(--good);
  padding: .5rem .6rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.msg.correction .body::before { content: "✓ "; color: var(--good); }
.msg.system { color: var(--text-dim); font-size: .8rem; font-style: italic; text-align: center; }
.msg .say { border: 0; background: transparent; cursor: pointer; opacity: .5; font-size: .8rem; padding: 0 .2rem; }
.msg:hover .say { opacity: 1; }
.chat-compose { border-top: 1px solid var(--line); padding-top: .6rem; margin-top: .6rem; }
.chat-kind { font-size: .78rem; color: var(--text-dim); }
.chat-kind label { display: flex; align-items: center; gap: .35rem; }
.chat-kind input { width: auto; margin: 0; }
.chat-compose textarea { margin-bottom: .4rem; }

/* decks */
.deck-head { display: flex; gap: .4rem; align-items: center; margin-bottom: .6rem; }
.deck-head select { margin: 0; }
.deck-list { list-style: none; margin: 0 0 .85rem; padding: 0; flex: 1; overflow-y: auto; min-height: 60px; }
.deck-list li {
  display: flex; align-items: center; gap: .4rem;
  padding: .4rem .5rem; border-radius: var(--radius-sm); font-size: .86rem;
  border: 1px solid var(--line); margin-bottom: .3rem; background: var(--bg);
}
.deck-list li.is-live { border-color: var(--accent); background: rgba(76,141,255,.1); }
.deck-list .w { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-list button { border: 0; background: transparent; cursor: pointer; padding: .1rem .25rem; border-radius: 4px; }
.deck-list button:hover { background: var(--bg-3); }
.deck-editor { border-top: 1px solid var(--line); padding-top: .75rem; }
.deck-editor h4, .tool-block h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); }
.deck-editor-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* tools */
.tool-block { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1rem; }
.tool-block:last-child { border-bottom: 0; }
.tool-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.tool-row input, .tool-row select { margin: 0; }
.tool-row label { margin: 0; white-space: nowrap; }
.timer-presets { flex-wrap: wrap; }

/* ─── control bar ─────────────────────────────────────────────────────── */
.controls {
  grid-area: ctrl; position: relative;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--bg-2); border-top: 1px solid var(--line);
}
.ctrl {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  border-radius: var(--radius-sm); padding: .4rem .8rem; cursor: pointer; min-width: 68px;
}
.ctrl:hover { background: #262e3a; }
.ctrl .ic { font-size: 1.15rem; line-height: 1.2; }
.ctrl .lb { font-size: .68rem; color: var(--text-dim); }
/* Only mic and camera turn red when off — a lowered hand is the normal state,
   not a warning. */
#btn-mic[aria-pressed="false"], #btn-cam[aria-pressed="false"] { background: var(--bad); border-color: var(--bad); }
#btn-mic[aria-pressed="false"] .lb, #btn-cam[aria-pressed="false"] .lb { color: rgba(255,255,255,.85); }
.ctrl.is-on { background: var(--accent); border-color: var(--accent); }
.ctrl.is-on .lb { color: rgba(255,255,255,.9); }
.ctrl-danger { background: var(--bad); border-color: var(--bad); }
.ctrl-danger:hover { background: #d94f3f; }
.react-tray {
  position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%);
  display: flex; gap: .25rem; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem; box-shadow: var(--shadow);
}
.react-tray[hidden] { display: none; }
.react-tray button { border: 0; background: transparent; font-size: 1.35rem; cursor: pointer; padding: .2rem .35rem; border-radius: 50%; }
.react-tray button:hover { background: var(--bg-3); transform: scale(1.15); }

/* ─── fatal ───────────────────────────────────────────────────────────── */
.fatal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(8,10,14,.94); padding: 1rem; }
.fatal[hidden] { display: none; }
.fatal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; text-align: center; max-width: 420px; }
.fatal-card p { color: var(--text-dim); line-height: 1.5; }

/* Hidden for students; app.js adds .is-teacher once the server confirms the
   role. Written as "hide when not a teacher" rather than hide-then-restore, so
   each element keeps whatever display its own rules give it. */
body:not(.is-teacher) .teacher-only { display: none !important; }

/* ─── responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body.room {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "stage" "film" "ctrl";
  }
  .sidebar {
    position: fixed; top: 52px; bottom: 72px; right: 0; width: min(360px, 100%);
    z-index: 50; transform: translateX(100%); transition: transform .22s ease;
    border-left: 1px solid var(--line); box-shadow: var(--shadow);
  }
  body.room.side-open .sidebar { transform: none; }
  .topbar-center { display: none; }
  .topbar { gap: .4rem; padding: 0 .5rem; }
  .class-title { max-width: 10ch; }
  .code-pill { white-space: nowrap; padding: .25rem .5rem; }
  .net-chip #net-text { display: none; }

  /* Eight controls have to fit a phone: drop the labels, tighten the boxes,
     and let the row scroll rather than clip Mute off the left edge. */
  .controls { gap: .3rem; padding: 0 .4rem; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .controls::-webkit-scrollbar { display: none; }
  .ctrl { min-width: 0; flex: 1 0 auto; padding: .5rem .4rem; }
  .ctrl .ic { font-size: 1.05rem; }
  .ctrl .lb { display: none; }
  .stage { padding: .4rem; }
  .board-wrap { inset: .4rem; }
  .board-tools { border-radius: var(--radius); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ─── large meetings ──────────────────────────────────────────────────────
   The pager and the audience notice only exist once a room outgrows one
   screenful, so both sit above the grid rather than taking space from it. */

.pager {
  position: absolute; bottom: .6rem; left: 50%; transform: translateX(-50%);
  z-index: 12; display: flex; align-items: center; gap: .35rem;
  padding: .2rem .35rem; border-radius: 999px;
  background: rgba(8, 10, 14, .78); backdrop-filter: blur(6px);
  border: 1px solid var(--line); font-size: .82rem;
}
.pager[hidden] { display: none; }
.pager button {
  border: 0; background: transparent; color: var(--fg);
  font-size: 1.1rem; line-height: 1; padding: .2rem .5rem; border-radius: 999px;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.pager button:disabled { opacity: .35; cursor: default; }
.pager #page-label { min-width: 4.5ch; text-align: center; color: var(--muted); }

.audience-note {
  position: absolute; top: .6rem; left: 50%; transform: translateX(-50%);
  z-index: 12; display: flex; align-items: center; gap: .6rem;
  padding: .45rem .8rem; border-radius: 999px;
  background: rgba(8, 10, 14, .82); backdrop-filter: blur(6px);
  border: 1px solid var(--line); font-size: .85rem; color: var(--muted);
  max-width: calc(100% - 1.2rem);
}
.audience-note[hidden] { display: none; }
.audience-note button {
  border: 1px solid var(--line); background: var(--accent); color: #fff;
  border-radius: 999px; padding: .25rem .7rem; font-size: .82rem; cursor: pointer;
}
.audience-note button.is-asking { background: transparent; color: var(--muted); }

/* An audience member has nothing to mute and no camera to turn off. */
body.is-audience #btn-mic,
body.is-audience #btn-cam,
body.is-audience #btn-share { display: none; }

.roster .acts button.is-on { background: var(--good); }

/* ─── choosing a meeting type ─────────────────────────────────────────────
   Three cards rather than a dropdown: the difference between them is what
   the room comes with, which is worth reading before you pick. */

.type-picker { border: 0; margin: .9rem 0 0; padding: 0; display: grid; gap: .45rem; }
.type-picker legend { padding: 0 0 .35rem; font-size: .85rem; color: var(--muted); }

.type {
  display: grid; grid-template-columns: auto 1fr; gap: 0 .55rem;
  align-items: baseline; cursor: pointer;
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, .02); transition: border-color .15s, background .15s;
}
.type:hover { border-color: var(--muted); }
.type:has(input:checked) { border-color: var(--accent); background: rgba(255, 106, 0, .12); }
.type:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.type input { margin: 0; accent-color: var(--accent); }
.type-name { font-weight: 600; font-size: .92rem; }
.type-what { grid-column: 2; font-size: .8rem; color: var(--muted); line-height: 1.35; }

/* Class-only tools disappear entirely in a personal or business room —
   a standup has no use for flashcards. */
body:not(.room-class) .class-only { display: none !important; }

/* ─── brandmark ───────────────────────────────────────────────────────────
   The logo already carries the wordmark and the tagline, so the heading is
   the mark plus the one word that says which OptiTide product this is. */

.brandmark {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 .9rem;
}
.brandmark img { width: auto; height: 40px; flex: 0 0 auto; }
.brandmark-name {
  font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; color: var(--text);
}
.brandmark-name em { font-style: normal; color: var(--accent); }
.brandmark-product {
  font-size: 1.5rem; font-weight: 400; letter-spacing: -.01em; color: var(--text-dim);
}

/* Same lock-up in the room's top bar, smaller and without the word. */
.topbar .brandmark { margin: 0; }
.topbar .brandmark img { height: 26px; }

@media (max-width: 900px) {
  .topbar .brandmark { display: none; }
}

/* ─── phones ──────────────────────────────────────────────────────────────
   This block is deliberately last in the file. The components above it (the
   type picker, the pager, the audience notice, the brandmark) were appended
   after the older `@media (max-width: 900px)` rules, so anything written up
   there loses to them on specificity ties. Mobile overrides go here, at the
   bottom, or they quietly do nothing. */

@media (max-width: 640px) {
  /* --- landing ------------------------------------------------------- */
  body.landing { padding: .9rem; place-items: start center; }
  .landing-card { padding: 1.35rem; border-radius: 14px; }
  .brandmark { gap: .4rem; margin-bottom: .7rem; }
  .brandmark img { height: 30px; }
  .brandmark-name, .brandmark-product { font-size: 1.2rem; }
  .tagline { font-size: .88rem; margin-bottom: 1.15rem; }

  /* Three tappable cards, each comfortably over the 44px touch target. */
  .type { padding: .7rem; }
  .type-name { font-size: .9rem; }
  .type-what { font-size: .78rem; }

  .feature-strip { margin-top: 1.25rem; gap: .3rem; }
  .feature-strip li { font-size: .7rem; }

  /* --- in a meeting -------------------------------------------------- */
  /* The pager sits above the control bar rather than over the last row of
     tiles, which on a phone is most of the screen. */
  .pager { bottom: .45rem; font-size: .78rem; }
  .pager button { padding: .3rem .6rem; }

  /* Nine controls do not fit a 360px phone, so the row scrolls — but Leave is
     the one button nobody should have to go looking for, least of all in a
     hurry. It stays pinned to the right edge while the rest slide under it. */
  #btn-leave {
    position: sticky; right: 0;
    box-shadow: -12px 0 14px -6px rgba(5, 9, 24, .95);
  }

  /* At 360px the notice and its button will not share a line legibly. */
  .audience-note {
    flex-direction: column; gap: .4rem; text-align: center;
    left: .6rem; right: .6rem; transform: none; max-width: none;
    font-size: .8rem; padding: .5rem .7rem;
  }
  .audience-note button { width: 100%; padding: .4rem; }
}

/* Coarse pointers get bigger hit areas regardless of width — a stylus or a
   finger on a tablet is not a mouse. */
@media (pointer: coarse) {
  /* Mute is a button people hit in a hurry and often without looking. 38px was
     under every platform's guidance; this costs four pixels of video. */
  .ctrl { min-height: 42px; min-width: 42px; }
  .pager button { min-width: 44px; min-height: 40px; }
  .type { padding-block: .8rem; }
  .roster .acts button { min-width: 36px; min-height: 32px; }
}

/* ─── invite ──────────────────────────────────────────────────────────────
   Deliberately a dialog rather than a toast: people need to read the link,
   check it, and choose how to send it. */

.invite-overlay {
  position: absolute; inset: 0; z-index: 45;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(8, 12, 30, .82); backdrop-filter: blur(4px);
}
.invite-overlay[hidden] { display: none; }
.invite-card {
  position: relative; width: min(460px, 100%);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 1.5rem; box-shadow: var(--shadow);
}
.invite-card h3 { font-size: 1.1rem; }
.invite-card input {
  font-size: .9rem; background: var(--bg); margin-bottom: .75rem;
}
.invite-close {
  position: absolute; top: .6rem; right: .6rem;
  background: transparent; border: 0; color: var(--text-dim);
  font-size: 1rem; cursor: pointer; padding: .3rem .5rem; border-radius: 6px;
}
.invite-close:hover { background: var(--bg-3); color: var(--text); }
.invite-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.invite-card strong { color: var(--accent); letter-spacing: .12em; }

@media (max-width: 640px) {
  .invite-card { padding: 1.15rem; }
  .invite-actions .btn { flex: 1 1 45%; }
}

/* ─── booking pages ───────────────────────────────────────────────────────
   These are seen by people who have never used the product and may never use
   it again, so they stay a single card with one decision at a time. */

.book-card { width: min(520px, 100%); }
.book-host { font-size: 1.25rem; margin-bottom: .35rem; }
.chosen {
  font-size: 1.05rem; font-weight: 600; margin: 0 0 1rem;
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  background: rgba(255, 106, 0, .12); border: 1px solid var(--accent);
}

.slot-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: .4rem; margin-bottom: .5rem;
}
.slot {
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  border-radius: var(--radius-sm); padding: .55rem .4rem; cursor: pointer;
  font-weight: 600; transition: border-color .15s, background .15s;
}
.slot:hover { border-color: var(--accent); background: rgba(255, 106, 0, .12); }
.slot span { font-size: .68rem; font-weight: 400; color: var(--text-dim); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
a.btn { text-decoration: none; display: inline-block; text-align: center; }

/* ─── the host's own booking setup, in the room panel ──────────────────── */
.avail-row { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; }
.avail-row select, .avail-row input { margin-bottom: 0; }
.avail-row input[type="time"] { max-width: 7.5rem; }
.avail-row button {
  background: transparent; border: 0; color: var(--text-dim);
  cursor: pointer; font-size: 1rem; padding: 0 .3rem;
}
.avail-row button:hover { color: var(--bad); }
.booking-url {
  display: block; word-break: break-all; color: var(--accent);
  font-size: .82rem; margin: .4rem 0 .6rem;
}
.mail-warning {
  font-size: .78rem; color: var(--warn); line-height: 1.45;
  border-left: 2px solid var(--warn); padding-left: .6rem; margin: .5rem 0;
}
