:root {
  --bg: #0b1020;
  --bg2: #0f1629;
  --panel: #131b31;
  --panel2: #18223d;
  --line: #24304f;
  --text: #e7eaf3;
  --muted: #8b95b2;
  --accent: #7c5cff;
  --accent2: #4cc9f0;
  --ok: #3ddc97;
  --bad: #ff5c7a;
  --warn: #ffd166;
  --mono: 'D2Coding', 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
  --sans: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: radial-gradient(1200px 600px at 80% -10%, #1d1846 0%, transparent 60%), var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); background: #ffffff12; padding: 1px 6px; border-radius: 5px; font-size: .92em; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.3rem; margin-top: 2rem; }
.muted { color: var(--muted); }
main { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 24px 40px; }

/* ---------- 상단바 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 28px; padding: 12px 24px; background: #0b1020d9; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; letter-spacing: -.02em; }
.logo-mark { font-family: var(--mono); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 2px 8px; border-radius: 8px; font-size: .9rem; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--text); background: #ffffff0d; }
.nav a.on { color: var(--text); background: #ffffff14; }
.lvpill { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-size: .85rem; }
.lvpill .lv { font-weight: 800; color: var(--warn); }
.lvpill .lvbar { width: 90px; height: 6px; background: #ffffff14; border-radius: 9px; overflow: hidden; }
.lvpill .lvbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .6s; }
.lvpill .xp { color: var(--muted); font-variant-numeric: tabular-nums; }
.lvpill.max { border-color: var(--warn); box-shadow: 0 0 20px #ffd16644; }

/* ---------- 버튼 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: 600 .92rem var(--sans); cursor: pointer; transition: transform .1s, background .2s; white-space: nowrap; }
.btn:hover { background: #22305a; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b6cff); border-color: transparent; color: #fff; box-shadow: 0 6px 20px #7c5cff55; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #ff5c7a66; color: var(--bad); background: transparent; }
.btn kbd { font: 600 .7rem var(--mono); background: #ffffff26; padding: 1px 6px; border-radius: 4px; }
.mini { font: 600 .75rem var(--sans); padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); cursor: pointer; }

/* ---------- 홈 ---------- */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; padding: 56px 0 32px; }
.eyebrow { display: inline-block; font-size: .82rem; font-weight: 700; color: var(--accent2); background: #4cc9f01a; padding: 4px 12px; border-radius: 99px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.6rem); letter-spacing: -.03em; font-weight: 900; }
.hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent2), var(--ok)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 560px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.player { display: flex; gap: 22px; align-items: center; background: linear-gradient(160deg, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 20px 50px #0006; transition: transform .2s; }
a.player:hover { transform: translateY(-3px); }
.player-lv { flex: none; width: 104px; height: 104px; border-radius: 50%; display: grid; place-content: center; text-align: center; font-size: 2.4rem; font-weight: 900; background: radial-gradient(circle, var(--panel) 60%, transparent 61%), conic-gradient(var(--accent), var(--accent2), var(--ok), var(--accent)); color: #fff; line-height: 1; }
.player-lv small { display: block; font-size: .62rem; letter-spacing: .2em; color: var(--muted); margin-top: 4px; }
.player-info { flex: 1; min-width: 0; }
.player-info > b { font-size: 1.2rem; }
.player-info > span { color: var(--muted); font-size: .85rem; }
.player-stats { display: flex; gap: 18px; margin-top: 14px; }
.player-stats div { display: flex; flex-direction: column; }
.player-stats b { font-size: 1.15rem; }
.player-stats small { color: var(--muted); font-size: .75rem; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 12px; }
.how div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.how span { display: inline-grid; place-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; margin-right: 8px; }
.how p { color: var(--muted); margin: 6px 0 0; font-size: .9rem; }

.pbar { height: 6px; background: #ffffff12; border-radius: 9px; overflow: hidden; margin: 8px 0; }
.pbar.big { height: 10px; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 9px; transition: width .4s; }

.sec { padding-top: 24px; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; }
.sec-head a { color: var(--muted); font-size: .9rem; }
.sec-head a:hover { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.ccard { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; transition: transform .15s, border-color .15s, box-shadow .15s; position: relative; overflow: hidden; }
.ccard::after { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.ccard:hover { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 12px 30px #0005; }
.ccard h3 { margin: 12px 0 4px; font-size: 1.12rem; }
.ccard p { color: var(--muted); font-size: .88rem; margin: 0 0 12px; flex: 1; }
.ccard-top { display: flex; justify-content: space-between; align-items: center; }
.ccard-foot { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.ccat { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cicon { display: inline-grid; place-content: center; min-width: 40px; height: 40px; padding: 0 6px; border-radius: 10px; background: color-mix(in srgb, var(--c) 22%, transparent); color: color-mix(in srgb, var(--c) 70%, white); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); font: 800 .9rem var(--mono); }

/* ---------- 목록 페이지 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 16px; }
.search { flex: 0 1 380px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: 1rem var(--sans); }
.search:focus { outline: 2px solid var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 20px; }
.chip { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: .88rem; font-weight: 600; }
.chip.on, .chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.course-hero { margin-top: 24px; padding: 28px; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 18%, var(--panel)), var(--panel)); border: 1px solid var(--line); }
.course-hero .back { color: var(--muted); font-size: .9rem; }
.course-hero-row { display: flex; gap: 18px; align-items: center; margin: 14px 0; }
.course-hero-row .cicon { min-width: 64px; height: 64px; font-size: 1.3rem; border-radius: 16px; }
.course-hero h1 { margin: 2px 0; font-size: 2rem; }
.course-hero p { margin: 0; color: var(--muted); }
.course-hero-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.llist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.llist a { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, transform .15s; }
.llist a:hover { border-color: var(--accent); transform: translateX(4px); }
.lnum { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-content: center; background: var(--panel2); font-weight: 800; color: var(--muted); }
.llist .done .lnum { background: var(--ok); color: #05301f; }
.ltitle { flex: 1; font-weight: 600; display: flex; flex-direction: column; }
.ltitle small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.lmeta { color: var(--muted); font-size: .85rem; }
.llist .done .lmeta { color: var(--ok); }

/* ---------- 레슨 ---------- */
main:has(.lesson) { max-width: none; padding: 0 16px 24px; }
.lesson-top { display: flex; align-items: center; gap: 16px; padding: 12px 4px; }
.lesson-top .back { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.lesson-top .back .cicon { min-width: 30px; height: 30px; font-size: .72rem; border-radius: 8px; }
.dots { flex: 1; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.dots a { width: 26px; height: 8px; border-radius: 9px; background: #ffffff1a; transition: background .2s; }
.dots a.ok { background: var(--ok); }
.dots a.cur { background: var(--accent); box-shadow: 0 0 0 2px #7c5cff55; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }
.pane.left { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
.pane h1 { font-size: 1.5rem; }
.desc { color: #c9cfe0; font-size: .97rem; }
.desc p { margin: 0 0 .6em; }
.desc ul { margin: 0 0 .6em; padding-left: 1.2em; }
.codehead { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 6px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.tag-lang { background: var(--panel2); padding: 2px 10px; border-radius: 6px; }
.code { display: flex; background: #0a0f1f; border: 1px solid var(--line); border-radius: 12px; overflow: auto; font: 14.5px/1.65 var(--mono); }
.code pre, .typeinner pre { margin: 0; padding: 14px 16px; font: inherit; white-space: pre; tab-size: 4; }
.gut { color: #4a5578; text-align: right; user-select: none; padding-right: 10px !important; border-right: 1px solid var(--line); min-width: 44px; background: #ffffff05; }
.code .kw { color: #c792ea; }
.code .str { color: #c3e88d; }
.code .num { color: #f78c6c; }
.code .com { color: #637199; font-style: italic; }
.code .fn { color: #82aaff; }
.code .tag { color: #ff7a93; }
.code .ty { color: #ffcb6b; }
.answer { max-height: 52vh; }
.prevcode { margin-top: 14px; }
.prevcode summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.prevcode .code { margin-top: 8px; max-height: 240px; font-size: 13px; opacity: .8; }
.outbox { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.outhead { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--panel2); font-size: .82rem; font-weight: 700; color: var(--muted); }
#preview { display: block; width: 100%; height: 340px; border: 0; background: #fff; }
.console { margin: 0; background: #070b16; padding: 12px 14px; min-height: 90px; max-height: 260px; overflow: auto; font: 13.5px/1.6 var(--mono); white-space: pre-wrap; color: #d6f5e3; }
.cl { border-bottom: 1px dashed #ffffff0d; padding: 1px 0; }
.cl.error { color: var(--bad); }
.cl.warn { color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--panel2); border-radius: 10px; padding: 8px 12px; }
.stats small { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; }
.stats b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stats em { font-style: normal; font-size: .7rem; color: var(--muted); margin-left: 3px; }

.typebox { position: relative; background: #0a0f1f; border: 2px solid var(--line); border-radius: 12px; height: 56vh; min-height: 300px; overflow: auto; font: 15.5px/1.7 var(--mono); cursor: text; transition: border-color .2s, box-shadow .2s; }
.typebox.focused { border-color: var(--accent); box-shadow: 0 0 0 4px #7c5cff22; }
.typebox.passed { border-color: var(--ok); box-shadow: 0 0 0 4px #3ddc9722; }
.typeinner { display: flex; min-width: max-content; min-height: 100%; }
.typearea { position: relative; flex: 1; }
.overlay { min-height: 100%; padding-bottom: 60px !important; }
#ta { position: absolute; inset: 0; width: 100%; height: 100%; padding: 14px 16px; margin: 0; border: 0; outline: 0; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: transparent; font: inherit; white-space: pre; tab-size: 4; }
#ta::selection { background: transparent; }
.overlay .ok { color: #e9edf7; }
.overlay .ghost { color: #46506f; }
.overlay .hide { color: transparent; }
.overlay .bad { color: #fff; background: #ff5c7acc; border-radius: 3px; }
.overlay .bad.sp { color: #ffd0d8; }
.overlay .pend { color: var(--warn); text-decoration: underline; }
.overlay .extra { color: #fff; background: #ff5c7a88; text-decoration: line-through; }
.overlay .nl { color: transparent; }
.overlay .cur { display: inline-block; width: 2px; height: 1.25em; margin-right: -2px; vertical-align: text-bottom; background: var(--warn); animation: blink 1s steps(1) infinite; box-shadow: 0 0 8px var(--warn); }
.typebox:not(.focused) .cur { animation: none; opacity: .5; }
.typebox.passed .cur { display: none; }
@keyframes blink { 50% { opacity: 0; } }
.focus-hint { position: sticky; bottom: 10px; left: 0; margin: 0 auto; width: max-content; background: var(--accent); color: #fff; font: 700 .85rem var(--sans); padding: 6px 14px; border-radius: 99px; pointer-events: none; transition: opacity .2s; }
.typebox.focused .focus-hint, .typebox.passed .focus-hint { opacity: 0; }
.nowline { display: flex; gap: 10px; align-items: center; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.nowline code { flex: 1; overflow: hidden; white-space: pre; text-overflow: ellipsis; color: var(--text); }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.controls .sp { flex: 1; }
.hint { color: var(--muted); font-size: .78rem; margin: 10px 0 0; }

.result { margin-top: 14px; padding: 20px; border-radius: 14px; background: linear-gradient(135deg, #3ddc9722, #7c5cff22); border: 1px solid #3ddc9766; animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
.result-big { font-size: 1.6rem; font-weight: 900; }
.result-big b { color: var(--warn); }
.result-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0; color: #cfd6ea; font-weight: 600; }
.result-bonus { color: var(--ok); font-size: .85rem; }
.levelup { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: #ffd16622; color: var(--warn); font-weight: 700; }
.result-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* ---------- 내 기록 ---------- */
.me-top { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.me-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.me-stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; }
.me-stats b { font-size: 1.6rem; display: block; }
.me-stats small { color: var(--muted); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: center; opacity: .4; filter: grayscale(1); }
.badge.on { opacity: 1; filter: none; border-color: var(--warn); box-shadow: 0 0 18px #ffd16622; }
.badge span { font-size: 2rem; display: block; }
.badge small { color: var(--muted); font-size: .75rem; display: block; }
.road { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.road div { flex: 1 0 120px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; opacity: .5; }
.road div.on { opacity: 1; border-color: var(--accent); }
.road b { display: block; color: var(--accent2); }
.road span { display: block; font-size: .85rem; font-weight: 600; }
.road small { color: var(--muted); font-size: .72rem; }
.progress-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.progress-list a { display: grid; grid-template-columns: auto 90px 1fr auto; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: .9rem; }
.progress-list .cicon { min-width: 32px; height: 32px; font-size: .72rem; }
.progress-list .pbar { margin: 0; }
.progress-list small { color: var(--muted); }
.settings { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.settings input { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px; }

/* ---------- 단계 선택 ---------- */
.stepsel { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.stepsel select { max-width: 280px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: 600 .88rem var(--sans); cursor: pointer; }
.stepsel select:focus { outline: 2px solid var(--accent); }
.small { font-size: .8rem; }
.settings p { margin: 0; }

/* ---------- 기타 ---------- */
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 30px); background: var(--panel2); border: 1px solid var(--accent); color: var(--text); padding: 10px 20px; border-radius: 99px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; box-shadow: 0 10px 30px #0008; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(60px); } }

@media (max-width: 960px) {
  .hero, .me-top { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .pane.left { position: static; max-height: none; }
  .nav { display: none; }
  .how { grid-template-columns: 1fr; }
  .typebox { height: 50vh; }
}
