html, body { height: 100%; overscroll-behavior: none; }
/* 페이지 자체는 스크롤하지 않는다: 실제 보이는 높이(dvh)에 고정하고, 카드 영역이 남은 공간을 쓴다 */
body { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.bar, .meter { flex: none; }
main { flex: 1; min-height: 0; width: 100%; }
[hidden] { display: none !important; }
.scroll { overflow-y: auto; }

.bar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 16px) 16px 8px;
  min-height: 56px;                  /* 뒤로 버튼이 없는 처음 화면도 같은 높이 → 화면마다 위치가 같게 */
}
.progress { font-size: 18px; color: var(--dim); white-space: nowrap; }
.spacer { flex: 1; }
.bar .title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress b { color: var(--fg); font-size: 22px; }
.mini-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--panel); border: 1px solid var(--line); color: var(--accent);
  display: grid; place-items: center; box-shadow: 0 2px 0 var(--shadow);
}
.mini-btn svg { width: 20px; height: 20px; }
.mini-btn:active { transform: translateY(2px); box-shadow: none; }
.mini-btn:disabled { opacity: .35; }
.meter { max-width: 528px; margin: 0 auto; height: 6px; border-radius: 3px; background: var(--panel2); margin-inline: 16px; }
@media (min-width: 560px) { .meter { margin-inline: auto; } }
.meter i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--t2); transition: width .2s; }

main { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(env(safe-area-inset-bottom) + 20px); }
#eval { display: flex; flex-direction: column; }

.stack { position: relative; flex: 1; min-height: 0; }
.card {
  position: absolute; inset: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 6px 18px var(--shadow);
  padding: 22px 18px 18px;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  will-change: transform; touch-action: pan-y;
}
.card.back { transform: scale(.96) translateY(10px); opacity: .7; pointer-events: none; }
.card.fly { transition: transform .16s ease-out, opacity .16s; }
/* 몰라요로 민 뒤 뜻을 보여주는 카드: 바탕은 그대로, 테두리와 뜻 글자만 경고색. '몰라요' 도장은 계속 보임 */
.card.unknown { border: 2px solid var(--warn); }
.card.unknown .stamp.no { opacity: 1 !important; }
.card.unknown .answer .m { font-size: 18px; font-weight: 700; color: var(--warn); }
.card .stamp {
  position: absolute; top: 18px; padding: 4px 12px; border-radius: 10px;
  font-weight: 900; font-size: 18px; opacity: 0; border: 3px solid currentColor; pointer-events: none;
}
/* 오른쪽으로 밀면 왼쪽 위에 '몰라요', 왼쪽으로 밀면 오른쪽 위에 '알아요' */
.card .stamp.no { left: 18px; color: var(--warn); transform: rotate(-10deg); }
.card .stamp.yes { right: 18px; color: var(--accent); transform: rotate(10deg); }

/* 긴 단어(テープレコーダー 등)는 JS가 글자 수에 맞춰 크기를 줄이고, 그래도 넘치면 줄바꿈 */
.word { text-align: center; font-size: 52px; font-weight: 900; line-height: 1.5; margin: 34px 0 6px; overflow-wrap: anywhere; }
.word ruby, .exs ruby { ruby-align: center; }   /* 二十歳(はたち)처럼 여러 글자에 걸친 읽기를 벌리지 않음 */
.word rt { font-size: 18px; font-weight: 700; color: var(--accent); }
.answer { text-align: center; }
.answer .r { font-size: 20px; color: var(--accent); font-weight: 700; }
.answer .m { font-size: 16px; color: var(--fg); margin-top: 2px; }
.answer .cover { font-size: 14px; color: var(--dim); padding-top: 12px; }
.marked { text-align: center; font-size: 13px; color: var(--warn); font-weight: 700; margin-top: 4px; }

