/* 디미고 준비반 자료실 */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #16191f;
  --text-2: #5a616d;
  --text-3: #8a919e;
  --accent: #2f5de0;
  --accent-soft: #eaefff;
  --accent-text: #ffffff;
  --basic: #2f9e6d;
  --adv: #c2571f;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .06), 0 1px 3px rgba(16, 20, 30, .04);
  --shadow-md: 0 4px 12px rgba(16, 20, 30, .08), 0 1px 3px rgba(16, 20, 30, .05);
  --shadow-lg: 0 18px 40px rgba(16, 20, 30, .14);
  --radius: 10px;
  --sidebar-w: 280px;
  --font: "Pretendard", "Noto Sans KR", "Noto Sans CJK KR", -apple-system,
          BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101216;
    --surface: #181b21;
    --surface-2: #1f232b;
    --border: #2a2f39;
    --border-strong: #3a404c;
    --text: #e8eaee;
    --text-2: #a4abb8;
    --text-3: #757d8b;
    --accent: #6e93ff;
    --accent-soft: #1d2740;
    --accent-text: #0d1016;
    --basic: #4fbe8c;
    --adv: #e0854a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

a { color: var(--accent); }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-text);
  padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* ---------- 사이드바 ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
  transition: transform .22s ease;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 16px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 38px; height: 38px; flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7d4ce0);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: .02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15.5px; font-weight: 700; }
.brand-text small { font-size: 12px; color: var(--text-3); }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }

.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  background: none; border: 0; border-radius: 8px;
  text-align: left; cursor: pointer;
  color: var(--text);
  transition: background .12s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.nav-l1 { font-weight: 650; font-size: 14.5px; }
.nav-l1 > span:not(.badge) { flex: 1; }

.ico, .caret {
  width: 17px; height: 17px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico { color: var(--text-2); }
.caret { width: 15px; height: 15px; color: var(--text-3); transition: transform .18s; }
.nav-item[aria-expanded="true"] .caret { transform: rotate(90deg); }

.nav-sub { padding: 2px 0 4px 10px; margin-left: 8px; border-left: 1px solid var(--border); }
.nav-branch + .nav-branch { margin-top: 1px; }

.nav-l2 { font-size: 14px; font-weight: 550; }
.nav-l2 > span:not(.dot):not(.badge) { flex: 1; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-basic { background: var(--basic); }
.dot-adv { background: var(--adv); }

.badge {
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 7px;
  flex: none;
}

.nav-files {
  list-style: none;
  margin: 2px 0 6px;
  padding: 0 0 0 17px;
  border-left: 1px solid var(--border);
  margin-left: 13px;
}
.nav-files a {
  display: flex; align-items: baseline; gap: 7px;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-files a:hover { background: var(--surface-2); color: var(--text); }
.nav-files a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-files .wk {
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-3); flex: none; min-width: 30px;
}
.nav-files a.active .wk { color: var(--accent); }
.nav-files .ttl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 13px 18px;
}
.sidebar-foot p { margin: 0; font-size: 11.5px; color: var(--text-3); line-height: 1.55; }

/* ---------- 모바일 토글 ---------- */

.nav-toggle {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  z-index: 60;
  width: 42px; height: 42px;
  display: none;
  flex-direction: column; justify-content: center; align-items: center; gap: 4.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.nav-toggle span {
  width: 17px; height: 2px; border-radius: 2px;
  background: var(--text);
  transition: transform .2s, opacity .2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(10, 12, 16, .45);
  backdrop-filter: blur(2px);
}

/* ---------- 본문 ---------- */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.view { padding: 30px 32px 64px; max-width: 1180px; }

.loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-2); padding: 40px 0;
}
.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.crumbs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-3);
  margin-bottom: 14px;
}
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--border-strong); }

.page-head { margin-bottom: 26px; }
.page-head h1 {
  margin: 0 0 7px;
  font-size: 26px; font-weight: 750; letter-spacing: -.02em;
  line-height: 1.3;
}
.page-head p { margin: 0; color: var(--text-2); font-size: 14.5px; }

