/* ===== LiveClass 메인 화면 (사용자 중심 UI) — style.css 위에 덧씌움 ===== */
:root { --sub-size: 19px; --red: #ff5a5e; --dock-h: 0px; color-scheme: dark; }
main { max-width: 860px; gap: 16px; }
.small { font-size: 12px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 500; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 헤더: 사용자 메뉴 ---------- */
.user-menu { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; font-size: 13px; }
.avatar-btn:hover { border-color: var(--primary); }
.avatar-btn img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--panel); }
.avatar-btn span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 6px; z-index: 50; animation: slideIn .15s ease; }
.menu.hidden { display: none; }
.menu-head { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head small { color: var(--muted); font-size: 12px; word-break: break-all; }
.menu-status { margin-top: 6px; font-size: 12px; padding: 3px 8px; border-radius: 6px; align-self: flex-start; background: rgba(70,211,154,.12); color: var(--green); }
.menu-status.warn { background: rgba(255,209,102,.12); color: var(--accent); }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font-size: 14px; padding: 10px; border-radius: 8px; cursor: pointer; text-decoration: none; font-family: inherit; }
.menu-item:hover { background: var(--panel-2); }
.menu-item.hidden { display: none; }

.live-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(255,90,94,.18); border: 1px solid rgba(255,90,94,.5); padding: 4px 10px; border-radius: 999px; letter-spacing: .5px; }
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--red); animation: pulse 1.2s infinite; }
.live-badge b { font-variant-numeric: tabular-nums; font-weight: 600; }
.live-badge.hidden { display: none; }

/* ---------- 알림 배너 ---------- */
.notice { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: rgba(255,209,102,.1); border: 1px solid rgba(255,209,102,.5); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.notice.info { background: rgba(108,140,255,.1); border-color: rgba(108,140,255,.5); }
.notice .n-text { flex: 1; min-width: 200px; }
.notice .n-actions { display: flex; gap: 8px; }
.notice.hidden { display: none; }

/* ---------- 1. 준비 ---------- */
.lang-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.lang-pair select { width: 100%; min-width: 0; font-size: 16px; padding: 12px; }
.field label .hint { color: var(--muted); font-size: 11px; margin-left: 4px; opacity: .8; }
.swap-btn { width: 44px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: 18px; cursor: pointer; transition: .2s; }
.swap-btn:hover:not(:disabled) { border-color: var(--primary); transform: rotate(180deg); }
.swap-btn:disabled { opacity: .4; cursor: not-allowed; }
.field-msg { font-size: 12px; color: var(--muted); min-height: 0; margin-top: 6px; line-height: 1.5; }
.field-msg:empty { display: none; }
.field-msg.warn { color: var(--accent); }
.field-msg.err { color: #ff8a8d; }
.field-msg.ok { color: var(--green); }
.field-msg.hidden { display: none; }

.switch-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; cursor: pointer; font-size: 14px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { flex-shrink: 0; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: .2s; margin-top: 1px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch-row input:checked + .switch { background: var(--primary); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-row input:disabled ~ * { opacity: .5; }
.switch-text small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- 시작/종료 도크 ---------- */
.dock { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 12px; }
.dock-live { display: flex; align-items: center; gap: 12px; }
.dock-live.hidden, .dock-idle.hidden { display: none; }
.live-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.live-info b { font-size: 20px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(255,90,94,.2); animation: pulse 1.2s infinite; flex-shrink: 0; }
.live-pair { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.stop { background: rgba(255,90,94,.15); border-color: var(--red); color: #fff; font-weight: 600; padding: 12px 18px; }
.btn.stop:hover:not(:disabled) { background: rgba(255,90,94,.3); border-color: var(--red); }
.meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; }
.meter i { width: 3px; height: 3px; background: var(--green); border-radius: 2px; transition: height .08s; }
.meter.hidden { display: none; }
body.is-live .setup { display: none; }

/* ---------- 2. 실시간 자막 ---------- */
.live { position: relative; }
.live-head h2 { margin: 0; }
.sub-tools { display: flex; gap: 6px; }
.icon-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; min-width: 36px; height: 34px; padding: 0 9px; font-size: 13px; cursor: pointer; font-family: inherit; }
.icon-btn:hover:not(:disabled) { border-color: var(--primary); }
.icon-btn.toggle.on { background: rgba(108,140,255,.18); border-color: var(--primary); }
.subtitles { height: min(52vh, 440px); scroll-behavior: auto; }
.sub-line .translated { font-size: var(--sub-size); line-height: 1.55; }
.sub-line .original { font-size: max(12px, calc(var(--sub-size) * .65)); }
.sub-line.pending .translated { color: var(--muted); }
.subtitles.hide-original .original { display: none; }
.sub-line:last-child { border-left-color: var(--green); }
.placeholder.onboarding { text-align: left; max-width: 460px; margin: auto; color: var(--text); }
.placeholder.onboarding h3 { margin: 0 0 12px; font-size: 16px; }
.placeholder.onboarding ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.9; font-size: 14px; }
.placeholder.onboarding .muted { font-size: 13px; }
.jump-latest { position: absolute; left: 50%; transform: translateX(-50%); bottom: 64px; background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: 8px 16px; font-size: 13px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.4); z-index: 2; }
.jump-latest.hidden { display: none; }

/* 자막 크게 보기 */
body.focus-mode { overflow: hidden; }
body.focus-mode .live { position: fixed; inset: 0; z-index: 150; border-radius: 0; border: 0; display: flex; flex-direction: column; padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: #0b0d12; }
body.focus-mode .subtitles { flex: 1; height: auto; }
body.focus-mode .sub-line { background: transparent; border-left-width: 4px; }
body.focus-mode .sub-line .translated { font-size: calc(var(--sub-size) * 1.45); }
body.focus-mode .jump-latest { bottom: 90px; }
body.focus-mode .dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 160; border-radius: 0; border: 0; border-top: 1px solid var(--line); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
body.focus-mode .live { padding-bottom: 100px; }
body.focus-mode #focusBtn { background: var(--primary); border-color: var(--primary); }

/* ---------- 3. 강의 후 정리 ---------- */
.post-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.post-head h2 { margin: 0; }
.post-head .muted { font-size: 13px; }
.post-empty { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.post-empty.hidden { display: none; }
.action-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.action-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--text); cursor: pointer; font-family: inherit; transition: .15s; }
.action-card:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-1px); }
.action-card:disabled { opacity: .45; cursor: not-allowed; }
.action-card.busy { opacity: .7; cursor: progress; }
.action-card.active { border-color: var(--primary); background: rgba(108,140,255,.12); }
.ac-icon { font-size: 22px; }
.ac-title { font-weight: 700; font-size: 15px; }
.ac-desc { color: var(--muted); font-size: 12px; }
.ready .action-card:not(:disabled) { border-color: rgba(108,140,255,.45); }

