/* ═══════════════════════════════════════════════════
   LoftMeet — Zoom/Meet 스타일 다크 UI
═══════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
  --bg:        #0b0d12;
  --surface:   #15181f;
  --surface2:  #1e222b;
  --surface3:  #2a2f3a;
  --border:    #2c313c;
  --accent:    #4f8cff;
  --accent-dim:#3a6fd0;
  --gold:      #c9a84c;
  --text:      #e8edf4;
  --text-muted:#9aa4b2;
  --danger:    #ef4444;
  --danger-dim:#c0392b;
  --success:   #22c55e;
  --radius:    14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 버튼 ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border: none; border-radius: 10px;
  font-size: .92rem; font-weight: 600; cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dim); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── 입력 ───────────────────────────────────── */
.input, select.input {
  width: 100%; padding: 11px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: .95rem; font-family: inherit; transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: #5a626f; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }

/* ════════════════════════════════════════════
   홈 (index.html)
═══════════════════════════════════════════════ */
.lm-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.lm-logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; }
.lm-logo .meet { color: var(--accent); }
.lm-user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 999px; font-size: .85rem;
}
.lm-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
}

.home-wrap { max-width: 920px; margin: 0 auto; padding: 48px 24px 80px; }
.home-hero { text-align: center; margin-bottom: 44px; }
.home-hero h1 { font-size: 2.2rem; font-weight: 700; letter-spacing: -1px; margin-bottom: 10px; }
.home-hero p { color: var(--text-muted); font-size: 1.02rem; }

.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 28px; }
@media (max-width: 680px) { .home-actions { grid-template-columns: 1fr; } }

.action-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; transition: border-color .15s;
}
.action-card:hover { border-color: var(--accent); }
.action-card .ic { font-size: 2rem; margin-bottom: 12px; }
.action-card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.action-card p { color: var(--text-muted); font-size: .88rem; margin-bottom: 18px; }

.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; }

