:root {
  /* 🇹🇷 터키블루 팔레트 (Pacific / Turkish Blue) */
  --primary: #0891b2;         /* cyan-600 톤 터키블루 */
  --primary-dark: #0e7490;    /* cyan-700 */
  --primary-light: #cffafe;   /* cyan-50 / 연한 배경 */
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #111827;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --user-bubble: #0891b2;     /* 채팅 말풍선도 터키블루 */
  --user-text: #ffffff;
  --bot-bubble: #ffffff;
  --bot-text: #111827;
  --flag: #ef4444;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
  --radius: 18px;
  --header-h: 78px;   /* 기존 64px → +20% (태그라인 한 줄 노출용) */
  --composer-h: 92px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
               "Apple SD Gothic Neo", "맑은 고딕", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ── Header ───────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: var(--safe-top);
}
/* 3열 Grid — 중앙 슬롯(AI조교)이 디바이스·회전 무관하게 수학적 중앙 고정 */
.header-inner {
  height: var(--header-h);
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* 좌 1fr · 중 auto · 우 1fr */
  align-items: center;
  gap: 10px;
}
.header-inner > .brand         { grid-column: 1; justify-self: start; min-width: 0; }
.header-inner > .header-center {
  grid-column: 2;              /* 중앙 슬롯 고정 */
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-inner > .header-actions { grid-column: 3; justify-self: end; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
}
.brand > div { min-width: 0; }
.user-info { flex-shrink: 0; flex-wrap: nowrap; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
  object-fit: cover;
}
/* 텍스트 fallback (div.brand-logo 사용 시) */
div.brand-logo {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
/* 기본 — 수학·관리자 페이지는 기존처럼 한 줄 타이틀 */
.brand-texts {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-sub);
  white-space: pre-line;   /* Enter(줄바꿈) 보존 */
  line-height: 1.35;
  max-height: 34px;
  overflow: hidden;
}

/* 메인 챗봇 페이지(index.html)에서만 — 학원명 2줄 표기 규칙 */
.chat-body .brand-texts { max-width: 130px; }
.chat-body .brand-title {
  font-size: 13.5px;
  white-space: pre-line;
  line-height: 1.15;
  word-break: keep-all;
  text-overflow: clip;
}
.chat-body .brand-sub {
  font-size: 11.5px;
  line-height: 1.3;
  margin-top: 2px;
}

.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 18px;
  color: var(--text-sub);
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn:active { transform: scale(0.95); }

/* ── Chat area ────────────────────────────────────── */
.chat-area {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px calc(16px + var(--composer-h)) 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.msg-row { display: flex; width: 100%; }
.msg-row.user { justify-content: flex-end; }
.msg-row.bot  { justify-content: flex-start; }

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow);
  animation: pop .18s ease-out;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-row.user .bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 6px;
}
.msg-row.bot .bubble {
  background: var(--bot-bubble);
  color: var(--bot-text);
  border-bottom-left-radius: 6px;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-sub);
  margin: 2px 4px 0;
}
.msg-row.user .msg-meta { text-align: right; }

.flag-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  color: var(--flag);
  border: 1px solid var(--flag);
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.msg-meta {
  white-space: nowrap;
}

/* Typing indicator */
.typing {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-sub);
  opacity: 0.5;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

.welcome {
  text-align: center;
  color: var(--text-sub);
  padding: 32px 20px 24px;
  line-height: 1.6;
  max-width: 520px;
  margin: 8px auto 0;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop .25s ease-out;
}
.welcome strong { color: var(--text); }
.welcome-logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.5px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}
.welcome-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.welcome-body {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-sub);
}
.welcome-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin: 0 auto;
  max-width: 420px;
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  text-align: left;
}
.welcome-cta-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.welcome-cta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--primary-dark);
  line-height: 1.5;
}
.welcome-cta-text strong {
  font-size: 14px;
  color: var(--primary-dark);
  font-weight: 700;
}
.welcome-cta-text b {
  color: var(--primary-dark);
  font-weight: 700;
  background: rgba(255,255,255,0.6);
  padding: 1px 6px;
  border-radius: 6px;
}
@media (prefers-color-scheme: dark) {
  .welcome-cta {
    background: #1e3a8a33;
    border-color: #1e3a8a;
  }
  .welcome-cta-text,
  .welcome-cta-text strong,
  .welcome-cta-text b {
    color: #dbeafe;
  }
  .welcome-cta-text b {
    background: #1e40af;
  }
}

/* ── Composer ─────────────────────────────────────── */
.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  z-index: 10;
}
.composer-form {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  background: var(--bg);
  outline: none;
  transition: border-color .15s, background .15s;
}
#input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.send-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { background: var(--primary-dark); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { background: #9ca3af; cursor: not-allowed; }

.composer-hint {
  max-width: 720px;
  margin: 4px auto 0;
  font-size: 11px;
  color: var(--text-sub);
  text-align: center;
}

@media (max-width: 480px) {
  .composer-hint { display: none; }
  .bubble { max-width: 84%; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-sub: #94a3b8;
    --border: #334155;
    --bot-bubble: #1e293b;
    --bot-text: #f1f5f9;
  }
}

/* ══════════════════════════════════════════════════
   로그인/회원가입 페이지
   ══════════════════════════════════════════════════ */
.auth-body {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(37, 99, 235, 0.12), 0 2px 8px rgba(0,0,0,0.04);
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .brand-logo {
  margin: 0 auto 14px;
  width: 56px;
  height: 56px;
  font-size: 18px;
  border-radius: 16px;
}
.auth-logo h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.auth-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
}
.field input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.auth-error {
  font-size: 13px;
  color: var(--flag);
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  transition: all .15s;
}
.auth-error.visible {
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  min-height: 20px;
}

/* 비밀번호 변경 — 성공 메시지 + 보조 버튼 (2026-05-06) */
.auth-ok {
  font-size: 13px;
  color: #0e7490;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  transition: all .15s;
}
.auth-ok.visible {
  padding: 10px 12px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  min-height: 20px;
}
.auth-secondary {
  margin-top: 6px;
  padding: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
}
.auth-secondary:hover { background: var(--bg); }
@media (prefers-color-scheme: dark) {
  .auth-error.visible {
    background: #7f1d1d33;
    border-color: #7f1d1d;
  }
}

.auth-submit {
  margin-top: 4px;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.auth-submit:hover:not(:disabled) { background: var(--primary-dark); }
.auth-submit:active:not(:disabled) { transform: scale(0.98); }
.auth-submit:disabled { background: #9ca3af; cursor: wait; }

.auth-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-sub);
  margin: 20px 0 0;
}

/* ══════════════════════════════════════════════════
   사용자 정보 바 (헤더 내)
   ══════════════════════════════════════════════════ */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-sub);
}
.user-info .username {
  font-weight: 600;
  color: var(--text);
}
.user-info .role-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.user-info .role-badge.admin {
  background: #fef3c7;
  color: #92400e;
}
@media (prefers-color-scheme: dark) {
  .user-info .role-badge { background: #164e63; color: #cffafe; }
  .user-info .role-badge.admin { background: #78350f; color: #fef3c7; }
}
.logout-btn {
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-sub);
}
.logout-btn:hover { background: var(--bg); }

/* ══════════════════════════════════════════════════
   드롭다운 메뉴 (점 3개 → 관리자/로그아웃)
   ══════════════════════════════════════════════════ */
.dropdown { position: relative; }
.dropdown-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-sub);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.dropdown-toggle:hover { background: var(--bg); }
.dropdown-toggle:active { transform: scale(0.95); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 172px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1), 0 2px 6px rgba(0,0,0,0.05);
  padding: 4px;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.dropdown-menu button:hover { background: var(--bg); color: var(--primary-dark); }
.dropdown-menu button + button { margin-top: 2px; }
.dropdown-menu button.danger { color: var(--flag); }
.dropdown-menu button.danger:hover { background: #fee2e2; color: var(--flag); }
@media (prefers-color-scheme: dark) {
  .dropdown-menu button.danger:hover { background: #7f1d1d33; }
}

/* 헤더 오른쪽 그룹 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 태그라인·유저명은 좁은 화면에서도 항상 노출 (관리자 요청) */
@media (max-width: 560px) {
  .user-info .role-badge { display: none; }
  .user-info { gap: 6px; }
  .header-inner { padding: 0 10px; gap: 8px; }
  .brand { gap: 8px; }
  .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
  .logout-btn { padding: 5px 8px; font-size: 11.5px; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .math-link-btn,
  .back-to-chat-btn { padding: 5px 9px; font-size: 11.5px; }

  /* 메인 챗봇 페이지만 좁은 화면에서 브랜드 폭 더 줄임 */
  .chat-body .brand-texts { max-width: 110px; }
  .chat-body .brand-title { font-size: 12.5px; }
  .chat-body .brand-sub { font-size: 10.5px; }
}

@media (max-width: 420px) {
  .header-inner { padding: 0 8px; gap: 6px; }
  .logout-btn, .math-link-btn, .back-to-chat-btn {
    padding: 4px 7px;
    font-size: 11px;
  }

  .chat-body .brand-texts { max-width: 96px; }
  .chat-body .brand-title { font-size: 12px; }
  .chat-body .brand-sub { font-size: 10px; }
}

/* ══════════════════════════════════════════════════
   관리자 대시보드
   ══════════════════════════════════════════════════ */
.admin-body {
  background: var(--bg);
  min-height: 100vh;
}

/* 관리자 페이지 전용 컨테이너 폭 — 헤더와 본문 동일 폭으로 맞춤
   (Phase 8-2F: 가로폭을 늘려 stat 카드 2행 3열이 좁은 노트북 폭에서도 한 화면에 보이도록) */
.admin-body .header-inner { max-width: 1100px; }

.admin-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  width: 100%;
}

/* 통계 카드 그리드 — 2행 3열 고정 (한 화면에 한 번에 보이도록) */
/* 통계 카드 — 2026-05-06: 「항목: 숫자」 한 줄 콤팩트 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  background: var(--surface);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat-card.stat-flag {
  background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
  border-color: #fecaca;
}
@media (prefers-color-scheme: dark) {
  .stat-card.stat-flag {
    background: linear-gradient(135deg, var(--surface) 0%, #450a0a 100%);
    border-color: #7f1d1d;
  }
}
.stat-label {
  font-size: 11.5px;
  color: var(--text-sub);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label::after { content: ':'; margin-left: 1px; }
.stat-card.stat-flag .stat-label { color: var(--flag); }
.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  flex-shrink: 0;
}
.stat-card.stat-flag .stat-value { color: var(--flag); }

/* 4×4 단축 버튼 그리드 — 가로 스크롤 탭의 풀-뷰 단축키 */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
@media (max-width: 480px) {
  .quick-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }
}
.quick-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-btn:hover { background: var(--bg); }
.quick-btn:active { transform: scale(0.98); }
.quick-btn.active {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  border-color: #0e7490;
  color: #fff;
}
.quick-btn .qb-icon { font-size: 13px; flex-shrink: 0; }
.quick-btn .qb-label { font-size: 12px; }
@media (max-width: 480px) {
  .quick-btn { padding: 6px 4px; font-size: 11.5px; }
  .quick-btn .qb-label { font-size: 11px; }
}
.quick-btn .qb-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--flag);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* 탭 */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}
.admin-tab:hover:not(.active) { color: var(--text); }

.tab-content { min-height: 200px; }
.loader, .empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-sub);
  font-size: 14px;
}

/* 특이사항 리스트 */
.flag-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.flag-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--flag);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.flag-item:hover { box-shadow: var(--shadow); }
.flag-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
.flag-user { font-weight: 600; color: var(--text); }
.flag-time { color: var(--text-sub); }
.flag-tag {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--flag);
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* Phase 8-2F: 미확인 특이사항 — NEW 라벨 + 카드 강조 */
.flag-new-badge {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 6px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: #dc2626;
  border-radius: 4px;
  vertical-align: middle;
  letter-spacing: 0.05em;
  animation: pulse-new 1.6s ease-in-out infinite;
}
@keyframes pulse-new {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.55); }
  50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.flag-item.is-new {
  background: linear-gradient(135deg, #fff 0%, #fff5f5 100%);
}

/* 신규 특이사항 알림 배너 (관리자 페이지 진입 시 미확인 N건 있을 때) */
.unseen-flag-banner[hidden] { display: none !important; }
.unseen-flag-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin: 0 0 16px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-left: 4px solid var(--flag);
  border-radius: 12px;
  color: #991b1b;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}
.unseen-flag-banner .ufb-icon { font-size: 22px; }
.unseen-flag-banner .ufb-text { flex: 1; font-size: 14px; line-height: 1.5; }
.unseen-flag-banner .ufb-text strong { color: var(--flag); font-weight: 700; }
.unseen-flag-banner .ufb-go {
  background: var(--flag);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.unseen-flag-banner .ufb-go:hover { background: #b91c1c; }
@media (prefers-color-scheme: dark) {
  .unseen-flag-banner {
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    border-color: #7f1d1d;
    color: #fecaca;
  }
  .flag-item.is-new {
    background: linear-gradient(135deg, var(--surface) 0%, #450a0a 100%);
  }
}

/* 관리자 챗봇 메인 — 신규 특이사항 알림 카드 (admin role + 미확인 N건) */
.admin-flag-alert[hidden] { display: none !important; }
.admin-flag-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fecaca;
  border-left: 4px solid var(--flag);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
  transition: transform .12s, box-shadow .12s;
}
.admin-flag-alert:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.15);
}
.admin-flag-alert .afa-icon { font-size: 24px; }
.admin-flag-alert .afa-text { flex: 1; }
.admin-flag-alert .afa-title {
  font-weight: 700; color: var(--flag); font-size: 15px;
}
.admin-flag-alert .afa-sub {
  font-size: 12.5px; color: #991b1b; margin-top: 2px;
}
.admin-flag-alert .afa-arrow {
  font-size: 20px; color: var(--flag); font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .admin-flag-alert {
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    border-color: #7f1d1d;
  }
  .admin-flag-alert .afa-sub { color: #fecaca; }
}

/* 전체 대화 탭 — 사용자 셀: 아이디(굵게) + 실명·역할(보조) */
.conv-user-id { font-weight: 600; color: var(--text); }
.conv-user-meta {
  font-size: 12px; color: var(--text-sub); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.conv-user-meta.missing { color: var(--flag); font-style: italic; }
.conv-role-tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-sub);
}

/* Phase 8-2G — 학생/사용자 행 더블클릭 단서 (이름·아이디에 점선 밑줄 + cursor) */
.student-name-link,
.student-id-link {
  border-bottom: 1px dashed var(--primary);
  cursor: help;
}
tr.student-row:hover,
tr.user-row[data-linked-student]:hover {
  background: rgba(8, 145, 178, 0.04);
}
tr.student-row,
tr.user-row[data-linked-student] { cursor: default; }
tr.student-row td,
tr.user-row td { user-select: none; }
tr.student-row td input,
tr.user-row td input { user-select: text; }

/* Phase 8-2H — 학부모 승인 탭 수동 연결 행 */
.manual-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.manual-link-select {
  flex: 1 1 180px;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.manual-link-relation {
  width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.manual-link-arrow { color: var(--text-sub); font-weight: 700; }
.manual-link-hint {
  font-size: 12px; color: var(--text-sub); margin-top: 6px;
  padding-left: 4px;
}

/* 회원가입 폼 — 필수 표시 */
.required-mark {
  color: var(--flag);
  font-weight: 700;
  font-style: normal;
  margin-left: 4px;
  font-size: 11px;
}

/* 전체 대화 탭 — 검색창 (학생 이름·제목으로 row 필터링) */
.conv-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.conv-search-input {
  flex: 1;
  padding: 9px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.conv-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}
.conv-search-count {
  font-size: 12.5px;
  color: var(--text-sub);
  white-space: nowrap;
}

/* 탭 버튼 옆 카운트 뱃지 (미확인 특이사항 N건) */
.tab-count-badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 20px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--flag);
  border-radius: 999px;
  text-align: center;
  vertical-align: middle;
  line-height: 1.4;
}
.flag-content {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text);
  word-break: break-word;
}
.flag-actions { margin-top: 10px; text-align: right; }
.view-conv-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.view-conv-btn:hover { text-decoration: underline; }

