/* アニ耳 — 스타일
 * 콘셉트: 만화 원고지(스크린톤) 위의 쪽빛 잉크, 도장(朱)으로 찍는 출석 스탬프
 * 서체: Dela Gothic One(표제) · IBM Plex Sans KR(본문) · Klee One(일본어 학습 글자, 교과서 필기체)
 */
:root {
  --paper: #F3F5FA;
  --card: #FFFFFF;
  --card-2: #ECEFF7;
  --ink: #171A2B;
  --ink-2: #454B64;
  --muted: #767D97;
  --line: #DCE1EC;
  --ruri: #1E50A2;
  --ruri-2: #163C7A;
  --ruri-soft: #E1E9F7;
  --on-ruri: #FFFFFF;
  --shu: #D23F2A;
  --shu-soft: #FBE6E1;
  --gold: #C98A00;
  --gold-fill: #F2B400;
  --gold-soft: #FFF2CC;
  --ok: #1B7F50;
  --ok-soft: #DBF1E4;
  --bad: #BF3434;
  --bad-soft: #FBE2E2;
  --tone: rgba(23, 26, 43, .08);
  --shadow: 0 1px 2px rgba(23, 26, 43, .06), 0 10px 28px rgba(23, 26, 43, .07);
  --heat-0: #E6EAF3;
  --heat-1: #BCD0F0;
  --heat-2: #7FA3E3;
  --heat-3: #3F6FC4;
  --heat-4: #1E50A2;
  --radius: 16px;
  --font-body: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-jp: "Klee One", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", "Noto Sans JP", serif;
  --font-display: "Dela Gothic One", "Black Han Sans", "IBM Plex Sans KR", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F111B; --card: #181B29; --card-2: #20243A; --ink: #E8EBF5; --ink-2: #B4BACF; --muted: #858CA6; --line: #2C3149;
    --ruri: #82A6EF; --ruri-2: #A9C2F6; --ruri-soft: #1C2746; --on-ruri: #0C0F1A;
    --shu: #F06B53; --shu-soft: #3B1F1B; --gold: #F2C14E; --gold-fill: #F2C14E; --gold-soft: #3A3014;
    --ok: #52C890; --ok-soft: #133021; --bad: #F27D7D; --bad-soft: #3B1C1E;
    --tone: rgba(232, 235, 245, .07); --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .3);
    --heat-0: #1E2236; --heat-1: #22365F; --heat-2: #2F5294; --heat-3: #4C76C9; --heat-4: #82A6EF;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F111B; --card: #181B29; --card-2: #20243A; --ink: #E8EBF5; --ink-2: #B4BACF; --muted: #858CA6; --line: #2C3149;
  --ruri: #82A6EF; --ruri-2: #A9C2F6; --ruri-soft: #1C2746; --on-ruri: #0C0F1A;
  --shu: #F06B53; --shu-soft: #3B1F1B; --gold: #F2C14E; --gold-fill: #F2C14E; --gold-soft: #3A3014;
  --ok: #52C890; --ok-soft: #133021; --bad: #F27D7D; --bad-soft: #3B1C1E;
  --tone: rgba(232, 235, 245, .07); --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .3);
  --heat-0: #1E2236; --heat-1: #22365F; --heat-2: #2F5294; --heat-3: #4C76C9; --heat-4: #82A6EF;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
