/* ===== ExamBank 관리 UI — 디자인 시스템 ===== */
:root {
  --brand: #0d9488; --brand-d: #0f766e; --brand-l: #ccfbf1;
  --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8;
  --line: #e2e8f0; --line-2: #eef2f7; --bg: #f1f5f9; --card: #fff;
  --ok: #16a34a; --ok-bg: #f0fdf4; --warn: #ea580c; --warn-bg: #fff7ed;
  --danger: #dc2626; --blue: #3b82f6; --blue-bg: #eff6ff;
  --radius: 12px; --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.18);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.55;
}

/* ---- Topbar (sticky) ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #0d9488, #14b8a6); color: #fff;
  padding: 14px 24px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 10px rgba(13,148,136,.25);
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.3px; }
.tagline { font-size: 12.5px; opacity: .9; }
@media (max-width: 640px) { .tagline { display: none; } }

.wrap { max-width: 1000px; margin: 0 auto; padding: 20px 16px 80px; }

/* ---- Cards / sections ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card > h2, .card-head h2 {
  margin: 0 0 14px; font-size: 16px; color: var(--ink); font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.card-head h2 { margin-bottom: 0; }
.step-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand-l);
  color: var(--brand-d); font-size: 13px; font-weight: 800; flex-shrink: 0;
}

/* ---- Forms ---- */
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid2 label { display: flex; flex-direction: column; font-size: 12.5px; font-weight: 600; gap: 5px; color: var(--ink-2); }
.grid2 .chk { flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

input, button, select, textarea { font-size: 14px; font-family: inherit; }
input[type=text], input[type=number], input:not([type]), select, textarea {
  padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}
input[type=file] { font-size: 13px; }

/* ---- Buttons ---- */
button {
  background: var(--brand); color: #fff; border: none; padding: 9px 16px; border-radius: 9px;
  cursor: pointer; font-weight: 600; transition: filter .15s, transform .05s, box-shadow .15s;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; filter: none; }
button.ghost { background: #eef2f7; color: var(--ink); }
button.ghost:hover { background: #e2e8f0; }
button.danger { background: var(--danger); }
button.small { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-link {
  display: inline-block; background: #eef2f7; color: var(--ink); text-decoration: none;
  border-radius: 8px; padding: 5px 11px; font-size: 12.5px; font-weight: 600;
}
.btn-link:hover { background: #e2e8f0; }
a { color: var(--brand-d); }

/* ---- Chips (과목) ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 8px 16px; border-radius: 20px; background: #eef2f7; cursor: pointer;
  font-weight: 600; font-size: 14px; border: 1px solid transparent; transition: all .15s;
}
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(13,148,136,.3); }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: middle; }
.tbl th { color: var(--ink-3); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl td button, .tbl td .btn-link { margin: 1px 2px; }
.table-scroll { overflow-x: auto; }

.muted { color: var(--ink-2); font-size: 13px; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 10px; background: var(--brand-l); color: var(--brand-d); font-weight: 700; }

/* ===== 챕터(강의) — CHAPTER별 접이식 그룹 ===== */
.chapter-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 14px; }
.chapter-toolbar input[type=search], .chapter-toolbar input#chap-filter { flex: 1; min-width: 180px; }
.sel-counter { font-size: 13px; font-weight: 700; color: var(--brand-d); background: var(--brand-l); padding: 5px 12px; border-radius: 20px; }

.ch-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.ch-group-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
  background: #f8fafc; user-select: none; transition: background .15s;
}
.ch-group-head:hover { background: #f1f5f9; }
.ch-group-head .grp-title { font-weight: 700; font-size: 14.5px; }
.ch-group-head .grp-meta { color: var(--ink-3); font-size: 12.5px; }
.ch-group-head .caret { margin-left: auto; color: var(--ink-3); transition: transform .2s; font-size: 12px; }
.ch-group.collapsed .caret { transform: rotate(-90deg); }
.ch-group.collapsed .ch-list { display: none; }
.grp-progress { height: 4px; background: var(--line); border-radius: 4px; width: 90px; overflow: hidden; }
.grp-progress > div { height: 100%; background: var(--ok); }

.ch-list { padding: 4px 6px 8px; }
.lec-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px;
  border-bottom: 1px solid var(--line-2); flex-wrap: wrap;
}
.lec-row:last-child { border-bottom: none; }
.lec-row:hover { background: #f8fafc; }
.lec-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); flex-shrink: 0; }
.lec-no { font-weight: 700; font-size: 12.5px; color: var(--brand-d); background: var(--brand-l); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.lec-title { flex: 1; min-width: 120px; font-size: 13.5px; word-break: keep-all; }
.lec-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.lec-actions input[type=number] { width: 62px; padding: 5px 7px; }

/* 상태 pill */
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.pill-done { background: var(--ok-bg); color: var(--ok); }
.pill-partial { background: var(--warn-bg); color: var(--warn); }
.pill-empty { background: #f1f5f9; color: var(--ink-3); }

/* 일괄생성 바 */
.bulk-bar {
  background: var(--blue-bg); border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.bulk-bar b { font-size: 14px; }
.progress-track { height: 10px; background: #dbeafe; border-radius: 6px; overflow: hidden; }
.progress-track > div { height: 100%; transition: width .4s ease; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); display: none; align-items: flex-start; justify-content: center; z-index: 2000; padding: 30px 12px; overflow-y: auto; }
.modal-box { background: #fff; border-radius: var(--radius); max-width: 820px; width: 100%; padding: 20px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; position: sticky; top: -20px; background: #fff; padding: 6px 0; z-index: 1; border-bottom: 1px solid var(--line); }
.page-block { border-top: 1px solid var(--line); padding: 10px 0; }
.page-meta { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.page-block pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f8fafc; padding: 8px; border-radius: 6px; margin: 0; max-height: 240px; overflow-y: auto; }

/* ---- 문항 관리 ---- */
.qm-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.qm-card.qm-inactive { opacity: .55; background: #f8fafc; }
.qm-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.qm-actions { margin-left: auto; display: flex; gap: 4px; }
.qm-stem { font-weight: 600; margin: 4px 0 10px; word-break: keep-all; }
.qm-opts { list-style: none; margin: 0; padding: 0; }
.qm-opts li { padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 7px; margin-bottom: 5px; font-size: 14px; }
.qm-opts li.opt-correct { background: var(--ok-bg); border-color: #22c55e; color: #15803d; font-weight: 600; }
.qm-exp { margin-top: 10px; font-size: 13px; background: var(--warn-bg); border: 1px solid #fed7aa; border-radius: 7px; padding: 10px; line-height: 1.6; }
.qm-edit { display: flex; flex-direction: column; gap: 8px; }
.qm-edit label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; gap: 3px; }
.qm-edit textarea, .qm-edit input { padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; }
.qm-edit-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.hanja { font-family: "Batang", "SimSun", serif; }

/* 제출 상세(시작/완료 시간) 미니 테이블 */
.subs-mini { border-collapse: collapse; margin: 6px 0; font-size: 12px; background: #fff; }
.subs-mini th, .subs-mini td { border: 1px solid var(--line); padding: 4px 9px; text-align: left; white-space: nowrap; }
.subs-mini th { background: #f8fafc; color: var(--ink-2); font-weight: 600; }

/* 페이지 텍스트 뷰어 (한 페이지씩) */
.pv-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 10px 0; padding: 8px 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; }
.pv-jump { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pv-pre { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; background: #f8fafc; border: 1px solid var(--line); padding: 14px 16px; border-radius: 9px; margin: 8px 0; max-height: 58vh; overflow-y: auto; line-height: 1.75; }

/* 도움말 텍스트 */
.hint { font-size: 12.5px; color: var(--ink-2); background: #f8fafc; border-left: 3px solid var(--brand); padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 8px 0; }
