:root {
  --navy: #0f2a4a;
  --navy-2: #1b3f6b;
  --red: #d7261e;
  --gold: #f5b301;
  --green: #12805c;
  --green-bg: #e6f6ef;
  --red-bg: #fdecea;
  --bg: #eef1f6;
  --card: #ffffff;
  --text: #16202e;
  --muted: #6b7a8d;
  --line: #e2e7ef;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(15, 42, 74, .08);
  --tab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: #dfe4ec;
  color: var(--text);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.phone {
  position: relative;
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(15, 42, 74, .18);
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--navy);
  color: #fff;
}
.topbar .backbtn {
  display: none;
  width: 30px; height: 30px; flex: 0 0 30px;
  border: 0; border-radius: 9px;
  background: rgba(255,255,255,.12);
  color: #fff; font-size: 22px; line-height: 1;
  padding: 0 0 3px; cursor: pointer;
}
.topbar.has-back .backbtn { display: block; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.brand-mark {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  padding: 5px 7px; border-radius: 8px;
  background: var(--red); color: #fff;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 10.5px; color: rgba(255,255,255,.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-badge {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 800;
  padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #ffd66b;
  border: 1px solid rgba(255,214,107,.35);
}
.mode-badge.paid { background: rgba(18,128,92,.28); color: #9df0c9; border-color: rgba(157,240,201,.35); }

/* ---------- view ---------- */
.view {
  flex: 1;
  padding: 14px 14px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  outline: none;
}
.view.nopad { padding: 0 0 calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); }
.screen { animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- generic ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card.tight { padding: 12px 14px; }
.h2 { font-size: 17px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.3px; }
.h3 { font-size: 14px; font-weight: 800; margin: 0 0 8px; }
.sub { font-size: 12.5px; color: var(--muted); margin: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.center { text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(15,42,74,.15); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 12.5px; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: default; }

.chip {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: #eef2f8; color: var(--navy-2);
}
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.gold { background: #fff6dd; color: #986b00; }

/* ---------- home ---------- */
.hero {
  position: relative;
  border-radius: 20px; padding: 18px 18px 16px;
  background: linear-gradient(140deg, #12335a 0%, #0f2a4a 55%, #0b1f39 100%);
  color: #fff; overflow: hidden; margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(15,42,74,.28);
}
.hero::after {
  content: ""; position: absolute; right: -46px; top: -60px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(215,38,30,.5), transparent 65%);
}
.hero-top { display: flex; gap: 14px; align-items: center; position: relative; z-index: 1; }
.ring { flex: 0 0 78px; width: 78px; height: 78px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.hero-copy { min-width: 0; }
.hero-copy .k { font-size: 11px; color: #ffd66b; font-weight: 800; letter-spacing: .3px; }
.hero-copy h1 { margin: 2px 0 3px; font-size: 19px; line-height: 1.3; letter-spacing: -.4px; }
.hero-copy p { margin: 0; font-size: 12px; color: rgba(255,255,255,.66); }
.stats { display: flex; gap: 8px; margin-top: 14px; position: relative; z-index: 1; }
.stat { flex: 1; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.09); border-radius: 12px; padding: 8px 9px; }
.stat b { display: block; font-size: 16px; line-height: 1.2; }
.stat span { font-size: 10.5px; color: rgba(255,255,255,.6); }

.banner {
  display: flex; align-items: center; gap: 10px;
  background: #fff6dd; border: 1px solid #f3dda1; color: #6b4c00;
  border-radius: 13px; padding: 10px 12px; margin-bottom: 12px;
  font-size: 12.5px; line-height: 1.45;
}
.banner b { font-weight: 800; }
.banner .btn { margin-left: auto; flex: 0 0 auto; }

.grid8 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feature {
  display: flex; flex-direction: column; gap: 8px;
  background: #fff; border-radius: 15px; padding: 13px;
  box-shadow: 0 3px 12px rgba(15,42,74,.06);
  border: 1px solid #e8edf4; cursor: pointer; text-align: left;
  position: relative; min-height: 116px;
}
.feature:active { transform: scale(.985); }
.feature .ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: #eef3fb; color: var(--navy-2); }
.feature .ico svg { width: 19px; height: 19px; fill: currentColor; }
.feature.law .ico { background: #fdecea; color: var(--red); }
.feature.gold .ico { background: #fff5d8; color: #a06f00; }
.feature.green .ico { background: var(--green-bg); color: var(--green); }
.feature b { font-size: 14px; letter-spacing: -.2px; }
.feature small { font-size: 11px; color: var(--muted); line-height: 1.4; }
.feature .badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px;
  background: #eef2f8; color: var(--navy-2);
}
.feature .badge.lock { background: #fff1e0; color: #a25700; }

.sect { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 9px; }
.sect h2 { font-size: 14px; margin: 0; font-weight: 800; }
.sect a { font-size: 11.5px; color: var(--muted); }

/* ---------- study hub ---------- */
.modelist { display: flex; flex-direction: column; gap: 10px; }
.modecard {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: #fff; border: 1px solid #e8edf4; border-radius: 15px; padding: 14px;
  cursor: pointer; width: 100%;
}
.modecard:active { transform: scale(.99); }
.modecard .ico { flex: 0 0 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #eef3fb; color: var(--navy-2); }
.modecard .ico svg { width: 21px; height: 21px; }
.modecard .txt { flex: 1; min-width: 0; }
.modecard .txt b { display: block; font-size: 14px; }
.modecard .txt small { color: var(--muted); font-size: 11.5px; }
.modecard .go { color: #b9c4d3; font-size: 20px; }

/* ---------- quiz ---------- */
.quizbar { position: sticky; top: 52px; z-index: 20; background: var(--bg); padding: 6px 0 10px; margin: 0 0 2px; }
.qprog { height: 6px; background: #dde3ec; border-radius: 99px; overflow: hidden; }
.qprog i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-2), #2f6fb5); border-radius: 99px; transition: width .25s; }
.quizbar .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.qmeta { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.qmeta .idx { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 700; }
.qtext { font-size: 17px; font-weight: 700; line-height: 1.62; margin: 0 0 14px; letter-spacing: -.25px; word-break: keep-all; }
.signbox { display: flex; justify-content: center; margin: 2px 0 16px; }
.signbox svg { width: 124px; height: 124px; filter: drop-shadow(0 5px 10px rgba(15,42,74,.13)); }

.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  background: #fff; border: 1.5px solid #e3e9f1; border-radius: 13px;
  padding: 12px 13px; font-size: 14.5px; line-height: 1.5; cursor: pointer;
  transition: border-color .15s, background .15s;
  word-break: keep-all;
}
.option .mark {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 800;
  background: #eef2f8; color: var(--navy-2); margin-top: 1px; text-decoration: none;
}
.option .txt { flex: 1; min-width: 0; }
.option:not(.locked):active { background: #f7f9fc; }
.option.locked { cursor: default; }
.option.correct { border-color: var(--green); background: var(--green-bg); }
.option.correct .mark { background: var(--green); color: #fff; }
.option.wrong { border-color: var(--red); background: var(--red-bg); }
.option.wrong .mark { background: var(--red); color: #fff; }
.option.dim { opacity: .62; }
.option.ox { justify-content: flex-start; text-align: left; font-weight: 700; }
.option.ox .mark { display: grid; }

.qactions { display: flex; gap: 8px; margin-top: 14px; }
.qactions .btn { flex: 1; }
.favbtn.on { color: #a06f00; border-color: #f3dda1; background: #fff8e6; }

.explain { margin-top: 14px; border-radius: 15px; overflow: hidden; border: 1px solid #e3e9f1; background: #fff; animation: fade .22s ease; }
.explain .head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  background: linear-gradient(120deg, #eef3fb, #f7f9fc); border-bottom: 1px solid #e8edf4;
}
.explain .head .ai {
  font-size: 10px; font-weight: 900; letter-spacing: .4px;
  background: var(--navy); color: #fff; padding: 3px 6px; border-radius: 6px;
}
.explain .head b { font-size: 13.5px; }
.explain .head .verdict { margin-left: auto; font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.verdict.ok { background: var(--green-bg); color: var(--green); }
.verdict.no { background: var(--red-bg); color: var(--red); }
.explain .body { padding: 13px 14px 15px; }
.explain .block { margin-bottom: 12px; }
.explain .block:last-child { margin-bottom: 0; }
.explain .block .k {
  font-size: 10.5px; font-weight: 900; color: var(--navy-2);
  letter-spacing: .35px; margin-bottom: 4px; display: flex; align-items: center; gap: 5px;
}
.explain .block .k::before { content: ""; width: 3px; height: 10px; border-radius: 2px; background: var(--red); }
.explain .block p { margin: 0; font-size: 13.5px; line-height: 1.66; color: #2b3648; word-break: keep-all; }
.explain .term { background: #f3f7fd; border: 1px dashed #cfdcec; border-radius: 10px; padding: 9px 11px; font-size: 12.5px; color: #33506f; }
.explain .term .k { color: #33506f; }
.explain .term .k::before { background: #2f6fb5; }
.explain ol.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.explain ol.notes li { display: flex; gap: 7px; font-size: 12.8px; line-height: 1.55; color: #3a4658; }
.explain ol.notes li .n {
  flex: 0 0 18px; width: 18px; height: 18px; border-radius: 5px;
  font-size: 10px; font-weight: 800; display: grid; place-items: center;
  background: #eef2f8; color: var(--navy-2); margin-top: 2px;
}
.explain ol.notes li.ok .n { background: var(--green-bg); color: var(--green); }
.explain .law { font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 9px; margin-top: 11px; }

.quiznav { display: flex; gap: 8px; margin-top: 14px; }
.quiznav .btn { flex: 1; }

/* ---------- exam ---------- */
.examhead {
  position: sticky; top: 52px; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); padding: 4px 0 10px;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; color: var(--navy); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.timer.warn { color: #fff; background: var(--red); border-color: var(--red); }
.examhead .count { font-size: 12px; color: var(--muted); font-weight: 700; }
.examhead .gridbtn { margin-left: auto; }
.sheetgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.sheetgrid button {
  aspect-ratio: 1; border-radius: 9px; border: 1px solid #dfe6ef; background: #fff;
  font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.sheetgrid button.done { background: #e8eff9; border-color: #c9d9ee; color: var(--navy-2); }
.sheetgrid button.cur { outline: 2px solid var(--navy); outline-offset: 1px; color: var(--navy); }
.sheetgrid button.flag { background: #fff5d8; border-color: #f0dca4; color: #8a5f00; }

.result-hero { text-align: center; padding: 22px 16px 18px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.result-hero .stamp {
  display: inline-flex; align-items: center; justify-content: center;
  width: 74px; height: 74px; border-radius: 50%; font-size: 13px; font-weight: 900;
  margin-bottom: 8px;
}
.result-hero .stamp.pass { background: var(--green-bg); color: var(--green); border: 2px solid #9fdcbf; }
.result-hero .stamp.fail { background: var(--red-bg); color: var(--red); border: 2px solid #f0b5b0; }
.result-hero .score { font-size: 40px; font-weight: 900; letter-spacing: -1.5px; line-height: 1.1; }
.result-hero .score small { font-size: 14px; font-weight: 700; color: var(--muted); }
.result-hero .msg { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.catbar { margin-bottom: 10px; }
.catbar .row { font-size: 12px; margin-bottom: 4px; }
.catbar .track { height: 7px; background: #e9eef5; border-radius: 99px; overflow: hidden; }
.catbar .track i { display: block; height: 100%; background: linear-gradient(90deg, #2f6fb5, #12805c); border-radius: 99px; }

.list { display: flex; flex-direction: column; }
.listitem {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left;
  padding: 12px 4px; border-bottom: 1px solid #eef2f7; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer;
}
.listitem:last-child { border-bottom: 0; }
.listitem .badge { flex: 0 0 auto; margin-top: 2px; }
.listitem .t { flex: 1; min-width: 0; font-size: 13px; line-height: 1.5; }
.listitem .t small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.listitem .arrow { color: #c2ccda; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; font-size: 12.5px; }

/* ---------- handsignals ---------- */
.hs { display: flex; flex-direction: column; gap: 12px; }
.hscard { background: #fff; border-radius: 16px; border: 1px solid #e8edf4; overflow: hidden; box-shadow: 0 3px 12px rgba(15,42,74,.05); }
.hscard .top { display: flex; gap: 12px; padding: 14px; align-items: center; }
.hscard .fig { flex: 0 0 92px; height: 112px; border-radius: 12px; background: linear-gradient(160deg, #eef3fb, #dfe9f6); display: grid; place-items: center; }
.hscard .fig svg { width: 82px; height: 100px; }
.hscard .nm { flex: 1; min-width: 0; }
.hscard .nm .no { font-size: 10.5px; font-weight: 800; color: var(--red); }
.hscard .nm b { display: block; font-size: 16px; letter-spacing: -.3px; margin: 1px 0 3px; }
.hscard .nm small { font-size: 11.5px; color: var(--muted); }
.hscard .det { padding: 0 14px 14px; font-size: 12.8px; line-height: 1.6; }
.hscard .det .lbl { font-size: 10.5px; font-weight: 900; color: var(--navy-2); letter-spacing: .3px; margin: 9px 0 3px; }
.hscard .det p { margin: 0; color: #3a4658; }
.hscard .det .tip { background: #fff8e6; border: 1px solid #f5e3b0; border-radius: 9px; padding: 8px 10px; color: #6b4c00; font-size: 12px; }

/* ---------- plans ---------- */
.plan {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1.5px solid #e3e9f1; border-radius: 15px; padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.plan.sel { border-color: var(--navy); background: #f7faff; box-shadow: 0 0 0 3px rgba(15,42,74,.06); }
.plan .days { flex: 0 0 54px; height: 54px; border-radius: 14px; background: #eef3fb; color: var(--navy); display: grid; place-items: center; font-weight: 900; font-size: 10.5px; line-height: 1.2; text-align: center; }
.plan.sel .days { background: var(--navy); color: #fff; }
.plan .days b { display: block; font-size: 17px; }
.plan .info { flex: 1; }
.plan .info b { font-size: 14.5px; }
.plan .info small { display: block; color: var(--muted); font-size: 11.5px; }
.plan .price { text-align: right; }
.plan .price b { display: block; font-size: 16px; color: var(--navy); }
.plan .price small { font-size: 10px; color: var(--muted); }

.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 30px; font-size: 12.8px; line-height: 1.55; color: #3a4658; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 21px; height: 21px; border-radius: 50%; background: var(--navy); color: #fff;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.steps li:last-child { padding-bottom: 0; }

.input {
  width: 100%; border: 1.5px solid #dfe6ef; border-radius: 12px; padding: 12px 13px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text); letter-spacing: .5px;
}
.input:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(27,63,107,.1); }
.field { display: flex; gap: 8px; }
.field .btn { flex: 0 0 auto; }

.codebox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; letter-spacing: 1px; background: #f4f7fb; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 7px;
}
.codebox.used { opacity: .55; }
.codebox button { border: 0; background: none; color: var(--navy-2); font-size: 11px; font-weight: 800; cursor: pointer; }

.passcard { background: linear-gradient(135deg, #12335a, #0b1f39); color: #fff; border-radius: 16px; padding: 16px; margin-bottom: 12px; }
.passcard .lab { font-size: 10.5px; color: #ffd66b; font-weight: 800; letter-spacing: .4px; }
.passcard b { display: block; font-size: 20px; margin: 3px 0; }
.passcard small { color: rgba(255,255,255,.66); font-size: 11.5px; }

.note { font-size: 11.5px; color: var(--muted); line-height: 1.55; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 460px; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.97);
  border-top: 1px solid #e6ebf2;
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tab-h); font-size: 10.5px; font-weight: 700; color: #97a4b6;
}
.tabbar a svg { width: 23px; height: 23px; fill: currentColor; opacity: .85; }
.tabbar a.on { color: var(--navy); }
.tabbar a.on svg { fill: var(--navy); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px); opacity: 0; pointer-events: none;
  background: rgba(22,32,46,.94); color: #fff; font-size: 12.5px; font-weight: 600;
  padding: 10px 15px; border-radius: 11px; z-index: 90; transition: opacity .2s, transform .2s;
  max-width: 88%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 461px) {
  body { padding: 18px 0; }
  .phone { min-height: calc(100vh - 36px); border-radius: 26px; }
  .topbar { border-radius: 26px 26px 0 0; padding-top: 14px; }
  .toast { bottom: 92px; }
}
