:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #86868b;
  --line: #e3e3df;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --rec: #e5484d;
  --other: #eef3ff;
  --me: #fff4e6;
  --note: #fff9db;
  --ok: #2e9e5b;
  --nav-h: 60px;
  --top-h: 54px;   /* 상단 제목줄 높이 (10 + 34 + 10) */
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --panel: #1d1d20;
    --text: #ececef;
    --muted: #8d8d93;
    --line: #2d2d32;
    --accent-soft: #1e2a47;
    --other: #1b2438;
    --me: #2f2619;
    --note: #2f2b17;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  min-height: 100dvh;
  word-break: keep-all;        /* 한국어를 단어 중간에서 자르지 않음 */
  overflow-wrap: anywhere;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--rec); }
button.icon { padding: 6px 9px; border: 0; background: transparent; font-size: 17px; }
button:disabled { opacity: .5; }
input[type=text], textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
}
textarea { resize: vertical; }

/* ---------- 상단 / 하단 ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.top h1 { font-size: 20px; line-height: 34px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--panel); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 12px; gap: 2px;
}
.tabs a span { font-size: 20px; }
.tabs a.active { color: var(--accent); font-weight: 600; }
body.recording .tabs { display: none; }
body.recording { padding-bottom: 0; }

main { padding: 0 16px 24px; max-width: 1000px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
h2 { font-size: 17px; margin: 20px 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }

/* ---------- 시작 화면 ---------- */
.start-hero { text-align: center; padding: 28px 8px 8px; }
.start-hero .mic { font-size: 54px; }
.big-btn { width: 100%; padding: 18px; font-size: 18px; border-radius: 14px; }
.status-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }

.start-hero { padding: 40px 8px 20px; }
.start-hero p { margin: 6px 0 18px; }
.start-btn { max-width: 420px; margin: 0 auto; display: block; padding: 20px; font-size: 19px; border-radius: 16px; }
.ready { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.prep { padding: 0; }
.prep summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.prep summary::-webkit-details-marker { display: none; }
.prep summary::after { content: "▾"; position: absolute; right: 16px; color: var(--muted); }
.prep { position: relative; }
.prep[open] summary::after { content: "▴"; }
.prep-title { font-weight: 700; }
.prep-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px; }
.prep > .stack { padding: 0 16px 16px; }
.prep .materials { margin: 0; background: var(--bg); border: 0; }
.prep .followup { background: var(--bg); border: 0; margin: 0; }

/* ---------- 녹음 중 ---------- */
.recbar {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px;
}
.livehead { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--top-h)); z-index: 9; background: var(--bg); padding: 0 0 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1.2s infinite; }
.paused .dot { animation: none; background: var(--muted); }
@keyframes blink { 50% { opacity: .3; } }
.meter { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--muted); transition: width .1s; }
.meter i.voiced { background: var(--ok); }
.timer { font-variant-numeric: tabular-nums; font-size: 14px; }

/* 글자 크기 (녹음 바의 '가' 버튼) */
body { --fs: 17px; }
body.fs-s { --fs: 15px; }
body.fs-l { --fs: 20px; }

.lines { padding-bottom: 140px; }
.turn { border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; background: var(--other); }
.turn.me { background: var(--me); }
.turn.listening { background: transparent; color: var(--muted); font-size: 14px; padding: 4px 14px; }
.turn .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.turn .pair { display: grid; gap: 2px; }
.turn .orig { font-size: var(--fs); font-weight: 600; line-height: 1.45; }
.turn .trans { font-size: calc(var(--fs) - 1px); line-height: 1.5; }
/* 한 발언 안의 문장들: 카드 하나에 얇은 줄로 구분 */
.sent + .sent { margin-top: 6px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, var(--muted) 30%, transparent); }
.tools { white-space: nowrap; display: none; }
.sent { cursor: pointer; border-radius: 8px; }
.sent.show-tools .tools { display: inline; }
.sent.show-tools { background: color-mix(in srgb, var(--panel) 55%, transparent); }
.tools button { border: 0; background: transparent; padding: 0 3px; font-size: .8em; opacity: .7; }
.gist {
  font-weight: 700; font-size: calc(var(--fs) - 1px); line-height: 1.45;
  background: var(--panel); border-radius: 10px; padding: 7px 10px; margin: 2px 0 8px;
}
.gist.pending { font-weight: 400; color: var(--muted); font-size: 13px; }
.new-lines {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(120px + var(--safe-b)); z-index: 25;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 8px 16px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
body.sheet-open .new-lines { bottom: calc(56dvh + 10px); }
.turn .trans::before { content: "→ "; color: var(--muted); }
.turn .note, .explain { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--note); font-size: 14px; line-height: 1.5; }
.explain ul { margin: 6px 0 0; padding-left: 18px; }
.pending { color: var(--muted); font-style: italic; }
.turn .pair.ko-line .trans { order: 2; }  /* 접은 화면: 내가 한 한국어 먼저, 영어 표현은 아래 */
.colhead { display: none; }

