:root {
  --bg: #0d1620;
  --panel: #ffffff;
  --panel-2: #f4f6f9;
  --ink: #14202c;
  --muted: #6b7886;
  --line: #d8dee5;
  --navy: #102131;
  --gold: #b98d45;
  --good: #2c8a5f;
  --bad: #c0453d;
  --blue: #1f6f9e;
  --accent-staff: #14202c;
  --accent-patient: #1f3a5a;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, select, input { font: inherit; }

.hidden { display: none !important; }

/* ───────────────── HOME ───────────────── */

.view-home {
  min-height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #0d1620 0%, #16263a 100%);
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.home-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 22px 24px;
  box-shadow: 0 30px 60px -25px rgba(0,0,0,0.55);
  display: grid;
  gap: 16px;
}

.brand {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.brand-sub {
  margin: -8px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.field { display: grid; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-input {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--ink);
}

.primary-btn {
  height: 54px;
  border: 0;
  border-radius: 11px;
  background: var(--gold);
  color: #1c1408;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-top: 6px;
}
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.primary-btn:active { transform: translateY(1px); }

.home-note {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ───────────────── INTERPRET ───────────────── */

.view-interpret {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--navy);
  color: white;
}

.bar-left, .bar-right { display: flex; align-items: center; gap: 10px; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #6b7886;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}
.dot[data-state="connecting"] { background: #ffb84d; animation: pulse 1.2s ease-in-out infinite; }
.dot[data-state="connected"]  { background: #4ad599; }
.dot[data-state="error"]      { background: #ff7d7d; }

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

.lang-pair { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.clock { font-family: Consolas, monospace; font-size: 13px; color: #cbd7e2; }

.stop-btn {
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: #fff2f2;
  color: var(--bad);
  font-weight: 800;
  cursor: pointer;
}
.stop-btn:active { transform: translateY(1px); }

/* 두 패널: 모바일 세로 스택, PC 가로 분할 */
.panes {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  background: #1a2733;
}

.pane {
  min-height: 0;
  background: var(--panel);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.pane-staff   { background: var(--panel); }
.pane-patient { background: #f8fafc; }

.pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.pane-flag { font-size: 18px; line-height: 1; }
.pane-lang { font-size: 14px; font-weight: 700; color: var(--ink); }

.pane-activity {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}
.pane-activity[data-state="listening"]  { color: var(--blue);  }
.pane-activity[data-state="translating"]{ color: var(--good);  }

.subtitle {
  padding: 18px 18px 22px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: keep-all;
  line-height: 1.5;
  font-size: clamp(20px, 4.6vw, 32px);
  color: var(--ink);
}

.pane-patient .subtitle { color: var(--accent-patient); }
.pane-staff   .subtitle { color: var(--accent-staff); }

/* 자동 스크롤 시 자연스럽게 */
.subtitle:empty::before {
  content: "···";
  color: var(--muted);
  font-size: 18px;
}

/* 하단 바: 마이크 상태 + 일시정지 */
.bar-bottom {
  background: #16263a;
  color: white;
  padding: 10px 14px calc(10px + var(--safe-bottom));
}

.mic-status { display: flex; align-items: center; gap: 10px; flex: 1; }
.mic-label { font-size: 12px; color: #cbd7e2; min-width: 56px; }
.mic-label[data-state="active"] { color: #99e3bb; }
.mic-label[data-state="muted"]  { color: #ffb84d; }
.mic-label[data-state="error"]  { color: #ff9a9a; }

.meter {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: inherit;
  transition: width 110ms linear;
}

.ghost-btn {
  height: 36px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: white;
  font-weight: 700;
  cursor: pointer;
}
.ghost-btn[aria-pressed="true"] {
  background: #ffb84d;
  border-color: #ffb84d;
  color: #1c1408;
}

/* PC: 두 패널 좌우 분할 */
@media (min-width: 760px) {
  .panes {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
  }
  .subtitle { font-size: clamp(24px, 2.6vw, 36px); padding: 24px 28px; }
  .lang-pair { font-size: 15px; }
  .home-card { max-width: 460px; padding: 36px 32px 32px; }
}

/* 가로 모드 모바일 */
@media (max-height: 480px) and (orientation: landscape) {
  .panes { grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .subtitle { font-size: clamp(18px, 3.5vw, 24px); }
}

audio { display: none; }

/* ───────── 원격 모드 ───────── */

.room-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #16263a;
  color: #cbd7e2;
  font-size: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
}
.room-bar.hidden { display: none; }
.room-label { font-weight: 700; color: #99b3cc; }
.room-bar code {
  font-family: Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: #fff;
  background: rgba(255,255,255,0.07);
  padding: 2px 8px;
  border-radius: 5px;
}
.room-presence {
  margin-left: auto;
  color: #ffb84d;
  font-weight: 600;
}
.room-presence[data-state="ready"] { color: #4ad599; }

.ghost-btn.small { height: 28px; font-size: 12px; padding: 0 10px; }

.guest-banner {
  background: #eef3f7;
  border: 1px solid #c8d4df;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: #24313d;
  line-height: 1.5;
  margin-top: 4px;
}
.guest-banner.hidden { display: none; }
.guest-banner code {
  font-family: Consolas, monospace;
  letter-spacing: 0.16em;
  font-weight: 700;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
}

/* 출력 옵션: 음성만 모드 — 자막 패널 숨기고 마이크/일시정지만 강조 */
body.hide-text .panes { display: none; }
body.hide-text .view-interpret { grid-template-rows: auto 1fr auto; }
body.hide-text .view-interpret::before {
  content: "음성 출력 중";
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: clamp(18px, 3.6vw, 24px);
  background: var(--panel);
  letter-spacing: 0.02em;
}
body.hide-text .bar-bottom .meter { height: 12px; }
