/* packages/ 에서 복사됨 (scripts/sync-packages.sh) — 여기서 고치지 말고 원본을 고칠 것: packages/ui/base.css */
/* packages/ui/base.css — 리셋·타이포·레이아웃 기본 (원래 각 앱의 static/style.css).
   색·글꼴 변수는 여기서 정하지 않는다: tokens.css(팔레트 A1) + components/v3.css 1부가 정한다.
   2026-10-17 SITES.md 2단계: 구버전 파란 토큰(--accent: #3b5bdb 계열)과 기기 다크 모드 블록을 지움.
   (v3.css 1부가 같은 변수를 모두 다시 정의하고 있어 화면은 그대로다. 파란 값은 다시 쓰지 않는다.) */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); }

/* ---------- 상단 바 ---------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.brand [data-brand] { color: inherit; }
.brand .brand-tag { color: var(--accent); }
.brand .brand-tag:empty { display: none; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }

/* ---------- 공통 요소 ---------- */
.container { max-width: 1040px; margin: 0 auto; padding: 32px 20px 64px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn kbd { font-family: var(--mono); font-size: 11px; opacity: .75; }

/* 입력칸(input·select·textarea) 규칙은 components/v3.css '입력' 한 곳에 있다 (2026-10-17 FE 보강 F1). 여기서 다시 정하지 않는다. */
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }

