/* ===== 색상 (밝은 화면 / 어두운 화면) ===== */
:root {
  --bg: #f5f4fb;
  --surface: #ffffff;
  --surface2: #f0eef9;
  --text: #1d1b2e;
  --muted: #6b6880;
  --line: #e2dfee;
  --primary: #5b4bdb;
  --primary-ink: #ffffff;
  --primary-soft: #ebe8fd;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --part: #a16207;
  --part-bg: #fef3c7;
  --bad: #c62828;
  --bad-bg: #fde2e2;
  --rec: #e11d48;
  --shadow: 0 2px 10px rgba(40, 30, 90, 0.08);
  --radius: 16px;
  --tabbar-h: 64px;
  /* 그래프 색: 맞음 / 일부 다름 / 틀림 (색약 검사 통과) + 달력 단계 */
  --c-ok: #15803d; --c-part: #e8a317; --c-bad: #c62828;
  --h0: #ebe9f3; --h1: #d4cefa; --h2: #a99ff2; --h3: #7a6cea; --h4: #4a3bc9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131c;
    --surface: #1e1c2a;
    --surface2: #272436;
    --text: #edeaf7;
    --muted: #a19db5;
    --line: #34314a;
    --primary: #8b7df5;
    --primary-ink: #14131c;
    --primary-soft: #2c2750;
    --ok: #4ade80;
    --ok-bg: #12351f;
    --part: #fbbf24;
    --part-bg: #3a2c0b;
    --bad: #f87171;
    --bad-bg: #3d1717;
    --rec: #fb7185;
    --shadow: none;
    --c-ok: #178a4c; --c-part: #bf8a0f; --c-bad: #d9467a;
    --h0: #2a2738; --h1: #3b3570; --h2: #5a4fb0; --h3: #7d70e8; --h4: #b0a6fa;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ===== 위쪽 바 ===== */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; }
.top-status { font-size: 14px; color: var(--muted); }

.view { max-width: 560px; margin: 0 auto; padding: 16px; }

/* ===== 아래 탭 (엄지로 누르기 쉬운 위치) ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar button {
  border: 0; background: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; gap: 2px; cursor: pointer;
}
.tabbar button span { font-size: 22px; line-height: 1; filter: grayscale(0.6); }
.tabbar button.active { color: var(--primary); font-weight: 700; }
.tabbar button.active span { filter: none; }

/* 문제 푸는 중에는 메뉴를 숨겨서 화면을 단순하게 */
body.in-session .tabbar, body.in-session .topbar { display: none; }
body.in-session { padding-bottom: 0; }
body.in-session #view-review { padding: 0; max-width: 560px; }

/* ===== 카드, 버튼 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 18px; margin: 0 0 10px; }
.card h3 { font-size: 16px; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; margin-bottom: 10px; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn.rec-on { background: var(--rec); color: #fff; border-color: var(--rec); }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
.link {
  background: none; border: 0; padding: 10px 4px; color: var(--muted);
  text-decoration: underline; cursor: pointer; font-size: 14px;
}

/* ===== 홈 ===== */
.hero { display: flex; gap: 14px; align-items: center; }
.hero-emoji { font-size: 44px; }
.hero h2 { margin: 0 0 2px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 8px; text-align: center;
}
.tile b { display: block; font-size: 22px; }
.tile span { font-size: 12px; color: var(--muted); }

/* ===== 설치 안내 배너 ===== */
.install-banner { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--primary-soft); border-color: var(--primary-soft); }
.ib-icon { font-size: 28px; }
.ib-text { flex: 1; min-width: 0; }
.ib-text small { display: block; font-size: 13px; color: var(--muted); }
.icon-btn.sm { width: 36px; height: 36px; font-size: 14px; }

