:root {
  --bg: #111418; --panel: #1c2128; --line: #2d343d; --text: #e8ecf1; --dim: #9aa5b1;
  --accent: #2f81f7; --on: #2ea043; --off: #6e7781; --danger: #da3633;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif; }
button { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.on { background: var(--on); border-color: var(--on); }
button.off { background: var(--off); border-color: var(--off); }
button.danger { background: var(--danger); border-color: var(--danger); }

/* 入室前 */
#lobby { max-width: 420px; margin: 0 auto; padding: 48px 16px; }
#lobby h1 { font-size: 24px; margin: 0 0 24px; }
#lobby label { display: block; margin-bottom: 14px; color: var(--dim); font-size: 14px; }
#lobby input:not([type=checkbox]) { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
#lobby .row { margin: 4px 0 18px; }
#lobby label.chk { color: var(--text); font-size: 15px; margin-bottom: 6px; }
#lobby label.chk input { margin-right: 8px; }
#joinBtn { width: 100%; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.msg { color: #ff7b72; min-height: 1.5em; margin: 12px 0 0; }

/* 入室後 */
#call { height: 100dvh; display: flex; flex-direction: column; }
#call[hidden] { display: none; }
#call header { display: flex; gap: 16px; align-items: center; padding: 8px 16px; font-size: 14px; color: var(--dim); border-bottom: 1px solid var(--line); }
#roomLabel { color: var(--text); font-weight: 600; }
#status { margin-left: auto; }
#call footer { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

#stage { flex: 1; min-height: 0; padding: 10px; display: grid; gap: 10px; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
/* 画面共有があるとき: 共有を大きく、顔は右の列に並べる */
#stage.has-share { grid-template-columns: minmax(0, 1fr) 220px; grid-auto-rows: minmax(0, 1fr); }
#stage.has-share .tile.share { grid-column: 1; grid-row: 1 / span var(--rows, 1); }
#stage.has-share .tile:not(.share) { grid-column: 2; }
@media (max-width: 700px) {
  #stage.has-share { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  #stage.has-share .tile.share, #stage.has-share .tile:not(.share) { grid-column: 1; grid-row: auto; }
  #stage.has-share .tile:not(.share) { aspect-ratio: 16 / 9; max-height: 22vh; }
}

.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden; outline: 3px solid transparent; outline-offset: -3px; transition: outline-color .15s; min-height: 0; }
.tile.speaking { outline-color: var(--on); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.share video { object-fit: contain; }
.tile.me:not(.share) video { transform: scaleX(-1); }
.tile .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--panel); font-size: clamp(20px, 5vw, 44px); color: var(--dim); }
.tile.has-video .ph { display: none; }
.tile .tag { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .6); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tag .muted { color: #ff7b72; margin-left: 6px; }