/* 펼친 폴드 / 태블릿: 왼쪽 English, 오른쪽 한국어 — 같은 줄 = 같은 시간 */
@media (min-width: 600px) {
  .colhead {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0;
    font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted);
    padding: 6px 0 4px;
  }
  .colhead > div { padding: 0 14px; }
  .colhead > div + div { border-left: 1px solid transparent; }
  .detail-colhead { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--top-h) + 40px); box-shadow: 0 -6px 0 var(--bg); z-index: 8; background: var(--bg); }

  .turn .pair { grid-template-columns: 1fr 1fr; gap: 0; }
  .turn .pair > div { padding: 2px 14px 2px 0; }
  .turn .pair > div + div { padding: 2px 0 2px 14px; border-left: 1px solid color-mix(in srgb, var(--muted) 30%, transparent); }
  .turn .pair.ko-line .trans { order: 0; }
  .turn .orig, .turn .trans { font-size: var(--fs); line-height: 1.5; }
  .turn .trans::before { content: ""; }
  .turn .trans { font-weight: 400; }
  .turn .note { margin-left: 50%; } /* 설명은 한국어 쪽 아래 */
}

/* ---------- 대답 도움 시트 ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(0,0,0,.08);
  padding: 8px 16px calc(12px + var(--safe-b));
  max-height: 55dvh; display: flex; flex-direction: column;
}
body.sheet-open .lines { padding-bottom: 56dvh; }  /* 시트가 열려도 마지막 문장이 가려지지 않게 */
.sheet-handle { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: 600; }
.sheet-handle .badge { background: var(--rec); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.sheet-body { overflow-y: auto; margin-top: 6px; }
.sheet.collapsed .sheet-body { display: none; }
.sug { width: 100%; text-align: left; margin-bottom: 8px; border-radius: 12px; padding: 12px; display: block; }
.sug .tone { font-size: 11px; color: var(--accent); font-weight: 700; }
.sug .en { font-size: 17px; font-weight: 600; margin: 3px 0; line-height: 1.4; }
.sug .ko { font-size: 13px; color: var(--muted); }
.composer { display: flex; gap: 8px; margin-top: 8px; }
.composer input { flex: 1; }

/* ---------- 사전 자료 ---------- */
.materials h3 { margin-bottom: 8px; }
.mat { border-top: 1px solid var(--line); padding: 10px 0; }
.mat-row { display: flex; align-items: center; gap: 10px; }
.mat-icon { font-size: 22px; }
.mat-main { flex: 1; min-width: 0; }
.mat-name { font-weight: 600; }
.mat-notes {
  white-space: pre-wrap; font-family: inherit; font-size: 13px; line-height: 1.55;
  background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 8px 0 0; max-height: 50vh; overflow: auto;
}
.mt-pick { text-align: left; width: 100%; margin-bottom: 6px; }
.followup { padding: 10px; }
.followup .mt-pick:only-child { border: 0; margin: 0; }
.series { margin: 8px 0 0; }
.series .chip { text-decoration: none; color: inherit; }
.series .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.series .chip.next { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.round { display: inline-block; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; margin-right: 6px; vertical-align: 2px; }

/* ---------- 기록 ---------- */
.mt-item { display: block; text-decoration: none; color: inherit; }
.mt-item .title { font-weight: 700; margin-bottom: 4px; }
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin: 8px 0 14px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 10px; font-size: 14px; }
/* 미팅 상세의 요약/학습/대화/자료 탭은 스크롤해도 위에 고정 */
.detail-tabs { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--top-h)); z-index: 9; box-shadow: 0 -8px 0 8px var(--bg); }
.seg button.on { background: var(--panel); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
ul.plain { margin: 0; padding-left: 20px; line-height: 1.6; }

/* ---------- 학습 ---------- */
.study-item { position: relative; }
.study-item .en { font-size: 17px; font-weight: 700; line-height: 1.4; }
.study-item .ko { margin-top: 4px; line-height: 1.5; }
.study-item .ex { margin-top: 8px; font-size: 14px; line-height: 1.5; padding-left: 10px; border-left: 3px solid var(--line); }
.study-item .from { font-size: 11px; color: var(--muted); margin-top: 8px; }
.study-item.known { opacity: .55; }
.study-item .icon { padding: 0 4px; font-size: 15px; line-height: 1; }
.tools-inline { white-space: nowrap; }
.hide-meaning .study-item:not(.revealed) .hideable { filter: blur(6px); user-select: none; }
.hide-meaning .study-item:not(.revealed) { cursor: pointer; }
.check { position: absolute; top: 10px; right: 10px; font-size: 12px; padding: 4px 9px; border-radius: 999px; }
.check.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.study-item .en, .study-item h3 { padding-right: 70px; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; margin: 4px 0 12px; }

/* ---------- 미팅 중 화면: 어두운 테마 + 말풍선 ---------- */
body.recording {
  --bg: #0e1014; --panel: #191c22; --text: #eef0f4; --muted: #8b92a1; --line: #2a2f38;
  --other: #1c2029; --me: #1b2a46; --note: #2a2716; --accent-soft: #1c2a48;
}
body.recording .top { background: color-mix(in srgb, var(--bg) 90%, transparent); }
body.recording .turn { border-radius: 18px; padding: 10px 14px 12px; box-shadow: 0 1px 0 rgba(255,255,255,.03) inset; }
body.recording .turn .orig { color: #fff; }
body.recording .turn .trans { color: #b9c1d0; }
body.recording .turn .meta .chip { background: transparent; border-color: var(--line); color: var(--muted); }
body.recording .gist { background: #232836; }
/* 접은 화면(좁은 폭): 상대방은 왼쪽, 나는 오른쪽 말풍선 */
@media (max-width: 599px) {
  body.recording .turn { max-width: 92%; border-top-left-radius: 6px; }
  body.recording .turn.me { margin-left: auto; border-top-left-radius: 18px; border-top-right-radius: 6px; }
}
.turn.partial .orig, .turn.partial .trans { opacity: .72; }
.turn.listening { display: flex; align-items: center; gap: 8px; }
.talking {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: middle;
  background: var(--ok); animation: blink 1s infinite;
}

/* 대답 도움: 빠른 버튼 */
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button {
  flex: none; border-radius: 999px; padding: 7px 12px; font-size: 14px;
  background: var(--bg); border: 1px solid var(--line);
}
.quick button:active { background: var(--accent); color: #fff; }

/* ---------- ⋯ 메뉴 ---------- */
.more { font-size: 22px; font-weight: 700; padding: 2px 10px; }
.sheet-menu { padding: 8px 12px calc(12px + var(--safe-b)); }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 15px 10px; font-size: 16px; border-radius: 10px; }
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: var(--rec); }
.menu-item.cancel { text-align: center; color: var(--muted); margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; }
.series:empty { display: none; }

/* ---------- 발음 연습 ---------- */
.pr-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.pr-card {
  background: var(--panel); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-b));
}
@media (min-width: 600px) { .pr-overlay { align-items: center; } .pr-card { border-radius: 20px; } }
.pr-sentence { font-size: 21px; font-weight: 700; line-height: 1.45; margin-top: 10px; }
.pr-result { margin-top: 14px; }
.pr-score { font-size: 28px; font-weight: 800; display: flex; align-items: baseline; gap: 10px; }
.pr-score span { font-size: 14px; font-weight: 500; color: var(--muted); }
.pr-score.good { color: var(--ok); }
.pr-score.mid { color: #d98a00; }
.pr-score.low { color: var(--rec); }
.pr-words { font-size: 20px; line-height: 1.8; margin: 8px 0; }
.pr-words span { margin-right: 6px; padding: 1px 3px; border-radius: 6px; }
.pr-words .ok { color: var(--ok); }
.pr-words .miss { color: var(--rec); background: color-mix(in srgb, var(--rec) 12%, transparent); text-decoration: underline wavy; cursor: pointer; }
.pr-tries { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.pr-tries .chip.good { background: var(--ok); color: #fff; border-color: var(--ok); }
.recording-now { background: var(--rec) !important; border-color: var(--rec) !important; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 70; max-width: 90vw;
}
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 로그인 ---------- */
.login-overlay { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card h2 { margin: 0; }
.login-card p { margin: 0; }
.login-icon { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 4px; }
.login-input { font-size: 18px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-align: center; letter-spacing: 1px; }
.login-btn { padding: 14px; font-size: 16px; }
.login-msg { min-height: 1.4em; color: var(--rec); font-size: 14px; }
