/* ─────────────────────────────────────────────
   씬짜오! 회화카드 — 여행 스티커북 스타일
   저사양 폰 대상: 프레임워크 없음, CSS 효과만 사용
   ───────────────────────────────────────────── */
@font-face {
  font-family: 'Jua';
  src: url('fonts/Jua-Regular.woff2') format('woff2');
  font-display: swap;
}

:root {
  --paper: #FFF6E4;
  --ink: #21304F;
  --red: #E8503A;
  --red-deep: #C93A26;
  --yellow: #FFC531;
  --blue: #2E63E7;
  --mint: #3FBF8F;
  --muted: #8A7F6C;
  --card: #FFFFFF;
  --radius: 18px;
  --shadow: 4px 4px 0 var(--ink);
  /* 섹션 색 (색으로 길찾기) */
  --c-cards: #F0A500;
  --c-learn: #2A9D6F;
  --c-talk: #E8503A;
  --c-travel: #2E63E7;
  --accent: var(--c-cards);
}
/* 현재 탭에 따라 강조색이 바뀜 → 화면 전체가 그 색 무드 */
body[data-view="cards"]  { --accent: var(--c-cards); }
body[data-view="quiz"]   { --accent: var(--c-learn); }
body[data-view="talk"]   { --accent: var(--c-talk); }
body[data-view="tools"]  { --accent: var(--c-travel); }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 속성은 display를 준 요소에서도 항상 숨김 (flex 등에 덮이지 않게) */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: 'Jua', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(232, 80, 58, .10) 2.5px, transparent 2.5px);
  background-size: 26px 26px;
  color: var(--ink);
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;   /* 구형 사파리(iOS<15.4) 폴백 */
  min-height: 100dvh;  /* 모던: 동적 툴바 제외 높이 */
  padding-bottom: 24px;
}

/* ── 헤더 ─────────────────────────── */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 5px solid var(--accent);
  box-shadow: 0 3px 0 rgba(33, 48, 79, .12);
  transition: border-color .2s ease;
}

.brand h1 {
  font-size: 1.7rem;
  letter-spacing: -.5px;
  line-height: 1.1;
}
.brand-vi {
  color: var(--red);
  text-shadow: 2.5px 2.5px 0 var(--yellow);
}
.brand-sub {
  font-size: .82rem;
  color: var(--muted);
  margin-top: 3px;
}
.arrow { color: var(--blue); }

.search-wrap { margin-top: 10px; }
#search {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  box-shadow: 3px 3px 0 var(--ink);
}
#search:focus { border-color: var(--blue); box-shadow: 3px 3px 0 var(--blue); }
#search::placeholder { color: #B4A98F; }

/* ── 카테고리 칩 ───────────────────── */
.chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font: inherit;
  font-size: .95rem;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background-color .08s ease;
}
.chip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.chip.on {
  background: var(--accent);
  color: #fff;
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink);
}

/* ── 카드 목록 ─────────────────────── */
.cards {
  padding: 16px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-title {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 8px 2px 0;
}

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 14px 16px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
  animation: pop .3s ease backwards;
}
.card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-text {
  flex: 1; min-width: 0;
  font: inherit; text-align: left; background: none; border: none;
  padding: 0; margin: 0; cursor: pointer; color: inherit;
}
.card-ko { font-size: 1.18rem; line-height: 1.25; }
.card-vi {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--red);
  margin-top: 4px;
}
.card-pr { font-size: .85rem; color: var(--muted); margin-top: 2px; }

.card-speak {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--yellow);
  box-shadow: 2.5px 2.5px 0 var(--ink);
  font-size: 1.35rem;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.card-speak:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.card-speak.playing { background: var(--mint); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0 20px;
  font-size: 1.05rem;
}

.foot-tip {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
  padding: 18px 16px calc(10px + env(safe-area-inset-bottom));
}
.foot-tip strong { color: var(--red); }

/* ── 크게 보여주기 (베트남 국기 무드) ── */
.show {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--red);
  display: flex;
  flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  animation: show-in .22s ease;
  overflow: hidden;
}
.show[hidden] { display: none; }
@keyframes show-in {
  from { opacity: 0; transform: scale(1.03); }
  to   { opacity: 1; transform: scale(1); }
}

.show-star {
  position: absolute;
  top: -70px;
  right: -60px;
  font-size: 260px;
  line-height: 1;
  color: rgba(255, 197, 49, .22);
  pointer-events: none;
  user-select: none;
}