/* 화자 사진: 표제어와 예문 사이 따로 한 줄, 왼쪽 정렬, 72×96 */
.face { margin-top: 10px; display: flex; justify-content: flex-start; }
.face img, .face .noface { width: 72px; height: 96px; object-fit: cover; object-position: center 30%;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); pointer-events: none; }
.face img.poster { object-position: center; }
.exs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.exs li { background: var(--panel2); border-radius: 14px; padding: 10px 12px; }
.exs .src { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.exs .src span { margin-right: auto; }
.ex-btn {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  color: var(--accent); border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
}
.ex-btn svg { width: 18px; height: 18px; }
/* 요미가나 토글: 카드 맨 위 가운데. 끄면 자리는 남겨서(visibility) 글자가 출렁이지 않게 */
.kana-btn { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); font-size: 15px; font-weight: 900; }
.kana-btn[aria-pressed="true"] { background: var(--t1); color: var(--fg); }
.card:not(.kana) rt { visibility: hidden; }
.exs .line { font-size: 19px; line-height: 2; margin-top: 2px;
  user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.exs .spk { font-weight: 800; color: var(--accent); }
.exs rt { font-size: 12px; color: var(--fg); }
/* 몰라요 답 카드: 무엇을 몰랐는지 (뜻·읽는 법, 둘 다 가능) */
.unk { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--dim); }
.unk-btn { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; font-weight: 700; color: var(--fg); }
.unk-btn[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: var(--panel); }
.miss .tag { font-style: normal; font-size: 12px; font-weight: 700; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 0 8px; margin-left: 6px; }
.exs .ko { font-size: 14px; color: var(--dim); margin-top: 2px; user-select: text; -webkit-user-select: text; }
.exs .hl { background: var(--t1); border-radius: 4px; padding: 0 1px; }
.noex { text-align: center; color: var(--dim); font-size: 14px; margin-top: 24px; }

.hint { text-align: center; font-size: 13px; color: var(--dim); margin: 10px 0 8px; }
.actions { display: flex; gap: 12px; }
.act {
  flex: 1; border-radius: 18px; padding: 10px; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; box-shadow: 0 4px 0 var(--shadow);
}
.act span { font-size: 28px; font-weight: 900; line-height: 1.1; }
.act small { font-size: 14px; font-weight: 700; }
.act.no { background: var(--t4); }
.act.yes { background: var(--t2); }
.act:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }

#result { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 24px; }
/* 결과: 점수는 민트 판, 모르는 단어는 진한 바탕 + 왼쪽 복숭아 띠로 배경·서로와 구별 */
.score { margin: 0; font-size: 72px; font-weight: 900; line-height: 1;
  align-self: stretch; text-align: center; background: var(--t2); border: 2px solid var(--line);
  border-radius: 22px; padding: 22px 0 6px; }
