:root {
  --bg: #fbf7ee;
  --card: #ffffff;
  --ink: #2b2a28;
  --muted: #7d7a72;
  --line: #ece6d8;
  --sky: #cfe7f5;
  --sky-d: #4f9fd1;
  --mint: #cdeee3;
  --mint-d: #35a37f;
  --yellow: #ffe9a8;
  --yellow-d: #d9a400;
  --red: #e36a6a;
  --shadow: 0 6px 20px rgba(80, 60, 20, 0.08);
  --r: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
.hanja-font { font-family: "Noto Serif KR", "Nanum Myeongjo", "Batang", "Songti SC", "SimSun", serif; }
button { font-family: inherit; cursor: pointer; }
a { color: var(--sky-d); }

/* 레이아웃 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(251, 247, 238, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
}
.topbar .logo { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar .logo .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--yellow); display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }
.topbar .spacer { flex: 1; }
.topbar .chip { font-size: 12px; background: var(--mint); color: var(--mint-d); padding: 4px 10px; border-radius: 99px; font-weight: 700; }
.topbar .chip.demo { background: var(--yellow); color: #8a6a00; }
.topbar .user { font-size: 13px; color: var(--muted); }
.nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.nav button { white-space: nowrap; border: 0; background: transparent; padding: 8px 12px; border-radius: 99px; font-size: 14px; color: var(--muted); font-weight: 600; }
.nav button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 60px; }
.screen { display: none; }
.screen.on { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 24px; margin: 8px 0 6px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.big { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* 버튼 */
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-size: 15px; font-weight: 700; background: var(--card); color: var(--ink); box-shadow: var(--shadow); transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--sky-d); color: #fff; }
.btn.mint { background: var(--mint-d); color: #fff; }
.btn.yellow { background: var(--yellow); color: #6b5200; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.danger { background: #ffe1e1; color: #a33; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.mt { margin-top: 14px; } .mt2 { margin-top: 24px; }

/* 첫 화면 */
.hero { text-align: center; padding: 40px 10px 20px; }
.hero .big-char { font-size: 96px; line-height: 1; margin-bottom: 10px; }
.hero .big-char span { display: inline-block; padding: 10px 18px; border-radius: 24px; margin: 0 4px; }
.hero h1 { font-size: 30px; }
.hero .sub { font-size: 16px; }
.demo-note { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* 급수 카드 */
.grade-card { cursor: pointer; position: relative; }
.grade-card:hover { transform: translateY(-2px); }
.grade-card .name { font-weight: 800; font-size: 17px; }
.grade-card .desc { color: var(--muted); font-size: 13px; margin: 4px 0 10px; min-height: 18px; }
.grade-card .meta { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--mint-d); border-radius: 99px; transition: width .3s; }
.check { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.grade-card.sel .check { background: var(--sky-d); border-color: var(--sky-d); color: #fff; }
.grade-card.sel { outline: 2px solid var(--sky-d); }

/* 학습 카드 */
.study-wrap { text-align: center; }
.flash { background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 30px 20px; min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.flash .char { font-size: 120px; line-height: 1.1; }
.flash .hint { color: var(--muted); font-size: 13px; margin-top: 14px; }
.flash .hunum { font-size: 30px; font-weight: 800; margin-top: 6px; }
.flash .info { color: var(--muted); font-size: 15px; margin-top: 6px; }
.flash .status-tag { position: absolute; top: 14px; left: 14px; font-size: 12px; padding: 4px 10px; border-radius: 99px; font-weight: 700; }
.status-tag.known { background: var(--mint); color: var(--mint-d); }
.status-tag.review { background: var(--yellow); color: #8a6a00; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.examples span { background: var(--bg); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.examples span b { font-weight: 600; }
.counter { color: var(--muted); font-size: 14px; margin: 10px 0; }
.dots { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line); }
.dots i.known { background: var(--mint-d); } .dots i.review { background: var(--yellow-d); } .dots i.cur { outline: 2px solid var(--sky-d); outline-offset: 1px; }

/* 게임 */
.game-card { cursor: pointer; display: flex; gap: 14px; align-items: center; }
.game-card .icon { width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.game-card .t { font-weight: 800; font-size: 16px; }
.game-card .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.hud { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; gap: 6px; }
.hud b { color: var(--ink); font-size: 16px; }
.hud .timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 800; color: var(--sky-d); }
.hud .timer.low { color: var(--red); }
.q-char { font-size: 110px; text-align: center; line-height: 1.1; padding: 20px 0; }
.q-text { font-size: 32px; font-weight: 800; text-align: center; padding: 28px 0; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 16px 10px; font-size: 20px; font-weight: 700; transition: all .15s; min-height: 64px; }
.choice.hanja { font-size: 40px; }
.choice:hover { border-color: var(--sky); }
.choice.ok { background: var(--mint); border-color: var(--mint-d); }
.choice.no { background: #ffe1e1; border-color: var(--red); }
.choice:disabled { cursor: default; }
.feedback { text-align: center; min-height: 28px; margin-top: 12px; font-weight: 700; font-size: 16px; }
.feedback.ok { color: var(--mint-d); } .feedback.no { color: var(--red); }
.combo { display: inline-block; background: var(--yellow); color: #8a6a00; padding: 2px 10px; border-radius: 99px; font-size: 13px; margin-left: 6px; }

/* 짝맞추기 */
.match-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mcard { aspect-ratio: 3/4; perspective: 600px; cursor: pointer; }
.mcard .inner { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.mcard.flip .inner { transform: rotateY(180deg); }
.mcard .face { position: absolute; inset: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; font-weight: 800; }
.mcard .front { background: var(--sky-d); color: #fff; font-size: 24px; }
.mcard .back { background: var(--card); box-shadow: var(--shadow); transform: rotateY(180deg); font-size: 15px; padding: 4px; text-align: center; }
.mcard .back.hj { font-size: 36px; }
.mcard.done .back { background: var(--mint); }
.mcard.done { opacity: .6; }

/* 타자 */
.type-input { width: 100%; font-size: 28px; text-align: center; padding: 14px; border-radius: 16px; border: 2px solid var(--line); outline: none; font-family: inherit; }
.type-input:focus { border-color: var(--sky-d); }
.time-opts { display: flex; gap: 8px; justify-content: center; }
.time-opts button { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 16px; font-weight: 700; }
.time-opts button.on { border-color: var(--sky-d); background: var(--sky); }

/* 결과 */
.result-score { text-align: center; padding: 20px 0; }
.result-score .n { font-size: 56px; font-weight: 900; color: var(--sky-d); }
.result-score .l { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stats .card { padding: 12px; }
.stats .v { font-size: 22px; font-weight: 800; } .stats .k { color: var(--muted); font-size: 12px; }
.wrong-list { display: flex; flex-wrap: wrap; gap: 8px; }
.wrong-list span { background: #fff1f1; border-radius: 10px; padding: 6px 10px; }
.wrong-list span b { font-size: 20px; margin-right: 6px; }

/* 리스트/표 */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); }
.list-item .c { font-size: 32px; width: 44px; text-align: center; }
.list-item .t { flex: 1; }
.list-item .t small { color: var(--muted); display: block; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 48px; margin-bottom: 8px; }

/* 폼 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); font-size: 15px; font-family: inherit; background: #fff; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--sky-d); }
.msg { padding: 10px 12px; border-radius: 12px; font-size: 14px; margin: 10px 0; }
.msg.err { background: #ffe1e1; color: #a33; } .msg.ok { background: var(--mint); color: var(--mint-d); } .msg.info { background: var(--sky); color: #1d5e85; }

/* 토스트 */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
.toast.on { opacity: 1; }

@media (max-width: 480px) {
  .flash .char { font-size: 96px; }
  .q-char { font-size: 88px; }
  .choice { font-size: 17px; padding: 14px 8px; }
  .choice.hanja { font-size: 34px; }
  .hero .big-char { font-size: 72px; }
  .match-grid { gap: 6px; }
}

/* ===== 20자 매일학습 / 학습 완료 체크 / 뜻·음 보기 ===== */
.daily-btn { margin-top: 12px; }
.daily-btn small { font-weight: 600; opacity: .8; margin-left: 4px; }
.daily-head { background: var(--yellow); color: #6b5200; border-radius: 14px; padding: 10px 14px; font-size: 14px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 10px; }
.show-bar { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 4px 0 12px; font-size: 13px; color: var(--muted); }
.toggle { border: 2px solid var(--line); background: var(--card); border-radius: 99px; padding: 7px 16px; font-weight: 700; font-size: 14px; color: var(--muted); }
.toggle.on { border-color: var(--sky-d); background: var(--sky); color: #1d5e85; }
.flash .mask { display: inline-block; min-width: 1.6em; padding: 0 .3em; border-radius: 10px; background: var(--line); color: var(--muted); }
.flash.is-done { outline: 3px solid var(--mint-d); }
.done-btn { display: inline-flex; align-items: center; gap: 8px; border: 2px solid var(--mint-d); color: var(--mint-d); }
.done-btn .box, .ck .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid currentColor; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
.done-btn.on { background: var(--mint-d); color: #fff; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; text-align: center; }
.ck { position: relative; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 6px 8px; cursor: pointer; border: 2px solid transparent; }
.ck.cur { border-color: var(--sky-d); }
.ck.done { background: var(--mint); }
.ck .box { position: absolute; top: 6px; left: 6px; background: #fff; color: var(--mint-d); border-color: var(--line); padding: 0; cursor: pointer; }
.ck.done .box { background: var(--mint-d); border-color: var(--mint-d); color: #fff; }
.ck .c { font-size: 34px; line-height: 1.2; }
.ck .t { font-size: 13px; color: var(--ink); margin-top: 2px; }
.ck .t i { font-style: normal; color: var(--muted); background: var(--line); border-radius: 6px; padding: 0 5px; font-size: 11px; }
h2 small.sub { display: block; font-size: 12px; font-weight: 400; margin: 2px 0 0; }

/* ===== 내 폴더 / 한자 추가 ===== */
.sec-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin: 30px 0 12px; }
.sec-head h2 { margin: 0; }
.folder-card .name { padding-right: 0; }
.tag { display: inline-block; font-size: 11px; background: var(--sky); color: #1d5e85; border-radius: 99px; padding: 1px 8px; font-weight: 700; vertical-align: middle; }
.list-item.is-known { background: #f1faf6; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal-bg.on { display: flex; }
.modal { background: var(--card); border-radius: 20px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-prev { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.add-prev span { border-radius: 10px; padding: 5px 10px; font-size: 13px; }
.add-prev span b { font-size: 20px; margin-right: 4px; font-weight: 600; }
.add-prev .ok { background: var(--mint); color: #1f6b52; }
.add-prev .new { background: var(--yellow); color: #6b5200; }