button, [data-act] { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--ruri); outline-offset: 2px; border-radius: 8px; }
.jp { font-family: var(--font-jp); font-weight: 600; }
ruby rt { font-size: .5em; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.no-furi ruby rt { display: none; }
.tabnum { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1, h2, h3 { text-wrap: balance; margin: 0; }

/* ---------- 앱 셸 ---------- */
.shell { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  /* 휴대폰 상태 표시줄(시계·배터리) 높이만큼 위 여백을 넣고 맨 위(0)에 붙임 — 상태 표시줄 밑까지 제목줄 배경이 덮어
     처음 화면에서 제목줄이 가려지지 않고, 스크롤할 때 본문이 제목줄 위로 비치지 않게 */
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-display); font-size: 18px; letter-spacing: .02em; display: flex; align-items: center; gap: 6px; margin-right: auto; }
.brand .mark { width: 26px; height: 26px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }
.chip.streak svg { color: var(--shu); }
.chip.xp svg { color: var(--gold-fill); }
.chip.rank { font-family: var(--font-display); font-weight: 400; color: var(--shu); border-color: var(--shu-soft); }

main.view { flex: 1; padding: 16px 16px 110px; display: flex; flex-direction: column; gap: 18px; }
/* 구글 플레이 판의 광고 배너(홈·나 화면, 탭 막대 바로 위)만큼 본문 아래 여백을 늘림 — 높이는 app/native.js가 --ad-h로 넣음 */
.has-ad main.view { padding-bottom: calc(110px + var(--ad-h, 0px)); }
.has-ad .toast { bottom: calc(90px + var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px)); }
.lic { margin: 0; white-space: pre-wrap; word-break: break-word; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--ink-2); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab {
  background: none; border: 0; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--muted); position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--ruri); font-weight: 700; }
.tab .dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--shu); color: #fff; font-size: 10px; line-height: 17px; font-weight: 700; }

/* ---------- 공통 카드/버튼 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sec-title { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.sec-title h2 { font-size: 17px; }
.sec-title .jp { color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px;
  background: var(--ruri); color: var(--on-ruri);
  box-shadow: 0 3px 0 var(--ruri-2);
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ruri-2); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.shu { background: var(--shu); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--shu) 70%, #000); }
.btn.ok { background: var(--ok); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 70%, #000); }
.btn.bad { background: var(--bad); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 70%, #000); }
a.btn { text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.sm svg { width: 16px; height: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.seg { display: inline-flex; background: var(--card-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.tone { background-image: radial-gradient(var(--tone) 1.1px, transparent 1.4px); background-size: 7px 7px; }

.audio-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none;
  display: inline-grid; place-items: center;
  background: var(--ruri-soft); color: var(--ruri);
}
.audio-btn svg { width: 22px; height: 22px; }
.audio-btn.big { width: 88px; height: 88px; background: var(--ruri); color: var(--on-ruri); box-shadow: 0 4px 0 var(--ruri-2); }
.audio-btn.big svg { width: 40px; height: 40px; }
.audio-btn.slow { background: var(--card-2); color: var(--ink-2); }
.audio-btn.playing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

.banner { border-radius: 12px; padding: 12px 14px; background: var(--gold-soft); color: var(--ink); font-size: 14px; border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.banner b { color: var(--gold); }

/* ---------- 홈: 오늘의 에피소드 ---------- */
.today {
  position: relative; overflow: hidden;
  border-radius: 22px; padding: 20px 18px 18px;
  background: var(--card); border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}
