/* Lighthouse Stage, in the Lighthouse v4 look (apollodaw: docs/design/lighthouse-v4, src/ui/Theme.h makeLighthouse):
   a deep charcoal canvas, quiet chrome made of tonal steps instead of outlines, one warm amber lamp, Geist and Geist Mono.
   Dark only, like Lighthouse. */

@font-face { font-family: 'Geist'; src: url('fonts/Geist-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Geist'; src: url('fonts/Geist-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('fonts/GeistMono-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('fonts/GeistMono-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }

:root {
  /* surfaces, darkest to lightest (Theme bg0..bg4, well, the v4 night canvas) */
  --night: #0b0d12;
  --well: #101216;
  --bg0: #14171d;
  --bg1: #1a1d25;
  --bg2: #21252e;
  --bg3: #282d39;
  --bg4: #343a49;
  /* text */
  --text: #dcdfe8;
  --dim: #9aa0b2;
  --faint: #6b7083;
  --off: #4a4f60;
  /* the lamp, and the state colors */
  --lamp: #f2a65a;
  --lamp-glow: rgba(242, 166, 90, 0.35);
  --record: #f25c4c;
  --record-glow: rgba(242, 92, 76, 0.4);
  --play: #7fc95a;
  --select: #4fb3f6;
  --warning: #f5c04a;
  /* Theme::Radius */
  --r-control: 6px;
  --r-panel: 8px;
  --r-chip: 4px;
  /* Theme::Space */
  --xs: 4px; --sm: 8px; --md: 12px; --lg: 16px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* hidden means hidden, whatever display a class gives */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg0);
  color: var(--text);
  font: 13px/1.45 'Geist', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.defs { position: absolute; }
.frame-clock { position: fixed; left: -10px; top: -10px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 var(--md); }
h2 { font-size: 13px; font-weight: 500; margin: 0 0 var(--sm); }
h2.later { margin-top: 28px; }
.lead { color: var(--dim); margin: 0 0 var(--lg); }
.hint { color: var(--faint); font-size: 12px; margin: var(--sm) 0; }
.faint { color: var(--faint); }
.spacer { flex: 1; }
.row { display: flex; gap: var(--sm); flex-wrap: wrap; }

/* ---------------------------------------------------------------- header: the take time is the hero */
.top {
  height: 56px;
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--lg);
  padding: 0 20px;
  background: var(--night);
}
.top-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.product { color: var(--lamp); font-weight: 500; }
.room { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-mid { display: flex; justify-content: center; }
.top-right { display: flex; justify-content: flex-end; gap: 6px; }

.rec {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.rec::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.rec.on { color: var(--text); font-size: 22px; }
.rec.on::before { width: 10px; height: 10px; background: var(--record); box-shadow: 0 0 12px var(--record-glow); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------------------------------------------------------------- controls */
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 1.5px solid var(--lamp); outline-offset: 2px; }

.glyph {
  position: relative;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-control);
  color: var(--faint);
}
.glyph:hover { color: var(--text); background: var(--bg2); }
.glyph.on { color: var(--text); background: var(--bg2); }
.glyph .count {
  position: absolute; top: 3px; right: 2px;
  font-size: 10px; font-family: 'Geist Mono', monospace; color: var(--dim);
}

/* the lamp: Lighthouse's one warm accent, for the main action on a screen */
.lamp {
  height: 40px; padding: 0 22px;
  border-radius: var(--r-control);
  background: var(--lamp); color: var(--night);
  font-weight: 600;
  box-shadow: 0 0 24px var(--lamp-glow);
}
.lamp:hover { filter: brightness(1.06); }
.lamp.wide { width: 100%; margin-top: var(--md); }

.quiet {
  height: 32px; padding: 0 14px;
  border-radius: var(--r-control);
  background: var(--bg2); color: var(--text);
}
.quiet:hover { background: var(--bg3); }
.quiet.danger, .round.danger { color: var(--record); }

label { display: block; margin: 0 0 var(--md); color: var(--dim); font-size: 12px; }
input, select {
  display: block; width: 100%;
  margin-top: 6px; height: 36px; padding: 0 10px;
  font: 13px 'Geist', system-ui, sans-serif;
  color: var(--text); background: var(--well);
  border: 0; border-radius: var(--r-control);
}
input::placeholder { color: var(--off); }

.mono { font-family: 'Geist Mono', monospace; }
.code-input { font: 500 24px 'Geist Mono', monospace; letter-spacing: 0.12em; text-align: center; height: 52px; text-transform: uppercase; }
.text-button { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.text-button:hover { color: var(--lamp); }
.center-text { text-align: center; }

.warn-note { color: var(--warning); }

.message {
  margin: 0; padding: 10px 20px;
  background: var(--bg1); color: var(--text);
  border-left: 3px solid var(--warning);
}

/* ---------------------------------------------------------------- start, setup and end: a card in the middle */
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; overflow: auto; }
.card { background: var(--bg1); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); width: 100%; }
.card.narrow { max-width: 440px; }
.card.setup { max-width: 920px; display: grid; grid-template-columns: 1.35fr 1fr; gap: 28px; }
.setup-preview .tile { aspect-ratio: 16 / 9; }

/* ---------------------------------------------------------------- the studio */
.studio { flex: 1; display: flex; min-height: 0; background: var(--bg0); }
.stage-area { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 16px 20px 12px; position: relative; }

.tiles {
  flex: 1; min-height: 0;
  display: grid; gap: 10px;
  justify-content: center;
  align-content: center;
}
.tile {
  position: relative; overflow: hidden;
  background: var(--night);
  border-radius: var(--r-panel);
  aspect-ratio: 16 / 9;
  box-shadow: inset 0 0 0 2px transparent;
  transition: box-shadow 120ms;
}
.tile.speaking { box-shadow: inset 0 0 0 2px var(--who, var(--lamp)); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .plate {
  position: absolute; left: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px 3px 7px; border-radius: var(--r-chip);
  background: rgba(11, 13, 18, 0.72);
  font-size: 12px; font-weight: 500;
}
.tile .plate::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--who, var(--dim)); }
.tile .badge {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--r-chip);
  background: rgba(242, 92, 76, 0.9); color: #fff; font-size: 11px; font-weight: 500;
}
.tile .nocam {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 600; color: var(--who, var(--dim)); background: var(--night);
}

.meter-strip { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(11, 13, 18, 0.6); }
.meter-strip div, .level span { display: block; height: 100%; width: 0; background: var(--play); transition: width 60ms linear; }

/* the dock: Lighthouse's transport, floating over the call */
.dock {
  align-self: center;
  margin-top: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 999px;
  background: var(--bg1); box-shadow: var(--shadow);
}
.dock-host { display: flex; align-items: center; gap: 8px; }
.dock-gap { width: 1px; height: 22px; background: var(--bg3); margin: 0 4px; }
.round {
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg2); color: var(--text);
  position: relative;
}
.round:hover { background: var(--bg3); }
.round[aria-pressed="true"] { background: var(--record); color: #fff; }
.round.select select { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; height: 100%; }
.round.select { cursor: pointer; margin: 0; }

.rec-button {
  height: 42px; padding: 0 18px 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--bg2); color: var(--text); font-weight: 600;
}
.rec-button .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--record); box-shadow: 0 0 14px var(--record-glow); }
.rec-button:hover { background: var(--bg3); }
.rec-button.recording { background: var(--record); color: #fff; }
.rec-button.recording .dot { width: 12px; height: 12px; border-radius: 2px; background: #fff; box-shadow: none; }

.status-line {
  display: flex; align-items: center; gap: 12px;
  margin-top: 10px; font-size: 12px; color: var(--dim);
}
.level { width: 64px; height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; flex: none; }
.progress { flex: 1; height: 3px; border-radius: 2px; background: var(--bg3); overflow: hidden; min-width: 60px; }
.progress span { display: block; height: 100%; width: 0; background: var(--lamp); }
.progress.big { display: block; height: 6px; margin: 4px 0 var(--lg); }

.countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font-family: 'Geist Mono', monospace; font-weight: 500; font-size: 180px; letter-spacing: -0.04em;
  color: var(--lamp); text-shadow: 0 0 60px var(--lamp-glow);
  background: rgba(11, 13, 18, 0.35);
}

/* ---------------------------------------------------------------- side panel */
.side {
  width: 380px; flex: none;
  display: flex; flex-direction: column;
  background: var(--bg1);
  min-height: 0;
}
.side-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 12px 6px 16px; }
.tab { height: 30px; padding: 0 10px; border-radius: var(--r-control); color: var(--faint); font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); background: var(--bg2); }
.pane { flex: 1; overflow: auto; padding: 8px 16px 20px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-weight: 500; color: var(--faint); padding: 6px 4px; }
td { padding: 9px 4px; border-top: 1px solid var(--bg2); vertical-align: top; }
/* people: one row each, the name and where they are on top, the rest as quiet chips underneath */
table.people thead { display: none; }
table.people tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 0; border-top: 1px solid var(--bg2); }
table.people td { border: 0; padding: 0; color: var(--dim); font-size: 11px; }
table.people td:nth-child(1) { flex: 1 1 60%; color: var(--text); font-weight: 500; font-size: 13px; }
table.people td:nth-child(2) { color: var(--faint); }
table.people td:nth-child(n+3) { background: var(--bg2); border-radius: var(--r-chip); padding: 2px 7px; }
table.people td:nth-child(n+3):empty { display: none; }
table.people td.rec-yes { color: var(--record); }
table.people td.warn { color: var(--warning); }
table.people td:nth-child(6) { font-family: 'Geist Mono', monospace; }
body:not(.host) .host-col, body:not(.host) table.people td:nth-child(6) { display: none; }
body:not(.host) .host-only { display: none; }