/* ===== 선택 칩 ===== */
.choices { display: grid; gap: 8px; margin-bottom: 14px; }
.choice {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface);
  text-align: left; cursor: pointer;
}
.choice.on { border-color: var(--primary); background: var(--primary-soft); }
.choice .ic { font-size: 22px; }
.choice small { display: block; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  min-height: 42px; padding: 8px 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600;
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ===== 입력 ===== */
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
input[type="text"], input[type="date"], textarea, select {
  width: 100%; padding: 12px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface2); font-size: 16px; /* 16px 미만이면 폰이 확대돼요 */
}
textarea { resize: vertical; min-height: 150px; line-height: 1.6; }
code { background: var(--surface2); padding: 1px 6px; border-radius: 6px; font-size: 14px; }
.help { font-size: 13px; color: var(--muted); margin: 8px 0; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; margin: 6px 0; }

mark { background: var(--primary-soft); color: var(--primary); font-weight: 700; padding: 0 3px; border-radius: 5px; }

.preview { margin: 10px 0; display: grid; gap: 6px; }
.pv { padding: 8px 10px; border-radius: 10px; font-size: 14px; background: var(--surface2); }
.pv.bad { background: var(--bad-bg); color: var(--bad); }
.pv.dup { opacity: 0.6; }
.pv .ko { font-weight: 600; }

/* ===== 저장된 표현 목록 ===== */
details.day { border-top: 1px solid var(--line); }
details.day:first-of-type { border-top: 0; }
details.day summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0; cursor: pointer; font-weight: 700;
}
details.day summary::-webkit-details-marker { display: none; }
details.day summary .cnt { color: var(--muted); font-weight: 500; font-size: 14px; }
.item { padding: 10px 0 12px; border-top: 1px dashed var(--line); }
.item-ko { font-weight: 600; }
.item-en { margin: 2px 0; }
.item-meta { font-size: 13px; color: var(--muted); }
.item-actions { display: flex; gap: 8px; margin-top: 6px; }

