:root {
  --c-primary: #3555d9;
  --c-primary-d: #2742b3;
  --c-accent: #ff6b4a;
  --c-bg: #f6f7fb;
  --c-card: #fff;
  --c-text: #1d2433;
  --c-muted: #667085;
  --c-line: #e3e6ee;
  --c-ok: #1a8f5a;
  --c-err: #c0392b;
  --r: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--c-bg); color: var(--c-text); line-height: 1.6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans KR", "Noto Sans Thai", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); line-height: 1.25; margin: .3em 0 .5em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.05rem; margin: 0 0 .4em; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 56px; min-height: 60vh; }
.muted { color: var(--c-muted); }
.ok { color: var(--c-ok); font-weight: 600; }
.center { text-align: center; padding: 56px 0; }
.lead { font-size: 1.1rem; color: var(--c-muted); }
.crumb { margin: 0; font-size: .92rem; }
.prose { max-width: 70ch; }
.inline { display: inline; }
.nowrap { white-space: nowrap; }

/* header */
.site-header { background: #fff; border-bottom: 1px solid var(--c-line); position: sticky; top: 0; z-index: 10; }
.bar { display: flex; align-items: center; gap: 14px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 800; color: var(--c-text); display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-ko { background: var(--c-primary); color: #fff; width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; }
.nav { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--c-text); font-weight: 500; }
.bar-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--c-line); border-radius: 8px; font-size: .85rem; font-weight: 600; }
.lang summary::-webkit-details-marker { display: none; }
.lang ul { position: absolute; right: 0; top: 110%; background: #fff; border: 1px solid var(--c-line); border-radius: 10px; box-shadow: var(--shadow); list-style: none; margin: 0; padding: 6px; min-width: 170px; }
.lang li a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--c-text); }
.lang li a:hover { background: var(--c-bg); text-decoration: none; }
.lang [aria-current] { font-weight: 700; color: var(--c-primary); }
.site-footer { border-top: 1px solid var(--c-line); padding: 22px 0; color: var(--c-muted); font-size: .9rem; background: #fff; }

/* buttons & forms */
.btn { display: inline-block; border: 1px solid var(--c-primary); background: var(--c-primary); color: #fff; padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { background: var(--c-primary-d); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--c-primary); }
.btn-ghost:hover { background: #eef1fd; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-lg { padding: 13px 24px; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; }
.btn.is-recording { background: var(--c-err); border-color: var(--c-err); }
.form { display: grid; gap: 14px; }
.form.wide { max-width: 760px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--c-line); border-radius: 10px; font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.auth-box { max-width: 420px; margin: 24px auto; background: var(--c-card); padding: 28px; border-radius: var(--r); box-shadow: var(--shadow); }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; background: #eef1fd; border: 1px solid #cfd7f7; }
.flash-error { background: #fdecea; border-color: #f5c6c0; color: #8a1f14; }
.flash-success { background: #e8f6ee; border-color: #bfe5cd; color: #145a39; }

/* home */
.hero { position: relative; overflow: hidden; background: linear-gradient(135deg, #3555d9, #5b7cff); color: #fff; border-radius: 18px; padding: clamp(28px, 6vw, 64px); margin-bottom: 28px; }
.hero h1 { color: #fff; font-size: clamp(1.8rem, 5vw, 2.8rem); max-width: 18ch; }
.hero .lead { color: #e6ebff; max-width: 52ch; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.hero .btn { background: #fff; color: var(--c-primary); border-color: #fff; }
.hero .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .7); }
.hangul-deco { position: absolute; right: 18px; bottom: -14px; font-size: clamp(3rem, 12vw, 7rem); font-weight: 800; color: rgba(255, 255, 255, .13); letter-spacing: .1em; pointer-events: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.feature { background: var(--c-card); padding: 18px; border-radius: var(--r); box-shadow: var(--shadow); }
.feature p { margin: 0; color: var(--c-muted); }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--c-card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.card h3 a { color: var(--c-text); }
.card p { margin: 0; }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.price { color: var(--c-accent); }
.price-big { font-size: 1.9rem; font-weight: 800; color: var(--c-accent); }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #eef1fd; color: var(--c-primary); align-self: flex-start; }
.badge-ok { background: #e3f5ea; color: var(--c-ok); }
.badge-mute { background: #eef0f4; color: var(--c-muted); }
progress { width: 100%; height: 8px; accent-color: var(--c-primary); }

/* course & lesson */
.course-head { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .course-head { grid-template-columns: 1fr 300px; align-items: start; } }
.buybox { background: var(--c-card); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 8px; position: sticky; top: 76px; }
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: l; }
.lesson-list li { counter-increment: l; background: var(--c-card); border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.lesson-list li::before { content: counter(l); font-weight: 800; color: var(--c-primary); margin-right: 10px; }
.lesson-list li > a, .lesson-list li > span:first-of-type { flex: 1; }
.lesson-list .is-locked { opacity: .7; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r); overflow: hidden; margin: 12px 0 18px; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 18px 0; }
.panel { background: var(--c-card); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin: 20px 0; }
.panel h2 { margin-top: 0; }
.q { border: 1px solid var(--c-line); border-radius: 10px; padding: 12px 14px; margin: 0; }
.q legend { font-weight: 700; padding: 0 6px; }
.opt { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; padding: 4px 0; font-size: 1.05rem; }
.opt input { width: auto; }
.score { font-size: 1.15rem; font-weight: 800; color: var(--c-primary); }
.quiz-result { padding-left: 20px; display: grid; gap: 8px; }
.is-right > span:first-of-type { color: var(--c-ok); }
.is-wrong > span:first-of-type { color: var(--c-err); }
.sub { border-top: 1px solid var(--c-line); padding: 12px 0; display: grid; gap: 6px; }
.sub-head { display: flex; justify-content: space-between; gap: 8px; }
.feedback { background: #f1f7ff; border-left: 4px solid var(--c-primary); padding: 8px 12px; border-radius: 6px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.plain { list-style: none; padding: 0; display: grid; gap: 8px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--c-muted); }
.dl dd { margin: 0; }
.bank { font-weight: 600; background: var(--c-bg); padding: 12px 14px; border-radius: 8px; }

/* pronunciation */
#pron-app { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 16px; }
.pron-card { background: var(--c-card); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 4px; }
.pron-ko { font-size: 2rem; font-weight: 800; }
.pron-rom { color: var(--c-primary); font-weight: 600; }
.pron-mean { font-size: 1.05rem; }
.pron-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.pron-result:not(:empty) { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--c-bg); }
.pron-score { font-size: 1.4rem; font-weight: 800; }
.is-great .pron-score { color: var(--c-ok); }
.is-good .pron-score { color: var(--c-primary); }
.is-keep .pron-score { color: var(--c-accent); }
.is-error { color: var(--c-err); }

/* admin */
.admin-nav { display: flex; gap: 14px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--c-line); flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; background: var(--c-card); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); font-size: .92rem; display: block; overflow-x: auto; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-line); vertical-align: top; }
.table th { background: #f0f2f8; white-space: nowrap; }
.mlf { border: 1px solid var(--c-line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; margin: 0; }
.mlf legend { font-weight: 700; padding: 0 6px; }
.mlf label { grid-template-columns: 34px 1fr; align-items: start; font-weight: 400 !important; }
.mlf-l { font-size: .75rem; font-weight: 800; color: var(--c-muted); padding-top: 10px; }
.opts { margin: 4px 0; }
.opts .is-answer { font-weight: 800; color: var(--c-ok); }
.stats .card { align-items: flex-start; }

/* 보호 HLS 플레이어 */
.hls-player { position: relative; background: #000; overflow: hidden; border-radius: 8px; }
.hls-player video { display: block; width: 100%; max-height: 80vh; background: #000; }
.hls-player .wm { position: absolute; top: 10%; left: 5%; padding: 2px 8px; color: rgba(255,255,255,.45); background: rgba(0,0,0,.15);
  font-size: 13px; pointer-events: none; user-select: none; white-space: nowrap; transition: top 1.2s, left 1.2s; z-index: 2; }
.hls-player .fs-btn { position: absolute; top: 8px; right: 8px; z-index: 3; border: 0; border-radius: 4px; padding: 4px 8px;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 16px; }
.hls-player.is-error::after { content: "Video unavailable"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0,0,0,.7); }
.hls-player:fullscreen { border-radius: 0; }
.hls-player:fullscreen video { max-height: 100vh; height: 100vh; }
.video-locked { padding: 40px 16px; text-align: center; background: #f1f3f5; border-radius: 8px; }
.vstatus-ready { color: #1a7f37; }
.vstatus-failed { color: #c62828; }
.vu-msg.is-err { color: #c62828; }
.vu-error { white-space: pre-wrap; background: #fff4f4; padding: 8px; font-size: 12px; max-height: 160px; overflow: auto; }
#video-upload progress { width: 100%; max-width: 420px; }

@media (max-width: 640px) {
  .nav { order: 3; width: 100%; }
  .bar-right { margin-left: auto; }
  .dl { grid-template-columns: 1fr; }
}
