:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --line: #d9dee5;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --danger: #c62828;
  --video: #11151a;
  --mine: #e8f0fe;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317;
    --surface: #181c22;
    --text: #e8ebef;
    --muted: #9aa4b1;
    --line: #2b313a;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --danger: #ff6b6b;
    --video: #000000;
    --mine: #1d2a40;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101317;
  --surface: #181c22;
  --text: #e8ebef;
  --muted: #9aa4b1;
  --line: #2b313a;
  --accent: #4c8dff;
  --accent-text: #0b1220;
  --danger: #ff6b6b;
  --video: #000000;
  --mine: #1d2a40;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.page { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; }
h1 { font-size: 1.6rem; margin: 0 0 8px; line-height: 1.3; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.points { margin: 0; padding-left: 1.2em; }
.points li { margin: 4px 0; }
.note { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--danger); margin: 12px 0 0; }
footer { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 24px 16px; }
footer a { color: inherit; }

.btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.outline { background: transparent; color: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.off { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.wide { width: 100%; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.field { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.check { display: flex; gap: 8px; align-items: center; margin: 12px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* 部屋 */
.room { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.bar .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .left { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.main { display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.stage { position: relative; background: var(--video); min-height: 0; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: var(--video); display: block; }
.stage .self {
  position: absolute; right: 12px; bottom: 12px; width: 28%; max-width: 220px; aspect-ratio: 4 / 3;
  border-radius: 8px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.3);
}
.stage .self video { object-fit: cover; transform: scaleX(-1); }
.stage .wait {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: #e8ebef; padding: 16px;
}
.stage .play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.stage .peer-state { position: absolute; left: 12px; top: 12px; color: #e8ebef; font-size: 0.9rem; background: rgba(0, 0, 0, 0.5); padding: 2px 8px; border-radius: 6px; }
.chat { display: grid; grid-template-rows: 1fr auto; border-left: 1px solid var(--line); background: var(--surface); min-height: 0; }
.log { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--mine); }
.msg .from { display: block; font-size: 0.8rem; color: var(--muted); }
.msg.sys { align-self: center; border: none; color: var(--muted); font-size: 0.85rem; }
.send { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.send textarea { resize: none; height: 44px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--surface); }

@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 45dvh) 1fr; }
  .chat { border-left: none; border-top: 1px solid var(--line); }
  .controls .btn { flex: 1 1 auto; padding: 10px 8px; }
}