.show-close {
  align-self: flex-end;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: transparent;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.show-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 10px;
  position: relative;
  perspective: 1400px;
}
.show-label {
  color: rgba(255, 255, 255, .85);
  font-size: .95rem;
  letter-spacing: .5px;
}
/* SOS·의료 오버레이(플립 아님)용 한국어 줄 */
.sos-view .show-ko, .med-view .show-ko {
  color: rgba(255, 255, 255, .92);
  font-size: 1.15rem;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px dashed rgba(255, 255, 255, .4);
}

/* 🔄 뒤집기 카드 (플래시카드) */
.flip-card {
  position: relative;
  flex: 1;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4, .15, .2, 1);
  cursor: pointer;
}
.flip-card.flipped { transform: rotateY(180deg); }
#show.flip-in .flip-card { animation: flipDeal .55s cubic-bezier(.3, 1, .4, 1); }
@keyframes flipDeal {
  from { transform: rotateY(-115deg) scale(.9); opacity: .2; }
  to   { transform: rotateY(0) scale(1); opacity: 1; }
}
.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 6px;
  overflow-y: auto; /* 긴 통역 문장도 잘리지 않고 스크롤 */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-back { transform: rotateY(180deg); }
.show-vi {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 900;
  color: #fff;
  font-size: clamp(2rem, 9.5vw, 3.2rem);
  line-height: 1.2;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .18);
}
.show-pr {
  color: var(--yellow);
  font-size: 1.4rem;
  font-weight: 700;
}
.show-ko-big {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 900;
  color: #fff;
  font-size: clamp(1.9rem, 8.5vw, 3rem);
  line-height: 1.25;
  word-break: keep-all;
  overflow-wrap: break-word;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .18);
}
.flip-hint {
  margin-top: 10px;
  font-size: .92rem;
  color: rgba(255, 255, 255, .82);
  background: rgba(0, 0, 0, .16);
  padding: 7px 14px;
  border-radius: 999px;
}