/* 랜딩 */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 26px;
}
.hero h1 {
  margin: 0 0 10px;
  font-size: 30px; font-weight: 780; letter-spacing: -.028em;
  line-height: 1.25;
}
.hero p { margin: 0; color: var(--text-2); font-size: 15px; max-width: 54ch; }
.hero .stats { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 22px; }
.hero .stat strong {
  display: block; font-size: 23px; font-weight: 750;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.hero .stat span { font-size: 12.5px; color: var(--text-3); }

.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
  margin: 0 0 13px;
}

.course-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.course-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.course-card .tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  padding: 3px 9px; border-radius: 20px;
  margin-bottom: 11px;
}
.tag-basic { background: color-mix(in srgb, var(--basic) 14%, transparent); color: var(--basic); }
.tag-adv { background: color-mix(in srgb, var(--adv) 14%, transparent); color: var(--adv); }
.course-card h3 { margin: 0 0 6px; font-size: 18px; font-weight: 700; letter-spacing: -.015em; }
.course-card p { margin: 0 0 14px; font-size: 13.5px; color: var(--text-2); }
.course-card .meta { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 강의 목록 */

.lesson-grid {
  display: grid; gap: 13px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.lesson-card {
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.lesson-thumb {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}
.lesson-thumb img { width: 100%; height: 100%; object-fit: cover; }
.lesson-thumb .count {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(8, 10, 14, .76); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 5px;
  font-variant-numeric: tabular-nums;
}
.lesson-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 5px; }
.lesson-wk {
  font-size: 11px; font-weight: 750; letter-spacing: .05em;
  color: var(--accent);
}
.lesson-title {
  font-size: 14.5px; font-weight: 650; line-height: 1.4;
  letter-spacing: -.01em;
}

/* 뷰어 */

.viewer-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.viewer-head h1 { margin: 0; font-size: 21px; font-weight: 720; letter-spacing: -.02em; line-height: 1.35; }
.viewer-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

.stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stage-img {
  position: relative;
  background: #0d0f13;
  display: grid; place-items: center;
  min-height: 220px;
}
.stage-img img {
  width: 100%; height: auto;
  max-height: calc(100vh - 290px);
  object-fit: contain;
}
.stage-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px;
  display: grid; place-items: center;
  background: rgba(12, 14, 20, .5);
  border: 0; color: #fff; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.stage-nav:hover:not(:disabled) { background: rgba(12, 14, 20, .78); }
.stage-nav:disabled { opacity: .22; cursor: default; }
.stage-nav.prev { left: 0; border-radius: 0 8px 8px 0; }
.stage-nav.next { right: 0; border-radius: 8px 0 0 8px; }
.stage-nav svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.stage-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.counter {
  font-size: 13px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-2); flex: none;
  min-width: 68px;
}
.progress {
  flex: 1; min-width: 100px; height: 4px;
  background: var(--surface-2); border-radius: 4px; overflow: hidden;
}
.progress i { display: block; height: 100%; background: var(--accent); transition: width .18s; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}

.thumbs {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 14px 2px 6px;
  scrollbar-width: thin;
}
.thumbs button {
  flex: none;
  width: 116px;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
  position: relative;
  transition: border-color .12s, transform .12s;
}
.thumbs button:hover { transform: translateY(-1px); }
.thumbs button.active { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .n {
  position: absolute; left: 3px; bottom: 3px;
  background: rgba(8, 10, 14, .76); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 0 4px; border-radius: 3px;
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 14px 0 0;
  font-size: 12px; color: var(--text-3);
}
kbd {
  display: inline-block;
  padding: 1px 5px; margin: 0 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 44px 24px;
  text-align: center;
  color: var(--text-2);
}

/* 전체화면 */

.stage:fullscreen { background: #0d0f13; display: flex; flex-direction: column; }
.stage:fullscreen .stage-img { flex: 1; }
.stage:fullscreen .stage-img img { max-height: none; height: 100%; }

/* ---------- 반응형 ---------- */

@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .view { padding: 68px 18px 56px; }
  .hero { padding: 26px 20px; }
  .hero h1 { font-size: 24px; }
  .page-head h1 { font-size: 22px; }
  .stage-img img { max-height: calc(100vh - 330px); }
}

@media (max-width: 480px) {
  .view { padding: 66px 16px 48px; }
  .lesson-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .lesson-body { padding: 10px 11px 12px; }
  .lesson-title { font-size: 13px; }
  .thumbs button { width: 92px; }
  .counter { min-width: 60px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}