/* ===== 문제 화면 ===== */
.session { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.s-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); font-size: 18px; cursor: pointer; flex: none;
}
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }
.s-count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.s-body { flex: 1; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.q-ko {
  font-size: 26px; font-weight: 800; line-height: 1.4; text-align: center;
  padding: 28px 8px 12px; word-break: keep-all;
}
.q-date { text-align: center; font-size: 13px; color: var(--muted); margin-top: -6px; }
.hint { text-align: center; color: var(--muted); }
.hint b { color: var(--text); font-size: 20px; }
.live {
  min-height: 56px; text-align: center; font-size: 19px; color: var(--muted);
  padding: 8px; border-radius: 12px; background: var(--surface2);
}
.notice { padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.notice.warn { background: var(--part-bg); color: var(--part); }
.notice.info { background: var(--primary-soft); color: var(--text); }

.verdict {
  text-align: center; font-size: 22px; font-weight: 800; padding: 12px; border-radius: 14px;
  animation: pop 0.25s ease-out;
}
.verdict small { display: block; font-size: 13px; font-weight: 500; opacity: 0.85; }
.v-correct { background: var(--ok-bg); color: var(--ok); }
.v-partial { background: var(--part-bg); color: var(--part); }
.v-wrong { background: var(--bad-bg); color: var(--bad); }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.compare { display: grid; gap: 8px; }
.cmp { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.cmp-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.cmp-text { font-size: 18px; line-height: 1.8; }
.w { padding: 1px 2px; border-radius: 4px; }
.w.key { font-weight: 800; border-bottom: 3px solid var(--primary); }
.w.miss { background: var(--bad-bg); color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.w.extra { background: var(--part-bg); color: var(--part); }
.w.form { background: var(--primary-soft); color: var(--primary); text-decoration: underline dotted; text-underline-offset: 4px; }
.w.neutral { color: var(--muted); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.alts { font-size: 13px; color: var(--muted); }
.alts summary { cursor: pointer; }

.s-bottom {
  position: sticky; bottom: 0;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg);
  display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mic {
  width: 104px; height: 104px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font-size: 44px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(91, 75, 219, 0.35);
  transition: transform 0.1s;
}
.mic:active { transform: scale(0.95); }
.mic.on { background: var(--rec); animation: pulse 1.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.5); }
  70% { box-shadow: 0 0 0 22px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}
.mic-label { font-size: 14px; color: var(--muted); }

/* ===== 내 목소리 ===== */
.voice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.voice .link { padding: 6px 0 0; }
audio { width: 100%; height: 44px; margin-top: 4px; display: block; }
.rec-live { font-size: 14px; color: var(--rec); font-weight: 600; }
.meter { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 2px; }
.meter div { height: 100%; width: 0; background: var(--rec); transition: width 0.1s; }

/* ===== 결과 요약 ===== */
.summary-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 16px; }
.summary-big div { text-align: center; padding: 12px 4px; border-radius: 14px; }
.summary-big b { display: block; font-size: 26px; }

/* ===== 기록: 그래프 ===== */
.tiles-4 { grid-template-columns: repeat(2, 1fr); }
.tiles-4 .tile b { font-size: 20px; }
.chart { position: relative; }
.ch-readout { font-size: 13px; color: var(--text); min-height: 20px; margin-bottom: 4px; font-weight: 600; }
.chart svg { display: block; overflow: visible; touch-action: pan-y; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ch-end { font-size: 12px; font-weight: 700; fill: var(--text); }
.ch-col { transition: opacity 0.15s; cursor: pointer; }
.ch-col.dim { opacity: 0.4; }
.ch-dot, .ch-focus { stroke: var(--surface); stroke-width: 2; }
.ch-cross { stroke: var(--muted); stroke-width: 1; }
.ch-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: -4px 0 6px; }
.ch-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.table-view summary { cursor: pointer; font-weight: 700; }
.table-view table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* ===== 기록: 학습 달력 ===== */
.cal-head, .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head span { text-align: center; font-size: 12px; color: var(--muted); }
.cal { margin-top: 4px; }
.cal .cell { aspect-ratio: 1; border-radius: 6px; border: 0; padding: 0; cursor: pointer; }
.cal .cell.h0 { background: var(--h0); } .cal .cell.h1 { background: var(--h1); } .cal .cell.h2 { background: var(--h2); }
.cal .cell.h3 { background: var(--h3); } .cal .cell.h4 { background: var(--h4); }
.cal .cell.future { background: transparent; cursor: default; }
.cal .cell.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal .cell.sel { outline: 2px solid var(--primary); outline-offset: 1px; }
.h0 { background: var(--h0); } .h1 { background: var(--h1); } .h2 { background: var(--h2); }
.h3 { background: var(--h3); } .h4 { background: var(--h4); }
.cal-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cal-legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ===== 약점 ===== */
.weak-note { font-size: 14px; padding: 8px 12px; border-radius: 10px; background: var(--surface2); }
.stage { display: inline-flex; gap: 3px; vertical-align: middle; margin-right: 4px; }
.stage i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.stage i.on { background: var(--primary); }

/* ===== 설정 ===== */
.check-list { list-style: none; padding: 0; margin: 8px 0; }
.check-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
ol.steps { padding-left: 20px; margin: 6px 0; font-size: 14px; }
ol.steps li { margin-bottom: 4px; }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ===== 수정 창 ===== */
dialog {
  border: 0; border-radius: 18px; padding: 18px; width: min(92vw, 480px);
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h3 { margin: 0 0 6px; }
dialog .row { margin-top: 14px; }

/* ===== 알림 ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px); width: max-content;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* 문제 화면에서는 마이크 버튼을 가리지 않도록 위쪽에 */
body.in-session #toast { bottom: auto; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-20px); }
body.in-session #toast.show { transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===================================================== */
/* 🎮 4단계: 게임 요소                                    */
/* ===================================================== */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* 캐릭터 카드 */
.char-card { display: flex; align-items: center; gap: 16px; }
.char {
  width: 84px; height: 84px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 48px;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--stage) 75%);
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--stage);
}
.char span { display: block; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.char-info { flex: 1; min-width: 0; }
.char-name { font-size: 15px; margin-bottom: 6px; }
.char-name b { font-size: 18px; }
.xpbar, .goalbar, .mbar { height: 10px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 4px 0; }
.xpbar div { height: 100%; background: linear-gradient(90deg, #8b7df5, var(--primary)); border-radius: 99px; transition: width 0.6s ease; }

/* 오늘 목표 */
.goal-card .goalbar { height: 14px; }
.goalbar div { height: 100%; background: var(--c-ok); border-radius: 99px; transition: width 0.6s ease; }
.goal-card.done { border-color: var(--c-ok); }
.goal-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-top: 8px; }

/* 주간 미션 */
.mission { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.mission:first-of-type { border-top: 0; }
.m-ic { font-size: 22px; flex: none; }
.m-body { flex: 1; min-width: 0; }
.m-name { font-size: 14px; font-weight: 600; }
.mbar { height: 6px; }
.mbar div { height: 100%; background: var(--primary); border-radius: 99px; }
.m-reward { font-size: 13px; color: var(--muted); white-space: nowrap; }
.m-done { font-size: 13px; color: var(--ok); font-weight: 700; white-space: nowrap; }
.mission.claimed { opacity: 0.6; }

/* 문제 화면: 콤보 + 결과 XP */
.combo { font-size: 14px; font-weight: 800; color: var(--part); animation: pop 0.25s ease-out; }
.xp-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: -4px; }
.xp-chip {
  display: inline-block; padding: 2px 10px; border-radius: 99px; font-weight: 800; font-size: 14px;
  background: var(--primary-soft); color: var(--primary); animation: floatUp 0.5s ease-out;
}
.xp-lv { font-weight: 800; color: var(--primary); }
@keyframes floatUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.sum-xp { margin-top: 4px; }

/* 배지판 */
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.badge {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); cursor: pointer; min-height: 84px;
}
.badge .b-ic { font-size: 28px; filter: grayscale(1); opacity: 0.35; }
.badge .b-name { font-size: 11px; line-height: 1.25; text-align: center; color: var(--muted); word-break: keep-all; }
.badge.on { background: var(--surface); border-color: var(--primary); }
.badge.on .b-ic { filter: none; opacity: 1; }
.badge.on .b-name { color: var(--text); font-weight: 700; }
.badge.sel { outline: 2px solid var(--primary); outline-offset: 1px; }
.b-prog { width: 70%; height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 2px; }
.b-prog i { display: block; height: 100%; background: var(--muted); }

/* 축하 창 */
#celebrate { text-align: center; overflow: hidden; }
#celebrate h3 { font-size: 22px; margin: 8px 0 4px; }
#celebrate p { margin: 0; }
.cel-big {
  font-size: 72px; width: 120px; height: 120px; margin: 8px auto 0; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--stage, var(--primary-soft)) 80%);
  animation: celPop 0.6s cubic-bezier(.2, 1.6, .4, 1);
}
.badge-big { background: radial-gradient(circle at 35% 30%, #fff 0%, #ffd76a 80%); }
.evo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 56px; margin-top: 8px; }
.evo-old { opacity: 0.5; filter: grayscale(0.6); font-size: 40px; }
.evo-arrow { font-size: 24px; color: var(--muted); }
.evo-new {
  width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; font-size: 64px;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--stage) 80%);
  animation: celPop 0.8s 0.2s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes celPop { 0% { transform: scale(0.2) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: 0;
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(420px) rotate(540deg); opacity: 0; }
}

