:root {
  --bg: #141c25;
  --bg2: #1e2a37;
  --panel: #2a3a4b;
  --panel2: #334a60;
  --text: #e9eef3;
  --muted: #9fb0c0;
  --accent: #1a73e8;
  --accent2: #3f8ff7;
  --danger: #e0434b;
  --ok: #37c66d;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- 공통 버튼 ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 12px 20px; font-size: 15px; font-weight: 600;
  background: var(--panel2); color: var(--text);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.wide { width: 100%; }

/* ---------- 로비 ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; letter-spacing: .3px; }
.brand.small { font-size: 16px; }
.logo { color: var(--accent2); font-size: 14px; }
.lobby-header { padding: 20px 32px; }
.lobby-main {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 24px; text-align: center;
}
.lobby-main h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.2; margin: 0 0 12px; }
.lobby-main .sub { color: var(--muted); max-width: 520px; margin: 0 0 28px; }
.lobby-form { display: flex; gap: 8px; width: min(560px, 100%); }
.lobby-form input {
  flex: 1; padding: 14px 16px; border-radius: 8px; border: 1px solid var(--panel2);
  background: var(--bg2); color: var(--text); font-size: 16px; outline: none;
}
.lobby-form input:focus { border-color: var(--accent2); }
.active-rooms { margin-top: 32px; width: min(560px, 100%); text-align: left; }
.active-title { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.active-rooms a {
  display: flex; justify-content: space-between; padding: 10px 14px; margin-bottom: 6px;
  background: var(--bg2); border-radius: 8px; color: var(--text); text-decoration: none;
}
.active-rooms a:hover { background: var(--panel); }

/* ---------- 입장 전 ---------- */
#prejoin { align-items: center; justify-content: center; padding: 16px; }
.prejoin-card {
  display: flex; gap: 24px; background: var(--bg2); border-radius: var(--radius);
  padding: 24px; width: min(900px, 100%); flex-wrap: wrap;
}
.prejoin-preview {
  position: relative; flex: 1 1 420px; aspect-ratio: 16/9; background: #000;
  border-radius: var(--radius); overflow: hidden;
}
.prejoin-preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-off {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--panel);
}
.preview-off span, .avatar {
  width: 96px; height: 96px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700;
}
.preview-controls { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.ctl {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15);
  color: #fff; font-size: 20px; backdrop-filter: blur(6px);
}
.ctl.off { background: var(--danger); }
.prejoin-side { flex: 1 1 260px; display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.prejoin-room { color: var(--muted); font-size: 14px; }
.prejoin-room b { color: var(--text); }
.prejoin-side input, .dev-select {
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--panel2);
  background: var(--bg); color: var(--text); font-size: 15px; outline: none;
}
.dev-select { font-size: 13px; color: var(--muted); }
.msg { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 회의 ---------- */
.meet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--bg2); height: 52px;
}
.room-info { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.link-btn {
  background: var(--panel); color: var(--text); border: 0; border-radius: 6px;
  padding: 6px 10px; font-size: 13px;
}
.link-btn:hover { background: var(--panel2); }
.meet-time { color: var(--muted); font-variant-numeric: tabular-nums; }

.meet-body { flex: 1; display: flex; min-height: 0; }
.videos {
  flex: 1; display: grid; gap: 8px; padding: 8px; min-height: 0; overflow: hidden;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, var(--tile-w, 100%)));
  grid-auto-rows: min-content; align-content: center; justify-content: center;
}
.tile {
  position: relative; background: var(--bg2); border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16/9; width: 100%;
  border: 2px solid transparent;
}
.tile.speaking { border-color: var(--ok); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.tile.local video.mirror { transform: scaleX(-1); }
.tile.screen video { object-fit: contain; }
.tile .avatar-wrap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--panel);
}
.tile.video-on .avatar-wrap { display: none; }
.tile .name {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55);
  padding: 4px 10px; border-radius: 6px; font-size: 13px; display: flex; gap: 6px; align-items: center;
}
.tile .status { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.tile .status span {
  background: rgba(0,0,0,.55); border-radius: 6px; padding: 4px 6px; font-size: 13px;
}
.tile .hand-ico { position: absolute; top: 8px; left: 8px; font-size: 22px; animation: wave 1s infinite alternate; }
@keyframes wave { from { transform: rotate(-10deg);} to { transform: rotate(15deg);} }

/* 발표자 보기 */
.videos.speaker { display: flex; flex-direction: column; }
.videos.speaker .tile.big { flex: 1; aspect-ratio: auto; height: 100%; }
.videos.speaker .tile.big video { object-fit: contain; }
.videos.speaker .strip { display: flex; gap: 8px; overflow-x: auto; height: 120px; flex-shrink: 0; }
.videos.speaker .strip .tile { width: 200px; flex-shrink: 0; }

/* 사이드 패널 */
.side-panel {
  width: 340px; background: var(--bg2); display: flex; flex-direction: column; border-left: 1px solid var(--panel);
}
.side-tabs { display: flex; align-items: center; border-bottom: 1px solid var(--panel); }
.side-tab {
  flex: 1; background: none; border: 0; color: var(--muted); padding: 14px 8px; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.side-tab.active { color: var(--text); border-bottom-color: var(--accent2); }
.side-close { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 10px 14px; }
.side-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 90%; }
.chat-msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.chat-msg .bubble { background: var(--panel); padding: 8px 12px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-msg.me { align-self: flex-end; text-align: right; }
.chat-msg.me .bubble { background: var(--accent); }
.chat-msg.sys { align-self: center; color: var(--muted); font-size: 12px; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--panel); }
.chat-form input {
  flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--panel2);
  background: var(--bg); color: var(--text); outline: none;
}
.chat-form .btn { padding: 10px 14px; }
.people-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.people-list li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; }
.people-list li:hover { background: var(--panel); }
.people-list .avatar { width: 36px; height: 36px; font-size: 15px; }
.people-list .pname { flex: 1; font-size: 14px; }
.people-list .pstat { color: var(--muted); font-size: 14px; letter-spacing: 2px; }