/* 테이블 */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr.conv-row { cursor: pointer; }
.admin-table tbody tr.conv-row:hover { background: var(--bg); }
.admin-table tbody tr.has-flag {
  background: #fff1f2;
}
@media (prefers-color-scheme: dark) {
  .admin-table tbody tr.has-flag { background: #7f1d1d22; }
}
.col-title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-num { text-align: right; font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.col-date { color: var(--text-sub); white-space: nowrap; width: 1%; }

/* 모달 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  cursor: pointer;
}
.modal-card {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.conv-head {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}
.conv-head strong { color: var(--text); font-weight: 600; }

.modal-msgs { display: flex; flex-direction: column; gap: 10px; }
.modal-msg {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
}
.modal-msg.user {
  background: var(--primary-light);
  border-color: transparent;
}
@media (prefers-color-scheme: dark) {
  .modal-msg.user { background: #164e6344; }
}
.modal-msg.flagged {
  border: 1px solid var(--flag);
  background: #fff1f2;
}
@media (prefers-color-scheme: dark) {
  .modal-msg.flagged { background: #7f1d1d33; }
}
.modal-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.modal-msg-head .msg-time { margin-left: auto; }
.modal-msg-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
  word-break: break-word;
}

@media (max-width: 600px) {
  .admin-main { padding: 12px 10px 30px; }
  /* 모바일에서도 한 줄 콤팩트 유지 */
  .stat-value { font-size: 14px; }
  .stat-label { font-size: 10.5px; }
  .stat-card { padding: 5px 8px; }
  .modal-card { max-height: 95vh; }
  /* Phase 1 Users 탭 — 좁은 화면에서 인풋·셀렉트 축소 */
  .admin-table .limit-input,
  .admin-table .def-input { width: 70px; padding: 4px 6px; }
  .admin-table .role-select { padding: 3px 4px; font-size: 12.5px; }
  .admin-table.compact td,
  .admin-table.compact th { padding: 4px 6px; font-size: 12.5px; }
  .admin-controls { padding: 10px 12px; gap: 8px; }
  .role-defaults h3, .users-block h3 { font-size: 13px; }
  .role-defaults .hint, .users-block .hint { display: block; margin-left: 0; margin-top: 2px; }
}

/* ══════════════════════════════════════════════════
   수학 페이지
   ══════════════════════════════════════════════════ */
.math-body { background: var(--bg); min-height: 100vh; }

.math-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 사용량 카드 */
.quota-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.quota-label {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
  margin-bottom: 8px;
}
.quota-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.quota-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width .3s ease-out;
}
.quota-fill.warn { background: #f59e0b; }
.quota-fill.danger { background: var(--flag); }
.quota-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-sub);
}
.quota-meta strong { color: var(--text); font-weight: 700; }
.quota-reset { font-size: 12px; }

