:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --ink: #161a2b;
  --muted: #646b80;
  --line: #e3e6ee;
  --brand: #3b5bdb;
  --brand-ink: #ffffff;
  --brand-soft: #e8edff;
  --ok: #2f9e44;
  --ok-soft: #e6f6ea;
  --warn: #e8590c;
  --warn-soft: #fff1e6;
  --drive: #0f1324;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1120;
    --card: #181c2e;
    --ink: #eef0f7;
    --muted: #9aa1b8;
    --line: #2a3048;
    --brand: #6f8cff;
    --brand-ink: #0e1120;
    --brand-soft: #222b4d;
    --ok: #51cf66;
    --ok-soft: #173322;
    --warn: #ff922b;
    --warn-soft: #3a2614;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; margin-top: 1em; }
code { background: var(--brand-soft); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.wrap { max-width: 640px; margin: 0 auto; padding: 12px 16px 40px; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .95rem; }
.fine { color: var(--muted); font-size: .84rem; margin: .5em 0; }
.tip { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.warn { color: var(--warn); }

/* 상단 바 */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 8px 8px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.05rem; margin: 0; }
.back { font-size: 2rem; line-height: 1; width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink); }

/* 홈 */
.hero { background: linear-gradient(135deg, #3b5bdb, #5f3dc4); color: #fff; padding: 28px 16px 22px; padding-top: max(28px, env(safe-area-inset-top)); text-align: center; }
.hero h1 { font-size: 1.5rem; margin-bottom: .2em; }
.hero p { margin: 0 0 16px; opacity: .85; font-size: .92rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 480px; margin: 0 auto; }
.stats div { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-size: 1.45rem; }
.stats b small { font-size: .8rem; opacity: .75; }
.stats span { font-size: .75rem; opacity: .85; }
.stats.inline div { background: var(--brand-soft); color: var(--ink); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.tile { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 16px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; min-height: 122px; border: 1px solid var(--line); }
.tile .ico { font-size: 1.8rem; }
.tile b { font-size: 1.05rem; }
.tile small { color: var(--muted); font-size: .8rem; }
.tile-drive { grid-column: 1 / -1; background: linear-gradient(135deg, #1f2f7a, #0f1324); color: #fff; border: none; min-height: 100px; }
.tile:last-child:nth-child(even) { grid-column: 1 / -1; min-height: 0; }
.tile-drive small { color: #b9c2ea; }
.suggest { display: block; color: var(--ink); }
.suggest .label { font-size: .76rem; color: var(--brand); font-weight: 600; }
.suggest b { display: block; margin: 4px 0; }
.suggest small { color: var(--muted); }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.links a { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); font-size: .92rem; }

/* 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card.warn { background: var(--warn-soft); color: var(--ink); border-color: transparent; font-size: .92rem; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.row:last-child { border-bottom: none; }
.row input { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-between h2 { margin: 0; }
.field { display: block; margin: 14px 0 6px; font-size: .92rem; }
.field select, .field input[type=range] { display: block; width: 100%; margin-top: 6px; }
select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
textarea { line-height: 1.5; resize: vertical; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 48px; margin: 6px 0; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.big { min-height: 60px; font-size: 1.08rem; }
.btn.small { width: auto; min-height: 36px; padding: 6px 12px; font-size: .88rem; margin: 4px 0; }
.btn.ghost { background: transparent; }
.btn.danger { color: #e03131; }
.btn:disabled { opacity: .4; }
.btn:active { transform: scale(.98); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chips button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: .9rem; cursor: pointer; }
.chips button small { color: var(--muted); font-size: .76rem; }
.chips button.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.chips button.on small { color: inherit; opacity: .8; }

/* 질문 목록 */
.group { font-size: .82rem; color: var(--muted); margin: 18px 4px 6px; }
.qitem { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 6px 0; color: var(--ink); }
.qko { flex: 1; font-size: .92rem; }
.meta { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.type { flex: none; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.t-past { background: #fff0f6; color: #c2255c; }
.t-compare, .t-issue { background: #f3f0ff; color: #6741d9; }
.t-rp-ask, .t-rp-solve { background: #fff4e6; color: #d9480f; }
@media (prefers-color-scheme: dark) {
  .t-past { background: #3a1a2a; color: #faa2c1; }
  .t-compare, .t-issue { background: #2a2249; color: #b197fc; }
  .t-rp-ask, .t-rp-solve { background: #3a2614; color: #ffc078; }
}

/* 연습 */
.qbox .qen { font-size: 1.05rem; font-weight: 600; margin: 10px 0 6px; }
.qen.small { font-size: .9rem; color: var(--muted); font-weight: 400; }
details summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.plan { padding-left: 1.3em; margin: 0 0 12px; }
.plan li { margin: 6px 0; }
.countdown { font-size: 3rem; font-weight: 800; text-align: center; color: var(--brand); margin: 6px 0; font-variant-numeric: tabular-nums; }
.round { font-size: .82rem; font-weight: 700; color: var(--brand); letter-spacing: .02em; margin-bottom: 6px; }
.bigtime { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.bigtime.low { color: #e03131; }
.rec .dot { display: inline-block; width: 9px; height: 9px; background: #e03131; border-radius: 50%; animation: blink 1s infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: .2; } }
.live { min-height: 110px; background: var(--bg); border-radius: 12px; padding: 12px; text-align: left; font-size: .95rem; color: var(--muted); margin: 10px 0; }
.transcript { background: var(--bg); border-radius: 12px; padding: 12px; font-size: .95rem; white-space: pre-wrap; }
audio { width: 100%; margin: 8px 0; }
.checks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.checks li { border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; }
.checks li.ok { background: var(--ok-soft); }
.checks li.no { background: var(--warn-soft); }
.checks small { color: var(--muted); font-size: .8rem; }
.sents { padding-left: 1.4em; margin: 6px 0; }
.sents li { padding: 8px 6px; border-radius: 8px; cursor: pointer; margin: 2px 0; }
.sents li.on { background: var(--brand-soft); }
.sents .en { display: block; }
.sents .ko { display: block; color: var(--muted); font-size: .84rem; }
.chunks { list-style: none; padding: 0; display: grid; gap: 6px; }
.chunks li { background: var(--bg); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.chunks b { display: block; font-size: .95rem; }
.chunks small { color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.big-msg { font-size: 1.02rem; background: var(--ok-soft); border-radius: 10px; padding: 10px 12px; }

/* 카드 */
.progress-line { text-align: center; color: var(--muted); font-size: .88rem; margin-top: 8px; }
.new { background: var(--brand); color: var(--brand-ink); font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-left: 4px; }
.flash { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; }
.flash .cat { font-size: .76rem; color: var(--brand); font-weight: 700; }
.fko { font-size: 1.45rem; font-weight: 700; margin: 14px 0; }
.fen { font-size: 1.35rem; font-weight: 700; color: var(--brand); margin: 0; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade .btn { flex-direction: column; gap: 0; min-height: 64px; }
.grade small { font-weight: 400; font-size: .74rem; color: var(--muted); }
.g0 { border-color: #ffc9c9; } .g2 { border-color: #b2f2bb; }
.bigemoji { font-size: 3rem; }

/* 모의고사 */
.mock .avatar { font-size: 4rem; margin: 10px 0; }
.peek { margin-top: 12px; text-align: left; }

/* 기록 */
.heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--line); }
.heat i.l1 { background: #a5b4fc; } .heat i.l2 { background: #6f8cff; } .heat i.l3 { background: #3b5bdb; }
.qcount { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.qcount li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.research p { margin: 0 0 6px; font-size: .93rem; }
.research small { color: var(--brand); font-weight: 600; }

.muted { color: var(--muted); font-weight: 400; }
.links a small { color: var(--muted); }
.free-note { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 18px; line-height: 1.8; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.two .btn { margin: 6px 0 0; font-size: .92rem; }
.meter { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; margin: 12px 0 4px; }
.meter div { height: 100%; width: 0; background: var(--brand); transition: width .3s; }
input[type=password] { display: block; width: 100%; margin-top: 6px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.row input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
.center-chips { justify-content: center; margin-top: 8px; }
.celebrate-cta { display: block; text-align: center; font-weight: 600; color: var(--ink); background: var(--brand-soft); border-color: transparent; }

/* 오답 노트 · 고쳐 말하기 카드 */
.fixes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.fixes li { position: relative; background: var(--bg); border-radius: 10px; padding: 10px 40px 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.fixes .said { color: var(--muted); text-decoration: line-through; text-decoration-color: #e03131; font-size: .9rem; }
.fixes .fix { font-weight: 600; }
.fixes small { color: var(--muted); font-size: .8rem; }
.x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border: none; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.flash .said { font-size: 1.2rem; font-weight: 600; margin: 14px 0; color: var(--muted); }

/* 아래에서 올라오는 시트 · 돌아왔을 때 알림 */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 12, 24, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .card { box-shadow: none; }
.return-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--brand); border-radius: 14px; padding: 8px 8px 8px 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .2); max-width: 616px; margin: 0 auto; }
.return-bar span { flex: 1; font-size: .9rem; }
.return-bar .btn { width: auto; margin: 0; }
.return-bar .x { position: static; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #161a2b; color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: .92rem; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .25); }

/* 운전 모드 실행 화면: 항상 어둡게, 크게 */
body[data-screen="drive-run"] { background: var(--drive); color: #e9ecff; }
.drive { min-height: 100dvh; display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.d-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .86rem; color: #9aa6d8; }
.d-exit { background: transparent; color: #9aa6d8; border: 1px solid #2c3459; border-radius: 10px; padding: 8px 12px; font: inherit; }
.d-part { margin-top: 10px; font-size: 1.1rem; font-weight: 700; color: #8ea2ff; }
.d-center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; cursor: pointer; user-select: none; }
.d-text { font-size: 1.6rem; line-height: 1.45; font-weight: 600; }
.d-text .ko { color: #c3c9e8; font-weight: 500; }
.d-gap { min-height: 70px; }
.d-gap b { display: block; font-size: 1.5rem; color: #69db7c; }
.d-gap small { font-size: 2.4rem; font-weight: 800; color: #69db7c; font-variant-numeric: tabular-nums; }
.d-progress { height: 4px; background: #232a4a; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.d-progress div { height: 100%; background: #6f8cff; width: 0; transition: width .3s; }
.d-ctrl { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 12px; }
.d-ctrl button { min-height: 86px; border-radius: 20px; border: none; background: #1d2440; color: #fff; font-size: 1.9rem; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; }
.d-ctrl button small { font-size: .78rem; color: #9aa6d8; }
.d-ctrl .play { background: #3b5bdb; font-size: 2.4rem; }