/* 툴바 */
.toolbar {
  display: flex; justify-content: center; gap: 8px; padding: 10px; background: var(--bg2);
  flex-wrap: wrap;
}
.tool {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 72px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: var(--panel); color: var(--text);
}
.tool:hover { background: var(--panel2); }
.tool .ico { font-size: 20px; }
.tool .lbl { font-size: 11px; color: var(--muted); }
.tool.off { background: var(--danger); }
.tool.off .lbl { color: #fff; }
.tool.on { background: var(--accent); }
.tool.on .lbl { color: #fff; }
.tool.danger { background: var(--danger); }
.tool.danger .lbl { color: #fff; }
.badge {
  position: absolute; top: 4px; right: 8px; background: var(--danger); color: #fff;
  border-radius: 10px; font-size: 10px; padding: 1px 6px; font-weight: 700;
}

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.8); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  z-index: 100; max-width: 90vw;
}

/* 모바일 */
@media (max-width: 720px) {
  .side-panel { position: absolute; right: 0; top: 52px; bottom: 76px; width: 100%; z-index: 10; }
  .tool { min-width: 56px; padding: 6px 6px; }
  .tool .lbl { display: none; }
  .meet-header .brand { display: none; }
}

/* ---------- 인증번호 게이트 ---------- */
.gate-card {
  background: var(--bg2); border-radius: var(--radius); padding: 32px 28px; width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center;
}
.gate-icon { font-size: 40px; }
.gate-card h2 { margin: 0; font-size: 22px; }
.gate-card .sub { margin: 0 0 8px; }
.gate-card form { display: flex; flex-direction: column; gap: 10px; }
.gate-card input {
  padding: 14px 16px; border-radius: 8px; border: 1px solid var(--panel2); background: var(--bg);
  color: var(--text); font-size: 20px; letter-spacing: 4px; text-align: center; outline: none;
}
.gate-card input:focus { border-color: var(--accent2); }

/* ---------- 모달 / 링크 ---------- */
.sub.small { font-size: 13px; margin: 0; }
.help-link { color: var(--muted); text-decoration: none; }
.help-link:hover { color: var(--text); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--bg2); border-radius: var(--radius); padding: 18px 20px; width: min(460px, 100%); display: flex; flex-direction: column; gap: 10px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.modal-card form { display: flex; flex-direction: column; gap: 10px; }
.modal-card textarea { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--panel2); background: var(--bg); color: var(--text); font-size: 14px; outline: none; resize: vertical; font-family: inherit; }
.modal-card textarea:focus { border-color: var(--accent2); }
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.msg.inline { min-height: 0; }
.msg.ok { color: var(--ok); }