.today::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(var(--tone) 1.1px, transparent 1.4px); background-size: 7px 7px; mask-image: linear-gradient(135deg, #000 0%, transparent 55%); -webkit-mask-image: linear-gradient(135deg, #000 0%, transparent 55%); }
.today > * { position: relative; }
.ep-no { font-family: var(--font-display); font-size: 15px; color: var(--shu); letter-spacing: .04em; }
.ep-title { font-family: var(--font-display); font-size: 26px; line-height: 1.25; margin: 4px 0 2px; }
.ep-sub { color: var(--ink-2); font-size: 14px; }
.type-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--ruri-soft); color: var(--ruri); }
.type-badge.boss { background: var(--shu-soft); color: var(--shu); }
.type-badge.listen { background: var(--ok-soft); color: var(--ok); }
.type-badge.exam { background: var(--gold-soft); color: var(--gold); }
.type-badge svg { width: 14px; height: 14px; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 16px; }
.flow span { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--card-2); color: var(--ink-2); }
.flow span b { color: var(--ink); }
.goal-line { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.goal-line b { color: var(--ink); }

/* ---------- 챕터 선택 & 스탬프 카드 ---------- */
.chapters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chapters::-webkit-scrollbar { display: none; }
.chap {
  flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 12px; text-align: left; min-width: 118px;
}
.chap .n { font-family: var(--font-display); font-size: 12px; color: var(--muted); }
.chap .t { font-weight: 700; font-size: 14px; }
.chap .r { font-size: 11px; color: var(--muted); }
.chap.on { border-color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.chap.lock { opacity: .55; }

.stampcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; }
.stampcard header { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 10px; gap: 8px; }
.stampcard header h3 { font-size: 15px; }
.stampcard header .jp { font-size: 13px; color: var(--muted); }
.weekrow { display: grid; grid-template-columns: 34px repeat(7, 1fr); gap: 5px; align-items: center; margin-bottom: 5px; }
.weekrow .wk { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; }
.cell {
  position: relative; aspect-ratio: 1; max-width: 100%;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 10px; background: var(--paper);
  display: grid; place-items: center; padding: 0;
  font-family: var(--font-display); font-size: 13px; color: var(--ink-2);
}
.cell .ic { position: absolute; top: 3px; right: 3px; width: 12px; height: 12px; color: var(--muted); }
.cell.boss { border-style: solid; border-color: var(--shu-soft); background: color-mix(in srgb, var(--shu-soft) 55%, var(--paper)); }
.cell.listen { border-style: solid; border-color: var(--ok-soft); }
.cell.exam { border-style: solid; border-color: color-mix(in srgb, var(--gold) 40%, transparent); background: color-mix(in srgb, var(--gold-soft) 60%, var(--paper)); }
.cell.lock { opacity: .4; }
.cell.cur { border: 2px solid var(--ruri); color: var(--ruri); background: var(--ruri-soft); animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ruri) 18%, transparent); } }
.cell.done { color: transparent; border-style: solid; border-color: var(--line); background: var(--card); }
.cell .stamp { position: absolute; inset: 8%; }
.cell .num-under { position: absolute; bottom: 2px; left: 4px; font-size: 9px; color: var(--muted); font-family: var(--font-body); }
.stamp-svg { width: 100%; height: 100%; color: var(--shu); transform: rotate(-9deg); }
.lastrow { grid-template-columns: 34px repeat(2, 1fr) 5fr; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 4px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }

/* ---------- 바텀시트 / 모달 ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(10, 12, 22, .45); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 88%;
  overflow: auto; background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-family: var(--font-display); font-size: 22px; font-weight: 400; margin: 4px 0; }
.kchips { display: flex; flex-wrap: wrap; gap: 6px; }
.kchips span { font-family: var(--font-jp); font-weight: 600; font-size: 20px; min-width: 38px; text-align: center; padding: 2px 6px; border-radius: 8px; background: var(--card-2); }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list-plain li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.list-plain li .jp { font-size: 16px; }

/* ---------- 레슨 러너 ---------- */
.runner { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; }
.run-top {
  display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  max-width: 560px; width: 100%; margin: 0 auto;
}
.icon-btn { border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); flex: none; }
.icon-btn svg { width: 24px; height: 24px; }
.pbar { flex: 1; height: 12px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--ruri); border-radius: 6px; transition: width .3s ease; }
.pbar.test i { background: var(--shu); }
.run-label { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.run-body { flex: 1; overflow-y: auto; }
.run-body .in { max-width: 560px; margin: 0 auto; padding: 8px 18px 24px; display: flex; flex-direction: column; gap: 16px; }
.run-foot { max-width: 560px; width: 100%; margin: 0 auto; padding: 12px 18px calc(16px + env(safe-area-inset-bottom, 0px)); }

.q-head { font-size: 15px; font-weight: 700; color: var(--ink-2); }
.q-prompt { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 4px; text-align: center; }
.jp-big { font-family: var(--font-jp); font-weight: 600; font-size: 96px; line-height: 1.1; }
.jp-word { font-family: var(--font-jp); font-weight: 600; font-size: 40px; line-height: 1.25; }
.ro-big { font-family: var(--font-display); font-size: 54px; line-height: 1.1; color: var(--ruri); }
.ko-big { font-size: 26px; font-weight: 700; }
.q-small { color: var(--muted); font-size: 15px; }
.q-sent { font-family: var(--font-jp); font-weight: 600; font-size: 24px; line-height: 2; text-align: center; }
.q-sent .blank { display: inline-block; min-width: 2.2em; border-bottom: 3px solid var(--ruri); margin: 0 3px; color: transparent; }
.q-ko { color: var(--ink-2); font-size: 15px; background: var(--card-2); padding: 6px 12px; border-radius: 10px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opts.one { grid-template-columns: 1fr; }
.opt {
  border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 14px 10px; min-height: 58px;
  font-size: 17px; font-weight: 600; line-height: 1.35; box-shadow: 0 3px 0 var(--line); text-align: center;
}
.opt.jp-opt { font-family: var(--font-jp); font-size: 24px; }
.opt.ko-opt { font-size: 15px; text-align: left; padding: 12px 14px; }
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.opt.sel-ok { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 3px 0 var(--ok); }
.opt.sel-bad { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); }
.opt.show-ok { border-color: var(--ok); }
.opts.locked .opt { pointer-events: none; }

.order-tray { min-height: 64px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; align-content: flex-start; }
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 8px; }
.tok { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 6px 12px; font-family: var(--font-jp); font-weight: 600; font-size: 20px; box-shadow: 0 3px 0 var(--line); line-height: 1.9; }
.tok.used { visibility: hidden; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.mbtn { border: 2px solid var(--line); background: var(--card); border-radius: 12px; min-height: 54px; padding: 8px; font-weight: 600; box-shadow: 0 3px 0 var(--line); font-size: 14px; }
.mbtn.jp { font-family: var(--font-jp); font-size: 22px; }
.mbtn.sel { border-color: var(--ruri); background: var(--ruri-soft); }
.mbtn.gone { opacity: .25; pointer-events: none; }
.mbtn.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: up .2s ease;
}
.feedback.ok { background: var(--ok-soft); border-top: 2px solid var(--ok); }
.feedback.bad { background: var(--bad-soft); border-top: 2px solid var(--bad); }
.feedback .in { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.fb-title { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.feedback.ok .fb-title { color: var(--ok); }
.feedback.bad .fb-title { color: var(--bad); }
.reveal { display: flex; gap: 12px; align-items: center; }
.reveal .txt { flex: 1; min-width: 0; }
.reveal .jp { font-size: 20px; line-height: 1.7; }
.reveal .kana { font-size: 13px; color: var(--ink-2); }
.reveal .ko { font-size: 14px; }

.stamp-pop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none; }
.stamp-pop .mark { width: 180px; height: 180px; animation: stampin .35s cubic-bezier(.2, 1.4, .4, 1); }
.stamp-pop .mark.ok { color: var(--shu); }
.stamp-pop .mark.bad { color: var(--ruri); }
@keyframes stampin { from { transform: scale(2.2) rotate(-18deg); opacity: 0; } to { transform: scale(1) rotate(-8deg); opacity: .92; } }

/* 학습 카드 */
.lcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.lcard .kind { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.glyph-wrap { display: flex; align-items: center; justify-content: center; gap: 18px; }
.glyph { font-family: var(--font-jp); font-weight: 600; font-size: 128px; line-height: 1.05; }
.glyph-ro { font-family: var(--font-display); font-size: 30px; color: var(--ruri); }
.mn { background: var(--card-2); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.mn b { color: var(--shu); }
.origin { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); }
.origin .oj { font-family: var(--font-jp); font-size: 34px; font-weight: 600; color: var(--ink); }
.vocab-main { text-align: center; }
.vocab-main .r { font-family: var(--font-jp); font-weight: 600; font-size: 44px; line-height: 1.2; }
.vocab-main .w { font-family: var(--font-jp); font-size: 20px; color: var(--ink-2); }
.vocab-main .ro { font-size: 14px; color: var(--muted); letter-spacing: .04em; }
.vocab-main .m { font-size: 22px; font-weight: 700; margin-top: 6px; }
.hint { font-size: 13px; color: var(--ink-2); background: var(--gold-soft); border-radius: 8px; padding: 4px 10px; align-self: center; }
.gram-title { font-family: var(--font-jp); font-size: 26px; font-weight: 600; }
.gram-m { font-weight: 700; color: var(--ruri); }
.gram-d { font-size: 15px; line-height: 1.75; }
.gram-d b { color: var(--shu); font-weight: 700; }
.ex { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px dashed var(--line); }
.ex:first-child { border-top: 0; }
.ex .txt { flex: 1; min-width: 0; }
.ex .jp { font-size: 20px; line-height: 1.9; }
.ex .ko { font-size: 14px; color: var(--ink-2); }
.ex .kana { font-size: 12px; color: var(--muted); }
.card-nav { display: flex; gap: 10px; }
.card-nav .btn { flex: 1; }
.counter { text-align: center; font-size: 13px; color: var(--muted); }

/* 대사·대화 */
.line-card { border-radius: 22px; padding: 22px 18px; background: var(--ink); color: var(--paper); position: relative; overflow: hidden; }
.line-card::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .06) 1.1px, transparent 1.4px); background-size: 7px 7px; pointer-events: none; }
.line-card > * { position: relative; }
.line-card .eyebrow { color: color-mix(in srgb, var(--paper) 65%, transparent); }
.line-card .jp { font-size: 30px; line-height: 1.9; margin: 8px 0; }
.line-card ruby rt { color: color-mix(in srgb, var(--paper) 60%, transparent); }
.line-card .ko { font-size: 16px; color: var(--gold-fill); }
.speed { display: flex; gap: 8px; flex-wrap: wrap; }
.speed button { border: 1px solid color-mix(in srgb, var(--paper) 30%, transparent); background: transparent; color: var(--paper); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.speed button svg { width: 16px; height: 16px; }
.shadow-count { display: flex; gap: 6px; }
.shadow-count i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ruri); }
.shadow-count i.on { background: var(--ruri); }
.dlg { display: flex; flex-direction: column; gap: 8px; }
.dlg .ln { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 12px; background: var(--card-2); border: 2px solid transparent; }
.dlg .ln.b { background: var(--ruri-soft); }
.dlg .ln.now { border-color: var(--ruri); }
.dlg .who { font-size: 12px; font-weight: 700; color: var(--muted); min-width: 48px; font-family: var(--font-jp); }
.dlg .jp { font-size: 18px; line-height: 1.8; }
.dlg .ko { font-size: 13px; color: var(--ink-2); }
.dlg .hid { color: var(--muted); letter-spacing: .2em; }