.show-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.show-speak-row { display: flex; gap: 10px; }
.btn-flip {
  font: inherit;
  font-size: 1.15rem;
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s ease;
}
.btn-flip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-speak {
  font: inherit;
  font-size: 1.05rem;
  padding: 15px 10px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  cursor: pointer;
  transition: transform .08s ease;
}
.btn-speak:active { transform: scale(.96); }
.btn-speak--vi {
  flex: 1.6;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn-speak--ko {
  flex: 1;
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn-speak--slow {
  flex: 0 0 auto;
  min-width: 58px;
  font-size: 1.5rem;
  background: #fff;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

/* ── 하단 탭바 ─────────────────────── */
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 3px solid var(--ink);
}
.tab {
  flex: 1;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease, background-color .1s ease;
}
.tab .ti { font-size: 1.7rem; line-height: 1; transition: transform .15s ease; }
.tab .tl { font-size: .82rem; }
.tab:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
/* 각 탭 고유색 */
#tab-cards { --tc: var(--c-cards); }
#tab-quiz  { --tc: var(--c-learn); }
#tab-talk  { --tc: var(--c-talk); }
#tab-tools { --tc: var(--c-travel); }
.tab .tl { color: var(--tc); }
.tab.on {
  background: var(--tc);
  transform: translateY(-3px);
  box-shadow: 3px 6px 0 var(--ink);
}
.tab.on .tl { color: #fff; }
.tab.on .ti { transform: scale(1.15); }

/* 카드 탭이 아닐 때는 검색·카테고리 숨김 */
body:not([data-view="cards"]) .search-wrap,
body:not([data-view="cards"]) .chips { display: none; }

/* ── 말로 통역 ─────────────────────── */
.talk {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.talk-status {
  width: 100%;
  text-align: center;
  font-size: .95rem;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
}
.talk-status[data-kind="on"] { background: #E4F7EE; }
.talk-status[data-kind="off"] { background: #FBE9E5; }

.seg {
  display: flex;
  gap: 6px;
  width: 100%;
}
.seg-btn {
  flex: 1;
  font: inherit;
  font-size: .82rem;
  padding: 8px 4px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.seg-btn.on { background: var(--accent); color: #fff; }

.talk-auto-hint {
  width: 100%;
  margin: 0;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .85rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
  padding: 8px 12px;
  background: var(--card);
  border: 2px dashed var(--ink);
  border-radius: 12px;
}
.talk-auto-hint b { color: var(--c-talk); }
.talk-auto-hint[hidden] { display: none; }

/* 💾 백업/복원 */
.backup-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.backup-btn {
  flex: 1 1 40%; text-align: center;
  font: inherit; font-size: 1rem; font-weight: 700;
  padding: 12px 10px; border: 3px solid var(--ink); border-radius: 14px;
  background: var(--yellow); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.backup-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.backup-msg {
  margin: 10px 0 0; font-size: .9rem; font-weight: 700;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
}
.backup-msg.ok { color: var(--c-learn); }
.backup-msg.err { color: var(--red); }
.backup-msg[hidden] { display: none; }

.mic {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: var(--red);
  color: #fff;
  font: inherit;
  box-shadow: 6px 6px 0 var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  margin-top: 14px;
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
}
.mic:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.mic:disabled { background: #C9BFA9; cursor: default; }
.mic-icon { font-size: 3.6rem; line-height: 1; }
.mic-label { font-size: 1.05rem; font-weight: 700; padding: 0 16px; text-align: center; line-height: 1.3; }
/* 준비됐을 때 "눌러 보라"고 초대하는 펄스 링 */
.mic:not(:disabled):not(.rec)::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 5px solid var(--red);
  z-index: -1;
  animation: micInvite 1.9s ease-out infinite;
}
@keyframes micInvite {
  0%   { transform: scale(1);    opacity: .55; }
  100% { transform: scale(1.32); opacity: 0; }
}
.mic.rec {
  background: var(--mint);
  animation: breathe 1.1s ease-in-out infinite;
}
.mic.rec::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 5px solid var(--mint);
  z-index: -1;
  animation: micInvite 1s ease-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.typed-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
#typed-text {
  flex: 1;
  font: inherit;
  font-size: .95rem;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  min-width: 0;
}
#typed-text:focus { border-color: var(--blue); }
#typed-text::placeholder { color: #B4A98F; }
#typed-send {
  font: inherit;
  padding: 10px 18px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
#typed-send:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.talk-result {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.talk-empty {
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  padding: 14px 10px;
  border: 3px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--card);
}
.talk-empty[hidden] { display: none; }
.talk-item {
  position: relative;
  font: inherit;
  text-align: left;
  width: 100%;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 12px 16px;
  cursor: pointer;
  animation: pop .25s ease backwards;
}
.talk-item:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
/* 방금 나온 통역을 눈에 띄게 */
.talk-item.newest {
  border-color: var(--c-talk);
  border-left: 9px solid var(--c-talk);
  box-shadow: 4px 4px 0 var(--c-talk);
}
.talk-src { display: block; font-size: .95rem; color: var(--muted); }
.talk-dst {
  display: block;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--red);
  margin-top: 5px;
  word-break: keep-all;
}
.talk-pr { display: block; font-size: .95rem; color: var(--muted); margin-top: 2px; }
.talk-pr--src { font-size: .85rem; margin: 0 0 4px; }
/* 📕 카드 사전 모드 (오프라인) — 초록=온라인 / 노랑=카드 사전 / 빨강=불가 */
.talk-status[data-kind="card"] { background: #FFF1C2; }
.talk-via { font-size: .75rem; padding: 1px 6px; border-radius: 8px; background: #FFF1C2; border: 1.5px solid var(--ink); white-space: nowrap; }
/* 후보 — '번역 결과'와 다른 물체로 보이게: 빨간 큰 글씨·🔊 없음, 점선 테두리 */
.talk-cand { background: #FFFBEF; border-style: dashed; cursor: default; }
.talk-cand.risky { border-color: var(--red); border-style: solid; }
.cand-head { margin: 0 0 8px; font-size: .95rem; line-height: 1.5; }
.cand-warn { margin: 0 0 8px; padding: 8px 10px; border-radius: 10px; background: #FDE3DC; color: var(--red-deep); font-size: .9rem; line-height: 1.45; }
.cand-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  margin: 6px 0 0; padding: 10px 12px; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 2px 2px 0 var(--ink);
}
.cand-row:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.cand-ko { font-size: 1.15rem; color: var(--ink); }
.cand-vi { font-size: .85rem; color: var(--muted); font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; }
.cand-risk { font-size: .82rem; color: var(--red-deep); margin-top: 2px; }
.cand-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cand-act {
  font: inherit; font-size: .88rem; padding: 7px 12px; cursor: pointer;
  background: #fff; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 2px 2px 0 var(--ink);
}
.cand-act--med { background: #FFE9A8; }
.talk-read-vi { display: block; font-size: 1.35rem; margin: 4px 0 2px; font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; }
.talk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.talk-play {
  flex: 0 0 auto;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.talk-play:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--ink); }
.talk-zoom-hint {
  font-size: .85rem;
  color: var(--muted);
}

.talk-settings {
  width: 100%;
  font-size: .9rem;
  color: var(--muted);
}
.talk-settings summary { cursor: pointer; padding: 6px 2px; }
.talk-settings-row { display: flex; gap: 8px; margin-top: 8px; }
#server-url {
  flex: 1;
  font: inherit;
  font-size: .9rem;
  padding: 9px 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
}
#server-save {
  font: inherit;
  padding: 9px 16px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  cursor: pointer;
}
.talk-settings-tip { margin-top: 6px; font-size: .8rem; }

/* ── 📷 사진 번역 ──────────────────── */
.cam-row { width: 100%; }
.cam-btn {
  display: block;
  width: 100%;
  text-align: center;
  font-size: .95rem;
  padding: 12px 14px;
  border: 3px dashed var(--ink);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
.cam-btn:active { background: var(--yellow); }
.cam-item { cursor: default; }
.cam-text {
  display: block;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--ink);
  margin-top: 6px;
  white-space: pre-wrap;
}

/* ── 🧳 여행 도구 ──────────────────── */
.tools {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tool-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tool-card h2 { font-size: 1.15rem; }
.tool-tip { font-size: .85rem; color: var(--muted); }
.tool-tip b { color: var(--red); }

.tool-set { font-size: .9rem; color: var(--muted); }
.tool-set summary { cursor: pointer; padding: 2px 0; }
.tool-set input {
  width: 100%;
  font: inherit;
  font-size: .9rem;
  padding: 9px 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  margin-top: 8px;
}
.tool-set button {
  font: inherit;
  margin-top: 8px;
  padding: 8px 16px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  cursor: pointer;
}

.sos-open {
  font: inherit;
  font-size: 1.25rem;
  line-height: 1.35;
  padding: 18px 14px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--red);
  color: #fff;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
}
.sos-open small { font-size: .8rem; opacity: .9; }
.sos-open:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.sos-view .show-vi { font-size: clamp(1.5rem, 7vw, 2.2rem); }
.sos-line {
  color: #fff;
  font-size: 1.05rem;
  margin-top: 10px;
  line-height: 1.4;
}
.sos-line b { color: var(--yellow); font-size: 1.3rem; word-break: break-all; }
.sos-line[hidden] { display: none; }
.sos-emerg b { font-size: 1.15rem; }
/* 아이 쪽 화면에만 뜨는 경고 — 베트남 어른이 보는 오버레이에는 한국어 안내를 넣지 않는다 */
.sos-warn {
  margin: 10px 0 4px; padding: 10px 12px;
  border: 3px solid var(--ink); border-radius: 12px;
  background: #FFE9A8; color: var(--ink);
  font-size: .9rem; line-height: 1.5;
}
.sos-warn[hidden] { display: none; }

.fx-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fx-row input {
  flex: 1;
  font: inherit;
  font-size: 1.3rem;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  min-width: 0;
}
.fx-unit { font-size: 1.05rem; width: 52px; }
.fx-eq { text-align: center; font-size: 1.2rem; color: var(--muted); }
.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-chip {
  font: inherit;
  font-size: .82rem;
  padding: 6px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}
.fx-chip:active { background: var(--yellow); }
.fx-rate-row input { width: 90px; display: inline-block; margin: 0 4px; }

/* 공지·일정 */
.board-time { font-size: .78rem; color: var(--muted); }
.board-notices { display: flex; flex-direction: column; gap: 8px; }
.board-notice {
  border: 2.5px solid var(--ink);
  border-left: 8px solid var(--red);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}
.bn-text {
  display: block;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .93rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.bn-time { display: block; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.board-sub { font-size: 1rem; margin-top: 4px; }
.board-schedule {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  border: 2.5px dashed var(--ink);
  border-radius: 12px;
  padding: 12px;
  background: #FFFDF6;
}

.board-places { display: flex; flex-wrap: wrap; gap: 8px; }
.place-btn {
  font: inherit;
  font-size: .92rem;
  padding: 9px 14px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 2.5px 2.5px 0 var(--ink);
}
.place-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

/* 준비 체크 */
.prep summary { cursor: pointer; list-style: none; }
.prep summary::-webkit-details-marker { display: none; }
.prep-title { display: inline; }
.prep-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.prep-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
}
.prep-item.ok { background: #E4F7EE; }
.prep-mark { font-size: 1.05rem; flex: 0 0 auto; }
.prep-body { flex: 1; min-width: 0; }
.prep-body b { display: block; font-size: .95rem; }
.prep-body small {
  display: block;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .78rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}
.prep-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.prep-btn {
  font: inherit;
  font-size: .8rem;
  padding: 6px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

/* 통역 결과 발음 표기 */
.talk-pr { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }

/* 방향 버튼 5개 줄바꿈 */
.seg { flex-wrap: wrap; }
.seg-btn { flex: 1 1 30%; }

.mission-count { color: var(--blue); font-size: 1rem; }
.mission-done { color: var(--mint); font-size: 1.05rem; }
.mission-list { display: flex; flex-direction: column; gap: 8px; }
.mission {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font: inherit;
  text-align: left;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
}
.mission.ok { background: #E4F7EE; }
.mission-check { font-size: 1.2rem; flex: 0 0 auto; }
.mission-body b { display: block; font-size: .98rem; }
.mission-body small {
  display: block;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .82rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

/* ── 업데이트 배너 ─────────────────── */
.update-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--blue);
  color: #fff;
  text-align: center;
  padding: 9px 12px;
  font-size: .92rem;
  border-bottom: 3px solid var(--ink);
}
.update-banner[hidden] { display: none; }
.update-banner button {
  font: inherit;
  margin-left: 8px;
  padding: 5px 14px;
  border: 2.5px solid #fff;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
}

/* ── 즐겨찾기 별 ───────────────────── */
.card-star {
  flex: 0 0 auto;
  align-self: center;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  border-radius: 50%;
  border: 2.5px solid #E5DCC8;
  background: #FFFBF0;
  color: #C9BFA9;
  cursor: pointer;
  user-select: none;
  transition: transform .12s ease;
}
.card-star.on {
  color: #F0A500;
  border-color: #F0A500;
  background: #FFF6DC;
}
.card-star.pop { animation: starpop .35s ease; }
@keyframes starpop {
  0% { transform: scale(1); }
  40% { transform: scale(1.5) rotate(12deg); }
  70% { transform: scale(.9); }
  100% { transform: scale(1); }
}


/* ── 📚 학습(퀴즈) ─────────────────── */
.quiz { padding: 18px 16px; }
.quiz-home { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.quiz-title { font-size: 1.6rem; text-align: center; }
.quiz-sub { text-align: center; color: var(--muted); margin-top: -8px; }
.quiz-modes { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.quiz-mode-btn {
  font: inherit;
  font-size: 1.25rem;
  padding: 20px 16px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}
.quiz-mode-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.quiz-mode-btn small { font-size: .85rem; color: var(--muted); }
.quiz-scope {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: .95rem;
  color: var(--muted);
  margin-top: 4px;
}
.quiz-scope select {
  font: inherit;
  font-size: .95rem;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}
.quiz-best { text-align: center; color: var(--mint); font-size: 1rem; min-height: 1.2em; }

/* 배움 허브: 베트남 알기·배움 일기 타일 */
.learn-tiles { display: flex; flex-direction: column; gap: 12px; }
.learn-tile {
  font: inherit; font-size: 1.25rem;
  padding: 20px 16px; text-align: center;
  border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
}
.learn-tile[data-open="culture"] { background: #FDEBD6; }
.learn-tile[data-open="journal"] { background: #E4F0FB; }
.learn-tile:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.learn-tile small { font-size: .85rem; color: var(--muted); font-weight: normal; }
.learn-quiz {
  margin-top: 6px; padding-top: 14px;
  border-top: 3px dashed var(--border-strong, #C9BFA9);
  display: flex; flex-direction: column; gap: 12px;
}
.learn-quiz-h { text-align: center; font-size: 1.05rem; color: var(--muted); }

/* 하위 화면 공통 바 */
.sub-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sub-back {
  font: inherit; padding: 8px 14px; border: 3px solid var(--ink);
  border-radius: 999px; background: var(--card); cursor: pointer;
}
.sub-title { font-size: 1.2rem; }

/* 🇻🇳 베트남 알기 */
.culture-list { display: flex; flex-direction: column; gap: 12px; }
.culture-card {
  border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--card); padding: 16px;
}
.culture-h { font-size: 1.1rem; margin-bottom: 8px; }
.culture-b {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .95rem; line-height: 1.7; color: var(--ink);
}

/* 📔 배움 일기 */
.journal-form {
  display: flex; flex-direction: column; gap: 10px;
  border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--card); padding: 14px;
}
.journal-form input, .journal-form textarea {
  width: 100%; font: inherit; font-size: .95rem;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  padding: 10px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #FFFDF6;
}
.journal-form textarea { min-height: 70px; resize: vertical; }
.journal-form #j-save {
  font-family: 'Jua', sans-serif; font-size: 1.05rem; padding: 12px;
  border: 3px solid var(--ink); border-radius: 14px;
  background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.journal-tools { display: flex; align-items: center; justify-content: space-between; margin: 12px 2px; }
.journal-count { color: var(--muted); font-size: .9rem; }
.j-copy {
  font: inherit; font-size: .9rem; padding: 8px 14px;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--blue); color: #fff; cursor: pointer;
}
.journal-list { display: flex; flex-direction: column; gap: 10px; }
.journal-card {
  border: 3px solid var(--ink); border-radius: 14px; background: var(--card); padding: 12px 14px;
}
.jc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.jc-date { font-size: 1.05rem; color: var(--red); }
.jc-del { font: inherit; border: none; background: none; cursor: pointer; font-size: 1.05rem; }
.journal-card p {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: .92rem; line-height: 1.55; margin-top: 3px;
}
.jc-word { color: var(--red); }

/* 🙋 친구가 소개하는 엄마 나라 */
.friend-card { background: #FFF3E0; border-color: var(--red); }
.friend-card .culture-h { color: var(--red-deep); }
.friend-phrases {
  margin-top: 10px; border-top: 2px dashed var(--red);
  padding-top: 10px; display: flex; flex-direction: column; gap: 6px;
}
.fp-h { font-size: .95rem; color: var(--muted); }
.fp-row {
  display: flex; align-items: center; gap: 8px;
  font: inherit; text-align: left;
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--card);
  padding: 8px 10px; cursor: pointer;
}
.fp-ko { flex: 0 0 auto; font-size: .9rem; }
.fp-vi { flex: 1; font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; font-weight: 800; color: var(--red); }
.fp-spk { flex: 0 0 auto; font-size: 1.1rem; }
.friend-msg {
  margin-top: 10px; font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-size: 1rem; color: var(--red-deep); font-weight: 800;
}

/* 📝 나의 배움 발표 */
.report-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.report-tools input {
  flex: 1 1 100%; font: inherit; font-size: .95rem; padding: 10px 12px;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--card);
}
.report-print, .report-share {
  font: inherit; font-size: .95rem; padding: 10px 16px; flex: 1;
  border: 3px solid var(--ink); border-radius: 12px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}
.report-print { background: var(--yellow); }
.report-share { background: var(--blue); color: #fff; }
.report-paper {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 18px;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
}
.rp-title { font-family: 'Jua', sans-serif; font-size: 1.5rem; text-align: center; color: var(--red); }
.rp-sub { text-align: center; color: var(--muted); font-size: .95rem; margin: 4px 0 16px; }
.rp-sec { margin-bottom: 16px; }
.rp-h { font-family: 'Jua', sans-serif; font-size: 1.1rem; border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 8px; }
.rp-item { font-size: .95rem; line-height: 1.7; }
.rp-jrn { border-left: 4px solid var(--yellow); padding-left: 10px; margin-bottom: 10px; }
.rp-jdate { font-weight: 800; color: var(--red); }
.rp-empty { color: var(--muted); font-size: .9rem; }

/* ✨ 스플래시 (앱을 켤 때마다 잠깐) */
.splash {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 50% 36%, #FFF6E4 0%, #FFE7BC 58%, #FFD37E 100%);
  transition: opacity .4s ease, visibility .4s;
}
.splash.gone { opacity: 0; visibility: hidden; }
.splash[hidden] { display: none; }
.splash-inner { text-align: center; }
.splash-logo {
  font-size: 4rem; line-height: 1; letter-spacing: -4px;
  animation: splashPop .6s cubic-bezier(.2, 1.5, .4, 1) both;
}
.splash-hand { display: inline-block; transform-origin: 70% 85%;
  animation: splashWave 1s ease-in-out .55s 2; }
.splash-title {
  font-size: 2.7rem; margin-top: 12px; color: var(--ink);
  text-shadow: 3px 3px 0 var(--yellow); animation: splashRise .5s ease .15s both;
}
.splash-sub {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; font-weight: 800;
  color: var(--ink); opacity: .72; margin-top: 2px; font-size: 1rem;
  animation: splashRise .5s ease .28s both;
}
.splash-dots { display: flex; gap: 13px; justify-content: center; margin-top: 26px; }
.splash-dots i {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--dc); border: 2.5px solid var(--ink);
  animation: splashBounce .7s ease-in-out infinite;
  animation-delay: calc(var(--d) * .13s);
}
@keyframes splashPop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes splashRise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes splashWave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(20deg); } 75% { transform: rotate(-12deg); } }
@keyframes splashBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-11px); } }

/* 👋 첫 실행 환영 */
.welcome {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(33, 48, 79, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.welcome[hidden] { display: none; }
.welcome-box {
  position: relative;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 22px;
  box-shadow: 6px 6px 0 var(--ink); padding: 30px 20px 22px; max-width: 420px; width: 100%;
  max-height: 92vh; overflow-y: auto;
  animation: welcomePop .42s cubic-bezier(.2, 1.35, .4, 1) both;
}
@keyframes welcomePop { from { transform: translateY(22px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.welcome-mascot {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  width: 56px; height: 56px; font-size: 1.9rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--yellow); border: 4px solid var(--ink); border-radius: 50%;
  box-shadow: 2px 3px 0 var(--ink); animation: splashWave 1.4s ease-in-out .3s 2;
}
.welcome-h { font-size: 1.7rem; text-align: center; margin-top: 4px; }
.welcome-sub {
  text-align: center; color: var(--muted); margin: 6px 0 16px; line-height: 1.45;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
}
.welcome-sub b { color: var(--ink); }
.welcome-tabs { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.welcome-tabs li {
  display: flex; align-items: center; gap: 11px;
  border: 3px solid var(--ink); border-left: 9px solid var(--wc);
  border-radius: 14px; background: var(--card); padding: 9px 12px;
}
.welcome-tabs .wt-ic {
  flex: 0 0 40px; width: 40px; height: 40px; font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--wc); border: 2.5px solid var(--ink); border-radius: 11px;
}
.welcome-tabs .wt-txt { display: flex; flex-direction: column; min-width: 0; }
.welcome-tabs b { color: var(--ink); font-size: 1.1rem; }
.welcome-tabs em {
  font-style: normal; color: var(--muted); font-size: .82rem; line-height: 1.3;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
}
.welcome-hint {
  text-align: center; margin: 14px 0 0; padding: 8px;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; font-weight: 700;
  color: var(--ink); background: var(--paper);
  border: 2.5px dashed var(--ink); border-radius: 12px; font-size: .92rem;
}
.welcome-hint b { color: var(--red); }
.welcome-snooze {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-top: 16px; cursor: pointer;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; font-weight: 700;
  color: var(--ink); font-size: .95rem;
}
.welcome-snooze input { width: 22px; height: 22px; accent-color: var(--c-talk); }
.welcome-btn {
  font: inherit; font-size: 1.3rem; width: 100%; margin-top: 12px; padding: 14px;
  border: 3px solid var(--ink); border-radius: 16px; background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.welcome-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-title, .splash-sub, .splash-hand, .splash-dots i,
  .welcome-box, .welcome-mascot,
  .mic.rec, .mic::before, .mic.rec::after,
  #show.flip-in .flip-card { animation: none; }
  .flip-card { transition: none; }
}

/* 🩺 알레르기·의료 */
.med-open {
  font: inherit; font-size: 1.05rem; width: 100%;
  padding: 14px; border: 3px solid var(--ink); border-radius: 14px;
  background: #FFE9A8; box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.med-open[hidden] { display: none; }
.med-view { background: #1C7C54; }
.med-big {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 900; color: #fff; font-size: clamp(1.8rem, 8vw, 2.6rem);
  line-height: 1.35; text-align: center; padding: 0 8px; white-space: pre-wrap;
}

/* 📔 일기 유실 방지 알림 */
.journal-nudge {
  background: #FFF3CD; border: 3px solid var(--ink); border-radius: 14px;
  padding: 10px 12px; margin: 12px 0; font-size: .9rem; line-height: 1.5;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
}
.journal-nudge b { color: var(--red); }

/* 👀 화면 설정 (접근성) */
.a11y-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.a11y-btns { display: flex; gap: 6px; }
.a11y-btns button {
  font: inherit; font-size: .9rem; padding: 8px 12px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--card); cursor: pointer;
}
.a11y-btns button.on { background: var(--yellow); }
.a11y-contrast { display: flex; align-items: center; gap: 8px; font-size: .95rem; cursor: pointer; }
.a11y-contrast input { width: 20px; height: 20px; }

/* 고대비 모드 */
body.contrast {
  --muted: #4A4033;
  --card: #FFFFFF;
}
body.contrast .card-pr, body.contrast .talk-pr, body.contrast .card-vi { font-weight: 800; }
body.contrast .card, body.contrast .chip, body.contrast .tab,
body.contrast .tool-card, body.contrast .talk-item { border-width: 4px; }
body.contrast .brand-sub, body.contrast .foot-tip { color: #3A3226; }

/* 인쇄 — 발표 자료만 깔끔하게 */
@media print {
  .top, .tabbar, .update-banner, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .quiz { padding: 0; }
  .report-paper { border: none; box-shadow: none; padding: 0; }
  .rp-item, .rp-sub { color: #000 !important; }
}

.quiz-play { display: flex; flex-direction: column; gap: 16px; }
.quiz-bar { display: flex; align-items: center; justify-content: space-between; }
.quiz-exit {
  font: inherit; width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--card); cursor: pointer;
}
.quiz-progress { font-size: 1rem; color: var(--muted); }
.quiz-score { font-size: 1.15rem; }
.quiz-card {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
  padding: 28px 20px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-align: center;
}
/* 🃏 플래시카드 3D 뒤집기 (크게 보기 카드와 통일) */
.quiz-card.flash {
  cursor: pointer;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  min-height: 0;
  height: clamp(220px, 44vh, 320px);
  perspective: 1200px;
  display: block;
}
.q-flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4, .15, .2, 1);
}
.q-flip.flipped { transform: rotateY(180deg); }
.q-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 22px 18px;
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
  overflow-y: auto;
}
.q-back { transform: rotateY(180deg); background: #FFFDF6; }
.q-label { font-size: .95rem; color: var(--muted); }
.q-ko { font-size: 1.7rem; line-height: 1.25; }
.q-vi {
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  font-weight: 800; font-size: 1.8rem; color: var(--red); line-height: 1.25;
}
.q-pr { font-size: 1.2rem; color: var(--muted); }
.q-flip-hint {
  font-size: .85rem; color: var(--muted);
  background: var(--paper); border: 2px dashed var(--ink);
  padding: 5px 13px; border-radius: 999px; margin-top: 2px;
}
.q-speak {
  font: inherit; font-size: 1rem; font-weight: 700;
  padding: 8px 18px; border: 3px solid var(--ink); border-radius: 12px;
  background: var(--c-learn); color: #fff; box-shadow: 2px 2px 0 var(--ink); cursor: pointer;
}
.q-speak:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--ink); }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.q-opt {
  font: inherit; font-size: 1.15rem;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif;
  padding: 15px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.q-opt:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.q-opt.done { cursor: default; }
.q-opt.right { background: #C8F0DC; border-color: var(--c-learn); animation: rightpop .4s ease; }
.q-opt.right::after { content: ' ⭕'; }
.q-opt.wrong { background: #FBD5CC; animation: wrongshake .35s ease; }
.q-opt.wrong::after { content: ' ❌'; }
@keyframes rightpop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes wrongshake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* ⌨️ 키보드·스위치 접근 — 어디에 있는지 또렷하게 */
:focus-visible {
  outline: 4px solid var(--c-travel);
  outline-offset: 2px;
  border-radius: 6px;
}

/* 잠깐 뜨는 안내 배너 */
.xc-toast {
  position: fixed; left: 14px; right: 14px; margin: 0 auto;
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: fit-content; max-width: 460px; z-index: 90;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans', sans-serif; font-weight: 700; font-size: .92rem;
  color: #fff; background: var(--ink);
  border: 3px solid var(--ink); border-radius: 14px; padding: 12px 18px;
  box-shadow: 4px 4px 0 rgba(0,0,0,.25); text-align: center; line-height: 1.4;
  opacity: 0; pointer-events: none; transform: translateY(20px);
  transition: opacity .25s ease, transform .25s ease;
}
.xc-toast.on { opacity: 1; transform: translateY(0); }

/* 🎉 축하 컨페티 */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span {
  position: absolute; top: -6vh; will-change: transform, opacity;
  animation: confetti-fall 2.2s cubic-bezier(.25,.6,.4,1) forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(115vh) rotate(540deg); opacity: 0; }
}
.quiz-next {
  font: inherit; font-size: 1.1rem; padding: 14px;
  border: 3px solid var(--ink); border-radius: 16px;
  background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
}
.quiz-next[hidden] { display: none; }

.quiz-done {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 40px 20px; text-align: center;
}
.quiz-done-emoji { font-size: 4rem; }
.quiz-done-score { font-size: 1.4rem; }
.quiz-done-msg { font-size: 1.1rem; color: var(--muted); }
.quiz-again, .quiz-home-btn {
  font: inherit; font-size: 1.1rem; width: 100%; max-width: 320px; padding: 14px;
  border: 3px solid var(--ink); border-radius: 16px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.quiz-again { background: var(--yellow); }
.quiz-home-btn { background: var(--card); }

@media (prefers-reduced-motion: reduce) {
  .card, .show, .mic.rec,
  .q-opt.right, .q-opt.wrong { animation: none; }
  .q-flip { transition: none; }
  .confetti { display: none; }
}

.phone-link {display:flex; flex-wrap:wrap; justify-content:space-between; gap:6px; align-items:center; padding:14px; margin:0 0 14px; background:#e2f2e9; color:#163c32; border:2px solid currentColor; border-radius:12px; text-decoration:none; font-weight:700}
.phone-link span {font-size:.82em}
