/* 배치: 한 화면 앱. 위 = 이름과 탭, 가운데 = 대화 기록(스크롤), 아래 = 자주 쓰는 말, 큰 말하기 버튼 두 개, 글 입력 칸.
   한국어는 파랑, 네팔어는 진홍으로 구분한다. 누르는 곳은 56px 이상. 글꼴은 휴대폰에 들어 있는 것을 쓴다. */
:root {
  color-scheme: light;
  --bg: #EDF0F4;
  --surface: #FFFFFF;
  --ink: #17202B;
  --muted: #586474;
  --line: #D3DAE3;
  --ko: #1D4FA3;
  --ko-soft: #E1EAF9;
  --ne: #B3122F;
  --ne-soft: #FBE4E8;
  --on-accent: #FFFFFF;
  --warn-bg: #FFF2CC;
  --warn-ink: #5C4400;
  --font: "Noto Sans KR", "Noto Sans CJK KR", "SamsungOneKorean", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-ne: "Noto Sans Devanagari", "Kohinoor Devanagari", "Mangal", "Nirmala UI", "Noto Sans KR", system-ui, sans-serif;
  --tap: 56px;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10151C; --surface: #1A212B; --ink: #E9EEF4; --muted: #9BA8B7; --line: #2D3743;
    --ko: #82ACF3; --ko-soft: #1A2A44; --ne: #F27D90; --ne-soft: #3E1F28;
    --on-accent: #0E1218; --warn-bg: #3D3210; --warn-ink: #F3DFA0;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-text-size-adjust: 100%;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--ko); outline-offset: 2px; }
.ne { font-family: var(--font-ne); line-height: 1.7; }
.gut { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* 머리 */
.top { background: var(--surface); border-bottom: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.name { font-weight: 900; font-size: 1.15rem; letter-spacing: -0.01em; margin: 0; display: flex; align-items: baseline; gap: 8px; }
.name .ne { font-weight: 700; font-size: 1rem; color: var(--ne); }
.name .kr { color: var(--ko); }
.tabs { margin-left: auto; display: flex; gap: 4px; background: var(--bg); border-radius: 999px; padding: 4px; }
.tab { border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; min-height: 40px; font-weight: 700; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--surface); }

.note { background: var(--warn-bg); color: var(--warn-ink); padding-top: 8px; padding-bottom: 8px; font-size: 0.9rem; }

/* 가운데 */
.pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-top: 14px; padding-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.empty { margin: auto 0; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 6px; padding: 24px 0; }
.empty b { color: var(--ink); font-size: 1.1rem; }

.msg { max-width: 90%; padding: 12px 14px; border-radius: var(--r); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg.from-ko { align-self: flex-start; background: var(--ko-soft); border-bottom-left-radius: 4px; }
.msg.from-ne { align-self: flex-end; background: var(--ne-soft); border-bottom-right-radius: 4px; }
.msg .who { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; }
.msg.from-ko .who { color: var(--ko); }
.msg.from-ne .who { color: var(--ne); }
.msg .src { color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.msg .out { font-size: 1.6rem; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.msg .out.ne { line-height: 1.7; }
.msg .pron { font-size: 1rem; opacity: 0.85; overflow-wrap: anywhere; }
.msg .back { font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.msg .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.msg .time { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; min-height: 40px; font-weight: 500; font-size: 0.9rem; }
.mini:disabled { opacity: 0.55; }
.busy { color: var(--muted); font-size: 1.1rem; }
.err { color: var(--ne); font-weight: 500; }

/* 아래 */
.dock { background: var(--surface); border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 40px; font-weight: 500; white-space: nowrap; }
.chip.k { background: var(--ko-soft); color: var(--ko); }
.chip.n { background: var(--ne-soft); color: var(--ne); font-family: var(--font-ne); }
.live { min-height: 1.6em; font-size: 1.1rem; color: var(--ink); overflow-wrap: anywhere; }
.live:empty { display: none; }
.mics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mic { border: 0; border-radius: var(--r); min-height: 84px; font-weight: 700; font-size: 1.15rem; color: var(--on-accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px; text-align: center; line-height: 1.3; }
.mic small { font-weight: 500; font-size: 0.8rem; opacity: 0.9; }
.mic.k { background: var(--ko); }
.mic.n { background: var(--ne); font-family: var(--font-ne); font-size: 1rem; }
.mic span, .mic small { max-width: 100%; overflow-wrap: anywhere; }
.mic[aria-pressed="true"] { outline: 4px solid var(--ink); outline-offset: 2px; animation: pulse 1s ease-in-out infinite; }
.mic:disabled { opacity: 0.4; }
@keyframes pulse { 50% { opacity: 0.7; } }
@media (prefers-reduced-motion: reduce) { .mic[aria-pressed="true"] { animation: none; } }
.entry { display: flex; gap: 8px; align-items: stretch; }
.entry textarea, .entry input {
  flex: 1 1 auto; min-width: 0; min-height: var(--tap); resize: none;
  border: 2px solid var(--line); border-radius: var(--r); background: var(--bg);
  padding: 12px 14px; font-size: 1.1rem;
}
.entry textarea:focus, .entry input:focus { border-color: var(--ink); outline: none; }
.go { flex: 0 0 auto; border: 0; border-radius: var(--r); background: var(--ink); color: var(--surface); font-weight: 700; padding: 0 18px; min-height: var(--tap); line-height: 1.25; }
.go:disabled { opacity: 0.5; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0; }
.stopbar { display: flex; justify-content: center; }
.stop { border: 0; border-radius: 999px; background: var(--ink); color: var(--surface); font-weight: 700; padding: 8px 22px; min-height: 44px; }

/* 단어 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card .w { color: var(--muted); }
.card .t { font-size: 1.9rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.card .p { font-size: 1.1rem; }
.card .ex { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.card .ex small { color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.h { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); margin: 6px 0 0; }
.book { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px; min-height: var(--tap); }
.item .txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; border: 0; background: none; text-align: left; padding: 0; }
.item .txt span:first-child { font-weight: 700; }
.item .txt span:last-child { color: var(--muted); font-size: 0.92rem; }

/* 설정 */
.set { display: flex; flex-direction: column; gap: 8px; }
.set dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.set dt { color: var(--muted); }
.set dd { margin: 0; font-weight: 500; }
.wide { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); min-height: var(--tap); font-weight: 700; padding: 0 16px; }

/* 암호 화면 */
.gate { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.gate form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; }
.gate h2 { margin: 0; font-size: 1.4rem; }
.gate p { margin: 0; color: var(--muted); }
.gate input { min-height: var(--tap); border: 2px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 12px 14px; font-size: 1.2rem; }
.gate input:focus { border-color: var(--ink); outline: none; }
.gate .go { min-height: var(--tap); }