/* ===================================================== */
/* 📚 5-1단계: 표현 노트                                  */
/* ===================================================== */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--surface2); border-radius: 14px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: none; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.seg button:disabled { opacity: 0.4; }
.seg small { font-weight: 600; opacity: 0.8; }
.note-tools input[type="search"] { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); font-size: 16px; }
.note-tools .chips { margin: 10px 0; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chips.scroll-x .chip { flex: none; }
.note-tools select { width: auto; flex: 1; margin: 0; padding: 10px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; white-space: nowrap; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }
.note-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; }
.day-card { padding-top: 6px; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0 8px; font-weight: 700; }
.day-head .cnt { color: var(--muted); font-weight: 500; font-size: 14px; }
.note-item:first-child { border-top: 0; }
.cue { font-size: 14px; color: var(--muted); margin: 2px 0; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface2); }
.tag.weak { background: var(--bad-bg); color: var(--bad); }
.masked { filter: blur(7px); cursor: pointer; user-select: none; transition: filter 0.2s; }
.masked.shown { filter: none; }

/* ===================================================== */
/* 🧩 5-2단계: 빈칸 모드                                  */
/* ===================================================== */
.q-tag { align-self: center; margin-top: 18px; margin-bottom: -18px; font-size: 13px; font-weight: 700;
  padding: 3px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.blank-sent { text-align: center; font-size: 21px; line-height: 1.9; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); word-break: keep-all; }