.adv-toggle {
  margin-top: 16px; font-size: .85rem; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.adv-toggle:hover { color: var(--text); }
.adv-panel { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.adv-panel.open { display: block; }
.adv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.share-box {
  display: none; margin-top: 20px; padding: 18px;
  background: var(--surface2); border: 1px solid var(--accent); border-radius: 12px;
}
.share-box.visible { display: block; }
.share-box .lbl { font-size: .82rem; color: var(--text-muted); margin-bottom: 8px; }
.share-row { display: flex; gap: 8px; }
.share-row .input { flex: 1; }

.gate-msg {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; text-align: center; color: var(--text-muted);
}
.gate-msg h3 { color: var(--text); margin-bottom: 10px; }

/* ════════════════════════════════════════════
   입장 프리뷰 (room.html — join)
═══════════════════════════════════════════════ */
.preview-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(circle at 50% 0%, #161b26, var(--bg));
}
.preview-card {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px;
  max-width: 880px; width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
@media (max-width: 760px) { .preview-card { grid-template-columns: 1fr; } }

.preview-video-wrap {
  position: relative; background: #000; border-radius: 14px; overflow: hidden;
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
}
.preview-video-wrap video {
  width: 100%; height: 100%; object-fit: contain; transform: scaleX(-1);
}
.preview-off {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--text-muted);
  background: var(--surface2);
}
.preview-off .av {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; color: #fff;
}
.preview-dev-bar {
  position: absolute; bottom: 12px; left: 0; right: 0;
  display: flex; gap: 10px; justify-content: center;
}
.dev-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(30,34,43,.85); backdrop-filter: blur(8px);
  border: 1px solid var(--border); color: var(--text);
  font-size: 1.1rem; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.dev-btn:hover { background: var(--surface3); }
.dev-btn.off { background: var(--danger); border-color: var(--danger); color: #fff; }

.preview-form { display: flex; flex-direction: column; justify-content: center; }
.preview-form .ws-name { font-size: .85rem; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.preview-form h2 { font-size: 1.4rem; margin-bottom: 4px; }
.preview-form .sub { color: var(--text-muted); font-size: .88rem; margin-bottom: 22px; }
.member-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .8rem;
  color: var(--success); background: rgba(34,197,94,.12);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 14px;
}

/* ── 로비 대기 ─────────────────────────────── */
.lobby-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px; padding: 24px; text-align: center;
}
.lobby-spinner {
  width: 48px; height: 48px; border: 4px solid var(--surface3);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.lobby-msg { font-size: 1.1rem; font-weight: 600; }
.lobby-sub { color: var(--text-muted); font-size: .9rem; }

/* ════════════════════════════════════════════
   회의실 (room.html — meeting)
═══════════════════════════════════════════════ */
.meeting-root {
  display: none; flex-direction: column;
  height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg);
}
.meeting-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.meeting-top .rname { font-weight: 600; font-size: .98rem; }
.meeting-top .rmeta { font-size: .8rem; color: var(--text-muted); }
.rec-badge {
  display: none; align-items: center; gap: 6px; font-size: .78rem;
  color: var(--danger); background: rgba(239,68,68,.12); padding: 4px 10px; border-radius: 999px;
}
.rec-badge.visible { display: inline-flex; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* 본문: 비디오 영역 + 사이드패널 */
.meeting-body { flex: 1; display: flex; min-height: 0; position: relative; }

.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px; gap: 12px; }

/* 화면공유 메인 뷰 */
.share-main {
  display: none; flex: 1; min-height: 0; position: relative;
  background: #000; border-radius: 12px; overflow: hidden;
}
.share-main.visible { display: flex; }
.share-main video { width: 100%; height: 100%; object-fit: contain; }
.share-main .lbl {
  position: absolute; top: 12px; left: 12px; font-size: .8rem;
  background: rgba(0,0,0,.6); padding: 5px 12px; border-radius: 8px;
}
.share-full-btn {
  position: absolute; top: 12px; right: 12px; font-size: .8rem;
  background: rgba(0,0,0,.6); border: 1px solid var(--border); color: #fff;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}

/* 비디오 그리드 — 핵심: 잘림 방지 */
.video-grid {
  flex: 1; min-height: 0; display: grid; gap: 12px;
  align-content: center; justify-content: center;
}
.video-grid.n1 { grid-template-columns: minmax(0, 1fr); }
.video-grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.video-grid.n3, .video-grid.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.video-grid.n5, .video-grid.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.video-grid.n7, .video-grid.n8, .video-grid.n9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.video-grid.nmany { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 화면공유 시 하단 스트립 */
.video-grid.strip {
  flex: none; display: flex; gap: 10px; height: 120px;
  overflow-x: auto; align-content: unset; justify-content: flex-start;
}
.video-grid.strip .tile { flex: 0 0 160px; height: 100%; }

.tile {
  position: relative; background: var(--surface2); border-radius: 12px;
  overflow: hidden; min-height: 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent; transition: border-color .15s;
}
.tile.speaking { border-color: var(--accent); }
/* 영상: contain 고정 = 절대 확대·잘림 없음 (전체 화면이 다 보임, 비율 안 맞으면 검은 여백). 거울모드는 로컬만 */
.tile video {
  width: 100%; height: 100%; object-fit: contain; background: #000;
}
.tile.local video { transform: scaleX(-1); }
.tile .label {
  position: absolute; bottom: 8px; left: 8px;
  font-size: .78rem; background: rgba(0,0,0,.6); color: #fff;
  padding: 4px 10px; border-radius: 8px; max-width: calc(100% - 16px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px;
}
.tile .cam-off {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface2); color: var(--text-muted);
}
.tile.cam-off-on .cam-off { display: flex; }
.tile.cam-off-on video { visibility: hidden; }
.tile .av-circle {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; color: #fff;
}
.tile .mic-off-ic { display: none; }
.tile.mic-muted .mic-off-ic { display: inline; }

/* ── 사이드 패널 (채팅/참여자) — 영상 영역에 영향 없음 ── */
.side-panel {
  width: 320px; flex-shrink: 0; background: var(--surface);
  border-left: 1px solid var(--border); display: none; flex-direction: column;
}
.side-panel.open { display: flex; }
@media (max-width: 760px) {
  .side-panel { position: absolute; right: 0; top: 0; bottom: 0; width: 100%; max-width: 100%; z-index: 20; }
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tab {
  flex: 1; padding: 12px; text-align: center; cursor: pointer;
  font-size: .88rem; color: var(--text-muted); border-bottom: 2px solid transparent;
}
.side-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.side-content { flex: 1; overflow-y: auto; padding: 14px 16px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 채팅 */
.chat-msg { margin-bottom: 12px; }
.chat-msg .sender { font-size: .76rem; color: var(--accent); font-weight: 600; margin-bottom: 2px; }
.chat-msg .body { font-size: .9rem; word-break: break-word; }
.chat-msg.mine .sender { color: var(--gold); }
.chat-input-row {
  display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border);
}
.chat-input-row .input { flex: 1; }

/* 참여자 목록 */
.pl-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pl-item .av {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg,var(--accent),var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.pl-item .nm { flex: 1; font-size: .9rem; }
.pl-item .co { font-size: .76rem; color: var(--text-muted); }

/* 대기실 알림 */
.waiting-item {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-bottom: 10px;
}
.waiting-item .nm { font-weight: 600; font-size: .9rem; }
.waiting-item .co { font-size: .78rem; color: var(--text-muted); margin-bottom: 8px; }
.waiting-item .acts { display: flex; gap: 8px; }
.waiting-item .acts button { flex: 1; padding: 7px; font-size: .82rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; }
.btn-approve { background: var(--success); color: #fff; }
.btn-reject { background: var(--surface3); color: var(--text); }

/* ── 컨트롤 바 (하단 플로팅) ────────────────── */
.control-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; background: var(--surface); border-top: 1px solid var(--border);
  flex-shrink: 0; position: relative;
}
.ctrl-btn {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 1.25rem; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.ctrl-btn:hover { background: var(--surface3); }
.ctrl-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctrl-btn.off { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctrl-btn.rec-on { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctrl-btn.leave { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctrl-btn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.ctrl-btn .ctrl-label {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: .62rem; color: var(--text-muted); white-space: nowrap;
}
.ctrl-divider { width: 1px; height: 32px; background: var(--border); margin: 0 4px; }

/* ── 토스트 + 모달 ─────────────────────────── */
.toast {
  position: fixed; bottom: 90px; right: 24px; max-width: 340px;
  background: var(--surface2); border: 1px solid var(--accent); border-radius: 12px;
  padding: 16px; box-shadow: 0 12px 30px rgba(0,0,0,.4);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
}
.toast.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast .t-title { font-weight: 700; margin-bottom: 6px; }
.toast .t-body { font-size: .85rem; color: var(--text-muted); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: none; align-items: center; justify-content: center; padding: 24px; z-index: 200;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  max-width: 720px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 28px;
}
.modal h2 { margin-bottom: 16px; }
.modal pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; line-height: 1.7; font-size: .92rem; }

/* ── 토글 스위치 ───────────────────────────── */
.switch-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.switch-row .lbl { font-size: .9rem; }
.switch-row .lbl small { display: block; color: var(--text-muted); font-size: .76rem; }
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--surface3); border-radius: 999px;
  cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ── admin ─────────────────────────────────── */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 32px 24px 80px; }
.admin-wrap h1 { margin-bottom: 24px; }
.admin-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.admin-section h2 { font-size: 1.1rem; margin-bottom: 16px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: .8rem; }

/* ═══════════════════════════════════════════════════
   📱 모바일 최적화
═══════════════════════════════════════════════════ */

/* iOS 안전영역(notch/홈바) 대응 */
.meeting-root { padding-bottom: env(safe-area-inset-bottom, 0); }

@media (max-width: 760px) {
  /* ── 헤더 컴팩트 ── */
  .lm-header { padding: 12px 16px; gap: 8px; }
  .lm-logo { font-size: 1.1rem; }
  .lm-user-chip { font-size: .8rem; padding: 4px 10px 4px 4px; }
  .lm-user-chip span:not(.lm-avatar) { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ── 홈 ── */
  .home-wrap { padding: 28px 16px 60px; }
  .home-hero h1 { font-size: 1.6rem; }
  .home-hero p { font-size: .92rem; }
  .action-card { padding: 20px; }

  /* ── 회의실 상단바 ── */
  .meeting-top { padding: 9px 14px; }
  .meeting-top .rname { font-size: .9rem; }
  .meeting-top .rmeta { font-size: .72rem; }

  /* ── 무대/그리드: 세로 화면 공간 활용 ── */
  .stage { padding: 8px; gap: 8px; }
  .video-grid { gap: 8px; }
  /* 모바일 세로: 2명까지는 위아래 분할 (더 크게 보임) */
  .video-grid.n2 { grid-template-columns: minmax(0,1fr); grid-template-rows: repeat(2, minmax(0,1fr)); }
  .video-grid.n3, .video-grid.n4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .video-grid.n5, .video-grid.n6,
  .video-grid.n7, .video-grid.n8, .video-grid.n9,
  .video-grid.nmany { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tile .label { font-size: .72rem; padding: 3px 8px; }
  .tile .av-circle { width: 52px; height: 52px; font-size: 1.2rem; }

  /* 화면공유 스트립: 모바일에선 더 작게 */
  .video-grid.strip { height: 92px; }
  .video-grid.strip .tile { flex: 0 0 124px; }

  /* ── 컨트롤바: 터치 친화 + 균등 분배 ── */
  .control-bar {
    gap: 4px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0));
    justify-content: space-around;
  }
  .ctrl-btn { width: 46px; height: 46px; font-size: 1.1rem; border-radius: 12px; }
  .ctrl-divider { display: none; }       /* 구분선 숨겨 공간 확보 */
  .ctrl-btn .ctrl-label { display: none; } /* 라벨 숨김 (아이콘만) */

  /* 화면공유는 모바일 미지원 多 → 숨김 */
  #screenBtn { display: none !important; }

  /* ── 사이드 패널: 풀스크린 ── */
  .side-panel { background: var(--bg); }
  .side-content { padding: 12px 14px; }
  .chat-input-row { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0)); }

  /* ── 프리뷰: 비디오 비율 조정 ── */
  .preview-screen { padding: 16px; align-items: flex-start; padding-top: 32px; }
  .preview-card { padding: 18px; gap: 16px; border-radius: 16px; }
  .preview-video-wrap { aspect-ratio: 16/10; }
  .preview-form h2 { font-size: 1.2rem; }

  /* ── 로비 ── */
  .lobby-msg { font-size: 1rem; }

  /* ── 토스트: 모바일 가로 꽉 ── */
  .toast { left: 12px; right: 12px; bottom: 80px; max-width: none; }

  /* ── 모달 ── */
  .modal { padding: 20px; border-radius: 12px; }

  /* ── admin 테이블 가로 스크롤 유지 ── */
  .admin-wrap { padding: 20px 14px 60px; }
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: 8px; }
}

/* 아주 좁은 기기 (≤360px) */
@media (max-width: 360px) {
  .ctrl-btn { width: 42px; height: 42px; font-size: 1rem; }
  .home-actions { gap: 12px; }
}

/* 가로 모드(landscape) 모바일: 컨트롤바 더 납작 */
@media (max-height: 480px) and (orientation: landscape) {
  .control-bar { padding: 6px; }
  .ctrl-btn { width: 40px; height: 40px; }
  .meeting-top { padding: 6px 12px; }
}

/* ── 자이로(AI) 채팅 메시지 강조 ── */
.chat-msg.gyro {
  background: linear-gradient(135deg, rgba(79,140,255,.12), rgba(201,168,76,.10));
  border: 1px solid rgba(79,140,255,.35);
  border-radius: 10px; padding: 8px 10px; margin-left: 0;
}
.chat-msg.gyro .sender { color: #6ea8ff; font-weight: 700; }
.chat-msg.gyro .body { color: var(--text); white-space: pre-wrap; }
.gyro-typing {
  display: none; align-items: center; gap: 8px; padding: 8px 10px;
  font-size: .82rem; color: #6ea8ff;
}
.gyro-typing .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #6ea8ff;
  animation: gyroPulse 1.2s infinite;
}
@keyframes gyroPulse { 0%,100%{opacity:.3} 50%{opacity:1} }
.gyro-hint {
  font-size: .76rem; color: var(--text-muted); background: var(--surface2);
  border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}
.gyro-hint b { color: #6ea8ff; }

/* ── 장치 선택 드롭다운 (프리뷰 + 회의 중) ─────────────── */
.device-selectors {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 18px;
}
.device-sel-row {
  display: flex; align-items: center; gap: 8px;
}
.device-sel-icon { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.device-sel {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 7px 10px;
  font-size: .82rem; font-family: inherit; cursor: pointer;
  appearance: auto; max-width: 100%;
}
.device-sel:focus { outline: none; border-color: var(--accent); }
.device-sel option { background: #1e222b; color: var(--text); }

/* ── 컨트롤바 장치 선택 그룹 ───────────────────────────── */
.ctrl-dev-group {
  display: flex; align-items: stretch; position: relative;
}
.ctrl-dev-group .ctrl-btn {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  border-right: none;
}
.ctrl-dev-pick {
  width: 18px; height: 52px;
  background: var(--surface2); border: 1px solid var(--border);
  border-left: 1px solid rgba(255,255,255,.08);
  border-top-right-radius: 14px; border-bottom-right-radius: 14px;
  color: var(--text-muted); font-size: .65rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; padding: 0; line-height: 1;
}
.ctrl-dev-pick:hover { background: var(--surface3); color: var(--text); }
.ctrl-dev-group .ctrl-btn.active + .ctrl-dev-pick {
  background: rgba(67,97,238,.6); border-color: var(--accent);
}
.ctrl-dev-group .ctrl-btn.off + .ctrl-dev-pick {
  background: rgba(220,38,38,.5); border-color: var(--danger);
}

/* 스피커 버튼 (독립형) */
#spkBtn { border-radius: 14px 0 0 14px; border-right: none; }
#spkPickBtn { border-radius: 0 14px 14px 0; }

/* ── 장치 선택 팝업 ─────────────────────────────────────── */
.dev-picker-popup {
  position: absolute; bottom: calc(100% + 10px);
  background: var(--surface2); border: 1px solid var(--accent);
  border-radius: 12px; padding: 12px; min-width: 220px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4); z-index: 200;
}
.dev-picker-title {
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 8px; letter-spacing: .03em;
}

/* 모바일에서 장치선택 그룹 ▾ 버튼 숨기지 않음 */
@media (max-width: 760px) {
  .ctrl-dev-pick { width: 14px; height: 46px; font-size: .55rem; }
  .ctrl-dev-group .ctrl-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
  .dev-picker-popup { min-width: 180px; }
}

/* ── 컨트롤바 모바일 스크롤 보험 ──────────────────────── */
@media (max-width: 760px) {
  .control-bar { overflow-x: auto; overflow-y: visible; flex-wrap: nowrap; }
  /* ▾ 장치선택 버튼 모바일에서 크기 통일 */
  .ctrl-dev-group { flex-shrink: 0; }
}

/* ═══════════════════════════════════════════════════
   🎨 카메라 화면 보정 (배경 블러 / 이미지 / 밝기)
═══════════════════════════════════════════════════ */

/* ── 프리뷰 보정 섹션 ────────────────────────── */
.effect-section {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.effect-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  background: var(--surface2);
  cursor: pointer;
  font-size: .85rem; font-weight: 600;
  user-select: none;
}
.effect-section-header:hover { background: var(--surface3); }
.effect-section-header .arrow { font-size: .7rem; transition: transform .2s; }
.effect-section-header.open .arrow { transform: rotate(180deg); }
.effect-section-body {
  display: none;
  padding: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.effect-section-body.open { display: block; }

/* ── 모드 탭 버튼 ──────────────────────────── */
.effect-mode-tabs {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.effect-tab-btn {
  flex: 1; padding: 7px 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted);
  font-size: .78rem; font-weight: 600; cursor: pointer;
  text-align: center; transition: all .15s;
}
.effect-tab-btn:hover { background: var(--surface3); color: var(--text); }
.effect-tab-btn.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}

/* ── 모드별 패널 ────────────────────────────── */
.effect-panel { display: none; }
.effect-panel.active { display: block; }

/* ── 슬라이더 행 ──────────────────────────── */
.effect-slider-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px; font-size: .8rem;
}
.effect-slider-row label {
  color: var(--text-muted); width: 60px; flex-shrink: 0; font-size: .78rem;
}
.effect-slider-row .val {
  color: var(--accent); width: 30px; text-align: right; flex-shrink: 0; font-size: .78rem;
}
.effect-slider {
  flex: 1; appearance: none; height: 4px;
  background: var(--surface3); border-radius: 2px; outline: none;
}
.effect-slider::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
}
.effect-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none; border-radius: 50%; background: var(--accent); cursor: pointer;
}

/* ── 배경 이미지 썸네일 그리드 ──────────────── */
.effect-bg-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.effect-bg-thumb {
  aspect-ratio: 16/9; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; overflow: hidden; position: relative;
  transition: border-color .15s;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
}
.effect-bg-thumb:hover { border-color: var(--accent); }
.effect-bg-thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79,140,255,.4); }
.effect-bg-thumb .thumb-label {
  position: absolute; bottom: 3px; left: 0; right: 0;
  font-size: .6rem; text-align: center; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.9); font-weight: 600;
}

/* 배경 그라데이션 미리 정의 */
.bg-none    { background: var(--surface2); color: var(--text-muted); font-size: .7rem; }
.bg-ocean   { background: linear-gradient(135deg, #0f4c75 0%, #1b6ca8 40%, #52b3d9 100%); }
.bg-forest  { background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 50%, #52b788 100%); }
.bg-city    { background: linear-gradient(135deg, #0d1b2a 0%, #1b2838 40%, #2c4a6e 70%, #ff8c42 100%); }
.bg-harbor  { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 70%, #e94560 100%); }

/* ── 회의 중 효과 팝업 패널 ─────────────────── */
.effect-popup {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 280px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.5);
  z-index: 200;
}
.effect-popup-title {
  font-size: .82rem; font-weight: 700; margin-bottom: 10px;
  color: var(--text); letter-spacing: .02em;
}

/* 모바일 팝업 위치 조정 */
@media (max-width: 760px) {
  .effect-popup { width: 240px; right: -10px; }
  .effect-bg-grid { grid-template-columns: repeat(4, 1fr); }
  .effect-section { margin-top: 10px; }
}