/* 비회원 안내 */
.notice {
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.6;
}
.notice-warn {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
}
.notice p { margin: 6px 0 0; }
@media (prefers-color-scheme: dark) {
  .notice-warn { background: #78350f; border-color: #92400e; color: #fef3c7; }
}

/* 업로드 영역 */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dropzone {
  position: relative;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 16px;
  min-height: 360px;
  display: flex;
  flex-direction: column;       /* 세로 배치 */
  align-items: center;          /* 가로 가운데 */
  justify-content: flex-start;  /* 세로 상단 정렬 (빈 상태 박스 상단으로) */
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.dropzone.has-image { cursor: default; }
.dz-preview-wrap {
  width: 100%;
  max-height: 620px;
  overflow: hidden;
  display: block;
}
.dz-preview-wrap[hidden] { display: none; }
.dz-preview-wrap .dz-preview {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
  max-height: 620px;
}
.dropzone:hover { border-color: var(--primary); }
.dropzone.drag { border-color: var(--primary); background: var(--primary-light); }
.dz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 16px 12px;
  color: var(--text-sub);
  text-align: center;
  pointer-events: none;
  width: 100%;
}
.dz-empty[hidden] { display: none; }
.dz-empty-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.dz-empty-head .dz-icon {
  font-size: 22px;
  line-height: 1;
}
.dz-empty-sub {
  font-size: 12px;
  color: var(--text-sub);
}
.dz-empty-hint {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  background: #fef3c7;
  color: #92400e;
  padding: 4px 10px;
  border-radius: 6px;
}

/* 2026-05-05 — 촬영 / 사진 선택 버튼 분리 (모바일 카메라 강제 함정 해결) */
.dz-pick-row {
  display: flex;
  gap: 12px;
  margin: 10px 0 6px;
  pointer-events: auto;   /* dz-empty의 pointer-events:none 무력화 */
  width: 100%;
  justify-content: center;
}
.dz-pick-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 22px;
  min-width: 110px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg, #fff);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  pointer-events: auto;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.dz-pick-btn:hover {
  border-color: var(--turkey-700, #0e7490);
  background: var(--bg-elev, #f0fdfa);
}
.dz-pick-btn:active { transform: scale(0.97); }
.dz-pick-icon { font-size: 26px; line-height: 1; }
.dz-pick-label { font-size: 13.5px; }

@media (prefers-color-scheme: dark) {
  .dz-pick-btn { background: #1f2937; }
  .dz-pick-btn:hover { background: #164e63; }
  .dz-empty-hint { background: #422006; color: #fde68a; }
}
@media (max-width: 540px) {
  .dz-pick-btn { min-width: 100px; padding: 10px 16px; }
  .dz-pick-icon { font-size: 22px; }
}

.dz-preview {
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  background: var(--bg);
}

/* 크롭 안내 바 */
.crop-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 10px;
  font-size: 12.5px;
  color: #9a3412;
  line-height: 1.4;
}
.crop-hint strong { font-weight: 700; }
.crop-reset {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  color: #9a3412;
  border: 1px solid #fdba74;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.crop-reset:hover { background: #fef3c7; }

/* 자동 감지 (Gemini Vision) — 툴바 + 오버레이 */
.detect-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #ecfeff, #cffafe);
  border: 1px solid #67e8f9;
  border-radius: 10px;
  font-size: 12.5px;
  color: #155e75;
  flex-wrap: wrap;
}
@media (prefers-color-scheme: dark) {
  .detect-toolbar {
    background: linear-gradient(135deg, #083344, #164e63);
    border-color: #155e75;
    color: #cffafe;
  }
}
.auto-detect-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.auto-detect-btn:hover { background: var(--primary-dark); }
.auto-detect-btn:disabled { opacity: .6; cursor: wait; }
.detect-hint { flex: 1; min-width: 140px; }

/* 감지된 문제 번호 칩 — 단일 UI로 통합 */
.detect-chips {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #ecfeff, #f0fdfa);
  border: 1px solid #67e8f9;
  border-radius: 10px;
  flex-wrap: wrap;
  animation: detectSlideDown .25s ease-out;
}
@keyframes detectSlideDown {
  from { transform: translateY(-4px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.detect-chips-label {
  font-size: 12.5px;
  color: #155e75;
  font-weight: 700;
  flex-shrink: 0;
}
.detect-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.detect-chip {
  width: 36px;
  height: 36px;
  border: 2px solid #67e8f9;
  background: #fff;
  color: #155e75;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.detect-chip:hover {
  background: #ecfeff;
  border-color: var(--primary);
}
.detect-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 2px 6px rgba(8,145,178,.35);
}
@media (prefers-color-scheme: dark) {
  .detect-chips {
    background: linear-gradient(135deg, #083344, #134e4a);
    border-color: #155e75;
  }
  .detect-chips-label { color: #cffafe; }
  .detect-chip {
    background: var(--surface);
    color: #cffafe;
    border-color: #155e75;
  }
  .detect-chip:hover { background: #164e63; }
}
@media (prefers-color-scheme: dark) {
  .crop-hint {
    background: #451a03;
    border-color: #9a3412;
    color: #fed7aa;
  }
  .crop-reset {
    background: #7c2d12;
    color: #fed7aa;
    border-color: #9a3412;
  }
  .crop-reset:hover { background: #9a3412; }
}

/* Cropper.js 컨테이너 제약 */
.dz-preview-wrap .cropper-container {
  max-width: 100%;
}

/* Cropper 선택 영역 커스텀 — 연한 클로드 오렌지 + 2배 굵은 테두리 */
.cropper-view-box {
  outline: 3px solid rgba(217, 119, 87, 0.85) !important;
  outline-color: rgba(217, 119, 87, 0.85) !important;
  box-shadow: 0 0 0 1px rgba(217, 119, 87, 0.3);
}
.cropper-dashed {
  border-color: rgba(217, 119, 87, 0.55) !important;
  border-width: 1.5px !important;
}
.cropper-line {
  background-color: #d97757 !important;
  opacity: 0.55;
}
.cropper-point {
  background-color: #d97757 !important;
  opacity: 0.95;
}
.cropper-point.point-se,
.cropper-point.point-sw,
.cropper-point.point-ne,
.cropper-point.point-nw {
  /* 코너 핸들 — 살짝 작게(12px) + 흰 테두리로 가시성 (2026-05-05 짱쌤 요청 반영) */
  width: 12px !important;
  height: 12px !important;
  background-color: #d97757 !important;
  border: 1.5px solid #fff !important;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  opacity: 1 !important;
}
.cropper-point.point-n,
.cropper-point.point-s,
.cropper-point.point-e,
.cropper-point.point-w {
  /* 변 중앙 핸들 — 작고 통일된 띠 + !important로 inline margin 무력화하여 정중앙 보장 */
  background-color: #d97757 !important;
  opacity: 1 !important;
  border: 1.5px solid #fff !important;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.cropper-point.point-n,
.cropper-point.point-s {
  width: 18px !important;
  height: 8px !important;
  /* Cropper.js inline style(margin-left:-3px)을 !important로 이겨 정중앙 유지 */
  margin-left: -9px !important;
}
.cropper-point.point-e,
.cropper-point.point-w {
  width: 8px !important;
  height: 18px !important;
  margin-top: -9px !important;
}
.cropper-face {
  background-color: rgba(217, 119, 87, 0.08) !important;
}
.dz-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dz-remove[hidden] { display: none; }

.math-note label { display: flex; flex-direction: column; gap: 6px; }
.math-note label span { font-size: 13px; color: var(--text-sub); font-weight: 500; }
.math-note textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 60px;
  box-sizing: border-box;
}
.math-note textarea:focus { border-color: var(--primary); background: var(--surface); }

/* 풀이 스타일 선택 (체크박스 UI + 단일선택 동작) — 컴팩트 + 가운데 정렬 */
.style-options {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 14px 4px;
  margin: 0;
}
.style-options legend {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
  padding: 0 6px;
  margin-bottom: 2px;
}
.style-option {
  display: flex;
  align-items: center;
  justify-content: center;     /* 가운데 정렬 — 박스 기준 */
  gap: 10px;
  padding: 5px 6px;            /* 기존 10px → 5px (약 20% 전체 높이 감소) */
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
  text-align: center;
}
.style-option:hover { background: var(--bg); }
.style-option + .style-option { border-top: 1px solid var(--border); }

/* 2×2 그리드 변형 (개인용 P 버전 — 짱쌤 4스타일) */
.style-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 6px;
  padding: 8px 10px 10px;
}
.style-options-grid legend {
  grid-column: 1 / -1;
}
.style-options-grid .style-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
}
.style-options-grid .style-option + .style-option {
  border-top: 1px solid var(--border);
}
.style-options-grid .style-option:hover {
  background: var(--bg);
}
.style-options-grid .style-option input:checked ~ .style-text strong {
  color: var(--primary);
}
.style-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.style-mark {
  flex-shrink: 0;
  margin-top: 2px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .12s, background .12s;
}
.style-option input:checked ~ .style-mark {
  border-color: var(--primary);
  background: var(--primary);
}
.style-option input:checked ~ .style-mark::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.style-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  align-items: center;         /* 텍스트 내부도 가운데 */
  text-align: center;
  line-height: 1.25;
}
.style-text strong {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 700;
}
.style-text small {
  font-size: 11.5px;
  color: var(--text-sub);
  line-height: 1.3;
  margin-top: 0;
}
.style-option input:checked ~ .style-text strong { color: var(--primary); }

/* 결과 영역 */
.result-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.result-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.result-text {
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 14.5px;
  line-height: 1.7;
  word-break: keep-all;
  color: var(--text);
  margin: 0 0 10px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 10px;
  max-height: 65vh;
  overflow-y: auto;
}
/* 마크다운 렌더링 결과 내부 스타일 */
.result-text p { margin: 0 0 10px; }
.result-text p:last-child { margin-bottom: 0; }
.result-text strong { color: var(--primary-dark); font-weight: 700; }
.result-text ol, .result-text ul { padding-left: 24px; margin: 6px 0 10px; }
.result-text li { margin-bottom: 4px; }
.result-text hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* KaTeX 수식 — 블록 수식이 가로 넘치면 스크롤 */
.result-text .katex-display {
  margin: 10px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}
.result-text .katex {
  font-size: 1.05em;
}

/* 관리자 모달 내부 풀이도 동일 스타일 */
.modal-msg-body.solution-rendered {
  font-size: 14px;
  line-height: 1.7;
}
.modal-msg-body.solution-rendered p { margin: 0 0 8px; }
.modal-msg-body.solution-rendered strong { color: var(--primary-dark); font-weight: 700; }
.modal-msg-body.solution-rendered .katex-display {
  margin: 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
}
@media (prefers-color-scheme: dark) {
  .result-text strong,
  .modal-msg-body.solution-rendered strong { color: #67e8f9; }
}
.result-meta {
  font-size: 11px;
  color: var(--text-sub);
  text-align: right;
}

/* 스피너 */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 수학 페이지 "챗봇으로" 복귀 버튼 — 클로드 오렌지 강조 */
.back-to-chat-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #d97757;
  border: 1px solid #c56843;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(217, 119, 87, 0.25);
  transition: background .15s, transform .08s, box-shadow .15s;
}
.back-to-chat-btn:hover {
  background: #c56843;
  box-shadow: 0 2px 6px rgba(217, 119, 87, 0.35);
}
.back-to-chat-btn:active { transform: scale(0.97); }

/* 챗봇 페이지 내 "수학 풀이" 진입 버튼 (레거시) */
.math-link-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.math-link-btn:hover { background: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) {
  .math-link-btn {
    background: #164e63;
    color: #cffafe;
  }
}

/* 짱쌤AI조교 진입 버튼 — 거의 정사각형, 세로 2줄 중앙 정렬 */
.ai-tutor-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;          /* 가로 중앙 */
  justify-content: center;      /* 세로 중앙 */
  gap: 3px;
  padding: 7px 10px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.05;
  min-width: 58px;
  min-height: 58px;             /* 가로 폭과 비슷 → 거의 정사각형 */
  box-shadow: 0 3px 10px rgba(8, 145, 178, 0.30);
  transition: transform .08s, box-shadow .15s, filter .15s;
  position: relative;
  text-align: center;
}
.ai-tutor-btn::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(8,145,178,0.30), rgba(14,116,144,0.30));
  filter: blur(6px);
  z-index: -1;
  opacity: 0.55;
  animation: tutorGlow 2.4s ease-in-out infinite;
}
@keyframes tutorGlow {
  0%, 100% { opacity: 0.30; transform: scale(0.98); }
  50%      { opacity: 0.65; transform: scale(1.03); }
}
.ai-tutor-btn:hover { filter: brightness(1.08); box-shadow: 0 5px 14px rgba(8, 145, 178, 0.42); }
.ai-tutor-btn:active { transform: scale(0.96); }
.ai-tutor-icon { font-size: 20px; line-height: 1; display: block; }
.ai-tutor-text { font-size: 10.5px; letter-spacing: -0.3px; line-height: 1.1; display: block; }

@media (max-width: 480px) {
  .ai-tutor-btn {
    padding: 6px 8px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 12px;
  }
  .ai-tutor-icon { font-size: 18px; }
  .ai-tutor-text { font-size: 10px; }
}

/* 관리자 대시보드 내 멤버십 토글 & 제한 편집 */
.admin-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-controls label {
  font-size: 13px;
  color: var(--text-sub);
}
.admin-controls input[type="number"] {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.admin-controls button {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
.admin-controls button:hover { background: var(--primary-dark); }

.toggle-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text-sub);
}
.toggle-btn.on {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.toggle-btn.off {
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  .toggle-btn.on { background: #14532d; border-color: #166534; color: #bbf7d0; }
}

/* 학생/과목 관리 (Phase 4B) */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.course-card.inactive { opacity: .55; }
.course-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.course-card-head h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.course-card .badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.course-card .badge.on { background: #dcfce7; color: #166534; }
.course-card .badge.off { background: var(--bg); color: var(--text-sub); }
@media (prefers-color-scheme: dark) {
  .course-card .badge.on { background: #14532d; color: #bbf7d0; }
}
.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-sub);
}
.course-section {
  font-size: 13px;
  color: var(--text);
}
.course-section strong {
  display: block;
  font-size: 12.5px;
  color: var(--text-sub);
  margin-bottom: 4px;
  font-weight: 600;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}
.chip.empty {
  background: var(--bg);
  color: var(--text-sub);
  border-color: var(--border);
  font-style: italic;
}
.chip.clickable {
  cursor: pointer;
  transition: background 0.12s, transform 0.05s;
}
.chip.clickable:hover {
  background: #bae6fd;
  border-color: #7dd3fc;
}
.chip.clickable:active {
  transform: scale(0.97);
}
.course-roster {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.course-roster .empty {
  font-size: 12.5px;
  color: var(--text-sub);
  font-style: italic;
}
.course-roster-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 2px;
}
/* 시험 정량 입력 필드 */
.exam-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fff7ed;
  border: 1px dashed #fb923c;
  border-radius: 8px;
  margin: 6px 0 8px;
}
.exam-field-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.exam-field-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 600;
}
.exam-field-row label.grow { flex: 1 1 200px; }
.exam-field-row input,
.exam-field-row select {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-weight: 400;
  color: var(--text);
}
.exam-field-row input[type="number"] { width: 90px; }
@media (prefers-color-scheme: dark) {
  .exam-fields { background: #422006; border-color: #c2410c; }
  .exam-field-row input,
  .exam-field-row select { background: #1c1917; color: #fafaf9; }
}
/* 시험 점수 칩 */
.record-exam {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 6px;
}
.exam-chip {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.exam-chip.score {
  background: #d97757;
  color: #fff;
}
.exam-chip.diff {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.exam-chip.round {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}
.exam-chip.course {
  background: #cffafe;
  color: #155e75;
  border: 1px solid #a5f3fc;
}

/* 악령 #2 (2026-04-30): 학생 상세 모달 헤더 — 수강 과목 칩 섹션 */
.student-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 8px;
  font-size: 13px;
}
.student-summary.student-summary-empty {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: var(--text-sub);
}
.ss-label {
  font-weight: 600;
  color: #155e75;
  white-space: nowrap;
}
.ss-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ss-chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 12px;
  background: #fff;
  color: #155e75;
  border: 1px solid #a5f3fc;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
}
.ss-chip:hover {
  background: #cffafe;
  transform: translateY(-1px);
}
.ss-chip:active {
  transform: translateY(0);
}

/* 악령 #1 (2026-04-30): 학생 상세 모달 — 챗봇 활동 카운트 바 + 인라인 미리보기 패널 */
.student-activity-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
}
.sa-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, transform 0.06s;
}
.sa-btn:hover:not(:disabled) {
  background: #fed7aa;
}
.sa-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.sa-count {
  background: #d97757;
  color: #fff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11.5px;
  min-width: 22px;
  text-align: center;
}
.sa-hint {
  font-size: 11.5px;
  color: var(--text-sub);
  margin-left: auto;
}
.student-activity-panel {
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.sa-panel-head {
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  /* 불투명 배경 명시 — sticky 시 아래 행과 글자 겹침 방지 */
  background: #fff7ed;
  color: #7c2d12;
  border-bottom: 2px solid #fed7aa;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.sa-panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sa-panel-head-actions button {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-weight: 600;
  cursor: pointer;
}
.sa-panel-head-actions button:hover:not(:disabled) {
  background: #fed7aa;
}
.sa-panel-head-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.sa-row-math {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.sa-row-check {
  flex-shrink: 0;
  margin-top: 3px;
  cursor: pointer;
}
.sa-row-content {
  flex: 1;
  min-width: 0;
}
.sa-row-stmt {
  font-size: 13px;
  color: #1f2937;
  margin-top: 4px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.sa-row-stmt strong { color: #d97757; }

/* Phase 8-3 (2026-04-30): [+] 자료 첨부 버튼 (메인 챗봇 composer) */
.attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary, #0891b2);
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, transform 0.08s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attach-btn:hover { background: var(--primary-dark, #0e7490); }
.attach-btn:active { transform: scale(0.93); }
.composer-form {
  /* 기존 form-flex 패턴이 [+] · textarea · 전송 3개를 잘 정렬해야 함.
     기존 스타일이 이미 flex 라면 별도 변경 없이 동작. 안전하게 align-items 명시. */
  align-items: flex-end;
}

/* Phase 8-3: 관리자 학생 자료 탭 — 그룹·행·배지 */
.up-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.up-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.up-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 14px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
.up-group-head small { color: var(--text-sub); font-size: 11.5px; }
.up-group-list { display: flex; flex-direction: column; }
.up-row {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
}
.up-row:last-child { border-bottom: none; }
.up-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.up-row-meta {
  color: var(--text-sub);
  font-size: 11.5px;
  margin-left: auto;
}
.up-row-note {
  margin-top: 6px;
  font-size: 12.5px;
  color: #1f2937;
  background: #fef9c3;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px dashed #fde047;
}
.up-row-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.up-row-actions button {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.up-row-actions .up-download {
  background: #d97757;
  color: #fff;
  border: 1px solid #d97757;
}
.up-row-actions .up-download:hover:not(:disabled) { background: #c2410c; }
.up-row-actions .up-download:disabled { opacity: 0.6; cursor: wait; }
.up-row-actions .up-delete {
  background: #fff;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.up-row-actions .up-delete:hover { background: #fee2e2; }
.up-new-badge {
  background: #d97757;
  color: #fff;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.up-stor {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}
.up-stor-gd {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.up-stor-local {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

/* Phase 8-3: 자료 미리보기 모달 — 이미지·PDF 뷰어 */
.up-row-actions .up-preview {
  background: #fff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}
.up-row-actions .up-preview:hover {
  background: #cffafe;
}
.up-preview-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 12px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 12px;
  font-size: 13px;
}
.up-preview-meta-mime {
  color: var(--text-sub);
  font-size: 11.5px;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 8px;
}
.up-preview-meta .up-preview-dl {
  margin-left: auto;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  background: #d97757;
  color: #fff;
  border: 1px solid #d97757;
  cursor: pointer;
  font-weight: 600;
}
.up-preview-meta .up-preview-dl:hover {
  background: #c2410c;
}
.up-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.up-preview-image {
  padding: 12px;
  max-height: 75vh;
}
.up-preview-image img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
}
.up-preview-pdf {
  height: 75vh;
  padding: 0;
}
.up-preview-pdf iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* ════════════════════════════════════════════════════
   Phase 9 (2026-05-01) — 숙제 모니터링 (관리자 UI)
   ════════════════════════════════════════════════════ */
.hw-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.hw-filter-chip {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #d4d4d8;
  color: #52525b;
  cursor: pointer;
  font-weight: 500;
}
.hw-filter-chip.active {
  background: #0e7490;
  color: #fff;
  border-color: #0e7490;
}
.hw-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.hw-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hw-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.hw-card-head strong { font-size: 14px; }
.hw-meta-line { font-size: 12px; color: var(--text-sub); }
.hw-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.hw-card-actions button {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  border: 1px solid #d4d4d8;
  background: #fff;
}
.hw-card-actions .primary {
  background: #d97757; color: #fff; border-color: #d97757;
}
.hw-card-actions .hw-publish {
  background: #16a34a; color: #fff; border-color: #16a34a;
}
.hw-card-actions .danger {
  background: #fff; color: #991b1b; border-color: #fecaca;
}
.hw-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 700;
}
.hw-badge-draft     { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.hw-badge-published { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.hw-badge-closed    { background: #e5e7eb; color: #374151; }

/* 등록 모달 */
.hw-create-form .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.hw-create-form .field > span { font-size: 11.5px; color: var(--text-sub); font-weight: 600; }
.hw-create-form .field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-create-form .field-row .field { flex: 1; min-width: 140px; }
.hw-create-actions { display: flex; gap: 8px; margin-top: 10px; }
.hw-create-actions .primary { background: #d97757; color: #fff; border: 1px solid #d97757; padding: 7px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.hw-create-actions button:not(.primary) { background: #fff; border: 1px solid #d4d4d8; padding: 7px 14px; border-radius: 6px; cursor: pointer; }

/* 편집 모달 */
.hw-edit-summary { padding: 8px 12px; background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 8px; margin-bottom: 12px; }
.hw-analyze-box { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 12px; }
.hw-analyze-box h4 { margin: 0 0 6px; color: #9a3412; }
.hw-analyze-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.hw-analyze-row input[type=text] { flex: 1; min-width: 200px; padding: 5px 8px; border: 1px solid #d4d4d8; border-radius: 5px; }
.hw-analyze-row .primary { background: #d97757; color: #fff; border: 1px solid #d97757; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.hw-analyze-replace { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.hw-analyze-status { margin-top: 10px; padding: 10px; background: #fff; border-radius: 6px; }
.hw-success { color: #065f46; font-weight: 600; }

/* 문항 그리드 */
.hw-prob-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.hw-prob-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hw-prob-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.hw-prob-head strong { color: #0e7490; }
.hw-prob-kind { background: #e0e7ff; color: #3730a3; padding: 1px 6px; border-radius: 8px; font-size: 10.5px; }
.hw-prob-points { margin-left: auto; color: var(--text-sub); font-size: 11px; }
.hw-prob-verify { font-size: 10.5px; padding: 1px 6px; border-radius: 8px; font-weight: 700; }
.hw-prob-verify.ok { background: #d1fae5; color: #065f46; }
.hw-prob-verify.auto { background: #fef3c7; color: #92400e; }
.hw-prob-verify.none { background: #fee2e2; color: #991b1b; }
.hw-prob-img-wrap {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hw-prob-img { max-width: 100%; max-height: 220px; object-fit: contain; display: block; }
.hw-prob-meta { display: flex; gap: 4px; flex-wrap: wrap; }
.hw-prob-tag { font-size: 10.5px; background: #f3f4f6; color: #1f2937; padding: 2px 6px; border-radius: 6px; }
.hw-prob-actions { display: flex; gap: 4px; }
.hw-prob-actions button { font-size: 11px; padding: 3px 8px; border-radius: 5px; border: 1px solid #d4d4d8; background: #fff; cursor: pointer; }

/* 문항 편집 폼 */
.hw-prob-edit .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.hw-prob-edit .field > span { font-size: 11.5px; color: var(--text-sub); font-weight: 600; }
.hw-prob-edit .field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-prob-edit .field-row .field { flex: 1; min-width: 100px; }
.hw-prob-edit .grow { flex-grow: 2; }
.hw-prob-edit-actions { display: flex; gap: 8px; }
.latex-preview {
  margin-top: 4px; padding: 8px 10px;
  background: #f0f9ff; border: 1px dashed #7dd3fc; border-radius: 6px;
  font-size: 14px; color: #0c4a6e; line-height: 1.7;
  word-break: break-word; overflow-x: auto;
}
.latex-preview::before {
  content: '👁 미리보기'; display: block;
  font-size: 10.5px; color: #0891b2; font-weight: 700; letter-spacing: 0.3px;
  margin-bottom: 4px; text-transform: uppercase;
}
.latex-preview .katex { font-size: 1.05em; }

/* ── OMR 카드 + 정답지 자동 인식 (Phase 9, 2026-05-02) ── */
.omr-wrap { padding: 4px; }
.omr-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.omr-table th { background: #f1f5f9; padding: 8px; text-align: left; border-bottom: 2px solid #cbd5e1; }
.omr-table td { padding: 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.omr-table code { background: #f8fafc; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.omr-kind { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.omr-kind-multiple_choice { background: #dbeafe; color: #1e40af; }
.omr-kind-short_answer    { background: #fef3c7; color: #92400e; }
.omr-kind-ox              { background: #ede9fe; color: #6b21a8; }
.omr-warn { color: #991b1b; font-size: 12px; margin-top: 3px; }

.omr-list { display: flex; flex-direction: column; gap: 6px; }
.omr-row {
  display: grid;
  grid-template-columns: 50px 110px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.omr-row .omr-num { font-weight: 700; color: #0e7490; font-size: 14px; }
.omr-row .omr-kind-sel { padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12.5px; }
.omr-input-area { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.omr-radio-mc, .omr-radio-ox { display: flex; gap: 4px; }
.omr-radio-lbl {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 6px; background: #fff; border: 1px solid #cbd5e1; border-radius: 4px;
  cursor: pointer; font-size: 13px;
}
.omr-radio-lbl input { margin: 0; cursor: pointer; }
.omr-radio-lbl:has(input:checked) { background: #cffafe; border-color: #0891b2; font-weight: 600; }
.omr-short {
  width: 200px; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 4px;
  font-size: 13px; font-family: 'Courier New', monospace;
}
.omr-short.omr-short-invalid { border-color: #dc2626; background: #fef2f2; }
.omr-row .omr-meta { grid-column: 1 / -1; font-size: 11.5px; color: #64748b; padding-left: 60px; }

/* 학생 단답형 입력 검증 */
.hw-short.hw-short-invalid { border-color: #dc2626; background: #fef2f2; }

/* ── 이미지 모음 → 숙제장 (Phase 9-비용, 2026-05-03) ── */
.from-img-drop {
  border: 2px dashed #fbbf24; border-radius: 8px;
  padding: 14px; background: #fffbeb;
  margin-bottom: 8px;
}
.from-img-drop.drag { background: #fef3c7; border-color: #d97706; }
.from-img-hint { font-size: 12px; color: #78716c; margin-top: 6px; }
.from-img-list {
  margin-top: 10px; max-height: 280px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.from-img-empty { color: #a8a29e; font-size: 12px; text-align: center; padding: 8px; }
.from-img-row {
  display: grid; grid-template-columns: 30px 1fr 80px 28px;
  gap: 6px; padding: 5px 8px;
  background: #fff; border: 1px solid #e7e5e4; border-radius: 5px;
  font-size: 12.5px; align-items: center;
}
.from-img-num { font-weight: 700; color: #d97706; }
.from-img-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.from-img-size { color: #78716c; font-size: 11px; }
.from-img-rm {
  background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
  border-radius: 4px; cursor: pointer; padding: 0; font-weight: 700;
}
.from-img-replace {
  display: block; margin: 8px 0; font-size: 12.5px; color: #57534e;
}
.from-img-result { padding: 12px; background: #f0fdf4; border: 1px solid #86efac; border-radius: 8px; }
.from-img-result h4 { color: #14532d; }
.from-img-result ul { margin: 8px 0; padding-left: 20px; line-height: 1.8; }
.hw-prob-edit-actions .primary { background: #0891b2; color: #fff; border: 1px solid #0891b2; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; }

/* 발행 모달 */
.hw-publish-summary { padding: 10px 12px; background: #ecfeff; border-radius: 8px; margin-bottom: 8px; }
.hw-publish-actions { display: flex; gap: 6px; margin: 8px 0; }
.hw-publish-actions button { font-size: 11.5px; padding: 4px 10px; border-radius: 12px; background: #fff; border: 1px solid #d4d4d8; cursor: pointer; }
.hw-student-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
}
.hw-student-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}
.hw-student-row:hover { background: #f9fafb; }
.hw-student-row small { color: var(--text-sub); margin-left: auto; }
.hw-publish-final { display: flex; gap: 8px; margin-top: 10px; }
.hw-publish-final .primary { background: #16a34a; color: #fff; border: 1px solid #16a34a; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 700; }

/* ════════════════════════════════════════════════════
   Phase 9 — 학생 메인 챗봇 카드 + 풀이 페이지 (homework.html)
   ════════════════════════════════════════════════════ */

/* 메인 챗봇 — 진행 중 숙제 카드 */
.hw-home-wrap { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.hw-home-title { font-size: 13px; color: #0e7490; font-weight: 700; padding: 0 4px; }
.hw-home-card {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hw-home-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.hw-home-card-head strong { font-size: 13.5px; color: #155e75; }
.hw-home-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 11.5px; color: #475569;
}
.hw-home-card-pill, .hw-card-pill {
  font-size: 10.5px; padding: 2px 8px; border-radius: 8px; font-weight: 700;
}
.hw-card-pill.new      { background: #fef3c7; color: #92400e; }
.hw-card-pill.progress { background: #cffafe; color: #155e75; }
.hw-card-pill.done     { background: #d1fae5; color: #065f46; }
.hw-card-pill.overdue  { background: #fee2e2; color: #991b1b; }
.hw-home-progress {
  height: 4px; background: rgba(255,255,255,0.6);
  border-radius: 2px; overflow: hidden;
}
.hw-home-progress-fill {
  height: 100%; background: #0891b2;
  transition: width 0.3s;
}
.hw-card-btn {
  display: block; text-align: center; text-decoration: none;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600;
  background: #fff; color: #0e7490; border: 1px solid #a5f3fc;
  margin-top: 2px;
}
.hw-card-btn.primary { background: #0891b2; color: #fff; border-color: #0891b2; }

/* homework.html — 풀이 페이지 */
.hw-body { background: #f9fafb; min-height: 100vh; }
.hw-main {
  max-width: 920px; margin: 0 auto;
  padding: 14px;
  padding-bottom: 80px;  /* submit-bar 공간 */
}
.hw-progress-bar {
  position: sticky; top: 0; z-index: 10;
  background: #fff; padding: 10px 12px;
  border: 1px solid #e5e7eb; border-radius: 8px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.hw-progress-track { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.hw-progress-fill { height: 100%; background: linear-gradient(90deg, #0891b2, #16a34a); transition: width 0.4s; }
.hw-progress-label { font-size: 12px; color: #475569; margin-top: 5px; text-align: center; }

.hw-instructions {
  background: #fef9c3; border: 1px dashed #fde047;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
  font-size: 13px; line-height: 1.6;
}

/* 2026-05-05 — 해설지 잠금 카드 (제출률 80% 도달 시 해제) */
.hw-solution-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.hw-solution-card .hw-sol-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  color: #134e4a;
  line-height: 1.55;
}
.hw-solution-card .hw-sol-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.hw-solution-card .hw-sol-text strong { color: var(--turkey-700, #0e7490); }

.hw-sol-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f1f5f9;
  color: #94a3b8;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: not-allowed;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.hw-sol-btn.unlocked {
  background: linear-gradient(135deg, #14b8a6 0%, #0e7490 100%);
  border-color: #0e7490;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(14,116,144,0.3);
}
.hw-sol-btn.unlocked:hover { transform: translateY(-1px); box-shadow: 0 3px 6px rgba(14,116,144,0.4); }
.hw-sol-btn.unlocked:active { transform: scale(0.98); }
.hw-sol-btn-icon { font-size: 15px; }

@media (prefers-color-scheme: dark) {
  .hw-solution-card { background: #134e4a; border-color: #115e59; }
  .hw-solution-card .hw-sol-text { color: #ccfbf1; }
  .hw-sol-btn { background: #1f2937; border-color: #334155; color: #64748b; }
}
@media (max-width: 540px) {
  .hw-solution-card { padding: 10px 12px; font-size: 12.5px; }
  .hw-sol-btn { padding: 7px 12px; font-size: 12.5px; }
}
.hw-bot-message {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border: 1px solid #fdba74;
  padding: 14px; border-radius: 10px; margin-bottom: 14px;
  font-size: 13.5px; line-height: 1.7; color: #7c2d12;
  white-space: pre-wrap;
}
.hw-problem-grid {
  /* 짱쌤 요청 (2026-05-02): 학생 폰 화면에서 문항 가로 1.2배 — 280→336 */
  display: grid; grid-template-columns: repeat(auto-fill, minmax(336px, 1fr));
  gap: 12px;
}
.hw-prob {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.hw-prob.mastered { background: #f0fdf4; border-color: #86efac; opacity: 0.85; }
.hw-prob.retry    { background: #fef2f2; border-color: #fca5a5; }
.hw-prob-head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.hw-prob-head strong { color: #0e7490; font-size: 14px; }
.hw-prob-pts { color: var(--text-sub, #64748b); margin-left: auto; }
.hw-state-mastered { background: #d1fae5; color: #065f46; padding: 1px 6px; border-radius: 8px; font-size: 10.5px; font-weight: 700; }
.hw-state-retry    { background: #fee2e2; color: #991b1b; padding: 1px 6px; border-radius: 8px; font-size: 10.5px; font-weight: 700; }
.hw-state-tried    { background: #e0e7ff; color: #3730a3; padding: 1px 6px; border-radius: 8px; font-size: 10.5px; font-weight: 700; }
.hw-state-todo     { background: #f3f4f6; color: #6b7280; padding: 1px 6px; border-radius: 8px; font-size: 10.5px; font-weight: 700; }
/* 짱쌤 요청 (2026-05-02 밤 ③): 학생 페이지 (.hw-main) 한정 selector 로 specificity ↑.
   ⚠ 위쪽 line ~2622 의 .hw-prob-img-wrap 옛 정의(display:flex + max-height:220px)가
   관리자 모달용으로 살아 있어, 같은 specificity 면 학생 화면도 영향받아 가로가 줄어듦.
   → .hw-main 한 단계 specificity 올려 옛 정의 무력화. */
.hw-main .hw-prob-img-wrap {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  overflow: hidden;
  display: block;       /* 옛 flex 무효화 */
  min-height: 0;        /* 옛 min-height 80 무효화 */
  font-size: 0;         /* inline 자식 미세 간격 제거 */
}
.hw-main .hw-prob-img {
  width: 100%; height: auto;
  max-height: none;     /* 옛 max-height 220 무효화 */
  object-fit: initial;  /* 옛 contain 무효화 (width 100% 면 무관하나 명시) */
  display: block;
}
.hw-prob-stmt { font-size: 13px; line-height: 1.6; padding: 4px; white-space: pre-wrap; word-break: break-word; }
/* 짱쌤 요청 (2026-05-02 저녁): 객관식 5지선다는 가로 1줄 배열.
   단답형(.hw-short)은 풀너비로 한 줄, OX 는 가로 2칸. */
.hw-answer-area {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0;
  align-items: stretch;
}
.hw-answer-area[inert] { opacity: 0.55; pointer-events: none; }
.hw-choice {
  flex: 1 1 50px; min-width: 50px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 10px 4px;
  background: #fff;
  border: 1px solid #e5e7eb; border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.hw-choice:hover { background: #f9fafb; }
.hw-choice input[type=radio] { width: 16px; height: 16px; cursor: pointer; }
.hw-choice:has(input:checked) {
  background: #cffafe; border-color: #0891b2;
}
.hw-choice-num { font-weight: 700; color: #0e7490; font-size: 16px; }
/* 가로 배열에서 보기 텍스트는 칸 좁아 숨김 — 짱쌤 PDF 또는 이미지로 학생이 봄 */
.hw-choice-text { display: none; }
.hw-short {
  flex: 1 1 100%;
  width: 100%; padding: 8px 10px;
  border: 1px solid #d4d4d8; border-radius: 6px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
}
.hw-submit-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid #e5e7eb;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  z-index: 20;
}
.hw-submit-bar .hint { flex: 1; font-size: 12px; }
.hw-submit-btn {
  padding: 10px 18px; border-radius: 8px;
  background: #0891b2; color: #fff; border: 1px solid #0891b2;
  font-weight: 700; cursor: pointer;
}
.hw-submit-btn:disabled { background: #9ca3af; border-color: #9ca3af; cursor: not-allowed; }

/* Phase 9 — 보고서 검토 모달 */
.hw-rep-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.hw-rep-row {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
}
.hw-rep-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hw-rep-head strong { font-size: 13.5px; }
.hw-rep-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.hw-rep-actions button {
  font-size: 11.5px; padding: 4px 10px; border-radius: 5px;
  border: 1px solid #d4d4d8; background: #fff; cursor: pointer; font-weight: 600;
}
.hw-rep-actions .primary { background: #16a34a; color: #fff; border-color: #16a34a; }
.hw-rep-actions .danger { color: #991b1b; border-color: #fecaca; }
.hw-rep-badge {
  font-size: 10.5px; padding: 2px 8px; border-radius: 8px; font-weight: 700;
}
.hw-rep-badge.draft     { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.hw-rep-badge.reviewed  { background: #cffafe; color: #155e75; border: 1px solid #a5f3fc; }
.hw-rep-badge.approved  { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.hw-rep-badge.in-weekly { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.hw-card-actions .hw-reports {
  background: #fff; color: #5b21b6; border: 1px solid #ddd6fe;
}
.hw-card-actions .hw-reports:hover { background: #ede9fe; }

/* Phase 9 (2026-05-01): 수동 크롭 모달 (HWPX 클로비스 패턴 이식) */
.mc-controls {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px; background: #faf5ff; border: 1px solid #e9d5ff; border-radius: 8px;
  margin-bottom: 10px;
}
.mc-controls input[type=text] { flex: 1; min-width: 200px; padding: 5px 8px; border: 1px solid #d4d4d8; border-radius: 5px; }
.mc-controls label { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }

.mc-pages-area {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;
  margin-bottom: 10px; padding: 10px;
}
.mc-page-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
  font-size: 13px; color: #475569;
}
.mc-page-nav button {
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  background: #fff; border: 1px solid #d4d4d8;
  font-weight: 600;
}
.mc-page-nav button:disabled { opacity: 0.5; cursor: not-allowed; }
.mc-img-wrap {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 0;  /* viewMode 2: padding 0 으로 좌표계 단순화 */
  height: 70vh;  /* 고정 높이 — Cropper 가 자동 fit (스크롤 X·줌 X 안정) */
  overflow: hidden;
}
.mc-img-wrap img { max-width: 100%; display: block; }

.mc-submit-area {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  position: sticky; bottom: 0; z-index: 10;
}
.mc-submit-area button {
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
  background: #fff; border: 1px solid #d4d4d8; font-weight: 600;
}
.mc-status {
  margin-top: 8px; padding: 10px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
}

/* Phase 9-개정 (2026-05-01): 자동 박스 검출 영역 + 페이지별 오버레이 박스 */
.mc-detect-area {
  background: #ecfeff; border: 1px solid #a5f3fc; border-radius: 8px;
  padding: 10px; margin-bottom: 10px;
}
.mc-detect-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  font-size: 12.5px;
}
.mc-detect-row label { display: inline-flex; align-items: center; gap: 4px; }
.mc-detect-row input[type=number] {
  padding: 2px 4px; border: 1px solid #d4d4d8; border-radius: 4px;
}
.mc-img-wrap { position: relative; }

/* Phase 9-개정 (2026-05-01): cropper-canvas 안에 삽입되는 오버레이.
   canvas 는 자연 이미지 크기로 그려지고 transform: scale 로 축소 → 오버레이도 같이 축소됨.
   따라서 박스 좌표는 자연 픽셀 그대로 사용 (getCanvasData().naturalWidth/Height). */
.mc-overlay {
  position: absolute;
  left: 0; top: 0;
  pointer-events: none;
  /* z-index 는 cropper-modal(z-index:2)·cropper-crop-box(z-index:2) 보다 높게 */
  z-index: 50;
}
.mc-box-overlay {
  position: absolute;
  border: 2px solid #16a34a;
  background: rgba(22, 163, 74, 0.10);
  pointer-events: auto;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, border-color 0.15s;
}
.mc-box-overlay:hover {
  background: rgba(22, 163, 74, 0.22);
  border-color: #15803d;
}
.mc-box-overlay.active {
  border: 3px solid #d97757;
  background: rgba(217, 119, 87, 0.12);
  box-shadow: 0 0 0 2px rgba(217, 119, 87, 0.25);
}
.mc-box-label {
  position: absolute; top: -10px; left: -2px;
  background: #16a34a; color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
}
.mc-box-overlay.active .mc-box-label {
  background: #d97757;
}

/* Phase 9-개정: 박스 칩 (math.html 의 detect-chip 패턴) */
.mc-chips-area {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: 8px; margin: 8px 0;
}
.mc-chips-label { font-size: 12px; color: #7c2d12; font-weight: 600; white-space: nowrap; }
.mc-chips-list { display: flex; gap: 5px; flex-wrap: wrap; }
.mc-chip {
  min-width: 32px; height: 32px;
  border-radius: 50%;
  background: #fff;
  color: #9a3412;
  border: 2px solid #fed7aa;
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  transition: all 0.12s;
  padding: 0 10px;
}
.mc-chip:hover { background: #fed7aa; }
.mc-chip.active {
  background: #d97757; color: #fff; border-color: #d97757;
  transform: scale(1.05);
}

/* Phase 9-개정: 문항 편집창 — 이미지 viewport + 4섹션 + collapse */
.hw-prob-viewport {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.hw-prob-viewport img {
  max-width: 100%; max-height: 50vh; object-fit: contain; display: block;
}
.hw-prob-noimg {
  background: #fef2f2; border: 1px dashed #fca5a5; border-radius: 8px;
  padding: 16px; text-align: center; color: #991b1b; font-size: 13px;
  margin-bottom: 12px;
}
.hw-section-h {
  margin: 16px 0 6px; font-size: 13.5px; color: #0e7490;
  border-bottom: 2px solid #cffafe; padding-bottom: 4px;
}
.hw-collapse {
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 8px 12px; margin: 10px 0;
}
.hw-collapse summary {
  font-size: 12.5px; color: var(--text-sub, #64748b); cursor: pointer;
  font-weight: 600;
}
.hw-collapse[open] summary { margin-bottom: 8px; }
.sa-panel-list {
  display: flex;
  flex-direction: column;
}
.sa-row {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 0.1s;
}
.sa-row:last-child { border-bottom: none; }
.sa-row:hover {
  background: #fff7ed;
}
.sa-row-title { font-size: 13.5px; }
.sa-row-meta {
  font-size: 11.5px;
  color: var(--text-sub);
  margin-top: 2px;
}
.sa-row-preview {
  font-size: 12.5px;
  color: #1f2937;
  margin-top: 4px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.sa-row-math { cursor: default; }
.sa-row-math:hover { background: transparent; }

/* 시험 통계 모달 */
.exam-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.stat-summary-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.stat-summary-card.primary {
  background: linear-gradient(135deg, #0891b2, #0e7490);
  color: #fff;
  border: none;
}
.stat-summary-card .ss-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.stat-summary-card.primary .ss-label { color: #cffafe; }
.stat-summary-card .ss-value {
  font-size: 22px;
  font-weight: 700;
}
.stat-summary-card .ss-sub {
  font-size: 10.5px;
  color: var(--text-sub);
  margin-top: 2px;
}
.stat-summary-card.primary .ss-sub { color: #a5f3fc; }
.stats-section-title {
  font-size: 14px;
  margin: 6px 0 4px;
  color: var(--text);
}
.admin-table.compact th,
.admin-table.compact td {
  padding: 6px 8px;
  font-size: 12.5px;
}
.admin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.rank-badge {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  background: #0891b2;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  margin-right: 6px;
}
/* Phase 7 — 인라인 편집 모드 표시 */
/* hidden 속성이 display:flex를 덮어쓸 수 있도록 명시 (분할 보기와 동일 패턴) */
.editing-badge[hidden] { display: none !important; }
.editing-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: #92400e;
}
.editing-badge strong { font-weight: 600; }
.editing-badge .link-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #fbbf24;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11.5px;
}
.editing-badge .link-btn:hover { background: #fbbf24; color: #fff; }
@media (prefers-color-scheme: dark) {
  .editing-badge { background: #422006; border-color: #d97706; color: #fde68a; }
  .editing-badge .link-btn { border-color: #d97706; color: #fde68a; }
}
/* 편집 버튼 (✏️) */
.edit-rec, .edit-trec, .edit-comment {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.12s, background 0.12s;
}
.edit-rec:hover, .edit-trec:hover, .edit-comment:hover {
  opacity: 1;
  background: #fef3c7;
}
/* 연락처 정보 컬럼 */
.contact-row {
  font-size: 12.5px;
  line-height: 1.4;
  padding: 1px 0;
}
.col-contacts { min-width: 200px; }
.muted { color: var(--text-sub); font-style: italic; }
.contact-input {
  font-size: 12.5px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 110px;
  background: #fff;
  color: var(--text);
}
@media (prefers-color-scheme: dark) {
  .contact-input { background: #1c1917; color: #fafaf9; }
}
/* 학생 폼 row 레이아웃 */
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.form-row .form-col { flex: 1 1 140px; min-width: 0; }
.form-section-title {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
}
/* Phase 7 — 풀이 결과 헤더 액션 + PDF 인쇄용 영역 */
.result-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.print-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 2px solid var(--turkey-700, #0e7490);
  margin-bottom: 14px;
}
.print-header h1 {
  margin: 0;
  font-size: 20px;
  color: var(--turkey-700, #0e7490);
}
.print-meta {
  font-size: 12.5px;
  color: var(--text-sub);
}
.print-image-wrap {
  margin: 8px 0 16px;
  text-align: center;
}
.print-image-wrap img {
  max-width: 100%;
  max-height: 400px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Phase 7-2 — 풀이 결과 분할 보기 (문제 위 고정 + 해설 독립 스크롤) */
/* hidden 속성이 display:flex를 덮어쓸 수 있도록 명시 */
.result-split[hidden],
.result-text[hidden],
.split-pane[hidden] { display: none !important; }
.result-split {
  display: flex;
  flex-direction: column;
  /* 화면 높이의 일정 비율 — 헤더·메뉴·메타 제외 영역 */
  height: calc(100vh - 240px);
  min-height: 360px;
  max-height: 900px;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.split-pane {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 위쪽 padding은 sticky 라벨이 흡수 — 라벨 위 빈 공간으로 콘텐츠 비침 방지 (2026-05-05) */
  padding: 0 14px 14px;
}
.split-pane.split-problem {
  /* 기본 30% — divider 드래그로 변경 가능 */
  flex: 0 0 32%;
  background: linear-gradient(180deg, #fef9c3 0%, #fefce8 100%);
  border-bottom: none;
}
.split-pane.split-answer {
  flex: 1 1 auto;
  background: #fff;
}
.split-label {
  position: sticky;
  top: 0;
  background: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-sub);
  /* 패널 좌우 padding(14px)을 negative margin으로 흡수 → 좌우 끝까지 라벨이 가림.
     위쪽 10px은 라벨 padding으로 흡수하여 sticky 빈틈 0. */
  margin: 0 -14px 8px;
  padding: 10px 14px 6px;
  border-bottom: 1px dashed var(--border);
  z-index: 2;
}
.split-pane.split-problem .split-label { color: #92400e; }
.split-pane.split-answer  .split-label { color: var(--turkey-700, #0e7490); }
.split-divider {
  height: 8px;
  background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 50%, #e2e8f0 100%);
  cursor: row-resize;
  position: relative;
  flex: 0 0 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  user-select: none;
  touch-action: none;
}
.split-divider::before {
  content: '═══';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #64748b;
  letter-spacing: 1px;
}
.split-divider:hover { background: linear-gradient(180deg, #cbd5e1, #94a3b8 50%, #cbd5e1); }
@media (prefers-color-scheme: dark) {
  .split-pane.split-problem { background: linear-gradient(180deg, #422006 0%, #1c1410 100%); }
  .split-pane.split-problem .split-label { color: #fde68a; }
  .split-pane.split-answer { background: #1f2937; }
  .split-divider { background: linear-gradient(180deg, #334155, #475569 50%, #334155); border-color: #1f2937; }
  .split-divider::before { color: #cbd5e1; }
}

/* Phase 7-3 — 관리자 수학풀이 사용자별 그룹 + PDF 모음 */
.math-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.math-user-group {
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px 12px;
}
.math-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 4px 10px;
  border-bottom: 2px solid var(--turkey-100, #cffafe);
  margin-bottom: 8px;
}
.math-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.math-group-toggle input { transform: scale(1.15); }
.math-group-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.math-group-actions .selected-count {
  font-size: 12px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.save-pdf-btn {
  font-size: 12.5px;
  padding: 6px 12px;
}
.math-row .checkbox-cell { text-align: center; cursor: default; }
.math-row .checkbox-cell input { transform: scale(1.15); cursor: pointer; }
.math-row .clickable-cell { cursor: pointer; }
.math-row .clickable-cell:hover { color: var(--turkey-700, #0e7490); text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  .math-user-group { background: #1f2937; }
  .math-group-head { border-bottom-color: #164e63; }
}

/* 인쇄 시 분할 컨테이너는 자연 흐름으로 (overflow/height 제한 해제) */
@media print {
  .result-split,
  .split-pane,
  .split-divider {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border: none !important;
    background: #fff !important;
    page-break-inside: auto;
  }
  .split-divider { display: none !important; }
  .split-label {
    position: static !important;
    color: #0e7490 !important;
    border-bottom: 1px solid #ccc !important;
  }
  /* 토글·PDF·새문제 버튼 인쇄 시 숨김 (이미 result-head-actions에 포함됨) */
  #toggleSplitBtn { display: none !important; }
}

/* ── 인쇄(=PDF 저장) 전용 ── */
@media print {
  /* 인쇄 시 페이지 전체 흰 배경, 검정 글씨 강제 */
  body, .app-body {
    background: #fff !important;
    color: #000 !important;
  }
  /* 헤더·업로드·메뉴·버튼·메타 다 숨김 (결과 섹션만 남김) */
  .app-header,
  #uploadSection,
  .result-head-actions,
  .result-meta,
  #errorMsg,
  .dropdown,
  .auth-error {
    display: none !important;
  }
  .result-head h2 {
    display: none !important;  /* 인쇄용 헤더로 대체됨 */
  }
  .result-section {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .print-header,
  .print-image-wrap {
    display: block !important;
  }
  .result-text {
    color: #000 !important;
    font-size: 12pt !important;
    line-height: 1.5 !important;
  }
  .result-text h1, .result-text h2, .result-text h3, .result-text h4 {
    color: #0e7490 !important;
    page-break-after: avoid;
  }
  .result-text pre, .result-text code {
    background: #f5f5f5 !important;
    color: #000 !important;
    border: 1px solid #ddd;
  }
  /* 페이지 여백 조정 */
  @page {
    size: A4;
    margin: 15mm 12mm;
  }
}
.student-link:hover { color: var(--turkey-700, #0e7490); text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  .stat-summary-card { background: #1f2937; border-color: #374151; }
}
@media (prefers-color-scheme: dark) {
  .chip { background: #164e63; color: #cffafe; border-color: #155e75; }
}
.course-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.course-actions button {
  padding: 5px 11px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.course-actions button.match-course {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.course-actions button.delete-course.danger {
  border-color: #fecaca;
  color: #b91c1c;
}
.admin-table .edit-student,
.admin-table .delete-student {
  padding: 4px 10px;
  font-size: 12.5px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.admin-table .delete-student.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

/* ════════════════════════════════════════════════
   2026-05-04 — "내 질문 모음" (학생 본인 수학 질의 조회)
   ════════════════════════════════════════════════ */
.myq-list-section {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 12px 60px;
}
.myq-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.myq-search {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg, #fff);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.myq-search:focus { border-color: var(--turkey-700, #0e7490); }
.myq-date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
}
.myq-date-lbl {
  font-weight: 600;
  color: var(--text-sub);
  font-size: 13px;
}
.myq-date {
  padding: 7px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg, #fff);
  color: var(--text);
}
.myq-date-sep { color: var(--text-sub); }
.myq-reset {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.myq-reset:hover { background: var(--bg-elev, #f1f5f9); }

.myq-list-meta {
  font-size: 13px;
  color: var(--text-sub);
  padding: 4px 6px 10px;
}
.myq-list-meta strong { color: var(--turkey-700, #0e7490); }

.myq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.myq-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 14px;
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.myq-card:hover {
  border-color: var(--turkey-700, #0e7490);
  box-shadow: 0 4px 10px rgba(8, 145, 178, 0.08);
}
.myq-card:active { transform: scale(0.995); }
.myq-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.myq-card-date {
  font-size: 12.5px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}
.myq-card-style {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
}
.myq-card-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  /* KaTeX inline-block과 line-clamp는 호환이 좋지 않아 max-height + fade로 처리 */
  position: relative;
  max-height: 4.65em;     /* 약 3줄 */
  min-height: 3em;
  overflow: hidden;
  word-break: break-word;
}
.myq-card-body::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1.4em;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, var(--bg-elev, #fff) 92%);
  pointer-events: none;
}
/* 카드 안 KaTeX 수식은 인라인 모드 — 폰트 크기 살짝 보정 */
.myq-card-body .katex { font-size: 1em; }
.myq-card-body .katex-display { display: inline; margin: 0; }
.myq-card-foot {
  text-align: right;
  font-size: 12.5px;
  color: var(--turkey-700, #0e7490);
  font-weight: 600;
}

.myq-empty,
.myq-empty-search {
  padding: 30px 20px;
  text-align: center;
  background: var(--bg-elev, #fff);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-sub);
}
.myq-empty strong { display: block; font-size: 16px; color: var(--text); margin-bottom: 6px; }
.myq-empty p { margin: 4px 0 14px; font-size: 13.5px; }

.myq-loadmore-wrap {
  text-align: center;
  margin-top: 18px;
}

/* 상세 화면 */
.myq-detail-section {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 12px 60px;
}
.myq-detail-section .result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.myq-detail-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.myq-detail-head-left h2 { margin: 0; font-size: 17px; }
.myq-detail-meta {
  font-size: 12.5px;
  color: var(--text-sub);
  margin-bottom: 12px;
  padding: 6px 10px;
  background: var(--bg-elev, #f8fafc);
  border-radius: 6px;
}

@media (prefers-color-scheme: dark) {
  .myq-toolbar { background: #1f2937; }
  .myq-card { background: #1f2937; }
  .myq-card-style { background: #422006; color: #fde68a; }
  .myq-card-body::after {
    background: linear-gradient(to bottom, rgba(31,41,55,0) 0%, #1f2937 92%);
  }
  .myq-empty,
  .myq-empty-search,
  .myq-detail-meta { background: #1f2937; color: #94a3b8; }
}

/* 모바일 — 카드 1열 + 검색·날짜 줄 줄임 */
@media (max-width: 540px) {
  .myq-grid { grid-template-columns: 1fr; }
  .myq-search { font-size: 14px; padding: 10px 12px; }
  .myq-date { font-size: 13px; padding: 6px 8px; }
  .myq-detail-section .result-head { gap: 8px; }
  .myq-detail-head-left h2 { font-size: 15px; }
}

/* 인쇄 — 상세 모드만 살리고 목록·검색·메뉴·메타·헤더 모두 숨김 */
@media print {
  #listSection,
  .myq-detail-section .result-head,
  .myq-detail-meta {
    display: none !important;
  }
  .myq-detail-section {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
}

/* CSV 업로드 모달 (Phase 4G) */
.csv-import { display: flex; flex-direction: column; gap: 14px; }
.csv-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}
.csv-info h4 { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.csv-info ul { margin: 4px 0 8px; padding-left: 18px; color: var(--text-sub); }
.csv-info ul li { margin: 2px 0; line-height: 1.5; }
.csv-info code {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 12px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.csv-upload-box { display: flex; }
.csv-drop {
  flex: 1;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.csv-drop:hover { border-color: var(--primary); background: var(--bg); }
.csv-icon { font-size: 28px; }
.csv-drop strong { font-size: 14px; color: var(--text); }
.csv-drop small { font-size: 12px; color: var(--text-sub); }
.csv-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.csv-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.csv-stat {
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
}
.csv-stat.inserted { background: #dcfce7; color: #166534; }
.csv-stat.updated { background: #dbeafe; color: #1e40af; }
.csv-stat.skipped { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) {
  .csv-stat.inserted { background: #14532d; color: #bbf7d0; }
  .csv-stat.updated { background: #1e3a8a; color: #bfdbfe; }
  .csv-stat.skipped { background: #78350f; color: #fde68a; }
}
.csv-stat-val { font-size: 22px; font-weight: 700; }
.csv-stat-label { font-size: 11.5px; font-weight: 600; margin-top: 2px; }
.csv-errors {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 12.5px;
  color: #7f1d1d;
}
.csv-errors ul { margin: 4px 0 0; padding-left: 18px; }
@media (prefers-color-scheme: dark) {
  .csv-errors { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
}

/* 학생/강사 상세 기록 (타임라인 모달) */
.record-panel { display: flex; flex-direction: column; gap: 12px; }
.record-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.rec-tab {
  padding: 6px 10px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-sub);
  cursor: pointer;
  font-weight: 600;
}
.rec-tab:hover { background: var(--bg); }
.rec-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.record-new {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.record-new input[type="text"],
.record-new textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
.record-new textarea { resize: vertical; min-height: 60px; }
.record-new-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.record-new-row input[type="date"] {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  flex: 1;
}
.record-new-row .primary {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.record-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.record-item {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}
.record-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.record-head strong { flex: 1; color: var(--text); }
.record-date {
  font-size: 11.5px;
  color: var(--text-sub);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
}
.del-rec, .del-trec {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.del-rec:hover, .del-trec:hover { color: #b91c1c; background: #fef2f2; }
.record-body {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.record-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-sub);
}
.dbl-hint {
  font-size: 10.5px;
  color: var(--text-sub);
  font-weight: 400;
  margin-left: 4px;
}
.student-chip, .teacher-chip { cursor: pointer; user-select: none; }
.student-chip:hover, .teacher-chip:hover {
  background: #bae6fd;
  border-color: #7dd3fc;
}
@media (prefers-color-scheme: dark) {
  .student-chip:hover, .teacher-chip:hover {
    background: #1e40af; border-color: #1d4ed8;
  }
}

/* 시간표 편집기 (요일 버튼 + 시간 드롭다운) */
.day-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.day-btn {
  width: 44px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
}
.day-btn:hover { background: var(--bg); }
.day-btn.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.time-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-range select {
  flex: 1;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.time-sep {
  font-size: 16px;
  color: var(--text-sub);
  flex-shrink: 0;
}
.schedule-preview {
  margin-top: 4px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 13px;
}
.schedule-preview strong { color: var(--primary); }
.schedule-fallback {
  margin-top: 6px;
  padding: 8px 10px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12.5px;
  color: #78350f;
}
@media (prefers-color-scheme: dark) {
  .schedule-fallback { background: #422006; border-color: #78350f; color: #fde68a; }
}

/* 강사 멘트 모달 (Phase 4E) */
.comments-panel { display: flex; flex-direction: column; gap: 16px; }
.comment-course {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
}
.comment-course-head h4 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}
.comment-course-head small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-sub);
}
.comment-latest {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}
.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.comment-meta strong { color: var(--primary); font-size: 12.5px; }
.comment-meta .period {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0 6px;
  border-radius: 4px;
}
.comment-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}
.toggle-history {
  margin-top: 6px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.toggle-history:hover { text-decoration: underline; }
.comment-history {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.comment-history-item {
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.del-comment {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
}
.del-comment:hover { color: #b91c1c; }
.comment-new {
  margin-top: 10px;
}
.comment-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
}
.comment-new-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  align-items: center;
}
.comment-new-actions .period-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--bg);
  color: var(--text);
}
.comment-new-actions .save-comment {
  padding: 6px 14px;
  font-size: 12.5px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.admin-table .comment-student {
  padding: 4px 10px;
  font-size: 12.5px;
  margin-right: 4px;
  border: 1px solid #d97757;
  background: #fff7ed;
  color: #9a3412;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* 학부모 승인 탭 (Phase 4D) */
.parents-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}
.parents-section .hint {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 400;
  margin-left: 6px;
}
.admin-table .link-student-select {
  padding: 4px 8px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  margin-right: 6px;
  max-width: 200px;
}
.admin-table .approve-req,
.admin-table .reject-req,
.admin-table .unlink {
  padding: 4px 10px;
  font-size: 12.5px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.admin-table .approve-req.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.admin-table .reject-req.danger,
.admin-table .unlink.danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: var(--surface);
}

/* 로그인 폼 — 가입 추가 필드 */
#registerFields .field { margin-top: 10px; }
#registerFields select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
#registerFields .field-hint {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-sub);
}
#registerFields em { color: var(--text-sub); font-style: normal; font-size: 12px; }

/* 개인정보 동의 섹션 (Phase 4H) */
.consent-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
}
.consent-row input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.consent-row.consent-sub {
  margin-left: 22px;
  padding: 6px 10px;
  background: var(--surface);
  border-radius: 6px;
  border-left: 3px solid #d97757;
}
.consent-row .link-btn {
  font-size: 11.5px;
  margin-left: 6px;
}

/* 약관 모달 (개인정보 동의서) */
.terms-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.terms-overlay[hidden] { display: none !important; }
.terms-card {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.terms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.terms-head h3 { margin: 0; font-size: 15px; color: var(--text); }
.terms-head button {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.terms-head button:hover { background: var(--bg); }
.terms-body {
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.terms-body h4 {
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--primary);
}
.terms-body h4:first-child { margin-top: 0; }
.terms-body ul { padding-left: 18px; margin: 4px 0 4px; }
.terms-body p { margin: 4px 0; }
.terms-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.terms-foot button { width: 100%; }

/* 과목 배정 모달 (Phase 4C) */
.match-section { margin-bottom: 20px; }
.match-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
}
.match-section .hint {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 400;
  margin-left: 6px;
}
.teacher-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 600px) {
  .teacher-slots { grid-template-columns: 1fr; }
}
.teacher-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.teacher-slot label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
}
.teacher-slot select {
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.student-match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) {
  .student-match-grid { grid-template-columns: 1fr; }
}
.student-pool, .student-selected {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  max-height: 360px;
  overflow: hidden;
}
.pool-head {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.pool-search {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.pool-search input {
  width: 100%;
  padding: 6px 10px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.pool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.pool-list li {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pool-list li:last-child { border-bottom: none; }
.pool-list li.empty {
  color: var(--text-sub);
  font-style: italic;
  justify-content: center;
}
.pool-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: 100%;
  font-size: 13px;
}
.pool-list input[type="checkbox"] { flex-shrink: 0; }
.pool-list small {
  display: block;
  font-size: 11.5px;
  color: var(--text-sub);
  margin-top: 1px;
}
.pool-list .remove-sel {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 16px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.pool-list .remove-sel:hover { background: #fef2f2; color: #b91c1c; }

/* 공지사항 관리 폼 (Phase 2 admin) */
.notice-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notice-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-top: 6px;
}
.notice-form input[type="text"],
.notice-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.notice-form textarea { resize: vertical; min-height: 160px; line-height: 1.5; }
.notice-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.notice-form-actions button {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.notice-form-actions button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.notice-body-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.notice-body-toolbar .ghost-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.notice-body-toolbar .ghost-btn:hover { background: var(--bg); }
.notice-attach-list {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
}
.notice-attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.notice-attach-row .ghost-btn.small {
  padding: 2px 8px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 5px;
  cursor: pointer;
}
.notice-attach-row .ghost-btn.small.danger {
  color: #b91c1c;
  border-color: #fca5a5;
}
.admin-table .edit-notice,
.admin-table .delete-notice {
  padding: 4px 10px;
  font-size: 12.5px;
  margin-right: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.admin-table .delete-notice.danger {
  border-color: #fecaca;
  color: #b91c1c;
}
.admin-table .delete-notice.danger:hover { background: #fef2f2; }
.admin-table .push-notice {
  padding: 4px 10px;
  font-size: 12.5px;
  margin-right: 4px;
  border: 1px solid #d97757;
  background: #fff7ed;
  color: #9a3412;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.admin-table .push-notice:hover { background: #ffedd5; }
.admin-table .push-notice:disabled { opacity: 0.6; cursor: wait; }

/* 공지사항 배너 (Phase 2) */
.notice-banner {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.admin-body .notice-banner { max-width: 920px; }
.notice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #fff7ed, #fffbeb);
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: #7c2d12;
  animation: noticeSlideDown .25s ease-out;
}
@keyframes noticeSlideDown {
  from { transform: translateY(-6px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.notice-icon { font-size: 16px; flex-shrink: 0; }
.notice-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.notice-view {
  padding: 4px 10px;
  font-size: 12.5px;
  border: 1px solid #d97757;
  background: #d97757;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
}
.notice-view:hover { background: #b45309; border-color: #b45309; }
.notice-close {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #7c2d12;
  font-size: 18px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.notice-close:hover { background: #fed7aa; }
@media (prefers-color-scheme: dark) {
  .notice-item {
    background: linear-gradient(90deg, #451a03, #422006);
    border-color: #78350f;
    color: #fed7aa;
  }
  .notice-close { color: #fed7aa; }
  .notice-close:hover { background: #78350f; }
}

/* 채팅창 내 공지 메시지 버블 */
.notice-bubble {
  background: linear-gradient(135deg, #fff7ed, #fffbeb);
  border: 1px solid #fed7aa;
  color: #7c2d12;
  border-radius: 14px;
  padding: 12px 16px;
  max-width: 80%;
}
.notice-msg-head {
  font-weight: 700;
  margin-bottom: 6px;
  color: #b45309;
  font-size: 13.5px;
}
.notice-msg-body {
  font-size: 14px;
  line-height: 1.55;
}
@media (prefers-color-scheme: dark) {
  .notice-bubble {
    background: linear-gradient(135deg, #451a03, #422006);
    border-color: #78350f;
    color: #fed7aa;
  }
  .notice-msg-head { color: #fdba74; }
}

/* 역할/한도 편집 UI (Phase 1) */
.role-defaults, .users-block { margin-bottom: 22px; }
.role-defaults h3, .users-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}
.role-defaults .hint, .users-block .hint {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 400;
  margin-left: 6px;
}
.admin-table.compact td, .admin-table.compact th {
  padding: 6px 10px;
  font-size: 13px;
}
.admin-table .limit-input,
.admin-table .def-input {
  width: 110px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.admin-table .limit-input::placeholder,
.admin-table .def-input::placeholder {
  color: var(--text-sub);
  font-size: 11.5px;
}
.admin-table .role-select {
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-sub);
  cursor: pointer;
}
.admin-controls button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ══════════════════════════════════════════════════
   관리자 — 브랜딩 탭
   ══════════════════════════════════════════════════ */
.branding-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.branding-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.branding-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
}
.branding-logo-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.branding-logo-preview {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.branding-logo-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}
.file-picker { display: inline-block; }
.file-picker-btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.file-picker-btn:hover { background: var(--border); }
.primary-btn {
  padding: 9px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.primary-btn:hover:not(:disabled) { background: var(--primary-dark); }
.primary-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.secondary-btn {
  padding: 9px 16px;
  background: var(--surface);
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.secondary-btn:hover { background: var(--bg); color: var(--text); }
.branding-help {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.45;
}
.branding-text-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.branding-text-form input[type="text"],
.branding-text-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  outline: none;
}
.branding-text-form input:focus,
.branding-text-form textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.branding-text-form textarea {
  resize: vertical;
  min-height: 54px;
  line-height: 1.5;
}

/* 미리보기 카드 — 실제 헤더와 유사하게 */
.branding-preview-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px dashed var(--primary);
}
.branding-preview-card img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
}
.preview-texts { min-width: 0; }
.preview-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: pre-line;
  line-height: 1.2;
}
.preview-tagline {
  font-size: 12px;
  color: var(--text-sub);
  white-space: pre-line;
  line-height: 1.35;
}

/* ══════════════════════════════════════════════════════
   Phase 8-2A 후속 — 정보 패널 슬라이드 다운/업 토글
   ══════════════════════════════════════════════════════ */
.info-toggle {
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(180deg, var(--surface) 0%, rgba(255,255,255,0.96) 100%);
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.info-toggle:hover { background: var(--bg); }
.info-toggle:active { background: #e0f2fe; }
.info-toggle-arrow {
  display: inline-block;
  font-size: 10px;
  transition: transform .25s ease;
}
.info-toggle.open .info-toggle-arrow {
  transform: rotate(180deg);
}
.info-toggle-label { line-height: 1; }
.info-toggle-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
}
.info-toggle.open .info-toggle-label::after {
  content: " · 닫기";
  font-weight: 500;
  opacity: 0.7;
}

.info-panel {
  max-width: 720px;
  margin: 0 auto;
  max-height: 0;
  overflow: hidden;
  transition: max-height .32s ease, opacity .2s ease;
  opacity: 0;
}
.info-panel.open {
  max-height: 78vh;
  overflow-y: auto;
  opacity: 1;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border);
}
.info-panel.open::-webkit-scrollbar { width: 6px; }
.info-panel.open::-webkit-scrollbar-thumb {
  background: rgba(8, 145, 178, 0.25);
  border-radius: 3px;
}

@media (max-width: 480px) {
  .info-panel.open { max-height: 70vh; }
  .info-toggle { padding: 7px 12px; font-size: 12.5px; }
}

/* ══════════════════════════════════════════════════════
   Phase 8-2B — 클립북 카드 + 모달
   ══════════════════════════════════════════════════════ */
.cb-cards-wrap { display: flex; flex-direction: column; gap: 8px; }
.cb-card-block {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.10);
}
.cb-card-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; margin-bottom: 8px; color: #78350f;
}
.cb-card-head .hint { font-size: 12px; color: #92400e; font-weight: 500; }
.cb-card-hint {
  font-size: 12.5px; color: #78350f; margin: 6px 0 8px;
}
.cb-card-btn {
  width: 100%;
  padding: 8px 10px;
  background: #d97706; color: white;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.cb-card-btn:hover { background: #b45309; }
.cb-card-btn:active { transform: scale(0.98); }

.cb-progress-bar {
  width: 100%; height: 6px;
  background: rgba(146, 64, 14, 0.15);
  border-radius: 3px; overflow: hidden;
}
.cb-progress-bar.lg { height: 10px; margin: 6px 0 12px; }
.cb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  transition: width .3s ease;
}

/* 모달 내부 */
.cb-modal-summary {
  font-size: 14px; padding: 8px 10px; color: var(--text);
  background: #fffbeb; border-radius: 8px; margin-bottom: 4px;
}
.cb-modal-note {
  font-size: 12px; padding: 6px 10px;
  background: #f0f9ff; border-radius: 6px; margin: 6px 0 10px;
}
.cb-groups { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.cb-unit-group { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cb-unit-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: #f9fafb;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.cb-unit-head .hint { font-size: 12px; color: var(--text-sub); }
.cb-unit-items { display: flex; flex-direction: column; gap: 8px; padding: 10px; }

.cb-problem {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  background: var(--surface);
  border-left: 3px solid #d97706;
}
.cb-problem.mastered {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-left-color: #059669;
  opacity: 0.95;
}
.cb-prob-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.cb-prob-no {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--bg);
  font-size: 12px; font-weight: 700; color: var(--text-sub);
}
.cb-state {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.cb-state.active { background: #fee2e2; color: #b91c1c; }
.cb-state.mastered { background: #d1fae5; color: #047857; }
.cb-prob-stmt {
  font-size: 14px; line-height: 1.5; margin-bottom: 8px;
  white-space: pre-wrap; color: var(--text);
}
.cb-last-result {
  font-size: 11.5px; padding: 4px 8px; border-radius: 6px;
  margin-bottom: 6px; display: inline-block;
}
.cb-last-result.ok { background: #d1fae5; color: #047857; }
.cb-last-result.bad { background: #fee2e2; color: #b91c1c; }

.cb-choices-wrap { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.cb-choice {
  text-align: left; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); font-size: 13.5px;
  cursor: pointer; transition: all .12s;
}
.cb-choice:hover { background: var(--bg); }
.cb-choice.selected {
  background: #fef3c7; border-color: #d97706; color: #78350f; font-weight: 600;
}

.cb-input-row { display: flex; gap: 6px; margin-bottom: 6px; }
.cb-short-input {
  flex: 1; padding: 7px 10px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.cb-short-input:focus { outline: none; border-color: #d97706; }

.cb-retry-btn {
  padding: 7px 14px;
  background: #d97706; color: white;
  border: none; border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.cb-retry-btn:hover:not(:disabled) { background: #b45309; }
.cb-retry-btn:disabled { background: #9ca3af; cursor: not-allowed; }

.cb-explanation {
  margin-top: 8px; padding: 8px 10px;
  background: #ecfdf5; border-radius: 6px;
  font-size: 12.5px; line-height: 1.5; color: #065f46;
}

.cb-toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(17, 24, 39, 0.92); color: white;
  padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.cb-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 학부모용 주간 리포트 카드 + 모달
   ══════════════════════════════════════════════════════ */
.weekly-report-area {
  padding: 10px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wr-card {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
  border: 1px solid #a5f3fc;
  border-left: 4px solid #0891b2;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 6px rgba(8, 145, 178, 0.08);
}
.wr-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.16);
}
.wr-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 8px;
}
.wr-card-title {
  font-weight: 700;
  font-size: 15px;
  color: #0e7490;
}
.wr-card-period {
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
}
.wr-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.wr-chip {
  background: white;
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  color: #0e7490;
  white-space: nowrap;
}
.wr-card-cta {
  margin-top: 8px;
  font-size: 12px;
  color: #0891b2;
  text-align: right;
}

/* 누적 공지함 카드 */
.notice-history-card { cursor: pointer; }
.notice-history-card:hover { background: var(--bg); }

/* 🎫 내 질문권 카드 */
.bonus-quota-card { cursor: pointer; }
.bonus-quota-card:hover { background: var(--bg); }
.quota-bonus-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  background: #fef2f2;
  color: #d97757;
  border: 1px solid #fca5a5;
  border-radius: 999px;
}

/* 질문권 모달 내부 */
.bq-section {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.bq-section:last-child { border-bottom: none; }
.bq-section h4 { margin: 0 0 8px 0; font-size: 14px; }
.bq-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.bq-stat {
  background: var(--bg);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
.bq-stat-label { display: block; font-size: 11px; color: var(--text-sub); margin-bottom: 4px; }
.bq-stat strong { font-size: 18px; color: var(--text); }
.bq-stat-total { background: #f0fdfa; }
.bq-stat-total strong { color: #0e7490; }
.bq-code-row { display: flex; align-items: center; gap: 10px; }
.bq-code {
  flex: 1;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #e0f2fe 0%, #f0fdfa 100%);
  padding: 10px 14px;
  border-radius: 8px;
  text-align: center;
  border: 1px dashed #0891b2;
}
.bq-referrer { padding: 6px 0; font-size: 14px; }
.bq-locked-note { font-size: 12.5px; color: #d97757; margin-top: 4px; }
.bq-correct-form { display: flex; gap: 6px; margin-top: 8px; }
.bq-correct-form input {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.bq-correct-form button {
  padding: 6px 12px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; font-size: 12.5px; cursor: pointer;
}
.bq-correct-form button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.bq-ledger { list-style: none; padding: 0; margin: 0; }
.bq-ledger li {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr auto;
  gap: 6px 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  align-items: baseline;
}
.bq-ledger li:last-child { border-bottom: none; }
.bq-led-when { color: var(--text-sub); }
.bq-led-reason { color: var(--text); }
.bq-led-delta { font-weight: 700; text-align: right; }
.bq-led-delta.plus { color: #0e7490; }
.bq-led-delta.minus { color: #b91c1c; }
.bq-led-note {
  grid-column: 2 / 4;
  color: var(--text-sub);
  font-size: 11.5px;
}
.bq-howto ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.bq-howto li strong { color: #0e7490; }

/* 가입 폼 추천인 (선택) 표시 */
.optional-mark {
  font-style: normal;
  font-size: 11px;
  color: var(--text-sub);
  margin-left: 4px;
}

/* admin 통계 탭 */
.stats-section {
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stats-section h3 { margin: 0 0 4px 0; font-size: 16px; }
.stats-section .hint { margin: 0 0 12px 0; }
.ref-row td { vertical-align: middle; }
.ref-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 1px;
  background: #e0f2fe;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.ref-detail td {
  background: var(--bg);
}
.ref-invitees {
  list-style: none;
  padding: 0;
  margin: 4px 0;
}
.ref-invitees li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.ref-invitees li:last-child { border-bottom: none; }
.ref-invitees .ref-when { margin-left: auto; color: var(--text-sub); font-size: 12px; }

/* 공지 본문에 인라인 이미지 (marked로 삽입된 <img>) */
.notice-msg-body img,
.nh-item-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 6px 0;
  display: block;
}
.notice-msg-body p,
.nh-item-body p { margin: 6px 0; }
.notice-msg-body a,
.nh-item-body a { color: #0891b2; text-decoration: underline; }

/* 공지 첨부 (PDF·파일) 카드 */
.notice-attach-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.notice-attach-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
}
.notice-attach-card:hover { background: var(--bg); }
.notice-attach-card .att-icon { font-size: 16px; }
.notice-attach-card .att-name { flex: 1; word-break: break-all; }
.notice-attach-card .att-size { color: var(--text-sub); font-size: 12px; }

/* 누적 공지함 모달 안의 항목 */
.nh-item {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.nh-item:last-child { border-bottom: none; }
.nh-item-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.nh-item-head strong { flex: 1; word-break: break-word; }
.nh-icon { font-size: 16px; }
.nh-item-meta {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 8px;
}
.nh-item-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.nh-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.nh-badge-unread {
  background: #fef2f2;
  color: #d97757;
  border: 1px solid #fca5a5;
}
.nh-badge-read {
  background: #f0fdfa;
  color: #0e7490;
  border: 1px solid #99f6e4;
}
.wr-card.unread::before {
  content: 'NEW';
  background: #d97757;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
}

/* 모달 */
.wr-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.wr-modal-overlay[hidden] { display: none; }
.wr-modal {
  background: white;
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.wr-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.wr-modal-head h3 {
  margin: 0;
  font-size: 17px;
  color: #0e7490;
}
.wr-modal-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-sub);
  padding: 0 4px;
}
.wr-modal-close:hover { color: var(--text); }
.wr-modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 14.5px;
  color: var(--text);
}
.wr-modal-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 관리자 주간 리포트 탭
   ══════════════════════════════════════════════════════ */
.wr-filter {
  display: flex;
  gap: 6px;
  padding: 8px 0 12px;
  flex-wrap: wrap;
}
.wr-filter-chip {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-sub);
  transition: all .12s ease;
}
.wr-filter-chip:hover { background: #f5f5f5; }
.wr-filter-chip.active {
  background: #0891b2;
  color: white;
  border-color: #0891b2;
  font-weight: 600;
}
.wr-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.wr-badge-draft  { background: #fef3c7; color: #92400e; }
.wr-badge-sent   { background: #dbeafe; color: #1e40af; }
.wr-badge-viewed { background: #dcfce7; color: #166534; }
.col-stats { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

/* 미리보기 모달 내부 */
.wr-preview-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-sub);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.wr-preview-stats {
  background: #ecfeff;
  border-left: 3px solid #0891b2;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #0e7490;
  margin-bottom: 12px;
}
.wr-preview-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fafafa;
  padding: 14px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  max-height: 50vh;
  overflow-y: auto;
  margin: 0;
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 학생 본인 학습 진도 카드 (오렌지 톤)
   ══════════════════════════════════════════════════════ */
.sr-card {
  background: linear-gradient(135deg, #fef6f0 0%, #fde8d8 100%);
  border: 1px solid #f5c8a8;
  border-left: 4px solid #d97757;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 6px rgba(217, 119, 87, 0.10);
}
.sr-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(217, 119, 87, 0.18);
}
.sr-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 8px;
}
.sr-card-title {
  font-weight: 700;
  font-size: 15px;
  color: #b45a3c;
}
.sr-card-sub {
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
}
.sr-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.sr-chip {
  background: white;
  border: 1px solid #f5c8a8;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  color: #b45a3c;
  white-space: nowrap;
}
.sr-card-cta {
  margin-top: 8px;
  font-size: 12px;
  color: #d97757;
  text-align: right;
}

/* 학생 모달 — 섹션별 구성 */
.sr-section { margin-bottom: 16px; }
.sr-section:last-child { margin-bottom: 0; }
.sr-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #b45a3c;
  border-bottom: 1px dashed #f5c8a8;
  padding-bottom: 4px;
}
.sr-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sr-list li {
  padding: 8px 10px;
  background: #fafafa;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13.5px;
  line-height: 1.45;
}
.sr-list .sr-meta {
  font-size: 11px;
  color: var(--text-sub);
  display: flex;
  gap: 8px;
  margin-bottom: 3px;
}
.sr-kind {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.sr-kind-exam       { background: #dbeafe; color: #1e40af; }
.sr-kind-attendance { background: #fef3c7; color: #92400e; }
.sr-kind-flag       { background: #fee2e2; color: #991b1b; }
.sr-kind-other      { background: #e5e7eb; color: #374151; }
.sr-empty {
  padding: 8px 10px;
  color: var(--text-sub);
  font-size: 12.5px;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 콘텐츠 자동 제작 탭
   ══════════════════════════════════════════════════════ */
.cw-panel { padding: 8px 0 0; }
.cw-intro h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--text);
}
.cw-intro p {
  margin: 0 0 16px;
  color: var(--text-sub);
  font-size: 13px;
  line-height: 1.5;
}
.cw-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.cw-form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cw-form .field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cw-form select,
.cw-form textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
}
.cw-form select:focus,
.cw-form textarea:focus {
  outline: none;
  border-color: #0891b2;
}
.cw-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}
.cw-actions button {
  font-size: 14px;
  padding: 8px 18px;
}
.cw-result-area {
  margin-top: 16px;
  background: white;
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 14px 16px;
}
.cw-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.cw-result-head h4 {
  margin: 0;
  font-size: 14px;
  color: #0e7490;
}
.cw-result-actions {
  display: flex;
  gap: 6px;
}
.cw-result-actions button {
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.cw-result-actions button:hover { background: #f5f5f5; }
.cw-result-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: #fafafa;
  padding: 14px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  max-height: 60vh;
  overflow-y: auto;
  margin: 0 0 8px;
  user-select: text;
}
.cw-result-meta {
  font-size: 11px;
  color: var(--text-sub);
  text-align: right;
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 학생 게임화 카드 (보라 톤)
   ══════════════════════════════════════════════════════ */
.gm-card {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #c4b5fd;
  border-left: 4px solid #7c3aed;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.10);
}
.gm-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.18);
}
.gm-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.gm-grade {
  font-weight: 700;
  font-size: 16px;
  color: #5b21b6;
}
.gm-points {
  font-size: 13px;
  color: #7c3aed;
  font-weight: 600;
  white-space: nowrap;
}
.gm-progress-wrap {
  margin-top: 8px;
  background: white;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  border: 1px solid #ddd6fe;
}
.gm-progress-bar {
  background: linear-gradient(90deg, #a78bfa, #7c3aed);
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
}
.gm-progress-label {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 3px;
  text-align: right;
}
.gm-quote {
  margin-top: 10px;
  padding: 8px 10px;
  background: white;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #5b21b6;
  border-left: 3px solid #a78bfa;
}
.gm-attend {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.gm-attend.yes { background: #dcfce7; color: #166534; }
.gm-attend.no  { background: #fef3c7; color: #92400e; }
.gm-card-cta {
  margin-top: 6px;
  font-size: 12px;
  color: #7c3aed;
  text-align: right;
}

/* 모달 내부 — 점수 내역 */
.gm-modal-grade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-radius: 10px;
  margin-bottom: 14px;
}
.gm-modal-grade-emoji { font-size: 32px; }
.gm-modal-grade-info { flex: 1; }
.gm-modal-grade-label { font-weight: 700; font-size: 16px; color: #5b21b6; }
.gm-modal-grade-points { font-size: 13px; color: #7c3aed; }
.gm-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.gm-breakdown-item {
  background: #fafafa;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.gm-breakdown-num {
  font-size: 20px;
  font-weight: 700;
  color: #5b21b6;
}
.gm-breakdown-label {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}
.gm-breakdown-pts {
  font-size: 10px;
  color: #7c3aed;
  margin-top: 1px;
}

/* ══════════════════════════════════════════════════════
   Phase 5 — 학부모 후기 카드 (분홍 톤) + 모달
   ══════════════════════════════════════════════════════ */
.pr-card {
  background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
  border: 1px solid #f9a8d4;
  border-left: 4px solid #db2777;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.pr-card-text {
  flex: 1;
  min-width: 0;
}
.pr-card-title {
  font-weight: 700;
  font-size: 14px;
  color: #9d174d;
}
.pr-card-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}
.pr-card-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.pr-btn {
  background: white;
  border: 1px solid #f9a8d4;
  color: #9d174d;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  transition: background .12s;
}
.pr-btn:hover { background: #fbcfe8; }
.pr-btn.primary { background: #db2777; color: white; border-color: #db2777; }
.pr-btn.primary:hover { background: #9d174d; }

/* 후기 작성 폼 (모달 안) */
.pr-form { display: flex; flex-direction: column; gap: 12px; }
.pr-form .field {
  display: flex; flex-direction: column; gap: 4px;
}
.pr-form .field label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.pr-form input[type=text],
.pr-form textarea,
.pr-form select {
  font-family: inherit; font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.pr-form textarea { resize: vertical; }
.pr-rating {
  display: flex;
  gap: 4px;
  font-size: 28px;
  cursor: pointer;
  user-select: none;
}
.pr-rating-star { color: #d4d4d8; transition: color .12s; }
.pr-rating-star.on { color: #fbbf24; }
.pr-rating-star:hover { color: #fbbf24; }
.pr-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* 공개 후기 목록 (모달 안) */
.pr-list-item {
  background: #fafafa;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid #f9a8d4;
}
.pr-list-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.pr-list-stars {
  color: #fbbf24;
  font-size: 13px;
  letter-spacing: 1px;
}
.pr-list-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}
.pr-list-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

/* 내 후기 상태 배지 */
.pr-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
}
.pr-status-pending  { background: #fef3c7; color: #92400e; }
.pr-status-approved { background: #dcfce7; color: #166534; }
.pr-status-hidden   { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════════════════
   Phase 5 — 관리자 후기 탭 — 카드 형태
   ══════════════════════════════════════════════════════ */
.rv-row {
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid #f9a8d4;
  border-radius: 10px;
  padding: 12px 14px;
}
.rv-row-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.rv-row-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.rv-row-title {
  font-size: 15px;
  margin-bottom: 6px;
}
.rv-row-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: #fafafa;
  padding: 10px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}
.rv-row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.rv-row-actions button {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}
.rv-row-actions button:hover { background: #f5f5f5; }
.rv-row-actions button.primary {
  background: #db2777; color: white; border-color: #db2777;
}
.rv-row-actions button.primary:hover { background: #9d174d; }
.rv-row-actions button.danger {
  background: white; color: #991b1b; border-color: #fecaca;
}
.rv-row-actions button.danger:hover { background: #fee2e2; }

/* ══════════════════════════════════════════════════════
   Phase 8 — 객관식 시험지 시스템
   ══════════════════════════════════════════════════════ */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.exam-card {
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exam-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.exam-card-head h4 { margin: 0; font-size: 15px; }
.exam-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--text-sub);
}
.exam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.exam-actions button {
  font-size: 12px;
  padding: 5px 10px;
}
.badge.badge-draft { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge.badge-published { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.badge.badge-closed { background: #e5e7eb; color: #374151; border: 1px solid #d1d5db; }

.exam-editor { display: flex; flex-direction: column; gap: 16px; }
.exam-form {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 12px;
}
.exam-problems-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.prob-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.prob-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 6px; margin-bottom: 8px;
}
.prob-head .hint { margin-left: auto; }
.prob-edit-btn, .prob-del-btn {
  background: none; border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 5px;
  font-size: 11px; cursor: pointer;
}
.prob-del-btn.danger { color: #b91c1c; border-color: #fecaca; }
.prob-body { font-size: 13px; line-height: 1.6; margin-bottom: 6px; }
.prob-choices {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12.5px; color: var(--text-sub); margin-bottom: 6px;
}
.prob-choice { display: block; padding: 2px 0; }
.prob-explain {
  background: #f0f9ff; border-left: 3px solid #38bdf8;
  padding: 8px 10px; margin-top: 4px; font-size: 12.5px;
}
.prob-analysis {
  background: #fff7ed; border-left: 3px solid #fb923c;
  padding: 8px 10px; margin-top: 4px; font-size: 12.5px; color: #9a3412;
}

.exam-analyze input[type="file"] {
  display: block; margin: 8px 0; padding: 8px;
  border: 1px dashed var(--border); border-radius: 6px; width: 100%;
}

.sub-detail .modal-msg {
  background: #f0f9ff; padding: 10px 12px;
  border-radius: 6px; margin: 8px 0;
}
.sub-prob-row {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px; margin-bottom: 8px;
  border-left: 4px solid var(--border);
}
.sub-prob-row.correct { border-left-color: #10b981; }
.sub-prob-row.wrong { border-left-color: #ef4444; }
.sub-prob-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
}

/* 학생 메인의 시험 카드 */
.ex-cards-wrap {
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 2px solid #fb923c;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
}
.ex-cards-title {
  font-weight: 700; font-size: 14px; color: #9a3412; margin-bottom: 8px;
}
.ex-card {
  background: #fff; border: 1px solid #fed7aa;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.ex-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; font-size: 14px;
}
.ex-card-meta {
  display: flex; flex-wrap: wrap; gap: 6px 12px;
  font-size: 11.5px; color: var(--text-sub); margin-bottom: 8px;
}
.ex-card-pill {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.ex-card-pill.new { background: #fb923c; color: #fff; }
.ex-card-pill.done { background: #10b981; color: #fff; }
.ex-card-btn {
  display: inline-block; padding: 6px 14px;
  border-radius: 6px; text-decoration: none;
  font-size: 12.5px; font-weight: 600;
  background: #fff; color: #9a3412; border: 1px solid #fed7aa;
}
.ex-card-btn.primary { background: #d97757; color: #fff; border-color: #d97757; }
.ex-card-btn:hover { filter: brightness(1.05); }

/* exam.html — 시험 풀기 */
.exam-intro {
  max-width: 720px; margin: 20px auto; padding: 20px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
}
.exam-intro h2 { margin: 0 0 8px; color: var(--turkey-700, #0e7490); }
.exam-instructions {
  background: #fef9c3; border-left: 3px solid #fde047;
  padding: 10px 14px; margin: 12px 0; font-size: 13.5px; line-height: 1.6;
}
.exam-play { max-width: 800px; margin: 0 auto; padding: 0 12px 80px; }
.exam-progress {
  position: sticky; top: 0; background: #fff;
  padding: 10px 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600;
}
.exam-progress-bar {
  flex: 1; height: 8px; background: #e5e7eb;
  border-radius: 4px; overflow: hidden;
}
#exProgFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0891b2, #06b6d4);
  transition: width 0.3s ease;
}
#exTimer { color: #b91c1c; font-variant-numeric: tabular-nums; }
.ex-prob-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin: 12px 0;
}
.ex-prob-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px; border-bottom: 1px dashed var(--border);
  padding-bottom: 6px;
}
.ex-prob-num {
  display: inline-block; background: #d97757; color: #fff;
  font-weight: 700; width: 30px; height: 30px;
  line-height: 30px; text-align: center; border-radius: 50%;
}
.ex-prob-points {
  font-size: 12px; color: var(--text-sub);
  background: #f3f4f6; padding: 2px 8px; border-radius: 10px;
}
.ex-prob-statement { font-size: 14px; line-height: 1.7; margin-bottom: 12px; }
.ex-choices { display: flex; flex-direction: column; gap: 8px; }
.ex-choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 2px solid var(--border);
  border-radius: 8px; cursor: pointer; background: #fff;
  transition: all 0.12s;
}
.ex-choice:hover { background: #f0f9ff; border-color: #7dd3fc; }
.ex-choice:has(input:checked) { background: #cffafe; border-color: #06b6d4; }
.ex-choice input[type="radio"] { margin-top: 3px; transform: scale(1.2); }
.ex-choice-num { font-weight: 700; color: #0e7490; min-width: 24px; }
.ex-choice-text { flex: 1; font-size: 13.5px; line-height: 1.5; }
.ex-short-input {
  width: 100%; padding: 8px 12px;
  border: 2px solid var(--border); border-radius: 6px; font-size: 14px;
}
.exam-submit-bar {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, #fff 80%, transparent);
  padding: 16px 0 8px; text-align: center;
}
.exam-submit-bar button {
  width: 100%; max-width: 400px; padding: 14px; font-size: 15px;
}

/* 채점 결과 */
.exam-result, .exam-result-detail {
  max-width: 800px; margin: 20px auto; padding: 20px;
}
.ex-result-score {
  background: #fff; border: 2px solid; border-radius: 12px;
  padding: 24px; text-align: center; margin-bottom: 16px;
}
.ex-result-score.good { border-color: #10b981; background: #d1fae5; }
.ex-result-score.okay { border-color: #f59e0b; background: #fef3c7; }
.ex-result-score.weak { border-color: #ef4444; background: #fee2e2; }
.ex-score-big { font-size: 48px; font-weight: 800; margin-bottom: 4px; }
.ex-result-score.good .ex-score-big { color: #065f46; }
.ex-result-score.okay .ex-score-big { color: #92400e; }
.ex-result-score.weak .ex-score-big { color: #991b1b; }
.ex-score-sub { font-size: 14px; color: var(--text-sub); }
.ex-result-summary {
  background: #fff; border-left: 4px solid #0891b2;
  padding: 14px 18px; border-radius: 6px;
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.7;
  margin-bottom: 16px;
}
.ex-teacher-note {
  background: #fef9c3; border-left: 4px solid #facc15;
  padding: 12px 16px; border-radius: 6px;
  margin-bottom: 16px; font-size: 13.5px;
}
.ex-result-actions { display: flex; gap: 8px; margin-top: 16px; }
.ex-result-actions button { flex: 1; padding: 10px; }
.ex-result-prob {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
  border-left: 4px solid var(--border);
}
.ex-result-prob.correct { border-left-color: #10b981; }
.ex-result-prob.wrong { border-left-color: #ef4444; }
.ex-result-prob header {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px; margin-bottom: 8px; font-size: 12.5px;
}
.ex-chip-result {
  font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}
.ex-chip-result.ok { background: #10b981; color: #fff; }
.ex-chip-result.no { background: #ef4444; color: #fff; }

@media (prefers-color-scheme: dark) {
  .exam-card, .prob-row, .sub-prob-row, .ex-prob-card,
  .exam-intro, .ex-result-score, .ex-result-summary,
  .ex-card { background: #1f2937; }
  .ex-cards-wrap { background: linear-gradient(135deg, #422006, #1c1410); }
  .exam-form { background: #422006; border-color: #d97706; }
  .ex-choice { background: #1f2937; }
  .ex-choice:hover { background: #1e3a5f; }
}

/* ── Phase 8-2A — 단원별 약점 분석 카드·모달 ───────── */
.wk-cards-wrap {
  background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
  border: 2px solid #0891b2;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wk-card-block {
  background: #fff;
  border: 1px solid #a5f3fc;
  border-radius: 10px;
  padding: 10px 12px;
}
.wk-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; font-size: 14px; color: #0e7490;
}
.wk-card-summary {
  font-size: 12.5px; color: var(--text-sub); margin-bottom: 8px; line-height: 1.5;
}
.wk-card-chips {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px;
}
.wk-chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 12px;
  border: 1px solid; font-weight: 600;
}
.wk-chip.weak { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.wk-chip.strong { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.wk-card-btn {
  background: #0891b2; color: #fff; border: 0;
  padding: 6px 14px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wk-card-btn:hover { background: #0e7490; }

.wk-modal-summary {
  background: #f0f9ff; border-left: 4px solid #0891b2;
  padding: 10px 14px; border-radius: 6px;
  font-size: 13px; line-height: 1.6; margin-bottom: 10px;
}
.wk-modal-meta {
  font-size: 12px; color: var(--text-sub); margin-bottom: 12px;
}
.wk-rows {
  display: flex; flex-direction: column; gap: 10px;
}
.wk-row {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  border-left: 4px solid var(--border);
}
.wk-row.tone-weak { border-left-color: #ef4444; }
.wk-row.tone-warning { border-left-color: #f59e0b; }
.wk-row.tone-stable { border-left-color: #06b6d4; }
.wk-row.tone-strong { border-left-color: #10b981; }
.wk-row-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px; font-size: 13px;
}
.wk-row-name { font-weight: 600; color: var(--text); }
.wk-row-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.wk-row-meta { font-weight: 400; color: var(--text-sub); font-size: 11.5px; }
.wk-row-cls {
  font-size: 11.5px; color: var(--text-sub); margin-top: 4px;
}
.wk-bar {
  height: 7px; background: #e5e7eb; border-radius: 4px; overflow: hidden;
}
.wk-bar-fill { height: 100%; transition: width 0.3s ease; }
.wk-bar-fill.tone-weak { background: linear-gradient(90deg, #ef4444, #f87171); }
.wk-bar-fill.tone-warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.wk-bar-fill.tone-stable { background: linear-gradient(90deg, #06b6d4, #22d3ee); }
.wk-bar-fill.tone-strong { background: linear-gradient(90deg, #10b981, #34d399); }

.wk-trend {
  display: inline-block; font-weight: 700; margin-left: 4px;
  font-size: 13px;
}
.wk-trend.up { color: #10b981; }
.wk-trend.down { color: #ef4444; }
.wk-trend.flat { color: #6b7280; }
.wk-trend.new { color: #94a3b8; }

.wk-modal-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 11.5px; color: var(--text-sub);
  margin-top: 12px; padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
}
.legend-dot.tone-weak { background: #ef4444; }
.legend-dot.tone-warning { background: #f59e0b; }
.legend-dot.tone-stable { background: #06b6d4; }
.legend-dot.tone-strong { background: #10b981; }

@media (prefers-color-scheme: dark) {
  .wk-cards-wrap { background: linear-gradient(135deg, #082f49, #0e1f2e); }
  .wk-card-block { background: #1f2937; }
  .wk-row { background: #1f2937; }
  .wk-modal-summary { background: #082f49; }
}

/* ════════════════════════════════════════════════════════
   클로비스 패밀리 브랜드 크레디트 (Phase 8-2D / 챗봇클로비스 출시)
   짱쌤 선호 (2026-04-27 재확인): 작고 차분한 가운데 정렬 회색 톤 + 챗봇클로비스만 터키블루 굵게.
   학원 페르소나(짱쌤AI조교) 보존 + 패밀리 브랜드 부드럽게 첨가.
   ════════════════════════════════════════════════════════ */
.brand-credit {
  font-size: 11px;
  color: var(--text-sub);
  text-align: center;
  letter-spacing: 0.02em;
  margin: 8px 0 0;
  padding: 4px 8px;
  user-select: none;
}
.brand-credit strong {
  color: var(--primary-dark);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* 드롭다운 메뉴 내부도 동일한 차분 톤 + 상단 구분선만 추가 */
.dropdown-menu .brand-credit {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding: 8px 8px 4px;
  font-size: 10.5px;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .brand-credit { color: #94a3b8; }
  .brand-credit strong { color: #67e8f9; }
  .dropdown-menu .brand-credit { border-top-color: #334155; }
}

/* ════════════════════════════════════════════════════════
   Phase 8-2E: 시험지 원본 이미지 미리보기 모달 (관리자)
   ════════════════════════════════════════════════════════ */
.exam-image-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.exam-image-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: var(--text-sub);
}
.exam-image-meta .hint {
  font-size: 11px;
  color: var(--text-sub);
}
.exam-image-frame {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  max-height: 70vh;
  overflow: auto;
}
.exam-image-frame img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
}
.exam-image-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
@media (prefers-color-scheme: dark) {
  .exam-image-frame { background: #0f172a; border-color: #334155; }
}
