:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e5ea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --stage: #0d0f13;
  --stage-ink: #f3f4f6;
  --panel: #161a21;
  --panel-line: #262b35;
  --mine: #1f2937;
  --theirs: #172036;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans SC", sans-serif;
}
.en { display: block; font-size: 0.78em; color: var(--muted); font-weight: 400; }
button { font: inherit; cursor: pointer; }

/* 입장 화면 */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.card {
  width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; display: grid; gap: 14px;
}
.eyebrow { margin: 0; font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: 0.04em; }
h1 { margin: 0 0 6px; font-size: 22px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
label .en { display: inline; margin-left: 4px; }
input, select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.primary {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px; font-weight: 600;
}
.primary .en { color: rgba(255, 255, 255, 0.8); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.share { background: #eef3ff; border-radius: 10px; padding: 12px; }
.share p { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.share .en { display: inline; margin-left: 4px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; font-size: 13px; }
.share-row button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 14px; }
.error { margin: 0; color: var(--danger); font-size: 13px; min-height: 1em; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.hint .en { display: inline; }

/* 통화 화면 */
.call {
  height: 100%; display: grid; grid-template-rows: auto 1fr auto; background: var(--stage); color: var(--stage-ink);
}
.call .en { color: #9ca3af; }
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--panel-line); font-size: 14px;
}
.tag { font-size: 12px; background: var(--panel-line); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.bar-right { display: flex; align-items: center; gap: 12px; }
.ctl.small { padding: 6px 10px; font-size: 12px; }
.ctl.small .en { display: inline; margin-left: 4px; }
.invite { margin-top: 18px; font-size: 13px; }
.invite code { display: inline-block; margin-top: 6px; padding: 6px 10px; background: var(--panel); border-radius: 8px; color: #e5e7eb; user-select: all; word-break: break-all; }
.meter { font-size: 12px; color: #9ca3af; font-variant-numeric: tabular-nums; text-align: right; }

.stage { display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.videos { position: relative; background: #000; min-height: 0; overflow: hidden; }
#remoteVideo { width: 100%; height: 100%; object-fit: contain; background: #000; }
.waiting {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #9ca3af; font-size: 15px;
}
.self {
  position: absolute; right: 16px; top: 16px; width: 200px; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--panel-line); background: #111; transform: scaleX(-1);
}
.speaking {
  position: absolute; left: 16px; top: 16px; font-size: 12px; background: rgba(37, 99, 235, 0.9);
  padding: 4px 10px; border-radius: 999px;
}
.speaking .en { display: inline; color: rgba(255, 255, 255, 0.8); }
.subtitle {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(90%, 900px);
  background: rgba(0, 0, 0, 0.72); padding: 10px 18px; border-radius: 10px; font-size: 22px; line-height: 1.4; text-align: center;
}

.captions { border-left: 1px solid var(--panel-line); background: var(--panel); display: grid; grid-template-rows: auto 1fr; min-height: 0; }
.captions-head { padding: 10px 14px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--panel-line); }
.captions-head .en { display: inline; margin-left: 4px; }
#captions { list-style: none; margin: 0; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.cap { border-radius: 10px; padding: 10px 12px; background: var(--theirs); }
.cap.mine { background: var(--mine); }
.cap .who { font-size: 11px; color: #9ca3af; margin-bottom: 2px; }
.cap .main { font-size: 16px; }
.cap .sub { font-size: 13px; color: #9ca3af; margin-top: 4px; }
.cap .sub b { font-weight: 600; color: #cbd5e1; }
.cap .badge { margin-top: 6px; font-size: 11px; color: #7dd3fc; font-variant-numeric: tabular-nums; }
.cap.pending .main { color: #9ca3af; }
.cap.noise { opacity: 0.55; }
.cap.revised { animation: revised 1.6s ease-out; }
@keyframes revised { from { box-shadow: 0 0 0 2px #7dd3fc; } to { box-shadow: 0 0 0 2px transparent; } }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  padding: 12px 16px; border-top: 1px solid var(--panel-line);
}
.ctl { background: var(--panel-line); color: var(--stage-ink); border: 0; border-radius: 10px; padding: 10px 14px; }
.ctl.off { background: #4b5563; }
.ctl.danger { background: var(--danger); }
.ctl-select { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; color: #cbd5e1; }
.ctl-select select { background: var(--panel); color: var(--stage-ink); border-color: var(--panel-line); padding: 8px 10px; }

dialog { border: 0; border-radius: 14px; padding: 20px; max-width: 560px; width: calc(100% - 32px); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog h2 .en { display: inline; margin-left: 6px; }
#summaryText { white-space: pre-wrap; font-size: 13px; background: var(--bg); padding: 12px; border-radius: 10px; margin: 0; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.dialog-actions button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 16px; }
.dialog-actions .primary { border: 0; background: var(--accent); }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; }
  .captions { border-left: 0; border-top: 1px solid var(--panel-line); }
  .self { width: 120px; }
  .subtitle { font-size: 18px; }
}