.score small { font-size: 24px; margin-left: 4px; }
.score-sub { margin: 0 0 8px; color: var(--fg); }
.miss-h { align-self: stretch; font-size: 17px; margin: 18px 0 0; }
.miss { align-self: stretch; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.miss li { background: var(--panel2); border: 2px solid var(--line); border-left: 6px solid var(--t1);
  border-radius: 14px; padding: 10px 14px; box-shadow: 0 2px 0 var(--shadow); }
.miss b { font-size: 20px; margin-right: 8px; }
.miss .r { color: var(--accent); font-weight: 700; }
.miss .m { display: block; font-size: 14px; color: var(--fg); margin-top: 2px; }

/* 문법 카드: 표제가 길어 줄바꿈 허용, 답 카드에 설명 */
.word.gram { line-height: 1.3; word-break: keep-all; }
.answer .x { font-size: 13px; color: var(--dim); margin: 6px 12px 0; text-align: left; line-height: 1.5; }
.miss .tag.ok { color: var(--c-learned); border-color: var(--c-learned); }

/* 차트 색: 모른 적 없음(민트) · 알게 됨(하늘) · 지금 모름(복숭아) — 테마 색 계열을 진하게, dataviz 검증 통과(라이트/다크 따로) */
:root { --c-always: #9ccbb0; --c-learned: #a8bce6; --c-unknown: #f0b393; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c-always: #6a9a7f; --c-learned: #7689bc; --c-unknown: #c08466; } }
:root[data-theme="dark"] { --c-always: #6a9a7f; --c-learned: #7689bc; --c-unknown: #c08466; }
.c-always { background: var(--c-always); } .c-learned { background: var(--c-learned); } .c-unknown { background: var(--c-unknown); }

/* 처음 화면 */
#home { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.h-streak { color: var(--dim); font-size: 13px; white-space: nowrap; }
.stars { color: var(--accent); font-size: 18px; letter-spacing: 2px; }
#home .menu-btn, #result .menu-btn, .q-done .menu-btn { font-size: 19px; padding: 12px 16px; }
.menu-btn small { display: block; font-size: 12px; font-weight: 700; color: var(--dim); margin-top: 2px; }

/* 퀴즈 */
.qcard { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 6px 18px var(--shadow); padding: 18px; }
.q-ask { margin: 0 0 6px; text-align: center; color: var(--dim); font-size: 14px; font-weight: 700; }
.q-stem { text-align: center; font-size: 40px; font-weight: 900; line-height: 1.4; overflow-wrap: anywhere; margin: 6px 0 14px; }
.q-stem.ko { font-size: 24px; }
.q-stem.sent { font-size: 20px; font-weight: 500; text-align: left; line-height: 2; }
.q-stem rt { visibility: hidden; }
.q-stem .blank { font-weight: 900; color: var(--accent); }
.q-stem .q-ctx { font-size: 17px; color: var(--dim); margin-bottom: 6px; }
.q-stem .okuri { font-weight: 400; opacity: .4; }
.q-stem .okuri + b, .q-stem b + .okuri { margin-left: 1px; }
.q-stem b { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; text-decoration-color: var(--accent); }
.q-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.q-c { min-height: 56px; padding: 8px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel2);
  font-size: 17px; font-weight: 700; color: var(--fg); box-shadow: 0 3px 0 var(--shadow); overflow-wrap: anywhere; }
.q-c.ja { font-size: 20px; }
.q-c:active { transform: translateY(2px); box-shadow: none; }
.q-c.right { background: var(--t2); border: 2px solid var(--c-always); }
.q-c.wrong { background: var(--panel); border: 2px solid var(--warn); color: var(--warn); }
.q-c:disabled { opacity: 1; }
.q-fb { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.q-fb .ok { color: var(--c-always); } .q-fb .ng { color: var(--warn); }
.fb-w { font-size: 22px; font-weight: 800; } .fb-w span { font-size: 15px; font-weight: 700; color: var(--accent); margin-left: 6px; }
.fb-m, .fb-ko { font-size: 15px; color: var(--dim); }
.fb-ex { font-size: 18px; line-height: 2; } .fb-ex rt { font-size: 11px; }
.q-next { margin: 8px auto 0; font-size: 18px; padding: 10px 16px; }
.q-done { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 30px; }

/* 단어장 */
.l-sum { margin: 0 0 8px; color: var(--dim); font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.chips .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; font-weight: 700; color: var(--dim); text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--t2); color: var(--fg); }
.l-rows li { cursor: pointer; }
.l-rows li.learned { border-left-color: var(--c-learned); opacity: .8; }
.l-meta { display: block; font-size: 12px; color: var(--dim); margin-top: 2px; }
.pop { position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .35); }
.pop .card { inset: calc(env(safe-area-inset-top) + 60px) 16px calc(env(safe-area-inset-bottom) + 24px); max-width: 528px; margin: 0 auto; }

/* 통계 */
.st-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.st-sec h2 { margin: 0 0 10px; font-size: 16px; }
.hero { margin: 0 0 10px; } .hero b { font-size: 40px; } .hero small { color: var(--dim); }
.sbar { display: flex; gap: 0; height: 18px; border-radius: 4px; overflow: hidden; background: var(--panel2); }
.sbar .seg { display: block; min-width: 2px; } .sbar .empty { background: var(--panel2); }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 6px; } .legend small { color: var(--dim); }
.key { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
/* 회차별 영역 그래프: 왼쪽 세로 눈금 · 그림 · 아래 첫/마지막 회차 */
.area-wrap { display: grid; grid-template-columns: auto 1fr; grid-template-rows: 140px auto; column-gap: 6px; margin-top: 4px; outline: none; }
.area-wrap .ay { display: flex; flex-direction: column; justify-content: space-between; font-size: 10px; color: var(--dim); text-align: right; line-height: 1; }
.area-wrap .aplot { position: relative; border-bottom: 1px solid var(--line); touch-action: pan-y; }
.area-wrap svg { display: block; width: 100%; height: 100%; }
.area-wrap .ax { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-top: 3px; }
.area-wrap path.edge { fill: none; stroke: var(--panel); stroke-width: .5; stroke-opacity: .7; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.area-wrap .gl { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.area-wrap .cross { stroke: var(--fg); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.f-always { fill: var(--c-always); } .f-learned { fill: var(--c-learned); } .f-unknown { fill: var(--c-unknown); }
.atip { position: absolute; top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 3px 10px var(--shadow);
  padding: 6px 9px; font-size: 12px; white-space: nowrap; pointer-events: none; display: flex; flex-direction: column; gap: 2px; }
.atip .key { width: 9px; height: 9px; margin-right: 4px; } .atip small { color: var(--dim); }
.legend.row { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.axis-note { font-size: 12px; color: var(--dim); margin: 6px 0 0; }
.tbl { margin-top: 8px; font-size: 13px; } .tbl table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.tbl th, .tbl td { padding: 3px 4px; text-align: right; border-bottom: 1px solid var(--line); } .tbl th { color: var(--dim); font-weight: 700; }
.tiles { display: flex; gap: 10px; } .tile { flex: 1; background: var(--panel2); border-radius: 14px; padding: 10px 12px; }
.tile small { display: block; color: var(--dim); font-size: 12px; } .tile b { font-size: 26px; }
.eta { margin: 8px 0 0; font-weight: 700; }
.streak { font-size: 13px; color: var(--accent); margin-left: 6px; }
.cal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-h .mini-btn { font-size: 22px; font-weight: 900; width: 34px; height: 34px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal > b { font-size: 12px; color: var(--dim); }
.cal i { font-style: normal; min-height: 44px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; padding-top: 4px; font-size: 13px; }
.cal i.on { background: var(--panel2); }
.cal i.today { outline: 2px solid var(--accent); }
.cal i em { font-style: normal; color: var(--accent); font-size: 11px; letter-spacing: -1px; }

/* 오류 신고: 카드는 오른쪽 아래, 퀴즈는 오른쪽 위 */
.flag-btn { position: absolute; right: 14px; bottom: 14px; color: var(--dim); opacity: .75; }
.qcard { position: relative; }
.qcard .flag-btn { top: 12px; bottom: auto; }
.qcard .q-ask { padding: 0 36px; }

/* 처음 화면: 급수 카드 (N5·N4·N3, N2·N1 예정) + 전체 합계 + 캘린더 */
#home > .lv-grid, #home > .st-sec, #home > .legend { width: 100%; max-width: 528px; box-sizing: border-box; }
#home > .st-sec { margin-bottom: 0; }
.lv-grid { display: flex; flex-direction: column; gap: 10px; }
.lv-card { display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 4px 0 var(--shadow); text-decoration: none; color: var(--fg); }
.lv-card > b { grid-row: span 2; font-size: 26px; font-weight: 900; color: var(--accent); text-align: center; }
.lv-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.lv-card.off { grid-template-columns: 56px 1fr; opacity: .55; box-shadow: none; }
.lv-card.off > b { grid-row: auto; color: var(--dim); }
.lv-card.off small { color: var(--dim); font-weight: 700; }
.lv-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.lv-row small { color: var(--dim); font-variant-numeric: tabular-nums; }
.sbar.mini { height: 10px; gap: 2px; background: none; }
.sbar.mini .seg { border-radius: 2px; }
.sbar.mini .empty, .key.empty { background: var(--panel2); border: 1px solid var(--line); box-sizing: border-box; }
.tiles + .tiles { margin-top: 10px; }