.note-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px; }
.note-card h3 { font-size: 21px; line-height: 1.4; margin: 6px 0 12px; }
.note-card p { margin: 0 0 12px; line-height: 1.85; font-size: 16px; max-width: 65ch; }

/* 인트로 · 결과 */
.titlecard { text-align: center; padding: 30px 12px 20px; border-radius: 24px; border: 2px solid var(--ink); background: var(--card); box-shadow: 6px 6px 0 var(--ink); position: relative; overflow: hidden; }
.titlecard::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(var(--tone) 1.1px, transparent 1.4px); background-size: 7px 7px; mask-image: radial-gradient(circle at 50% 110%, #000 0%, transparent 70%); -webkit-mask-image: radial-gradient(circle at 50% 110%, #000 0%, transparent 70%); }
.titlecard > * { position: relative; }
.titlecard .ep { font-family: var(--font-display); font-size: 40px; color: var(--shu); }
.titlecard h1 { font-family: var(--font-display); font-weight: 400; font-size: 30px; margin: 6px 0; }
.steps-list { display: flex; flex-direction: column; gap: 8px; }
.steps-list div { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.steps-list .n { width: 26px; height: 26px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.boss-card { text-align: center; padding: 22px 16px; border-radius: 24px; background: var(--ink); color: var(--paper); position: relative; overflow: hidden; }
.boss-card .name { font-family: var(--font-display); font-size: 30px; margin: 6px 0; }
.boss-card .sub { opacity: .75; font-size: 14px; }
.boss-svg { width: 120px; height: 120px; margin: 6px auto 0; display: block; color: var(--shu); }
.hpbar { height: 14px; border-radius: 7px; background: color-mix(in srgb, var(--shu) 22%, transparent); overflow: hidden; }
.hpbar i { display: block; height: 100%; background: var(--shu); transition: width .35s ease; }
.hearts { display: flex; gap: 4px; justify-content: center; }
.hearts svg { width: 18px; height: 18px; color: var(--shu); }
.hearts svg.off { color: var(--line); }
.boss-hud { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.boss-hud .t { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }
.boss-hud .jp { color: var(--shu); }
.hit { animation: hit .35s; }
@keyframes hit { 30% { transform: translateX(-6px) rotate(-2deg); } 60% { transform: translateX(6px) rotate(2deg); } }

.result { text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.result .big-stamp { width: 170px; height: 170px; color: var(--shu); animation: stampin .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.result .big-stamp.fail { color: var(--ruri); }
.result .score { font-family: var(--font-display); font-size: 56px; line-height: 1; }
.result .score small { font-size: 22px; }
.result .verdict { font-size: 18px; font-weight: 800; }
.xp-rows { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.xp-rows div { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.xp-rows b { color: var(--gold); }
.lvl { width: 100%; }
.lvl .bar { height: 10px; border-radius: 5px; background: var(--gold-soft); overflow: hidden; }
.lvl .bar i { display: block; height: 100%; background: var(--gold-fill); }
.lvl .t { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.newbadge { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--gold-soft); width: 100%; text-align: left; }
.newbadge svg { width: 36px; height: 36px; flex: none; }
.wrong-list { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.wrong-list .w { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.wrong-list .w .txt { flex: 1; min-width: 0; }
.wrong-list .jp { font-size: 17px; }
.sections { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.sections .s { display: grid; grid-template-columns: 56px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.meter { height: 10px; border-radius: 5px; background: var(--ruri-soft); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ruri); border-radius: 5px; }
.rankup { width: 100%; padding: 18px; border-radius: 18px; background: var(--ink); color: var(--paper); }
.rankup .r { font-family: var(--font-display); font-size: 64px; color: var(--gold-fill); line-height: 1; }

/* ---------- 복습 탭 ---------- */
.hero-num { font-family: var(--font-body); font-weight: 700; font-size: 52px; line-height: 1; }
.boxes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; align-items: end; height: 90px; }
.boxes .b { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.boxes .b i { width: 100%; max-width: 24px; background: var(--ruri); border-radius: 4px 4px 0 0; min-height: 2px; }
.boxes .b span { font-size: 11px; color: var(--muted); }
.boxes .b em { font-style: normal; font-size: 11px; color: var(--ink-2); }
.item-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.item-row:first-child { border-top: 0; }
.item-row .txt { flex: 1; min-width: 0; }
.item-row .jp { font-size: 19px; }
.item-row .m { font-size: 13px; color: var(--ink-2); }
.dots { display: flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--ruri); }

/* ---------- 문자표 ---------- */
.kgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.kgrid.three { grid-template-columns: repeat(3, 1fr); }
.kcell { border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; min-height: 62px; }
.kcell .c { font-family: var(--font-jp); font-weight: 600; font-size: 26px; line-height: 1.2; }
.kcell .r { font-size: 11px; color: var(--muted); }
.kcell.empty { border: 0; background: none; }
.kcell.m1 { background: var(--ruri-soft); }
.kcell.m2 { background: color-mix(in srgb, var(--ruri) 40%, var(--card)); }
.kcell.m3 { background: var(--ruri); color: var(--on-ruri); border-color: var(--ruri); }
.kcell.m3 .r { color: color-mix(in srgb, var(--on-ruri) 75%, transparent); }
.kcell.m4 { background: var(--gold-fill); color: #1a1400; border-color: var(--gold); }
.kcell.m4 .r { color: #4a3a00; }
.kcell.nolearn .c { color: var(--muted); }

canvas.pad { width: 100%; max-width: 300px; aspect-ratio: 1; border-radius: 16px; border: 2px dashed var(--line); background: var(--card); touch-action: none; align-self: center; }

/* ---------- 단어장 ---------- */
.search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 16px; color: var(--ink); }
.group-h { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 4px; letter-spacing: .04em; }
details.gitem { border-top: 1px solid var(--line); padding: 10px 0; }
details.gitem summary { list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.gitem summary::-webkit-details-marker { display: none; }
details.gitem summary .jp { font-size: 18px; }
details.gitem[open] summary { margin-bottom: 8px; }

/* ---------- 나(통계) ---------- */
.profile { display: flex; gap: 16px; align-items: center; }
.rank-emblem { width: 84px; height: 84px; flex: none; position: relative; color: var(--shu); }
.rank-emblem svg { width: 100%; height: 100%; }
.rank-emblem b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 400; font-size: 38px; color: var(--shu); }
.rank-title { font-family: var(--font-jp); font-size: 18px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.tile .l { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.2; }
.tile .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.skill { display: grid; grid-template-columns: 64px 1fr 42px; gap: 10px; align-items: center; font-size: 14px; margin: 8px 0; }
.skill .v { text-align: right; font-size: 13px; color: var(--ink-2); }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -120%); }
.heat { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; grid-template-rows: repeat(7, auto); gap: 3px; }
.heat i { width: 100%; aspect-ratio: 1; border-radius: 3px; background: var(--heat-0); }
.heat i.h1 { background: var(--heat-1); } .heat i.h2 { background: var(--heat-2); } .heat i.h3 { background: var(--heat-3); } .heat i.h4 { background: var(--heat-4); }
.heat-legend { display: flex; gap: 4px; align-items: center; font-size: 11px; color: var(--muted); justify-content: flex-end; margin-top: 6px; }
.heat-legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge { text-align: center; font-size: 12px; padding: 10px 6px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge svg { width: 44px; height: 44px; }
.badge.off { opacity: .45; filter: grayscale(1); }
.badge b { font-size: 12px; }
.badge span { font-size: 11px; color: var(--muted); line-height: 1.3; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row .l { font-size: 15px; }
.set-row .d { font-size: 12px; color: var(--muted); }
/* 설명이 길어도 선택 버튼은 줄지 않게 (좁은 폰에서 '자/동'처럼 글자가 꺾이던 문제) */
.set-row .seg { flex: none; }
.set-row .seg button { white-space: nowrap; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--line); border: 0; position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch.on { background: var(--ruri); }
.switch.on::after { transform: translateX(20px); }
select, input[type="range"] { font: inherit; color: var(--ink); }
select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px; max-width: 180px; }
input[type="range"] { accent-color: var(--ruri); width: 140px; }
.danger-zone { border: 1px solid var(--bad-soft); border-radius: 14px; padding: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); animation: up .2s ease; max-width: calc(100% - 32px); }

/* 온보딩 */
.welcome { display: flex; flex-direction: column; gap: 18px; padding: 24px 0; }
.welcome .logo { width: 88px; height: 88px; }
.welcome h1 { font-family: var(--font-display); font-weight: 400; font-size: 34px; line-height: 1.2; }
.welcome .lead { font-size: 16px; color: var(--ink-2); max-width: 36ch; }

@media (min-width: 420px) {
  .jp-big { font-size: 112px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