.dub-panel { margin-top: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.dub-panel.hidden { display: none; }
.dub-panel h3 { margin: 0 0 12px; font-size: 15px; }
.dub-mode { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.mode-card { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; font-size: 14px; }
.mode-card input { margin-top: 3px; accent-color: var(--primary); }
.mode-card small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }
.mode-card:has(input:checked) { border-color: var(--primary); background: rgba(108,140,255,.1); }
.mode-card.disabled { opacity: .5; }
.voice-row { margin: 14px 0 0; }
.dub-lang-hint { margin: 12px 0 0; }
.dub-go { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.dub-result { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.dub-result audio { flex: 1; min-width: 220px; }
.dub-result.hidden { display: none; }

/* 결과 탭 */
.result-head { flex-wrap: wrap; gap: 10px; }
.tabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 4px; }
.tab { background: none; border: 0; color: var(--muted); padding: 7px 14px; border-radius: 7px; font-size: 14px; cursor: pointer; font-family: inherit; }
.tab.active { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.tab.empty::after { content: " +"; opacity: .6; }
.result-tools { display: flex; gap: 6px; }
.result-body { white-space: normal; font-size: 15px; }
.result-body.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }

/* ---------- 모달 ---------- */
.modal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-top h2 { margin: 0; }
.modal-box.narrow { max-width: 400px; }
.key-state { display: grid; gap: 6px; margin-bottom: 14px; }
.key-row { display: flex; justify-content: space-between; gap: 10px; background: var(--panel-2); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.key-row .st { font-weight: 600; }
.key-row .st.ok { color: var(--green); } .key-row .st.warn { color: var(--accent); } .key-row .st.off { color: var(--muted); font-weight: 400; }
.btn.ghost { background: transparent; }
.choice-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.choice-btns .btn { width: 100%; text-align: left; padding: 12px 14px; }
.choice-btns .btn small { display: block; color: inherit; opacity: .75; font-weight: 400; margin-top: 2px; font-size: 12px; }

/* 로그인 화면 기능 소개 */
.auth-features { list-style: none; padding: 0; margin: -12px 0 24px; text-align: left; display: grid; gap: 8px; font-size: 14px; color: var(--text); }
.auth-features li { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.auth-box.state-pending .auth-features, .auth-box.state-blocked .auth-features { display: none; }

/* 토스트 */
.toast { bottom: calc(24px + var(--dock-h)); max-width: calc(100vw - 32px); text-align: center; line-height: 1.5; }

/* ---------- 반응형 ---------- */
@media (max-width: 760px) {
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .dub-mode { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --dock-h: 84px; }
  .topbar { flex-wrap: nowrap; }
  .top-right { width: auto; }
  .avatar-btn span { display: none; }
  .avatar-btn { padding: 3px 8px 3px 3px; }
  .lang-pair { grid-template-columns: 1fr; gap: 8px; }
  .swap-btn { justify-self: center; height: 36px; transform: rotate(90deg); }
  .swap-btn:hover:not(:disabled) { transform: rotate(270deg); }
  .lang-pair select { min-width: 100%; }
  /* 엄지로 누르기 쉽게: 하단 고정 도크 */
  .dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; border-radius: 16px 16px 0 0; border-bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(0,0,0,.35); }
  body { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); }
  body.focus-mode .dock { z-index: 160; }
  body.focus-mode .live { padding-bottom: calc(var(--dock-h) + 16px); }
  .subtitles { height: 56vh; }
  .live-head { flex-wrap: wrap; gap: 8px; }
  .icon-btn { height: 38px; min-width: 40px; }
  .jump-latest { bottom: 56px; }
  .post-head { flex-direction: column; gap: 2px; }
  .foot { padding-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 결과 본문 타이포 / 모달 버튼 정렬 */
.result-body > :first-child { margin-top: 0; }
.result-body h2 { font-size: 18px; margin: 18px 0 8px; }
.result-body h3 { font-size: 16px; margin: 16px 0 6px; color: var(--primary); }
.result-body h4 { font-size: 15px; margin: 14px 0 6px; }
.result-body p { margin: 0 0 10px; }
.result-body ul, .result-body ol { margin: 0 0 10px; }
.result-body li { margin: 3px 0; }
.modal-actions #saveKeysBtn { margin-left: auto; }

/* ===== 메뉴 언어 선택 ===== */
.ui-lang { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 4px 0 10px; height: 36px; cursor: pointer; }
.ui-lang:hover, .ui-lang:focus-within { border-color: var(--primary); }
.ui-lang span { font-size: 14px; }
.ui-lang select { background: transparent; border: 0; color: var(--text); font-size: 13px; padding: 6px 4px; min-width: 0; max-width: 150px; cursor: pointer; font-family: inherit; }
.ui-lang select:focus { outline: none; }
.ui-lang select option { background: var(--panel); color: var(--text); }
.auth-lang { display: flex; justify-content: flex-end; margin: -20px -14px 12px 0; }
@media (max-width: 640px) {
  .ui-lang { padding-left: 8px; height: 34px; }
  .ui-lang select { max-width: 92px; font-size: 12px; }
  body.is-live .brand strong { display: none; }
  .top-right { gap: 6px; }
}

/* ===== 교수님 목소리 등록 ===== */
.vr-step { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.vr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.vr-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.vr-step p { margin: 6px 0 10px; line-height: 1.5; }
.vr-ctrl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vr-ctrl audio { flex: 1; min-width: 180px; height: 36px; }
.vr-rec.recording { background: rgba(255,90,94,.18); border-color: var(--red); color: #fff; }
.vr-consent { margin: 0 0 10px; padding: 10px 12px; border-left: 3px solid var(--primary); background: var(--panel); border-radius: 6px; font-size: 15px; line-height: 1.6; }
.vr-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 4px 0 6px; cursor: pointer; }
#voiceModal .vr-check input { width: auto; flex: none; margin: 3px 0 0; padding: 0; accent-color: var(--primary); }
#voiceModal .vr-check { color: var(--text); }
#voiceModal .modal-box { max-height: calc(100vh - 40px); overflow-y: auto; }
#voiceModal input#vrName, #voiceModal select#vrLang { width: 100%; }
#voiceModal select#vrLang { min-width: 0; }
.voice-row .btn.small { white-space: nowrap; }
