/* 욘데톡톡 — 오늘한끼와 같은 디자인 언어 (네이비 다크 · 파랑 강조 · 노랑 포인트 · Gowun Dodum 제목)
   기본은 다크. data-theme=light 또는 system(+라이트 환경)이면 라이트 */
:root {
  --bg: #0E141C;
  --card: #161D27;
  --ink: #EEF1F5;
  --ink2: #A7B0BD;
  --ink3: #6F7885;
  --line: #22303F;
  --chip: #1B2532;
  --accent: #2D92F9;
  --accent-ink: #FFFFFF;
  --accent-soft: #12345C;
  --accent-text: #5AAEFF;   /* 어두운 판 위 파란 글자(발음) — 조금 밝게 */
  --listen: #E5A84A;
  --listen-soft: #3A2C13;
  --star: #FEDF2F;
  --bar: #2D8CF0;           /* 상단 파란 띠 */
  --bar-ink: #FFFFFF;
  --shadow: none;
  --radius: 16px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #E8EFF7;
  --card: #FFFFFF;
  --ink: #111722;
  --ink2: #4C5A6E;
  --ink3: #7A889B;
  --line: #C9D8EA;
  --chip: #DDE7F3;
  --accent-soft: #D3E8FF;
  --accent-text: #1B74D8;
  --listen: #B97414;
  --listen-soft: #FBF0DC;
  --star: #D9A900;
  --shadow: 0 6px 18px rgba(30, 60, 110, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #E8EFF7;
    --card: #FFFFFF;
    --ink: #111722;
    --ink2: #4C5A6E;
    --ink3: #7A889B;
    --line: #C9D8EA;
    --chip: #DDE7F3;
    --accent-soft: #D3E8FF;
    --accent-text: #1B74D8;
    --listen: #B97414;
    --listen-soft: #FBF0DC;
    --star: #D9A900;
    --shadow: 0 6px 18px rgba(30, 60, 110, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* iOS 기본 동작 끄기: 두 번 탭 확대 · 길게 눌러 글자 선택/메뉴 · 화면 끝 고무줄 튕김 (오늘한끼와 같게) */
html { -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
html, body { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ── 상단 파란 띠: [뒤로] [아이콘 욘데톡톡 | 화면 이름] [설정] ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--top) + 8px) 10px 8px;
  background: var(--bar); color: var(--bar-ink);
}
.brand { color: inherit; text-decoration: none; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-align: left; padding: 0 4px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex: none; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.brand .nm { font-family: "Gowun Dodum", sans-serif; font-size: 20px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand .sep { width: 1.5px; height: 20px; background: rgba(255,255,255,.55); flex: none; margin: 0 2px; }
.brand .pg {
  min-width: 0; flex: 1; font-size: 16px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 3px 10px; border-radius: 8px; background: rgba(255,255,255,.16);
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--bar-ink);
}
.icon-btn.ring { border: 1.5px solid rgba(255,255,255,.7); width: 38px; height: 38px; }
.icon-btn:active { background: rgba(255,255,255,.18); }

main {
  max-width: 720px; margin: 0 auto;
  padding: 14px 16px calc(var(--bottom) + 40px);
  outline: none;
}

/* ── 섹션 제목: 노란 세로 막대 ── */
.sec {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  margin: 24px 2px 12px; padding-left: 12px; position: relative;
  font-family: "Gowun Dodum", sans-serif; font-size: 21px; font-weight: 700; line-height: 1.3;
}
.sec::before { content: ""; position: absolute; left: 0; top: .18em; height: 1.05em; width: 4px; border-radius: 2px; background: var(--star); }
.sec em { font-style: normal; color: var(--accent-text); }
.sec .n { font-family: "Noto Sans KR", sans-serif; font-size: 13px; font-weight: 500; color: var(--ink3); }
.sec .path { font-family: "Noto Sans KR", sans-serif; font-size: 14px; font-weight: 500; color: var(--ink3); }

/* ── 홈 ── */
.hero { display: flex; align-items: center; gap: 16px; padding: 10px 2px 6px; }
.hero img { width: 84px; height: 84px; border-radius: 20px; flex: none; box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.hero h2 { margin: 0; font-family: "Gowun Dodum", sans-serif; font-size: 26px; line-height: 1.25; }
.hero p { margin: 4px 0 0; color: var(--ink2); font-size: 14px; }

.lang-list { display: grid; gap: 12px; }
.lang-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  padding: 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.lang-card:active, .cat-card:active, .banner:active { transform: scale(.985); }
.lang-card .flag { font-size: 44px; line-height: 1; }
.lang-card .info { flex: 1; min-width: 0; }
.lang-card .name { font-family: "Gowun Dodum", sans-serif; font-size: 24px; font-weight: 700; line-height: 1.2; }
.lang-card .label { color: var(--ink3); font-size: 14px; margin-left: 6px; }
.lang-card .count { display: block; margin-top: 2px; color: var(--accent-text); font-weight: 700; font-size: 15px; }
.lang-card .go { color: var(--ink3); }

/* ── 언어 화면 ── */
.search { position: relative; margin: 0 0 12px; }
.search input {
  width: 100%; height: 46px; padding: 0 40px 0 42px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--ink3); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 14px; top: 13px; color: var(--ink3); pointer-events: none; }
.search .clear {
  position: absolute; right: 6px; top: 5px; width: 36px; height: 36px;
  display: grid; place-items: center; color: var(--ink3); border-radius: 10px;
}

.pills { display: flex; gap: 8px; margin-bottom: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink2); font-size: 14px;
}
.pill b { color: var(--ink); font-weight: 700; }
.pill.star { border-color: var(--star); color: var(--star); }
.pill.star b { color: var(--star); }

/* 오늘의 한마디 배너 */
.card.banner {
  position: relative; overflow: hidden; width: 100%; text-align: left;
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px 26px 20px; border-radius: var(--radius);
  background: linear-gradient(120deg, #1B5FB8 0%, #2D8CF0 100%); color: #fff;
  border: 1px solid rgba(255,255,255,.12);
}
.banner::after {
  content: ""; position: absolute; right: -30px; top: -40px; width: 200px; height: 200px;
  background:
    linear-gradient(115deg, transparent 46%, rgba(255,255,255,.14) 47%, rgba(255,255,255,.14) 52%, transparent 53%),
    linear-gradient(25deg, transparent 46%, rgba(255,255,255,.10) 47%, rgba(255,255,255,.10) 52%, transparent 53%);
  pointer-events: none;
}
.banner .bt { flex: 1; min-width: 0; position: relative; z-index: 1; }
.banner .k { font-size: 13px; opacity: .8; }
.banner .t { font-size: 20px; font-weight: 700; line-height: 1.35; margin: 2px 0; word-break: keep-all; overflow-wrap: anywhere; }
.banner .m { font-size: 14px; opacity: .88; }
.banner .play { background: rgba(255,255,255,.22); color: #fff; box-shadow: none; position: relative; z-index: 1; }
.banner .again {
  position: absolute; right: 12px; bottom: 6px; z-index: 1;
  font-size: 12px; opacity: .8; padding: 2px 4px;
}

.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cat-card {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left;
  padding: 16px 14px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.cat-card .top { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; }
.cat-card .t { font-family: "Gowun Dodum", sans-serif; font-size: 21px; font-weight: 700; line-height: 1.25; word-break: keep-all; }
.cat-card .icon { font-size: 22px; line-height: 1; }
.cat-card .c { margin-top: 2px; color: var(--accent-text); font-weight: 700; font-size: 15px; }
.cat-card .c small { font-weight: 500; color: var(--ink3); font-size: 13px; }
.cat-card .d { margin-top: 8px; font-size: 13.5px; color: var(--ink3); line-height: 1.55; word-break: keep-all; }
.cat-card .d b { color: var(--ink); font-weight: 700; }

/* ── 상황 화면 ── */
.toolbar {
  position: sticky; top: calc(var(--top) + 56px); z-index: 10;
  margin: -14px -16px 0; padding: 12px 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px;
  scroll-snap-type: x proximity; scroll-padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent;
  font-size: 14px; color: var(--ink2); white-space: nowrap; scroll-snap-align: start;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

.seg { display: flex; gap: 4px; margin-top: 10px; background: var(--chip); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 7px 0; border-radius: 8px; color: var(--ink2); font-weight: 500; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

.group { scroll-margin-top: calc(var(--top) + 160px); }

/* ── 표현 카드 ── */
.cards { display: grid; gap: 12px; }
.card {
  position: relative;
  padding: 14px 14px 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.badge {
  font-size: 12.5px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
}
.badge.them { background: var(--listen-soft); color: var(--listen); }
.card-head .star {
  margin-left: auto; width: 36px; height: 32px; margin-right: -6px;
  display: grid; place-items: center; color: var(--ink3); border-radius: 8px;
}
.card-head .star svg { opacity: .55; }
.card-head .star.on { color: var(--star); }
.card-head .star.on svg { opacity: 1; }

.phrase { display: flex; gap: 12px; align-items: center; }
.phrase .body { flex: 1; min-width: 0; }
.say {
  display: block; text-align: left; width: 100%;
  font-size: 20px; font-weight: 700; line-height: 1.35;
  word-break: keep-all; overflow-wrap: anywhere;
}
.reading { margin-top: 2px; font-size: 13.5px; color: var(--ink3); }
.pron { margin-top: 4px; font-size: 15.5px; color: var(--accent-text); font-weight: 500; }
.them-card .pron { color: var(--listen); }
.ko { margin-top: 2px; font-size: 15px; color: var(--ink2); }
.note {
  margin-top: 10px; padding: 8px 11px; border-radius: 10px;
  background: var(--chip); font-size: 13.5px; color: var(--ink2); line-height: 1.55;
}

.play {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 12px rgba(45, 146, 249, .35);
}
.them-card .play { background: var(--listen); box-shadow: 0 4px 12px rgba(229, 168, 74, .3); }
.play.small { width: 38px; height: 38px; box-shadow: none; }
.play.speaking { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .75; } }

/* 가려진 발음·뜻: 탭하면 보임 */
.masked { color: transparent !important; background: var(--chip); border-radius: 6px; cursor: pointer; user-select: none; }
.masked::after { content: "탭하여 보기"; color: var(--ink3); font-size: 12px; font-weight: 500; position: absolute; }
.pron.masked, .ko.masked { position: relative; min-height: 1.5em; }
.pron.masked::after, .ko.masked::after { left: 8px; top: 50%; transform: translateY(-50%); }

.alt-toggle {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 13.5px; font-weight: 500; color: var(--accent-text);
  padding: 4px 10px 4px 12px; border-radius: 999px; border: 1px solid var(--accent);
}
.them-card .alt-toggle { color: var(--listen); border-color: var(--listen); }
.alt-toggle svg { transition: transform .2s; }
.alt-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.alts { margin-top: 12px; border-top: 1px dashed var(--line); }
.alt { display: flex; gap: 12px; align-items: center; padding: 12px 0 2px; }
.alt + .alt { border-top: 1px solid var(--line); margin-top: 10px; }
.alt .body { flex: 1; min-width: 0; }
.alt .say { font-size: 17px; }
.alt .pron, .alt .ko { font-size: 14px; }

.empty { padding: 48px 12px; text-align: center; color: var(--ink3); line-height: 1.7; }
.hint { margin: 4px 2px 0; font-size: 13px; color: var(--ink3); }

/* ── 설정 ── */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 8px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; min-height: 54px; }
.row + .row { border-top: 1px solid var(--line); }
.row .lbl { flex: 1; font-size: 15.5px; }
.row .lbl small { display: block; color: var(--ink3); font-size: 13px; }
.row.wrap { flex-wrap: wrap; row-gap: 8px; }
.row.wrap .lbl { flex-basis: 100%; }
.row select {
  flex: 1; min-width: 0;
  font: inherit; font-size: 14px; color: var(--ink); background: var(--chip);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.row .seg { margin: 0; flex: none; width: 190px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 14px; background: var(--chip); border: 1px solid var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.btn {
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--accent-text); border: 1px solid var(--accent); }
.rate-val { width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink2); font-size: 14px; }
input[type=range] { accent-color: var(--accent); flex: 1; }
.about { font-size: 13px; color: var(--ink3); margin: 8px 4px 0; line-height: 1.65; }
.about b { color: var(--ink2); }
.credit { display: flex; align-items: center; gap: 10px; margin: 28px 4px 0; color: var(--ink3); font-size: 13px; }
.credit img { width: 36px; height: 36px; border-radius: 9px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottom) + 24px); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #0A3F7E; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 일본어 문장은 일본어 글꼴로 (한국어 글꼴로 가나를 그리면 자간이 어색함) */
:lang(ja) { font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif; }
.brand .pg:empty { display: none; }
.brand .sep:has(+ .pg:empty) { display: none; }

/* ── 잠금 화면 (오늘한끼 스플래시와 같은 파랑 그라데이션) ── */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--top) + 20px) 24px calc(var(--bottom) + 20px);
  background: linear-gradient(180deg, #1A3973, #0E1D44); color: #fff;
  transition: opacity .25s ease;
}
.lock.open { opacity: 0; pointer-events: none; }
body.locked { overflow: hidden; }
.lock-in { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; }
.lock-in img { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 10px 24px rgba(0,0,0,.4); }
.lock-nm { margin-top: 14px; font-family: "Gowun Dodum", sans-serif; font-size: 28px; font-weight: 700; letter-spacing: .04em; }
.lock-msg { margin-top: 6px; font-size: 14px; color: rgba(255,255,255,.7); min-height: 1.5em; }
.dots { display: flex; gap: 18px; margin: 22px 0 30px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.75); transition: background .1s; }
.dots i.on { background: #FEDF2F; border-color: #FEDF2F; }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 16px 26px; }
.pad button {
  width: 72px; height: 72px; border-radius: 50%;
  font-size: 28px; font-weight: 500; color: #fff;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
}
.pad button:active { background: rgba(255,255,255,.3); }
.pad button[data-del] { background: none; border: 0; font-size: 24px; }
