/* =========================================================================
 * styles.css — 햄스터로봇S 사용법 · 스크래치 기초 과정
 * ========================================================================= */
:root {
  --navy: #1c2541; --navy2: #2b3a67; --ink: #1f2933; --muted: #66707a;
  --line: #e3e8ef; --bg: #f5f7fb; --card: #fff;
  --scratch: #f59f00; --robot: #37b24d; --blue: #4c97ff; --purple: #9966ff;
  --radius: 16px; --shadow: 0 6px 22px rgba(28,37,65,.08); --shadow-lg: 0 14px 40px rgba(28,37,65,.16);
  --topbar-h: 58px; /* 실제 값은 app.js의 ResizeObserver가 갱신 (모바일에서 헤더가 여러 줄로 접힘) */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Pretendard","Apple SD Gothic Neo","Segoe UI","Malgun Gothic",system-ui,sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1,h2,h3 { line-height: 1.25; margin: 0; }
code { font-family: "Consolas","D2Coding",monospace; }

/* 상단바 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px clamp(16px,4vw,40px); background: rgba(28,37,65,.96); backdrop-filter: blur(8px); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 16px; }
.brand-text small { font-size: 11px; opacity: .7; }
.topnav { display: flex; gap: 6px; flex-wrap: wrap; }
.topnav a { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: #d7def0; transition: .15s; }
.topnav a:hover { background: rgba(255,255,255,.12); color: #fff; }

.app { max-width: 940px; margin: 0 auto; padding: clamp(20px,4vw,38px) clamp(16px,4vw,24px) 56px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.crumbs a:hover { color: var(--navy); text-decoration: underline; }
.page-title { font-size: clamp(24px,4vw,32px); margin-bottom: 8px; }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* 버튼 */
.btn { display: inline-block; padding: 12px 22px; border-radius: 12px; font-weight: 700; font-size: 15px; transition: .15s; }
.btn-primary { background: var(--robot); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.26); }
.hero-class { align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.15); }
.hero-class-label { color: rgba(255,255,255,.7); font-size: 13px; font-weight: 700; margin-right: 2px; }
.btn-role { padding: 9px 16px; font-size: 14px; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.28); }
.btn-role:hover { background: rgba(255,255,255,.2); transform: translateY(-1px); }

/* 히어로 */
.hero { display: flex; align-items: center; gap: 24px; border-radius: 24px; padding: clamp(26px,5vw,48px);
  background: radial-gradient(120% 140% at 0 0, #2b3a67 0%, #1c2541 60%, #161c30 100%); color: #fff;
  box-shadow: var(--shadow-lg); margin-bottom: 26px; }
.hero-copy { flex: 1; }
.hero-eyebrow { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; opacity: .7; margin: 0 0 10px; }
.hero-title { font-size: clamp(26px,5vw,40px); font-weight: 800; margin: 0 0 14px; }
.hero-desc { color: #cdd6ee; max-width: 540px; margin: 0 0 22px; }
.hero-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-art { width: clamp(110px,18vw,170px); height: auto; border-radius: 24px; flex: none; }

/* 홈 카드 */
.home-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 16px; }
.home-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; border-top: 4px solid var(--robot); transition: .12s; }
.home-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.home-card-icon { font-size: 34px; }
.home-card strong { font-size: 18px; }
.home-card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.home-card-go { font-weight: 700; color: var(--robot); font-size: 14px; }
.home-progress { margin-top: 22px; background: var(--card); border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; }
.home-progress em { font-style: normal; font-size: 13px; color: var(--muted); font-weight: 600; }

