* { box-sizing: border-box; }
/* hidden 속성은 다른 display 지정보다 항상 우선 (숨긴 화면이 겹쳐 보이는 문제 방지) */
[hidden] { display: none !important; }
body { margin: 0; font-family: 'Malgun Gothic', '맑은 고딕', system-ui, sans-serif; background: #f4f6f9; color: #1d2433; font-size: 15px; }
.top { display: flex; align-items: center; gap: 16px; padding: 12px 28px; background: #fff; color: #1d2433; border-bottom: 3px solid #0070c0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.top .logo { height: 40px; width: auto; display: block; }
.top h1 { margin: 0; font-size: 20px; padding-left: 16px; border-left: 1px solid #d6dbe4; color: #1f3a68; }
.top .sub { color: #6b7280; font-size: 14px; flex: 1; }
.save-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.save-box .save { background: #6cc644; border-color: #6cc644; font-weight: bold; }
.save-status { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #eef1f6; color: #4b5563; }
.save-status.unsaved { background: #fde2e2; color: #b42318; }
.save-status.saved { background: #e3f6e8; color: #1e7b3a; }
.btn-link { display: inline-block; text-decoration: none; border: 1px solid #1f3a68; border-radius: 8px; padding: 8px 14px; color: #1f3a68; font-size: 15px; }
.btn-link:hover { background: #f3f7fc; }
.archive-filter input { flex: 1; min-width: 200px; }
.archive-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.archive-table th { text-align: left; color: #6b7280; font-weight: normal; border-bottom: 2px solid #e5e7eb; padding: 8px 6px; }
.archive-table td { border-bottom: 1px solid #f0f0f0; padding: 9px 6px; }
.archive-table tr:hover td { background: #f8fafd; }
.archive-table .open { font-weight: bold; color: #1f3a68; cursor: pointer; }
.archive-table .del, button.del { color: #b42318; border-color: #f3c2bd; }
.archive-table tr.group-row td { background: #eef3fa; color: #1f3a68; font-weight: bold; border-bottom: 2px solid #c9d8ee; padding: 7px 6px; }
.archive-table tr.group-row:hover td { background: #eef3fa; }
.archive-table tr.group-row small { font-weight: normal; color: #6b7280; margin-left: 6px; }
.view-toggle { flex-wrap: wrap; }
.passage-head { flex-wrap: wrap; gap: 6px; }
.passage-head .pname, .passage-head .pcount { white-space: nowrap; }
.passage-head .pcount { margin-left: auto; margin-right: 10px; font-weight: normal; font-size: 13px; color: #4b5563; display: flex; align-items: center; gap: 6px; }
.passage-head .pcount select { min-width: 0; padding: 3px 6px; font-size: 13px; }
.passage-head .palloc { color: #0070c0; }
.reading-plan { margin: 4px 0 12px; padding: 8px 12px; border-radius: 8px; background: #eef3fb; font-size: 13px; color: #1f3a68; }
.reading-plan:empty { display: none; }
.reading-plan.bad { background: #fde2e2; color: #b42318; }
.ai-mode { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #eef1f6; color: #4b5563; white-space: nowrap; }
.ai-mode.api { background: #e3f6e8; color: #1e7b3a; }
.ai-mode.bad { background: #fde2e2; color: #b42318; }
.top .lan { border: 1px dashed #9db8d9; background: #f3f7fc; color: #1f3a68; font-size: 13px; padding: 6px 10px; }
main, #progress, #result { max-width: 980px; margin: 20px auto; padding: 0 16px; }
.card { background: #fff; border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
h2 { margin: 0 0 12px; font-size: 18px; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #1f3a68; color: #fff; font-size: 14px; margin-right: 6px; }
.row { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #555; }
input[type=text], input:not([type]), select, textarea { font: inherit; padding: 8px 10px; border: 1px solid #cdd3dd; border-radius: 8px; min-width: 180px; }
textarea { width: 100%; min-height: 150px; resize: vertical; line-height: 1.5; }
.field { display: flex; gap: 10px; align-items: center; }
.lbl { font-size: 13px; color: #555; }
.pill, .switch { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: #1d2433; cursor: pointer; }
.hint { color: #6b7280; font-size: 13px; margin: 0 0 10px; }
.summary { background: #eef3fb; border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.summary b { color: #1f3a68; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.types h3 { margin: 0 0 8px; font-size: 15px; color: #1f3a68; }
.type { display: flex; align-items: flex-start; gap: 6px; padding: 6px 0; flex-direction: row; color: #1d2433; font-size: 14px; }
.type small { display: block; color: #888; font-size: 12px; }
.type select { min-width: 0; padding: 3px 6px; font-size: 12px; margin-top: 4px; }
.type.disabled { opacity: .45; }
.passage { margin-bottom: 12px; }
.passage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-weight: bold; color: #1f3a68; }
button { font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid #1f3a68; background: #fff; color: #1f3a68; }
button.primary { background: #1f3a68; color: #fff; }
button.primary:hover { background: #2b4f8c; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: wait; }
.actions { text-align: center; margin: 24px 0 60px; }
.actions .primary { font-size: 17px; padding: 12px 40px; }
#log { margin: 0; padding-left: 20px; color: #374151; line-height: 1.8; }
.sticky { position: sticky; top: 0; z-index: 5; }
.result-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.result-head h2 { margin: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 17px; font-weight: bold; color: #1f3a68; margin: 24px 4px 8px; }
.item { position: relative; }
.group { border-left: 4px solid #1f3a68; background: #f8fafd; }
.group-head { font-weight: bold; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item.in-group { margin-left: 18px; }
.item.busy { opacity: .5; }
.item .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f6; color: #4b5563; }
.tag.d-하 { background: #e3f6e8; color: #1e7b3a; }
.tag.d-중 { background: #fff4d6; color: #8a5a00; }
.tag.d-상 { background: #fde2e2; color: #b42318; }
.stem { font-weight: bold; margin-bottom: 8px; }
.body { border: 1px solid #d6dbe4; border-radius: 6px; padding: 10px 14px; white-space: pre-wrap; line-height: 1.7; margin-bottom: 8px; font-family: 'Times New Roman', 'Malgun Gothic', serif; font-size: 15.5px; }
.cond { white-space: pre-wrap; color: #374151; margin-bottom: 8px; font-size: 14px; }
.choices { list-style: none; padding-left: 8px; margin: 0 0 8px; line-height: 1.8; }
.parts { margin: 0 0 8px; padding-left: 28px; line-height: 1.8; }
.parts li { white-space: pre-wrap; }
.parts li::marker { content: "(" counter(list-item) ") "; font-weight: bold; }
.parts small { color: #6b7280; }
.ans { background: #fbf7ee; border-left: 3px solid #d4a017; padding: 8px 12px; border-radius: 4px; font-size: 14px; white-space: pre-wrap; }
.ans b { color: #b42318; }
.hide-ans .ans { display: none; }
.regen { display: flex; gap: 6px; margin-top: 10px; }
.regen input { flex: 1; min-width: 0; font-size: 13px; padding: 5px 8px; }
.failed .stem { color: #b42318; }
.opt { font-weight: normal; color: #888; font-size: 13px; }
.scope-summary { background: #f3f7ee; border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 10px; line-height: 1.7; }
.scope-summary .chip { display: inline-block; background: #fff; border: 1px solid #cfe3b8; border-radius: 999px; padding: 1px 10px; margin: 2px 4px 2px 0; font-size: 13px; }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 30; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; width: min(920px, 94vw); height: min(640px, 90vh); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-head { background: #d4edb0; padding: 14px 18px; font-weight: bold; text-align: center; position: relative; }
.modal-head .x { position: absolute; right: 10px; top: 6px; border: 0; background: transparent; font-size: 24px; padding: 2px 10px; }
.modal-body { flex: 1; overflow: auto; padding: 16px 20px; }
.modal-body.split { display: grid; grid-template-columns: 260px 1fr; padding: 0; }
.modal-foot { display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid #e5e7eb; }
.modal-foot .wide { flex: 1; background: #6cc644; border-color: #6cc644; font-weight: bold; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.book-card { border: 1px solid #d6dbe4; border-radius: 10px; padding: 14px; min-height: 110px; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(160deg, #f6f9ff, #eef3fb); }
.book-card:hover { border-color: #1f3a68; }
.book-card b { font-size: 14px; color: #1f3a68; }
.book-card .lv { align-self: flex-start; font-size: 11px; padding: 1px 8px; border-radius: 999px; margin-bottom: 6px; }
.lv-elementary { background: #e3f6e8; color: #1e7b3a; }
.lv-middle { background: #e6effa; color: #1f3a68; }
.book-card small { color: #6b7280; }
.empty { color: #6b7280; padding: 30px; text-align: center; line-height: 1.8; }
.chapters { border-right: 1px solid #e5e7eb; overflow: auto; padding: 10px; }
.chapters input { width: 100%; min-width: 0; margin-bottom: 8px; }
.chapters ul, .sections ul { list-style: none; margin: 0; padding: 0; }
.chapters li { padding: 10px 8px; border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 14px; display: flex; justify-content: space-between; gap: 6px; }
.chapters li.active { color: #4a9a1f; font-weight: bold; border-left: 3px solid #6cc644; }
.chapters li .cnt { background: #6cc644; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; height: 18px; line-height: 18px; }
.sections { overflow: auto; padding: 14px 20px; }
.sections-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 16px; }
.sections li label { flex-direction: row; align-items: center; gap: 8px; padding: 12px 4px; border-bottom: 1px solid #f0f0f0; font-size: 14px; color: #1d2433; cursor: pointer; }
.book-form { display: flex; flex-direction: column; gap: 10px; }
.book-form textarea { min-height: 300px; font-family: inherit; }
.mode-tabs { display: flex; gap: 0; border-bottom: 2px solid #e5e7eb; }
.mode-tabs .tab { border: 0; border-radius: 0; background: none; color: #6b7280; padding: 8px 14px; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.mode-tabs .tab.active { color: #1f3a68; font-weight: bold; border-bottom-color: #1f3a68; }
.ch-block { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; margin-bottom: 10px; background: #fafbfc; }
.ch-line, .sec-line { display: flex; gap: 6px; align-items: center; }
.ch-line .num { font-weight: bold; color: #1f3a68; width: 26px; }
.ch-line input { flex: 1; min-width: 0; font-weight: bold; }
.sec-line { margin: 6px 0 0 32px; }
.sec-line input { flex: 1; min-width: 0; padding: 5px 8px; font-size: 14px; }
.icon-btn { border: 0; background: none; color: #9ca3af; padding: 2px 8px; font-size: 16px; }
.icon-btn:hover { color: #b42318; }
.add-sec { margin: 6px 0 0 32px; font-size: 13px; padding: 3px 10px; }
.drop { display: block; border: 2px dashed #9db8d9; border-radius: 10px; padding: 26px; text-align: center; background: #f7faff; color: #4b5563; cursor: pointer; margin-bottom: 12px; }
.drop.over { background: #e8f1fd; border-color: #0070c0; }
.student-table { display: block; overflow-x: auto; }
.student-table input.note { width: 100%; min-width: 180px; font-size: 13px; padding: 5px 8px; }
.result-bar { display: flex; align-items: center; gap: 12px; }
.result-bar .hint { flex: 1; margin: 0; }
.fb-card .fb-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.fb-name { font-size: 17px; color: #1f3a68; }
.short-ta { min-height: 90px; margin-bottom: 10px; }
.fb-text { width: 100%; min-height: 200px; line-height: 1.8; font-size: 15px; }
.fb-count { text-align: right; margin: 4px 0 0; }
details summary { cursor: pointer; color: #1f3a68; margin: 6px 0; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 12px 20px; border-radius: 8px; max-width: 80%; z-index: 20; white-space: pre-wrap; }
#toast.error { background: #b42318; }
@media (max-width: 800px) {
  .types { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .top .logo { height: 30px; }
  .top h1 { font-size: 17px; padding-left: 10px; }
  .top .sub { flex-basis: 100%; order: 3; }
  .sticky { position: static; }
  .modal-body.split { grid-template-columns: 1fr; grid-template-rows: 40% 1fr; }
  .chapters { border-right: 0; border-bottom: 1px solid #e5e7eb; }
}

/* 서버(클라우드)에서는 성적표 PDF(엑셀 필요) 버튼 숨김 */
.no-pdf [data-pdf], .no-pdf #pdfAll { display: none !important; }

/* 보관함: 직접 올린 파일 */
.archive-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.archive-top .hint { margin: 0; }
.nowrap { white-space: nowrap; }
.up-tag { background: #fff4d6; color: #8a5a00; }
.files-box { height: auto; max-height: 90vh; }
.new-exam { margin-bottom: 12px; }
.file-table td { vertical-align: top; }
.upload-box { margin-top: 14px; padding: 12px 14px; border: 1px dashed #9db8d9; border-radius: 10px; background: #f7faff; }
.upload-box .row { margin: 8px 0 4px; }
.upload-box label.grow { flex: 1; min-width: 220px; }
.upload-box label.grow input { width: 100%; }