.muted { color: var(--muted); }
.error-text { color: var(--bad); font-size: 14px; min-height: 1.4em; }
.hidden { display: none !important; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- 로그인 ---------- */
.login-wrap { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; height: 40px; }

/* ---------- 문제 목록 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; }
.progress { font-size: 14px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.link { cursor: pointer; }
.table tbody tr.link:hover td { background: var(--surface-2); }
.table .num { width: 56px; color: var(--muted); }
.table .status { width: 120px; }
.tags { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 8px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- 문제 풀이 화면 ---------- */
.solve {
  height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: minmax(320px, 42%) 1fr;
}
.pane-left {
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 28px 48px;
}
.pane-left h1 { font-size: 21px; margin: 0 0 8px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.markdown h2 { font-size: 16px; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 15px; margin: 20px 0 6px; }
.markdown p, .markdown li { font-size: 15px; }
.markdown code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.markdown pre { background: var(--code-bg); padding: 12px 14px; border-radius: 8px; overflow: auto; border: 1px solid var(--border); }
.markdown pre code { background: none; padding: 0; }
.markdown table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 12px; }
.markdown th { background: var(--surface-2); }
.markdown img { max-width: 100%; }

.pane-right { display: grid; grid-template-rows: auto 1fr auto minmax(180px, 34%); min-height: 0; min-width: 0; }
.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.toolbar .spacer { flex: 1; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
#line-badge { white-space: nowrap; }
.editor-wrap { min-height: 0; position: relative; }
.editor-wrap .CodeMirror { position: absolute; inset: 0; height: auto; font-family: var(--mono); font-size: 14px; line-height: 1.55; }

.tabs { display: flex; gap: 2px; padding: 0 8px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font-family: inherit;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body { overflow: auto; padding: 14px 16px; background: var(--bg); min-height: 0; }

.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.result-head .big { font-size: 17px; font-weight: 700; }
.big.ok { color: var(--ok); }
.big.bad { color: var(--bad); }
.case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; margin-bottom: 14px; }
.case-chip { padding: 8px 10px; border-radius: 8px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); }
.case-chip.ok { border-color: var(--ok); }
.case-chip.bad { border-color: var(--bad); }
.case-chip .t { font-size: 11px; color: var(--muted); }
.case-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.case-detail h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: 72px 1fr; gap: 4px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
pre.out {
  margin: 0; padding: 8px 10px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto;
}
pre.out.err { color: var(--bad); }
.stdin-box { margin-bottom: 12px; }
.stdin-box textarea { min-height: 64px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 관리자 ---------- */
.admin-grid { display: grid; gap: 20px; }
.admin-grid > * { min-width: 0; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 16px; }
.section-title .spacer { flex: 1; }
.scroll-x { overflow-x: auto; }
.matrix td, .matrix th { white-space: nowrap; text-align: center; padding: 8px 10px; font-size: 13px; }
.matrix td:first-child, .matrix th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.matrix th:first-child { background: var(--surface-2); }
.cell { display: inline-block; min-width: 44px; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.cell.ok { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.cell.part { background: var(--warn-soft); color: var(--warn); }
.cell.none { color: var(--muted); cursor: default; }
.validate-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.validate-list li { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(900px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .solve { grid-template-columns: 1fr; height: auto; }
  .pane-left { border-right: 0; border-bottom: 1px solid var(--border); max-height: none; }
  .pane-right { grid-template-rows: auto 60vh auto auto; }
  .tab-body { max-height: 60vh; }
  .table .hide-sm { display: none; }
}
.topbar > * { white-space: nowrap; }
@media (max-width: 560px) {
  .topbar { gap: 10px; padding: 0 16px; }
  .topbar .who { display: none; }
}

/* ---------- 급수 ---------- */
.grade-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.grade-card { display: block; padding: 22px; color: var(--text); transition: border-color .15s, transform .15s; }
.grade-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.grade-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.grade-desc { font-size: 14px; min-height: 1.6em; margin-bottom: 16px; }
.grade-progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 6px; }
.grade-progress > div { height: 100%; background: var(--ok); }
.grade-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.grade-tabs.by-subject { flex-direction: column; flex-wrap: nowrap; gap: 10px; }
.grade-tab-row { display: flex; gap: 12px; align-items: flex-start; }
.grade-tab-row + .grade-tab-row { border-top: 1px solid var(--border); padding-top: 10px; }
.grade-tab-label { flex: none; width: 56px; padding-top: 8px; font-weight: 700; font-size: 14px; color: var(--muted); }
.grade-tab-btns { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; flex: 1; }
@media (max-width: 640px) { .grade-tab-row { flex-direction: column; gap: 4px; } .grade-tab-label { padding-top: 0; } }

/* '한 줄 수정' 문제에서 시작 코드와 달라진 줄 */
.cm-changed-line { background: var(--warn-soft); }
.toolbar { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 1280px) { .toolbar .btn kbd { display: none; } }
@media (max-width: 560px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar .badge { display: none; }
  .topbar .btn.sm { padding: 0 8px; }
}
.modal { min-width: 0; max-width: 100%; }
.section-title { flex-wrap: wrap; row-gap: 8px; }

/* ---------- 객관식 / 단답형 ---------- */
.solve.quiz-mode { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 56px); }
.solve.quiz-mode .pane-right { display: none; }
.solve.quiz-mode .pane-left { border-right: 0; overflow: visible; width: 100%; max-width: 860px; margin: 0 auto; padding-bottom: 64px; }
.quiz { margin-top: 24px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice-no { font-weight: 700; color: var(--accent); }
.choice-text code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.quiz-input { font-size: 16px; padding: 12px 14px; }
.quiz-actions { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.quiz-result { padding: 12px 14px; border-radius: 10px; font-weight: 700; margin-bottom: 12px; }
.quiz-result.ok { background: var(--ok-soft); color: var(--ok); }
.quiz-result.bad { background: var(--bad-soft); color: var(--bad); }
.quiz-sub { font-size: 15px; margin: 28px 0 10px; }

/* 관리자: 학생 등록 */
.register-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.register-grid > * { min-width: 0; }
.register-grid textarea { font-family: inherit; font-size: 14px; }
@media (max-width: 760px) { .register-grid { grid-template-columns: 1fr; } }

/* 로그인 화면: 로그인 / 가입하기 탭 */
.login-tabs { border-top: 0; padding: 0; }
.login-tabs .tab { flex: 1; height: 46px; font-size: 15px; }

/* ---------------------------------------------------------------- 개념 학습 (lesson.html) */
.grade-kinds { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.grade-kinds:empty { display: none; }

.lesson-banner {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; margin-bottom: 16px;
  color: var(--text); border-color: var(--accent); background: var(--accent-soft);
}
.lesson-banner:hover { text-decoration: none; }
.lesson-banner > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lesson-banner .muted { font-size: 13px; }
.lesson-banner-icon { font-size: 26px; }
.lesson-banner-go { color: var(--accent); font-weight: 600; font-size: 14px; white-space: nowrap; }

.lesson-layout { max-width: 1120px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.lesson-layout:has(.lesson-toc.hidden) { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
.lesson-toc { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; font-size: 13px; }
.lesson-toc-title { font-weight: 700; color: var(--muted); font-size: 12px; letter-spacing: .02em; margin: 6px 0 8px 10px; }
.lesson-toc nav { display: flex; flex-direction: column; border-left: 2px solid var(--border); }
.lesson-toc a { color: var(--muted); padding: 5px 10px; margin-left: -2px; border-left: 2px solid transparent; line-height: 1.45; }
.lesson-toc a:hover { color: var(--text); text-decoration: none; }
.lesson-toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.lesson-toc a.toc-deep { margin-top: 6px; }

.lesson-head { margin-bottom: 16px; }
.lesson-kicker { font-size: 13px; font-weight: 600; }
.lesson-head h1 { margin: 2px 0 12px; font-size: 26px; }
.lesson-actions:empty { display: none; }
.muted-inv { opacity: .8; font-weight: 500; font-size: 12px; margin-left: 4px; }

.lesson-body { padding: 8px 32px 28px; }
.lesson-body.markdown { font-size: 16px; line-height: 1.75; }
.lesson-body.markdown p, .lesson-body.markdown li { font-size: 16px; }
.lesson-body.markdown h2 { font-size: 20px; margin: 36px 0 12px; scroll-margin-top: 76px; }
.lesson-body.markdown h3 { font-size: 17px; margin: 24px 0 8px; }
.lesson-body.markdown pre { font-size: 14px; line-height: 1.6; }
.lesson-body.markdown pre code { font-size: 14px; }
.lesson-body.markdown blockquote {
  margin: 14px 0; padding: 10px 14px; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.lesson-body.markdown blockquote p { margin: 4px 0; }
.lesson-body.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.table-scroll { overflow-x: auto; }

/* 접히는 심화 학습 / 예시 답안 */
.markdown details {
  border: 1px solid var(--border); border-radius: 10px; margin: 14px 0; background: var(--surface);
}
.markdown details > summary {
  cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px;
}
.markdown details > summary::-webkit-details-marker { display: none; }
.markdown details > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.markdown details[open] > summary::before { transform: rotate(90deg); }
.markdown details[open] > summary { border-bottom: 1px solid var(--border); }
.markdown details > :not(summary) { margin-left: 16px; margin-right: 16px; }
.markdown details > :last-child { margin-bottom: 14px; }
.markdown details.deep { border-color: var(--accent); }
.markdown details.deep > summary { color: var(--accent); background: var(--accent-soft); border-radius: 10px; }
.markdown details.deep[open] > summary { border-radius: 10px 10px 0 0; }
.markdown details.answer > summary { color: var(--ok); font-size: 14px; }

.lesson-pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-top: 20px; }
.pager-link { display: flex; flex-direction: column; padding: 14px 18px; color: var(--text); font-size: 14px; }
.pager-link:hover { text-decoration: none; border-color: var(--accent); }
.pager-link .muted { font-size: 12px; }
.pager-next { text-align: right; }
.pager-main { text-align: center; border-color: var(--accent); }

@media (max-width: 900px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .lesson-toc { display: none; }
  .lesson-body { padding: 4px 18px 22px; }
  .lesson-pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
}

/* 좁은 화면: 로고가 길어서 뒤로 가기 글자는 숨기고(로고가 첫 화면 링크), 로고는 넘치면 … 로 줄인다 */
@media (max-width: 560px) {
  .topbar > a.muted { display: none; }
  .topbar .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
}

/* 회원 관리 */
.member-events { margin-top: 14px; }
.member-events summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }

/* 관리자 권한 */
.perm-table td, .perm-table th { text-align: center; }
.perm-table th { white-space: nowrap; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
/* 칸이 좁으면(F8): 계정마다 카드 한 장 — 이름 / 권한 체크(줄바꿈) / 마지막 로그인·버튼.
   화면 폭이 아니라 표를 담은 칸(.perm-wrap) 폭으로 판단 — 768px 태블릿은 왼쪽 메뉴 때문에 칸이 500px 정도 */
.perm-wrap { container-type: inline-size; }
@container (max-width: 880px) {
  .perm-table, .perm-table tbody, .perm-table tr { display: block; }
  .perm-table thead { display: none; }
  .perm-table tr { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
  .perm-table td { display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; border: 0; text-align: left; }
  .perm-table td[data-label]::before { content: attr(data-label); font-size: 13px; color: var(--muted); order: 1; }   /* 권한: ☑ 이름 */
  .perm-table td.muted::before { order: 0; }   /* 마지막 로그인: 이름 먼저 */
  .perm-table td:first-child, .perm-table td:last-child { flex: 1 0 100%; }
  .perm-table td:last-child:empty { display: none; }
}
.perm-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.perm-checks label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }

/* 풀이 화면: 이전·다음 / 힌트 / 해설 영역 (P2) */
.problem-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.problem-nav .muted { font-size: 13px; min-width: 52px; text-align: center; }
.review-area { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }
.review-title { font-size: 16px; margin: 0 0 10px; }
.hint-card { display: block; padding: 12px 14px; margin: 12px 0 0; border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.hint-head { margin-bottom: 4px; }
.hint-text > :first-child { margin-top: 0; }
.hint-text > :last-child { margin-bottom: 0; }
.hint-link { display: inline-block; margin-top: 8px; font-size: 14px; }
.hint-locked { margin: 12px 0 0; font-size: 13px; }
.answer-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cell.viewed { outline: 2px solid var(--warn, #d97706); outline-offset: -2px; }
.concept-target { background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; margin-left: -6px; }

/* ---------- 관리자 화면 레이아웃 (P3): 왼쪽 메뉴 + 본문 ---------- */
.admin-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 20px; max-width: 1440px; margin: 0 auto; padding: 20px 16px 64px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 72px; align-self: start; }
.admin-nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.admin-nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-version { margin-top: 10px; padding: 6px 12px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; font-family: var(--mono); }
.admin-nav-item.active { background: var(--accent-soft); color: var(--accent); }
.admin-nav-item .nav-icon { width: 20px; text-align: center; }
.admin-nav .nav-student { margin-top: 10px; color: var(--muted); font-weight: 500; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.admin-main { min-width: 0; }
@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; padding-top: 12px; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; position: static; gap: 4px; padding-bottom: 4px; }   /* 가로로 밀어야 보이던 메뉴(F9) → 여러 줄 */
  .nav-version { margin: 0; padding: 9px 8px; border-top: 0; white-space: nowrap; align-self: center; }
  .admin-nav-item { white-space: nowrap; padding: 7px 10px; }
  .admin-nav .nav-student { margin-top: 0; }
}

/* 현황: 요약 카드, 정답률 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat-card { padding: 14px 16px; }
.stat-value { font-size: 24px; font-weight: 800; margin: 4px 0 2px; }
.rate { font-weight: 700; }
.rate.low { color: var(--bad); }
.rate.mid { color: var(--warn); }
.rate.high { color: var(--ok); }

/* 알림 상자 */
.notice { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; margin-bottom: 8px; }
.notice.ok { background: var(--ok-soft); border-color: var(--ok); }
.notice.bad { background: var(--bad-soft); border-color: var(--bad); }

/* 문제 편집기 */
.edit-tabs { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 0; flex-wrap: wrap; }
.edit-tabs .tab .muted { font-weight: 400; font-size: 12px; }
.edit-wrap { border: 1px solid var(--border); border-top: 0; }
.edit-wrap .CodeMirror { height: 64vh; font-family: var(--mono); font-size: 14px; line-height: 1.55; }

/* 피드백 (관리자) */
.feedback-item { padding: 14px 16px; }
.feedback-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.feedback-head .spacer { flex: 1; }
.feedback-msg { white-space: pre-wrap; margin: 10px 0; line-height: 1.6; }
.feedback-reply { display: grid; gap: 6px; }
.feedback-reply textarea { font-family: inherit; font-size: 14px; }

/* 튜터링 */
.tutor-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.tutor-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.tutor-list li { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.tutor-list li a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tutor-editor .CodeMirror { height: 46vh; border: 1px solid var(--border); border-radius: 8px; font-family: var(--mono); font-size: 14px; }
.tutor-problem summary, .tutor-work details summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.tutor-problem .markdown { max-height: 260px; overflow: auto; padding: 8px 0; }
@media (max-width: 900px) { .tutor-layout { grid-template-columns: 1fr; } }

/* 학생: 피드백 창 · 튜터 알림 */
.fb-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.fb-item { border-bottom: 1px solid var(--border); padding: 10px 0; font-size: 14px; }
.fb-item .fb-reply { margin-top: 6px; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; white-space: pre-wrap; }
/* 풀이 화면 오른쪽은 줄 순서가 정해진 grid라, 알림은 툴바 위에 떠 있게 한다 */
.pane-right { position: relative; }
.tutor-banner { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
                padding: 10px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--accent); font-size: 14px; box-shadow: var(--shadow); }
.tutor-banner.hidden { display: none; }
@media (max-width: 560px) { .feedback-btn .feedback-label { display: none; } }

/* 개념 페이지: 실행해 보기 · 바로 풀어 보기 (FE-7) */
.run-block, .problem-embed, .turtle-block { border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0; background: var(--surface); overflow: hidden; }
.problem-embed { border-color: var(--accent); }
.run-head, .embed-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.run-head .spacer, .embed-head .spacer { flex: 1; }
.run-label { font-size: 13px; font-weight: 700; color: var(--accent); }
.run-block .CodeMirror, .embed-work .CodeMirror, .turtle-block .CodeMirror { height: auto; min-height: 60px; font-family: var(--mono); font-size: 14px; line-height: 1.5; }
.run-stdin { padding: 8px 10px; border-top: 1px solid var(--border); }
.run-stdin textarea { width: 100%; font-family: var(--mono); font-size: 13px; }
.run-out { padding: 8px 10px; border-top: 1px solid var(--border); }
.run-out .out, .embed-result .out { margin: 6px 0 0; }
.run-error { color: var(--bad); }
.embed-body { padding: 10px 14px; border-bottom: 1px solid var(--border); max-height: 360px; overflow: auto; }
.embed-work { padding: 0; }
.embed-work .choice { margin: 8px 12px; }
.embed-work .quiz-input { margin: 10px 12px; width: calc(100% - 24px); }
.embed-work > div:last-child { padding: 0 12px 10px; }
.embed-result { padding: 8px 12px; }
.embed-result:empty { display: none; }
/* 코드 한 줄씩 보기 (CT-2) */
.markdown details.explain { margin-top: -4px; }
.markdown details.explain > summary { color: var(--warn); font-size: 14px; }
.markdown details.explain table { font-size: 14px; }
.markdown details.explain td:first-child { white-space: nowrap; }
.markdown details.explain td:first-child code { font-size: 13px; }
@media (max-width: 560px) { .markdown details.explain td:first-child { white-space: normal; } }
@media (max-width: 560px) {   /* 좁은 화면: 표 대신 '코드 위, 설명 아래'로 쌓는다 */
  .markdown details.explain thead { display: none; }
  .markdown details.explain table, .markdown details.explain tbody, .markdown details.explain tr, .markdown details.explain td { display: block; width: auto; border: 0; }
  .markdown details.explain tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .markdown details.explain td { padding: 2px 0; }
}

/* 개념 페이지 복사 방지 (FE-8): 에디터·입력칸은 선택 가능 */
.no-copy { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.no-copy .CodeMirror, .no-copy input, .no-copy textarea, .no-copy select { -webkit-user-select: text; user-select: text; }
.copy-tip {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.copy-tip.show { opacity: 1; transform: translate(-50%, 0); }
@media print { .no-copy { display: none; } }

/* 에러 도우미 (BE-10) */
.err-help { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); font-size: 14px; line-height: 1.6; }
.err-help-head { display: block; font-weight: 700; color: var(--warn); margin-bottom: 2px; font-size: 13px; }
.err-help code { font-size: 13px; }
.cm-error-line { background: color-mix(in srgb, var(--bad) 24%, transparent) !important; }   /* 에디터 다크/라이트 모두에서 읽히게 반투명 */

/* 문제 검색 · 개념 목차 (FE-14) */
.search-box { margin: 0 0 16px; }
.search-box input { width: 100%; font-size: 16px; padding: 12px 14px; }
.search-count { margin: 0 0 8px; font-size: 14px; }
.search-list { padding: 4px 0; }
.search-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; color: var(--text); border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: 0; }
.search-item:hover { background: var(--surface-2); text-decoration: none; }
.search-title { font-weight: 600; }
.search-meta { font-size: 13px; }
.search-snippet { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-card { padding: 12px 16px; margin-bottom: 12px; }
.toc-card > summary { cursor: pointer; font-weight: 700; }
.toc-card > summary .muted { font-weight: 400; font-size: 13px; }
.toc-list { margin: 10px 0 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.toc-list li { display: grid; gap: 4px; }
.toc-sec { font-weight: 600; font-size: 14px; }
.toc-empty .toc-sec { font-weight: 400; color: var(--muted); }
.toc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.toc-chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-chip:hover { text-decoration: none; border-color: var(--accent); }
.toc-chip.ok { border-color: var(--ok); background: var(--ok-soft); }
.toc-chip.tried { border-color: var(--warn); background: var(--warn-soft); }
.list-tools { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; flex-wrap: wrap; }
.list-tools input { flex: 1; min-width: 180px; }
.list-tools a { font-size: 13px; }

/* 코드 수정 기록 (BE-8) */
.tl-player { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tl-player input[type=range] { flex: 1; min-width: 200px; }
.tl-code { max-height: 320px; margin-bottom: 10px; }
.tl-code .tl-new { background: var(--ok-soft); display: inline-block; width: 100%; }
.tl-row.tl-active td { background: var(--accent-soft); }

/* 선생님 대시보드 보강 (BE-11) */
.stuck-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.stuck-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cell.draft { background: var(--surface-2); color: var(--muted); }
.mini-progress { display: inline-block; width: 50px; height: 6px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; margin-right: 4px; overflow: hidden; }
.mini-progress > div { height: 100%; background: var(--ok); }

/* 반·수업 그룹 (BE-9) */
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin: 0 0 10px; border-radius: 8px; background: var(--accent-soft); }
#member-table th, #member-table td, #matrix th, #matrix td { white-space: nowrap; }
@media (max-width: 560px) {
  #group-form, #exempt-form { grid-template-columns: 1fr !important; }
}

/* 터틀 실행 블록 (브라우저 Skulpt) — 테두리·머리·에디터는 위 .run-block 규칙을 함께 씀 */
.turtle-stage { padding: 10px; display: flex; justify-content: center; background: var(--surface-2); border-top: 1px solid var(--border); }
.turtle-canvas { background: #fff; border: 1px solid var(--border); max-width: 100%; overflow: hidden; }
.turtle-canvas canvas { max-width: 100%; height: auto; }

/* 확인 퀴즈: 내 답 먼저 써 보기 */
.quiz-try { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.quiz-try input { flex: 1 1 220px; min-width: 0; }
.quiz-try-msg { font-size: 14px; }
.quiz-try-msg.ok { color: var(--ok); font-weight: 700; }

/* 실시간 함께 편집 (BE-7) */
.collab-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--amber, #E3A33B); color: var(--navy-deep, #122F4D); font-size: 13px; white-space: nowrap; }
.collab-chip.hidden { display: none; }
.collab-chip .btn { min-height: 0; padding: 2px 8px; }
.collab-caret { position: relative; border-left: 2px solid; margin-left: -1px; margin-right: -1px; }
.collab-name { position: absolute; top: -1.35em; left: -2px; padding: 0 4px; font-size: 11px; line-height: 1.4; color: #122F4D; white-space: nowrap; border-radius: 2px; pointer-events: none; font-family: var(--font-body, sans-serif); font-weight: 700; }
.collab-state { font-size: 13px; }
/* 파이게임 블록 (v3.5) */
.pygame-block { border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0; background: var(--surface); overflow: hidden; }
.pygame-block .CodeMirror { height: auto; min-height: 60px; font-family: var(--mono); font-size: 14px; line-height: 1.5; }
.pygame-stage { padding: 10px; display: flex; justify-content: center; background: #10161F; border-top: 1px solid var(--border); }
.pygame-stage.hidden { display: none; }
.pygame-canvas { max-width: 100%; height: auto; background: #000; outline: none; image-rendering: pixelated; }
.pygame-canvas:focus { box-shadow: 0 0 0 3px var(--amber, #E3A33B); }

/* 웹 과목 (v4.2): 미리보기 창 + 콘솔 + 검사 항목. 미리보기 바탕은 언제나 흰색(학생 페이지 기본 배경) */
.web-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: var(--surface); color: var(--text); }
.wp-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.wp-frame { display: block; width: 100%; height: 280px; border: 0; background: #fff; color-scheme: light; }
.wp-console { max-height: 160px; overflow: auto; padding: 6px 10px; border-top: 1px solid var(--border); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.wp-console .err-help { font-family: var(--font-body); white-space: normal; }
.wc-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; }
.wc-error { color: var(--bad); }
.wc-warn, .wc-hint { color: var(--warn); }
.wc-info { color: var(--muted); }
.web-checks { margin: 16px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.web-checks h3 { margin: 0 0 6px; font-size: 15px; }
.web-checks ul { margin: 0; padding-left: 20px; }
.web-checks p { margin: 6px 0 0; font-size: 13px; }
.check-row { display: flex; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); margin: 6px 0; background: var(--surface); }
.check-row.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.check-mark { flex: none; }
.check-main { min-width: 0; flex: 1; }
.check-main .out { margin: 6px 0 0; }
.run-block .wp-frame { height: 200px; }