.blank { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.14em; font-weight: 700;
  color: var(--primary); white-space: nowrap; }
.mode-line { font-size: 14px; color: var(--muted); margin: -4px 4px 10px; }
.mode-line .link { padding: 4px; }

/* ===================================================== */
/* 🗣️ 5-3단계: 음성 대화 모드                             */
/* ===================================================== */
.conv-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface)); border-color: var(--primary); }
.conv-card small { display: block; color: var(--muted); font-size: 13px; }
.conv-ic { font-size: 30px; }
.conv-go { margin-left: auto; font-size: 26px; color: var(--primary); }
.conv-btn { border-color: var(--primary); color: var(--primary); }
.conv-title { text-align: center; font-size: 13px; color: var(--muted); margin-top: 4px; }
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.bubble-row { display: flex; align-items: flex-end; gap: 8px; animation: floatUp 0.3s ease-out; }
.bubble-row.me { flex-direction: row-reverse; }
.avatar { font-size: 26px; flex: none; width: 36px; text-align: center; }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 18px; font-size: 17px; line-height: 1.45;
  background: var(--surface); border: 1px solid var(--line); word-break: keep-all; overflow-wrap: anywhere; }
.bubble-row.bot .bubble { border-bottom-left-radius: 6px; }
.bubble-row.me .bubble { background: var(--primary-soft); border-color: var(--primary-soft); border-bottom-right-radius: 6px; }
.bubble.live { color: var(--muted); font-style: italic; }
.b-en { font-size: 19px; font-weight: 700; }
.b-ko { font-size: 20px; font-weight: 800; }
.b-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.b-res { font-size: 13px; margin-top: 4px; color: var(--muted); }
.conv-status { text-align: center; font-size: 15px; font-weight: 700; color: var(--primary); min-height: 22px; }
.mic.talk { background: var(--surface2); color: var(--text); box-shadow: none; border: 2px solid var(--line); }
.session.conv .s-top { position: sticky; top: 0; z-index: 3; background: var(--bg); }

/* ===================================================== */
/* 📱 QR로 표현 옮기기                                    */
/* ===================================================== */
.qr-box { display: grid; place-items: center; margin: 12px auto 6px; padding: 10px; background: #fff;
  border-radius: 14px; width: min(100%, 300px); min-height: 120px; }
.qr-box svg { width: 100%; height: auto; display: block; }
.qr-pager { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 14px; min-height: 38px; }
.imp-list { max-height: 50vh; overflow-y: auto; }
.note-head .row .btn { flex: none; }

.hint-label { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: -6px; }