.bar { flex: 1; height: 10px; background: #eef1f6; border-radius: 999px; overflow: hidden; min-width: 120px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg,var(--scratch),var(--robot)); border-radius: 999px; transition: width .4s; }

/* 패널(사용법) */
.panel { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h2 { font-size: 19px; margin-bottom: 14px; }
.panel-intro { color: var(--muted); margin: 0 0 16px; }
.spec-row { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; }
.spec-item { background: #f3f6fd; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.spec-item strong { color: var(--navy2); font-size: 13px; }
.spec-item span { font-size: 14px; }
.part-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 12px; }
.part-card { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.part-icon { font-size: 28px; line-height: 1.1; }
.part-card strong { display: block; }
.part-card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* 단계 리스트 */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.step-no { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--robot); color: #fff; font-weight: 800; display: grid; place-items: center; }
.steps strong { display: block; }
.steps p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.tipbox { background: #e7f5ff; border-radius: 12px; padding: 14px 16px; margin-top: 16px; font-size: 14px; color: #1864ab; }
.tipbox strong { margin-right: 4px; }
.tipbox ul { margin: 8px 0 0; padding-left: 18px; }
.page-next { text-align: center; margin-top: 24px; }

/* 블록사전 */
.blk-group { margin: 22px 0; }
.blk-title { font-size: 18px; margin-bottom: 12px; border-left: 5px solid var(--c); padding-left: 10px; }
.blk-table { display: grid; gap: 8px; }
.blk-row { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(110px,.9fr) 1.5fr; gap: 14px; align-items: center;
  background: var(--card); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--c); }
.blk-name { display: flex; align-items: center; }
.blk-val { font-size: 13px; font-weight: 700; color: color-mix(in srgb, var(--c) 65%, #1c2541); }

.blk-desc { font-size: 13.5px; color: var(--muted); }

/* 기초 과정 목록 */
.course-head { margin-bottom: 18px; }
.course-progress { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.course-progress em { font-style: normal; font-size: 13px; color: var(--muted); }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lesson-item a { display: flex; align-items: center; gap: 16px; background: var(--card); padding: 16px 18px; border-radius: 14px;
  box-shadow: var(--shadow); border: 1px solid transparent; transition: .12s; }
.lesson-item a:hover { transform: translateY(-1px); border-color: var(--robot); }
.lesson-no { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #eef1f6; color: var(--navy2); font-weight: 800; display: grid; place-items: center; }
.is-done .lesson-no { background: var(--robot); color: #fff; }
.lesson-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lesson-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lesson-goal { font-size: 13.5px; color: var(--muted); }
.lesson-dur { font-size: 12.5px; color: var(--muted); flex: none; }
.lv { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #fff4e6; color: #e8590c; }

/* 강의 상세 */
.lesson { background: var(--card); border-radius: var(--radius); padding: clamp(22px,4vw,34px); box-shadow: var(--shadow); border-top: 5px solid var(--robot); }
.lesson-head h1 { font-size: clamp(22px,4vw,28px); }
.lesson-meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.goalbox { background: #eef9f1; border-left: 4px solid var(--robot); padding: 14px 16px; border-radius: 10px; margin: 18px 0 26px; }
.goalbox strong { color: var(--robot); margin-right: 6px; }
.lsec { margin: 24px 0; }
.lsec h2 { font-size: 17px; margin-bottom: 12px; }
.dot-list, .check-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.dot-list li, .check-list li { padding-left: 26px; position: relative; }
.dot-list li::before { content: "🎯"; position: absolute; left: 0; }
.check-list li::before { content: "☑"; position: absolute; left: 2px; color: var(--robot); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.block-chips { gap: 12px 10px; align-items: center; }
.blk-img { display: block; max-width: 100%; height: auto; }
.lsec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.lsec .lsec-head h2 { margin: 0; }
.btn-insert { background: #ffab19; color: #fff; padding: 7px 14px; font-size: 13.5px; border: 0; cursor: pointer; }
.btn-insert:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-insert:disabled { opacity: .85; cursor: default; transform: none; }
.code-shot { background: #f9f9f9; border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto; }
.code-shot .blk-img { max-width: none; }
.code-text { margin-top: 10px; }
.code-text summary { cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--navy2); padding: 6px 0; }
.chip { background: var(--c); color: #fff; font-weight: 700; font-size: 13px; padding: 7px 12px; border-radius: 9px; }
.mission { background: #fff9db; border: 1px dashed #f2c94c; border-radius: 12px; padding: 16px 18px; }
.mission h2 { margin-bottom: 6px; }
.mission p { margin: 0; }
.complete { text-align: center; margin: 28px 0 8px; }
.complete button { border: none; cursor: pointer; font-size: 15px; font-weight: 700; padding: 13px 26px; border-radius: 12px; background: var(--robot); color: #fff; transition: .15s; }
.complete button:hover { filter: brightness(1.05); transform: translateY(-1px); }
.complete button.is-done { background: #fff; color: var(--robot); border: 2px solid var(--robot); }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }
.ln { padding: 12px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: 14px; max-width: 48%; }
.ln:hover:not(.dis) { border-color: var(--robot); color: var(--robot); }
.ln.dis { color: var(--muted); opacity: .6; }
.ln.next { margin-left: auto; text-align: right; }

/* 푸터 */
.footer { text-align: center; padding: 26px 20px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.footer-sub { font-size: 11.5px; opacity: .85; margin-top: 6px; }
.footer-sub a { color: var(--robot); }

@media (max-width: 600px) {
  .hero { flex-direction: column-reverse; text-align: center; }
  .hero-desc { margin-inline: auto; }
  .hero-btns { justify-content: center; }
  .blk-row { grid-template-columns: 1fr; gap: 6px; }
  .blk-val::before { content: "값: "; color: var(--muted); font-weight: 400; }
  .lesson-nav { flex-direction: column; }
  .ln, .ln.next { max-width: 100%; text-align: center; }
}

/* =========================================================================
 * 🧱 실습 플레이그라운드 & 스플릿 뷰(Split View) 추가 스타일
 * ========================================================================= */

/* 실습하기 내비게이션 특별 하이라이트 */
.topnav .nav-playground {
  background: linear-gradient(135deg, var(--scratch) 0%, var(--robot) 100%);
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(245, 159, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: pulse-border 2s infinite alternate;
}
.topnav .nav-playground:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 159, 0, 0.35);
}

@keyframes pulse-border {
  0% { box-shadow: 0 4px 12px rgba(245, 159, 0, 0.2); }
  100% { box-shadow: 0 4px 16px rgba(55, 178, 77, 0.4); }
}

/* 전체 화면 플레이그라운드 레이아웃 */
body.playground-active {
  overflow: hidden !important; /* 메인 윈도우 스크롤 방지 */
  height: 100vh;
  height: 100dvh; /* 모바일 주소창을 제외한 실제 표시 영역 */
}
.full-viewport {
  max-width: 100% !important;
  width: 100% !important;
  height: calc(100vh - var(--topbar-h)); /* 헤더를 제외한 창 전체를 가득 채움 */
  height: calc(100dvh - var(--topbar-h));
  margin: 0 !important;
  padding: 0 !important;
}
.playground-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #fff;
}
.playground-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy2) 100%);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}
.playground-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.playground-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
}
.playground-status-info {
  font-size: 12px;
  color: #cdd6ee;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.playground-frame {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: #fff;
}

/* 스플릿 뷰(Split View) 레이아웃 */
.app:has(.split-layout) {
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  height: calc(100vh - var(--topbar-h)); /* 헤더 높이를 제외한 화면 가득 채움 */
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

.split-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.lesson-pane {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: clamp(20px, 4vw, 38px) clamp(16px, 4vw, 24px) 56px;
  background: var(--bg);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.lesson-pane-inner {
  max-width: 940px;
  margin: 0 auto;
}

.sidebar-pane {
  width: 0;
  height: 100%;
  border-left: 0px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 5;
}

/* 스플릿 뷰 활성화 상태 (기본 50:50, --split 변수로 드래그 조절) */
.split-layout.split-active .lesson-pane {
  flex: 0 0 calc(var(--split, 50%) - 4px);
}
.split-layout.split-active .sidebar-pane {
  flex: 1;
  width: auto;
  border-left: 2px solid var(--line);
  box-shadow: -8px 0 24px rgba(28, 37, 65, 0.08);
}

/* 드래그 크기 조절 핸들 */
.split-resizer {
  display: none;
  flex: 0 0 8px;
  cursor: col-resize;
  background: var(--line);
  position: relative;
  touch-action: none;
  transition: background 0.15s;
  z-index: 6;
}
.split-resizer::after {
  content: "⋮";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}
.split-resizer:hover, .split-resizer:active {
  background: var(--robot);
}
.split-resizer:hover::after, .split-resizer:active::after {
  color: #fff;
}
.split-layout.split-active .split-resizer {
  display: block;
}

/* 드래그 중에는 부드러운 전환 애니메이션 비활성화 */
.split-layout.no-anim .lesson-pane,
.split-layout.no-anim .sidebar-pane {
  transition: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}
.sidebar-title {
  font-weight: 700;
  font-size: 13.5px;
  color: #fff;
}
.sidebar-frame {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
  background: #fff;
}

/* 전역 실습창(iframe) — body에 고정 배치되어 페이지 이동에도 살아있음(로봇 연결 유지) */
.pg-global {
  position: fixed;
  left: 0;
  top: 0;
  border: none;
  background: #fff;
  z-index: 15;
}
.pg-global.pg-hidden {
  visibility: hidden;
  pointer-events: none;
}

/* 실습창이 겹쳐질 슬롯 영역 */
.pg-slot {
  flex: 1;
  min-height: 0;
  background: #f0f2f8;
}
.pg-full-slot {
  height: 100%;
}

/* 스플릿 내 크럼브 및 토글 버튼 */
.split-crumbs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  background: var(--card);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.crumbs-left {
  font-size: 13px;
  color: var(--muted);
}
.crumbs-left a {
  font-weight: 600;
  color: var(--navy2);
}
.crumbs-left a:hover {
  color: var(--scratch);
}

.btn-toggle-split {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(55, 178, 77, 0.15);
  font-weight: 700;
}
.btn-toggle-split.btn-ghost {
  background: #fff;
  color: var(--robot);
  border: 1px solid var(--robot);
  box-shadow: none;
}
.btn-toggle-split.btn-ghost:hover {
  background: rgba(55, 178, 77, 0.05);
}

/* 추가 소형 버튼 스타일 및 헤더 리페어 */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

@media (max-width: 950px) {
  /* 태블릿 및 모바일에서는 50:50 스플릿 대신 세로 정렬 */
  .split-layout.split-active {
    flex-direction: column;
  }
  .split-layout.split-active .split-resizer {
    display: none; /* 모바일 세로 배치에서는 드래그 조절 비활성화 */
  }
  .split-layout.split-active .lesson-pane {
    flex: 0 0 45%;
  }
  .split-layout.split-active .sidebar-pane {
    width: 100%;
    height: 55%;
    border-left: none;
    border-top: 2px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 37, 65, 0.08);
  }
  .split-crumbs {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .btn-toggle-split {
    width: 100%;
    text-align: center;
  }
}

/* 교구 선택 스위치 (Robot Selector) */
.robot-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  padding: 3px;
  margin: 0 10px;
}
.selector-btn {
  background: none;
  border: none;
  color: #cdd6ee;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.selector-btn:hover {
  color: #fff;
}
.selector-btn.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 언어 스위치 (교구 스위치와 동일 톤, 약간 컴팩트) */
.lang-selector {
  margin: 0 4px;
}
.lang-selector .selector-btn {
  padding: 6px 10px;
  font-size: 12px;
}

/* 라쿤 로봇 히어로 이미지 최적화 */
.hero-art.hero-racoon {
  background: white;
  padding: 8px;
  object-fit: contain;
}

/* 예제 코드 프리뷰어 스타일링 */
.code-preview-section {
  margin: 24px 0;
}
.code-preview-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.code-preview-block {
  background: #1f2937;
  color: #f3f4f6;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: auto;
  border-left: 6px solid var(--scratch);
  box-shadow: var(--shadow);
  margin: 0;
}
.code-preview-block code {
  font-family: "Consolas", "D2Coding", monospace;
  white-space: pre-wrap;
}

/* 예제 파일(.sb3) 다운로드 링크 */
.file-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f3f6fd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy2);
  transition: .15s;
}
.file-link:hover {
  background: var(--navy2);
  color: #fff;
  border-color: var(--navy2);
  transform: translateY(-1px);
}

/* 기초 과정 하단 예제 자료실 패널 */
.example-archive {
  margin-top: 26px;
}
.example-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  margin-top: 10px;
  background: #fafbfe;
}
.example-group summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  padding: 12px 0;
  color: var(--navy2);
  list-style-position: inside;
}
.example-group summary:hover {
  color: var(--scratch);
}
.example-group .file-list {
  padding: 4px 0 14px;
}
.example-count {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
}

/* =========================================================================
 * 📱 모바일 최적화 — 상단바 재배치 · 실습창 헤더 컴팩트화
 * ========================================================================= */

/* 태블릿 이하: 상단바를 두 줄로 접고, 메뉴는 가로 스크롤 한 줄로 */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .brand { margin-right: auto; }
  .robot-selector { margin: 0; }
  .topnav {
    order: 5; width: 100%;
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -ms-overflow-style: none;
    padding-bottom: 2px;
  }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { flex: none; white-space: nowrap; padding: 8px 13px; }
}

/* 스마트폰: 브랜드·스위치를 더 컴팩트하게 */
@media (max-width: 480px) {
  .brand-logo { width: 32px; height: 32px; }
  .brand-text strong { font-size: 15px; }
  .brand-text small { display: none; }
  .selector-btn { padding: 5px 10px; font-size: 12px; }
  .lang-selector .selector-btn { padding: 5px 8px; font-size: 11.5px; }
  .panel { padding: 18px 16px; }
  .home-progress { padding: 14px 16px; }
  .lesson-item a { padding: 14px 14px; gap: 12px; }
  .lesson-dur { display: none; }
}

/* 초소형 화면: 로고만 남기고 텍스트 숨김 */
@media (max-width: 380px) {
  .brand-text { display: none; }
}

/* 실습창 상단 헤더 — 좁은 화면에서는 안내 문구를 숨겨 한 줄 유지 */
@media (max-width: 600px) {
  .playground-header { padding: 8px 12px; gap: 8px; }
  .playground-status-info { display: none; }
  .playground-title { font-size: 13.5px; }
  .sidebar-header { padding: 8px 12px; }
}

/* =========================================================================
 * 💻 크롬북 등 낮은 화면(1366×768 → 실제 표시 약 657px) — 실습창 세로 공간 확보
 * ========================================================================= */

/* 강의 스플릿 화면은 자체 스크롤이 있으므로 푸터를 숨겨 페이지 전체가 밀리지 않게 */
body:has(.split-layout) .footer { display: none; }

@media (max-height: 760px) {
  .topbar { padding-top: 6px; padding-bottom: 6px; }
  .brand-logo { width: 32px; height: 32px; }
  .topnav a { padding: 6px 12px; }
  .playground-header { padding: 6px 16px; }
  .playground-status-info { display: none; }
  .sidebar-header { padding: 6px 12px; }
  .lesson-pane { padding-top: 16px; }
  .split-crumbs { margin-bottom: 14px; padding: 8px 14px; }
}

/* 스크래치 화면이 보일 때 챗봇 버튼을 우리 헤더 줄로 옮겨 스크래치 버튼(배경 고르기 등)을 가리지 않게 */
body.playground-active .hchat-fab,
body:has(.split-layout.split-active) .hchat-fab {
  top: calc(var(--topbar-h) + 4px); bottom: auto; right: 150px;
  width: 36px; height: 36px; font-size: 1.1rem;
}
body:has(.split-layout.split-active) .hchat-fab { right: 96px; }
body.playground-active .hchat-win,
body:has(.split-layout.split-active) .hchat-win {
  top: calc(var(--topbar-h) + 48px); bottom: auto;
}

/* =========================================================================
 * 👥 우리 반 — 입장 · 학생 나의 기록 · 교사 총괄 대시보드 (js/class.js)
 * ========================================================================= */
.app.app-wide { max-width: 1180px; }
.class-badge { flex: none; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(55,178,77,.18); color: #b2f2bb; border: 1px solid rgba(55,178,77,.45); white-space: nowrap; }
.class-badge:hover { background: rgba(55,178,77,.3); color: #fff; }

.class-entry { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.class-entry.single { max-width: 480px; }
.entry-switch { margin-top: 16px; font-size: 14px; }
.entry-switch a { color: var(--robot); font-weight: 700; }
.class-panel h2 { margin-bottom: 16px; }
.class-form { display: grid; gap: 12px; }
.class-form label, .create-row label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--navy2); }
.class-form label[hidden] { display: none; }
.class-form input, .create-row input, .note-box textarea {
  font: inherit; font-size: 15px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
.class-form input:focus, .create-row input:focus, .note-box textarea:focus { outline: none; border-color: var(--robot); box-shadow: 0 0 0 3px rgba(55,178,77,.15); }
.code-input { font-family: "Consolas","D2Coding",monospace; font-size: 26px !important; letter-spacing: 6px; text-transform: uppercase; text-align: center; }
.pin-input { font-size: 24px !important; letter-spacing: 10px; text-align: center; max-width: 220px; }
.form-err { color: #e03131; font-size: 13.5px; margin: 0; min-height: 1em; }
.class-form .btn, .create-row .btn { border: none; cursor: pointer; font-family: inherit; }
.btn:disabled, .btn.is-busy { opacity: .6; cursor: wait; }
.link-btn { background: none; border: none; color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; justify-self: start; padding: 4px 0; }
.link-btn:hover { color: var(--navy); text-decoration: underline; }
.btn-outline { background: #fff; color: var(--navy2); border: 1px solid var(--line); cursor: pointer; font-family: inherit; }
.btn-outline:hover { border-color: var(--navy2); }
.btn.danger { background: #e03131; color: #fff; border-color: #e03131; }
.class-hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.class-hint.small { font-size: 12.5px; margin: 8px 0; }
.class-name-line { margin: 0 0 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.class-name-line code, .code-pill { font-family: "Consolas","D2Coding",monospace; background: #eef1f6; color: var(--navy); padding: 2px 10px; border-radius: 8px; font-weight: 800; letter-spacing: 2px; }
.code-pill.big { font-size: .7em; vertical-align: middle; }
.no-chip { background: var(--robot); color: #fff; font-weight: 800; border-radius: 999px; padding: 2px 12px; }

.seg { display: inline-flex; background: #eef1f6; border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg-btn { border: none; background: none; font: inherit; font-size: 14px; font-weight: 700; color: var(--muted); padding: 6px 16px; border-radius: 8px; cursor: pointer; }
.seg-btn.active { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.no-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.no-btn { position: relative; height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; font: inherit; font-size: 18px; font-weight: 800; color: var(--navy2); cursor: pointer; transition: .12s; }
.no-btn:hover { border-color: var(--robot); color: var(--robot); transform: translateY(-1px); }
.no-btn.is-joined::after { content: "✓"; position: absolute; top: 2px; right: 6px; font-size: 11px; color: var(--robot); }

.class-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.class-head .crumbs { margin-bottom: 6px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 14px; padding: 14px 18px; box-shadow: var(--shadow); display: grid; gap: 6px; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 24px; color: var(--navy); }
.stars { color: #f59f00; letter-spacing: 1px; }
.me-list .lesson-goal { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.note-box { background: #f3f9ff; border: 1px solid #d0ebff; border-radius: 12px; padding: 16px 18px; }
.note-desc { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
.star-pick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.star-btn { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 18px; color: #ced4da; }
.star-btn small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.star-btn.on { color: #f59f00; border-color: #ffd43b; background: #fff9db; }
.note-box textarea { resize: vertical; }
.note-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 10px; }
.note-actions .btn { border: none; cursor: pointer; font-family: inherit; }
.note-status { font-size: 13px; color: var(--robot); font-weight: 600; }
.note-guest { margin-top: 18px; padding: 12px 16px; border-radius: 12px; background: #f8f9fa; color: var(--muted); font-size: 13.5px; }
.note-guest a { color: var(--robot); font-weight: 700; margin-left: 4px; }

.class-create h2 { margin-bottom: 12px; }
.create-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.create-row label { flex: 1 1 220px; }
.create-row label.size { flex: 0 0 140px; }
.class-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.class-card { background: var(--card); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); display: grid; gap: 8px; border-top: 4px solid var(--blue); transition: .12s; }
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.class-card strong { font-size: 18px; }
.class-card .code-pill { justify-self: start; font-size: 18px; }
.class-card span { font-size: 13px; color: var(--muted); }
.class-card em { font-style: normal; font-weight: 700; color: var(--blue); font-size: 14px; }

.per-lesson { display: grid; gap: 8px; }
.pl-row { display: grid; grid-template-columns: 26px minmax(120px, 1.2fr) 2fr 52px; gap: 10px; align-items: center; font-size: 13.5px; }
.pl-no { width: 24px; height: 24px; border-radius: 50%; background: #eef1f6; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: var(--navy2); }
.pl-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-row em { font-style: normal; color: var(--muted); text-align: right; font-size: 12.5px; }

.mx-scroll { overflow-x: auto; }
.mx { border-collapse: separate; border-spacing: 3px; font-size: 13px; }
.mx th { font-weight: 700; color: var(--muted); padding: 4px 6px; text-align: center; }
.mx tbody th { color: var(--navy2); background: #eef1f6; border-radius: 8px; min-width: 34px; }
.mx-row { cursor: pointer; }
.mx-row:hover th { background: #dbe4ff; }
.mx-cell { width: 34px; height: 30px; text-align: center; border-radius: 7px; background: #f1f3f5; font-weight: 800; color: #fff; }
.mx-cell.done { background: var(--robot); }
.mx-cell.noted:not(.done) { color: #f59f00; font-size: 20px; line-height: 1; }
.mx-cell.done.noted { box-shadow: inset 0 0 0 2px #ffd43b; }
.mx-pct { font-weight: 800; color: var(--navy); text-align: right; padding: 0 8px; white-space: nowrap; }
.mx-last { color: var(--muted); white-space: nowrap; font-size: 12px; }
.mx-off { color: #adb5bd; font-size: 12.5px; padding-left: 10px; }
.mx-row.is-off th { opacity: .5; }
.detail-box { background: #f8f9fc; border-radius: 10px; padding: 12px 16px; display: grid; gap: 10px; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.note-list small { color: var(--muted); margin-left: 6px; }
.class-settings summary { cursor: pointer; font-weight: 700; color: var(--navy2); }
.class-settings form { margin: 14px 0; }

.class-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 10001; background: var(--navy); color: #fff;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); }
.code-overlay { position: fixed; inset: 0; z-index: 10002; background: rgba(22,28,48,.96); color: #fff; display: grid; place-content: center; text-align: center; gap: 10px; cursor: pointer; padding: 20px; }
.ov-name { font-size: clamp(20px, 3vw, 32px); margin: 0; opacity: .85; }
.ov-code { font-family: "Consolas","D2Coding",monospace; font-size: clamp(64px, 14vw, 200px); font-weight: 800; letter-spacing: .12em; margin: 0; color: #b2f2bb; }
.ov-how { font-size: clamp(14px, 2vw, 22px); margin: 0 0 16px; opacity: .8; }
.code-overlay .btn { justify-self: center; border: none; cursor: pointer; }

@media (max-width: 600px) {
  .pl-row { grid-template-columns: 24px 1fr 52px; }
  .pl-row .bar { grid-column: 2 / 4; }
  .star-btn small { display: none; }
}


