* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #0a0c10;
  color: #cfd6e0;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "top top" "main side" "ctl side";
  gap: 12px 16px;
  padding: 12px 16px 16px;
  align-content: start;
}

.top { grid-area: top; display: flex; align-items: center; gap: 14px; }
.brand { color: #5f6d7d; letter-spacing: .5px; }
.clock {
  font-size: 20px; color: #e6c07b; background: #1a1408;
  border: 1px solid #3a2f12; border-radius: 6px; padding: 2px 10px;
}
.clock.hidden { display: none; }
.fps { margin-left: auto; color: #6f7c8c; }

/* --- tiles --- */
.grid {
  grid-area: main;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
.tile {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  border: 1px solid #222a35;
  line-height: 0;
}
.tile.you .label { color: #b9c6d6; }

#youTile.speaking { border-color: #4ea1ff; box-shadow: 0 0 0 2px #4ea1ff; }
#youTile.glancing { border-color: #2f5f8f; }
.tile canvas { display: block; width: 100%; height: auto; }
.tile video { display: none; }
.tile canvas.calibrating { cursor: crosshair; }

.label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1.3;
  color: #dfe6ef;
  background: linear-gradient(transparent, rgba(0, 0, 0, .78));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#youTile {
  align-self: start;
}

/* --- controls --- */
.controls { grid-area: ctl; display: flex; flex-direction: column; gap: 8px; align-content: start; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 10px; }

button, select, input[type=text], input[type=password] {
  background: #1b2029; color: #cfd6e0;
  border: 1px solid #2b3340; border-radius: 6px;
  padding: 5px 10px; font: inherit;
}
button { cursor: pointer; }
button:hover { background: #242b36; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
button.on { background: #24486b; border-color: #3a6f9e; color: #eaf2fb; }

.slider { display: flex; align-items: center; gap: 8px; }
.slider input { width: 170px; }
.calib { display: flex; align-items: center; gap: 6px; color: #e6c07b; }
.textrow { display: flex; gap: 6px; }
.textrow input { min-width: 210px; }
.hint { color: #7f8b9b; }

details {
  border: 1px solid #222a35; border-radius: 6px; padding: 6px 8px; background: #0f131a;
}
summary { cursor: pointer; color: #8b97a7; }
.transcript { max-height: 260px; overflow-y: auto; margin-top: 6px; font-size: 12px; }
.transcript div { padding: 2px 0; border-bottom: 1px solid #171d26; }
.transcript b { color: #9fc4e8; }
.dbg { margin-top: 6px; color: #7f8b9b; font-size: 12px; }
.dbg b { color: #cfd6e0; }
.summary { border: 1px solid #3a2f12; background: #16110a; color: #e6c07b; border-radius: 6px; padding: 8px; }
.hidden { display: none; }

/* --- key panel --- */
.keys { border-color: #3a2f12; background: #12100a; }
.keys summary { color: #e6c07b; }
.keybody { margin-top: 6px; }
.keynote {
  margin: 4px 0 8px; color: #9aa5b4; font-size: 12px; max-width: 72ch;
}
#keyInput { min-width: 260px; }
#keyHint, #localHint { display: block; margin-top: 6px; }
.backends { gap: 16px; margin-bottom: 4px; }
.rad { display: flex; align-items: center; gap: 6px; color: #e6c07b; cursor: pointer; }
.rad input { accent-color: #c8a24a; }
.pane { margin-top: 4px; }
.progress {
  height: 6px; margin-top: 8px; border-radius: 999px;
  background: #1b1f27; overflow: hidden; max-width: 420px;
}
.progress .bar { height: 100%; width: 0; background: #c8a24a; transition: width .25s ease; }
.hint.active { display: block; margin-top: 10px; color: #8fae7a; }

/* --- about / FAQ --- */
.panel {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 16px 18px;
  border: 1px solid #222a35;
  border-radius: 8px;
  background: #0f131a;
  max-width: 80ch;
}
.panel h1 { font-size: 19px; color: #e6c07b; margin: 0 0 10px; }
.panel h3 { font-size: 14px; color: #9fc4e8; margin: 16px 0 4px; }
.panel p { margin: 0 0 8px; color: #aab4c2; }

footer {
  grid-column: 1 / -1;
  padding: 12px 0 4px;
  color: #6f7c8c;
  border-top: 1px solid #1a2029;
}
footer a { color: #7fa8d0; }

@media (max-width: 900px) {
  body { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main" "ctl" "side"; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #youTile { margin-top: 0; }
}