.take { margin: 12px 0 18px; }
.take h3 { font-size: 12px; font-weight: 500; color: var(--dim); margin: 0 0 4px; font-family: 'Geist Mono', monospace; }
.take td.state { color: var(--faint); font-family: 'Geist Mono', monospace; font-size: 11px; }
.take td.state.partial { color: var(--record); font-family: 'Geist', sans-serif; }
.take td:last-child { text-align: right; }
.take button { height: 26px; padding: 0 10px; border-radius: var(--r-chip); background: var(--bg2); font-size: 11px; }
.take button:hover { background: var(--bg3); color: var(--lamp); }

.link-box { background: var(--well); border-radius: var(--r-control); padding: 10px 12px; margin: var(--sm) 0 var(--md); }
.link-box code { font: 12px 'Geist Mono', monospace; color: var(--dim); word-break: break-all; }
#invite-out { font-size: 15px; color: var(--text); }
.link-box.small code { font-size: 11px; color: var(--faint); }
#room-code { font-family: 'Geist Mono', monospace; color: var(--text); letter-spacing: 0.04em; }

/* ---------------------------------------------------------------- call controls: chat, hand, muted, quality */
.glyph .count.unread { top: 1px; right: 0; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--lamp); color: #1b1208; font-weight: 600; line-height: 15px; text-align: center; }
.chat-pane { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.chat-pane[hidden] { display: none; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-msg { display: flex; flex-direction: column; gap: 2px; }
.chat-msg .who { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600; color: var(--who, var(--text)); }
.chat-msg .when { font-weight: 400; color: var(--faint); font-family: 'Geist Mono', monospace; font-size: 11px; }
.chat-msg .text { font-size: 13px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.mine .who { color: var(--dim); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: var(--r-control); border: 1px solid var(--bg3); background: var(--bg0); color: var(--text); font: inherit; }
.ptt { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); padding: 6px 0 4px; }
.muted-banner {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 4;
  padding: 8px 14px; border-radius: 999px; background: var(--record); color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); pointer-events: none;
}
.muted-note { color: var(--record); font-weight: 500; white-space: nowrap; }
.tile .hand { position: absolute; right: 10px; top: 10px; padding: 3px 8px; border-radius: var(--r-chip); background: var(--lamp); color: #1b1208; font-size: 11px; font-weight: 600; }
.qdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; background: var(--faint); }
.qdot.good { background: var(--play); }
.qdot.fair { background: var(--warning); }
.qdot.poor { background: var(--record); }
.tile .plate .qdot { margin-left: 2px; }
table.people td:nth-child(7) { background: none !important; padding: 0 !important; }
table.people td:nth-child(7) button { height: 24px; padding: 0 10px; border-radius: var(--r-chip); background: var(--bg2); color: var(--text); font-size: 11px; }
body:not(.host) table.people td:nth-child(7) { display: none; }
dialog#leave-dialog { border: 0; color: var(--text); background: var(--bg1); box-shadow: var(--shadow); max-width: min(440px, calc(100vw - 32px)); }
dialog#leave-dialog::backdrop { background: rgba(11, 13, 18, 0.6); }
dialog#leave-dialog .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
dialog#leave-dialog button { height: 38px; padding: 0 14px; border-radius: var(--r-control); background: var(--bg2); }
dialog#leave-dialog button.danger { background: var(--record); color: #fff; }

/* the recordings on their own (the host coming back later) */
body.files-only .side { width: auto; max-width: 900px; margin: 24px auto; border-radius: 12px; flex: 1; }
body.files-only .side-tabs { display: none; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .card.setup { grid-template-columns: 1fr; }
  .side { position: fixed; top: 56px; right: 0; bottom: 0; width: min(380px, 100%); z-index: 5; box-shadow: var(--shadow); }
}
@media (max-width: 600px) {
  .top { grid-template-columns: auto 1fr auto; padding: 0 12px; gap: 8px; }
  .room { display: none; }
  .rec.on { font-size: 17px; }
  .stage-area { padding: 10px 10px 8px; }
  .tiles { grid-template-columns: 1fr; }
  .dock { gap: 6px; padding: 6px; }
  .round { width: 40px; height: 40px; }
  .rec-button { padding: 0 12px; }
  #record-label { display: none; }
  .status-line { flex-wrap: wrap; row-gap: 4px; }
  .muted-note { flex-basis: 100%; text-align: center; }
  .muted-banner { top: 10px; font-size: 12px; }
  .countdown { font-size: 110px; }
  .card { padding: 20px; }
}

/* ---------------------------------------------------------------- the host's shared Lighthouse window */
.share-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 12px;
  border-radius: var(--r-control); background: var(--bg2); color: var(--text); font-size: 13px; font-weight: 600;
  box-shadow: inset 0 0 0 2px var(--record);
}
.share-bar .share-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--record); }
.share-bar button { margin-left: auto; height: 32px; padding: 0 12px; }
.screen-view { position: relative; margin: 0 0 10px; flex: 3; min-height: 0; display: flex; justify-content: center; align-items: center; background: var(--night); border-radius: var(--r-panel); overflow: hidden; }
.screen-view img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.screen-view .plate { position: absolute; left: 10px; bottom: 10px; padding: 3px 9px; border-radius: var(--r-chip); background: rgba(11, 13, 18, 0.7); color: var(--text); font-size: 11px; }
.round#share.sharing { background: var(--record); color: #fff; }
