/* ══ 기본 변수 설정 ══ */
:root {
  --primary:     #1a3a5c;
  --accent:      #2e86de;
  --bg:          #f5f7fa;
  --card:        #ffffff;
  --sidebar-w:   220px;
  --sub-w:       230px;
  --header-h:    54px;
  --text:        #222;
  --muted:       #666;
  --border:      #dde3ec;
  --table-head:  #1a3a5c;
  --table-alt:   #eef3fb;
  --radius:      8px;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
}

/* ══ 초기화 ══ */
* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ══ 헤더 (상단 고정 및 레이아웃) ══ */
#header {
  position: sticky; 
  top: 0; 
  left: 0; 
  right: 0;
  height: var(--header-h);
  background: var(--primary); 
  color: #fff;
  display: flex; 
  align-items: center; 
  gap: 12px;
  padding: 0 16px; 
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

#burger {
  background: none; 
  border: none; 
  color: #fff;
  font-size: 22px; 
  cursor: pointer;
  padding: 4px 8px; 
  border-radius: 4px; 
  line-height: 1;
}

#burger:hover { 
  background: rgba(255,255,255,.15); 
}

#site-title { 
  font-size: 18px; 
  font-weight: 700; 
  letter-spacing: -.3px; 
  flex: 1; 
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* [수정] 헤더 순번 숫자 희미하게 표시 */
.header-num {
  opacity: 0.4;
  font-weight: 400;
  margin-right: 6px;
}

#header-btns { 
  display: flex; 
  gap: 8px; 
  flex-wrap: wrap; 
  align-items: center; 
}

.hbtn {
  padding: 6px 14px; 
  border-radius: 6px; 
  border: none;
  cursor: pointer; 
  font-size: 13px; 
  font-weight: 600; 
  transition: .2s;
}

#btn-test-mode  { background: #8e44ad; color: #fff; }
#btn-test-mode.active { 
  background: #e74c3c; 
  box-shadow: 0 0 0 3px rgba(231,76,60,.35); 
}

#btn-add-chapter { background: #27ae60; color: #fff; display: none; }
#btn-edit-page   { background: var(--accent); color: #fff; display: none; }
#btn-save        { background: #e67e22; color: #fff; display: none; }
#btn-cancel      { background: #888;    color: #fff; display: none; }

#btn-login-open  {
  background: rgba(255,255,255,.15); 
  color: #fff;
  font-size: 16px; 
  padding: 6px 10px; 
  border-radius: 6px;
}

#btn-login-open:hover { background: rgba(255,255,255,.28); }
#btn-login-open.logged-in { background: #27ae60; }

/* ══ 오버레이 ══ */
#overlay {
  position: fixed; 
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200; 
  display: none;
}

/* ══ 단원 추가 모달 ══ */
#add-chapter-modal {
  position: fixed; 
  inset: 0; 
  z-index: 500;
  display: none; 
  align-items: center; 
  justify-content: center;
  pointer-events: none;
}
#add-chapter-modal.show { 
  display: flex; 
  pointer-events: auto; 
}

#add-chapter-modal-box {
  background: #fff; 
  border-radius: 16px;
  padding: 28px 24px 24px;
  width: 340px; 
  max-width: 92vw;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#add-chapter-modal-title {
  font-size: 17px; 
  font-weight: 700;
  color: var(--primary); 
  text-align: center; 
  margin-bottom: 6px;
}

#add-chapter-modal-desc {
  font-size: 13px; 
  color: var(--muted);
  text-align: center; 
  margin-bottom: 20px;
}

#add-chapter-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-choice-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f7f9fc;
  cursor: pointer;
  transition: .18s;
  text-align: left;
}

.add-choice-btn:hover {
  border-color: var(--accent);
  background: #eef6ff;
  transform: translateX(3px);
  box-shadow: 0 2px 12px rgba(46,134,222,.15);
}

.add-choice-icon  { font-size: 26px; flex-shrink: 0; }
.add-choice-label { font-size: 14px; font-weight: 700; color: var(--primary); }
.add-choice-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

#btn-add-modal-cancel {
  position: absolute; 
  top: 12px; 
  right: 14px;
  background: none; 
  border: none;
  font-size: 18px; 
  color: #aaa; 
  cursor: pointer; 
  line-height: 1;
}

/* ══ 로그인 모달 ══ */
#login-modal {
  position: fixed; 
  inset: 0; 
  z-index: 500;
  display: none; 
  align-items: center; 
  justify-content: center;
}

#login-modal.show { display: flex; }

#login-modal-box {
  background: #fff; 
  border-radius: 14px;
  padding: 28px; 
  width: 320px; 
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
}

#login-form input {
  width: 100%; 
  padding: 10px 12px;
  border: 1px solid var(--border); 
  border-radius: 7px;
  margin-bottom: 10px; 
  font-size: 14px;
}

#login-form button {
  width: 100%; 
  padding: 11px;
  background: var(--accent); 
  color: #fff;
  border: none; 
  border-radius: 7px; 
  cursor: pointer;
  font-weight: 700;
}

#user-info { text-align: center; }

#user-email-display {
  font-size: 14px; 
  color: var(--primary); 
  font-weight: 600;
  margin-bottom: 12px; 
  background: #eef6ff; 
  padding: 10px; 
  border-radius: 8px;
}

#login-modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

#btn-logout, #btn-modal-close {
  padding: 9px 24px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
#btn-logout {
  background: #e74c3c;
  color: #fff;
}
#btn-modal-close {
  background: #f0f0f0;
  color: #333;
}
#btn-modal-close:hover {
  background: #e0e0e0;
}

#btn-modal-cancel {
  position: absolute; 
  top: 12px; 
  right: 14px;
  background: none; 
  border: none; 
  font-size: 18px; 
  color: #aaa; 
  cursor: pointer;
}

/* ══ 사이드바 (1단) ══ */
#sidebar {
  position: fixed; 
  top: 0;
  left: calc(-1 * var(--sidebar-w)); 
  width: var(--sidebar-w);
  height: 100%; 
  background: var(--primary); 
  color: #fff;
  z-index: 250; 
  transition: left .3s ease;
  display: flex; 
  flex-direction: column;
  padding-top: var(--header-h);
}

#sidebar.open { left: 0; }

#sidebar-inner { 
  flex: 1; 
  overflow-y: auto; 
  padding: 14px 0 8px; 
}

#cat-buttons { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  padding: 0 12px; 
}

.cat-btn {
  display: flex; 
  align-items: center; 
  gap: 10px;
  width: 100%; 
  padding: 14px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; 
  color: #fff; 
  cursor: pointer;
  font-size: 14px; 
  font-weight: 600; 
  transition: .18s; 
  text-align: left;
}

.cat-btn:hover { background: rgba(46,134,222,.3); }

.cat-btn.active { 
  background: rgba(46,134,222,.45); 
  border-color: var(--accent); 
}

/* ══ 서브 사이드바 (2단) ══ */
#sub-sidebar {
  position: fixed; 
  top: 0;
  left: -100%; 
  width: max-content;
  min-width: var(--sub-w);
  max-width: 80vw;
  height: 100%;
  background: #1e2d3d; 
  color: #fff;
  z-index: 260; 
  transition: left .3s ease;
  display: flex; 
  flex-direction: column;
  padding-top: var(--header-h);
  border-left: 1px solid rgba(255,255,255,.07);
}

#sub-sidebar.open { left: var(--sidebar-w); }

#sub-sidebar-inner { flex: 1; overflow-y: auto; }

#sub-sidebar-header {
  display: flex; 
  align-items: center; 
  gap: 10px;
  padding: 12px 14px; 
  border-bottom: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,0.15);
}

#sub-back {
  background: none; 
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff; 
  cursor: pointer; 
  width: 30px; 
  height: 30px; 
  border-radius: 6px;
  display: flex; 
  align-items: center; 
  justify-content: center;
}

.chapter-list { padding: 8px 0; }

.chapter-item {
  display: flex; 
  align-items: center;
  padding: 11px 14px; 
  cursor: pointer; 
  font-size: 13px;
  border-left: 3px solid transparent; 
  gap: 8px;
  transition: .15s;
}

.chapter-item:hover { background: rgba(255,255,255,.08); }

.chapter-item.active { 
  background: rgba(46,134,222,.25); 
  border-left-color: var(--accent); 
}

.chapter-item span.num { 
  font-size: 11px; 
  color: rgba(255,255,255,.4); 
  min-width: 24px; 
}

.chapter-item span.title { 
  flex: 1; 
  line-height: 1.3; 
  color: rgba(255,255,255,.9);
  white-space: nowrap;
}

.chapter-item .del-ch {
  background: none; 
  border: none; 
  color: #ff5050;
  cursor: pointer; 
  font-size: 14px; 
  display: none;
}

.chapter-item:hover .del-ch { display: inline; }

#no-chapters { 
  padding: 20px 14px; 
  color: rgba(255,255,255,.4); 
  font-size: 13px;
  text-align: center; 
}

/* ══ 메인 콘텐츠 영역 ══ */
#main {
  margin-top: 0;
  padding: 24px 16px;
  max-width: 800px;
  margin-left: auto; 
  margin-right: auto;
  min-height: calc(100vh - var(--header-h));
}

#page-title {
  position: sticky;
  top: var(--header-h);
  font-size: 22px; 
  font-weight: 700; 
  color: var(--primary);
  margin-bottom: 18px; 
  padding: 10px 0 12px;
  border-bottom: 2px solid var(--accent);
  background: var(--bg);
  z-index: 90;
}

#page-title:empty {
  display: none;
  padding: 0;
  margin: 0;
  border: none;
}

#page-content { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
}

/* ══ 이전/다음 단원 네비게이션 ══ */
#page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  gap: 12px;
}

#page-nav button {
  padding: 9px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}

#page-nav button:hover { background: var(--accent); }
#page-nav button:disabled { background: #ccc; cursor: default; }

#page-nav-select {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  outline: none;
  text-align: center;
}
#page-nav-select:focus { border-color: var(--accent); }

#empty-state { 
  text-align: center; 
  color: var(--muted); 
  padding: 60px 0; 
  font-size: 15px; 
}

#empty-state .icon { 
  font-size: 48px; 
  margin-bottom: 12px; 
}

/* ══ 뷰 블록 스타일 ══ */
.block-text { 
  font-size: 15px; 
  line-height: 1.8; 
  word-break: break-all; 
  white-space: pre-wrap; 
  padding: 4px 0; 
}

.block-text div, .block-text p { 
  margin: 0; 
  padding: 0; 
  min-height: 1.4em; 
}

.block-heading {
  font-size: 17px; 
  font-weight: 700; 
  color: var(--primary);
  border-left: 4px solid var(--accent);
  padding: 6px 12px; 
  background: rgba(46,134,222,.06);
  border-radius: 0 6px 6px 0;
  margin-top: 10px;
}

/* ══ 표 뷰 스타일 ══ */
.block-table-wrap { 
  overflow-x: auto; 
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius); 
  box-shadow: var(--shadow); 
}

.block-table { 
  width: 100%; 
  border-collapse: collapse; 
  min-width: 100%; 
  font-size: 14px; 
}

.block-table th {
  background: var(--table-head); 
  color: #fff;
  padding: 10px 12px; 
  text-align: center; 
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.15);
}

.block-table td {
  padding: 9px 12px; 
  border: 1px solid var(--border);
  vertical-align: top; 
  line-height: 1.6;
  word-break: break-all; 
  white-space: pre-wrap;
  background: #fff;
}

.block-table td:first-child {
  background: rgba(26,58,92,.03);
  font-weight: 600; 
  color: var(--primary);
}

/* ══ TEST 모드 가리개 ══ */
.test-td { 
  position: relative; 
  padding: 0 !important; 
}

.test-content { 
  padding: 9px 12px; 
  line-height: 1.6; 
}

.test-cover {
  position: absolute; 
  inset: 0;
  background: #2c2c2c; 
  color: rgba(255,255,255,0.8);
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 12px; 
  cursor: pointer; 
  user-select: none;
  border-radius: 2px;
  transition: background .15s;
}

.test-cover:hover { background: #444; }

/* ══ CPX 병명 카드 뷰 ══ */
.disease-card-view {
  margin-bottom: 16px; 
  border-radius: var(--radius);
  overflow: hidden; 
  box-shadow: var(--shadow);
}

.dc-view-table { 
  width: 100%; 
  border-collapse: collapse; 
  font-size: 13px; 
  table-layout: auto; 
}

/* 첫 번째 표: 내용물까지 모두 가운데 정렬 */
.dc-view-table:first-of-type td, 
.dc-view-table:first-of-type .dcv-val { 
  text-align: center !important; 
}

.dc-view-table td { 
  border: 1px solid var(--border); 
  padding: 0; 
  vertical-align: top; 
  background: #fff !important; 
  color: var(--text) !important;
  min-width: 50px; 
}

.dcv-label { 
  font-size: 10px; 
  font-weight: 700; 
  color: #fff; 
  background: var(--primary); 
  padding: 4px 10px; 
  display: block; 
  text-align: center; 
  letter-spacing: .4px;
}

/* 두 번째 표: 내용 왼쪽 정렬 */
.dcv-val { 
  padding: 8px 10px; 
  font-size: 13px; 
  line-height: 1.5; 
  word-break: break-all; 
  overflow-wrap: break-word; 
  white-space: pre-wrap; 
  display: block; 
  text-align: left; 
}

.dc-view-table-bottom td { 
  width: auto !important; 
  padding: 0 !important; 
  vertical-align: top !important; 
  background: #fff !important; 
  cursor: pointer; 
  position: relative; 
  text-align: left !important; 
}

.dc-view-table-bottom tr:first-child td { 
  text-align: center !important; 
}

.dc-view-table-bottom td[data-covered] .dcv-val { 
  background: #2c2c2c; 
  color: transparent; 
  user-select: none; 
}

/* 가리개 상태일 때 링크도 완전히 숨김 */
.dc-view-table-bottom td[data-covered] .dcv-val a,
.dc-view-table-bottom td[data-covered] .dcv-val * {
  color: transparent !important;
  text-decoration-color: transparent !important;
  pointer-events: none;
}

/* ══ 편집 패널 ══ */
#edit-panel, 
#edit-panel-disease,
#edit-panel-strategy,
#edit-panel-flashcard { 
  display: none; 
  background: #fff; 
  border-radius: var(--radius);
  padding: 16px; 
  margin-bottom: 20px; 
  box-shadow: var(--shadow); 
}

#edit-panel { border: 2px solid var(--accent); }
#edit-panel-disease { border: 2px solid #27ae60; }
#edit-panel-strategy { border: 2px solid #8e44ad; }
#edit-panel-flashcard { border: 2px solid #f39c12; }

/* 툴바 고정 */
.edit-sticky {
  position: sticky;
  top: var(--header-h);
  background: #fff;
  z-index: 100;
  padding: 10px 0 4px;
  margin: -4px 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

#page-title-input, 
#page-title-input-disease { 
  width: 100%; 
  padding: 8px 12px; 
  margin-bottom: 12px; 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  font-size: 16px; 
  font-weight: 700; 
}

.toolbar { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 6px; 
  margin-bottom: 8px; 
}

.tbtn { 
  padding: 6px 12px; 
  border: 1px solid var(--border); 
  border-radius: 5px; 
  cursor: pointer; 
  font-size: 12px; 
  font-weight: 600; 
  background: #fff; 
  color: var(--primary);
  transition: .15s; 
}

.tbtn:hover { 
  background: var(--accent); 
  color: #fff; 
}

.beditor { 
  background: #fafbfc; 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  padding: 12px; 
  margin-bottom: 10px; 
}

.beditor-header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  margin-bottom: 8px; 
  font-size: 11px; 
  font-weight: 700; 
  color: var(--accent); 
  text-transform: uppercase;
}

.rich-editor { 
  min-height: 90px; 
  padding: 10px; 
  border: 1px solid var(--border); 
  border-radius: 5px; 
  font-size: 13px; 
  outline: none; 
  background: #fff; 
  white-space: pre-wrap; 
}

/* ══ 표 에디터 (+- 버튼 스타일) ══ */
.table-editor-wrap { overflow-x: auto; }

.table-editor { 
  border-collapse: collapse; 
  width: 100%; 
}

.table-editor td { 
  border: 1px solid var(--border); 
  padding: 4px; 
  background: #fff; 
  vertical-align: top; 
}

.cell-editor { 
  min-height: 36px; 
  padding: 6px; 
  outline: none; 
  font-size: 13px; 
  white-space: pre-wrap; 
}

.row-ctrl-td { 
  width: 70px; 
  text-align: center; 
  border: none !important; 
  background: none !important; 
  padding: 0 4px !important; 
}

.row-btn { 
  width: 28px; 
  height: 28px; 
  margin: 2px; 
  border: 1px solid #ccc; 
  background: #fff; 
  border-radius: 4px; 
  cursor: pointer; 
  font-weight: bold; 
}

.row-btn:hover { 
  background: #eee; 
  border-color: var(--accent); 
}

/* ══ 병명 편집기 (치료 셀 크기 보정 고정 레이아웃) ══ */
.disease-card-editor { 
  background: #f7f9fc; 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  padding: 12px; 
  margin-bottom: 12px; 
}

.dc-table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-bottom: 8px; 
  table-layout: fixed; /* 고정 레이아웃: 셀 너비 강제 조정 */
}

.dc-table td { 
  border: 1px solid var(--border); 
  padding: 6px; 
  vertical-align: top; 
  background: #fff; 
  width: 33.33%; 
}

/* 치료 셀이 포함된 하단 행 너비 25% 고정 */
.dc-table.dc-table-bottom td { 
  width: 25% !important; 
} 

.dc-label { 
  font-size: 10px; 
  font-weight: 700; 
  color: var(--accent); 
  margin-bottom: 4px; 
}

.dc-cell { 
  min-height: 60px; 
  padding: 6px; 
  font-size: 13px; 
  outline: none; 
  line-height: 1.5; 
  word-break: break-all; 
  white-space: pre-wrap; 
  border: 1px solid #f0f0f0; 
  background: #fff;
}

.dc-cell:focus {
  border-color: var(--accent);
  background: #f0f7ff;
}

/* ══ 모바일 전용 미디어 쿼리 ══ */
@media (max-width: 600px) {
  #sidebar, #sub-sidebar { width: 85%; left: -85%; }
  #sidebar.open { left: 0; }
  #sub-sidebar.open { left: 0; z-index: 270; }
  #main { padding: 16px 10px; }
  #page-title { font-size: 18px; }
  .hbtn { padding: 5px 10px; font-size: 12px; }
  .dc-cell { min-height: 40px; }
}
/* ══ 단원 순서 버튼 ══ */
.ch-order-btns { display: flex; flex-direction: column; gap: 1px; margin-right: 4px; flex-shrink: 0; }
.ch-order-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  font-size: 9px; width: 20px; height: 16px; border-radius: 3px;
  cursor: pointer; padding: 0; line-height: 1; transition: .15s;
}
.ch-order-btn:hover:not(:disabled) { background: rgba(46,134,222,.5); }
.ch-order-btn:disabled { opacity: 0.25; cursor: default; }

/* ══ 홈 버튼 ══ */
#btn-home {
  width: 100%; margin-top: 16px; padding: 8px 14px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; color: rgba(255,255,255,.55); font-size: 12px;
  cursor: pointer; text-align: left; transition: .15s;
}
#btn-home:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ══ 서식 툴바 ══ */
.fmt-toolbar { margin-top: -6px; padding: 4px 0; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.fmt-btn { min-width: 30px; padding: 5px 10px; font-size: 13px; }
.fmt-select {
  padding: 5px 6px; border: 1px solid var(--border); border-radius: 5px;
  font-size: 12px; font-family: inherit; background: #fff; color: var(--primary);
  cursor: pointer; height: 30px;
}
.fmt-select:focus { outline: none; border-color: var(--accent); }

/* ══ 링크 스타일 ══ */
.block-table a, .block-text a, .rich-editor a, .cell-editor a, .dcv-val a, .dc-cell a {
  color: var(--accent); text-decoration: underline; cursor: pointer;
}

/* ══ 첫 화면 ══ */
#page-title:empty { display: none !important; margin: 0; padding: 0; border: none; }
#empty-state { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 4px 0; }
#empty-state .icon { display: none; }

#usage-guide {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; width: fit-content; max-width: 480px;
}
#usage-title {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--accent);
}
#usage-list { padding-left: 20px; margin: 0; text-align: left; }
#usage-list li { font-size: 14px; line-height: 2; color: var(--text); }
#usage-list b { color: var(--accent); }

/* ══ 업데이트 내역 ══ */
#notice-board { width: 100%; max-width: 640px; }
#notice-board-title {
  font-size: 15px; font-weight: 700; color: var(--primary);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--accent);
}
#notice-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
#notice-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
#notice-table td { padding: 10px 14px; vertical-align: middle; }
#notice-table td.notice-td-date {
  white-space: nowrap; font-size: 11px; color: var(--accent);
  font-weight: 600; width: 1%; padding-right: 8px;
  vertical-align: middle;
}
#notice-table td.notice-td-content { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; text-align: left; vertical-align: middle; }
#notice-table td.notice-td-btns { white-space: nowrap; width: 1%; padding-left: 6px; vertical-align: middle; }
.notice-edit-btn { background: none; border: none; cursor: pointer; font-size: 12px; color: var(--accent); padding: 0 2px; }
.notice-del-btn  { background: none; border: none; cursor: pointer; font-size: 12px; color: #e74c3c; padding: 0 2px; }

/* ══ 공지 작성/수정 모달 ══ */
#notice-modal {
  position: fixed; inset: 0; z-index: 500;
  display: none; align-items: center; justify-content: center;
}
#notice-modal.show { display: flex; }
#notice-modal-box {
  background: #fff; border-radius: 14px; padding: 28px 24px 20px;
  width: 440px; max-width: 92vw; position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,.25); animation: modalIn .2s ease;
}
#notice-modal-title { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 14px; }
#notice-datetime-row { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
#notice-date-input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
#notice-date-input:focus { border-color: var(--accent); }
#notice-hour-select, #notice-min-select {
  padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; cursor: pointer; outline: none;
}
#notice-textarea {
  width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; resize: vertical; font-family: inherit; line-height: 1.6; outline: none;
}
#notice-textarea:focus { border-color: var(--accent); }
#notice-modal-btns { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
#btn-notice-submit { background: var(--accent); color: #fff; border: none; padding: 8px 22px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 13px; }
#btn-notice-close { background: #ddd; color: #555; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
#btn-notice-modal-cancel { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 18px; color: #aaa; cursor: pointer; }

/* ══ 삽입 이미지 스타일 ══ */
.block-text img, .block-heading img,
.rich-editor img, .cell-editor img, .dc-cell img,
.dcv-val img, #page-content img {
  max-width: 100%;
  border-radius: 6px;
  margin: 4px 0;
  display: block;
}

/* ══ 상단 네비게이션 (제목 아래) ══ */
#page-nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

#page-nav-top button {
  padding: 7px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}

#page-nav-top button:hover { background: var(--accent); }
#page-nav-top button:disabled { background: #ccc; cursor: default; }

#page-nav-select-top {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  outline: none;
  text-align: center;
}
#page-nav-select-top:focus { border-color: var(--accent); }

/* ══ 블록 순서 이동 버튼 ══ */
.beditor-controls {
  display: flex;
  gap: 3px;
}

.beditor-header button {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #f5f7fa;
  cursor: pointer;
  transition: .12s;
}
.beditor-header button:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.beditor-header button:disabled { opacity: 0.3; cursor: default; }

/* ══ 가운데 정렬 아이콘 (흰검흰 세로 네모) ══ */


/* ══ 정렬 버튼 스타일 (깔끔한 3선 아이콘) ══ */
.align-btn {
  padding: 6px 10px !important;
  background: #fff !important;
  border: 1px solid #ddd !important;
  min-width: 36px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.align-btn:hover {
  background: #f5f5f5 !important;
  border-color: #ccc !important;
}

/* 정렬 아이콘 컨테이너 */
.align-icon {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 16px;
  height: 14px;
}

/* 세 줄의 선 */
.align-icon span {
  height: 2px;
  background: #333;
  border-radius: 1px;
  display: block;
}

/* 왼쪽 정렬 - 긴줄, 중간줄, 긴줄 */
.align-icon.left span:nth-child(1) { width: 100%; }
.align-icon.left span:nth-child(2) { width: 75%; }
.align-icon.left span:nth-child(3) { width: 100%; }

/* 가운데 정렬 - 긴줄, 중간줄(가운데), 긴줄 */
.align-icon.center span:nth-child(1) { width: 100%; }
.align-icon.center span:nth-child(2) { width: 75%; margin: 0 auto; }
.align-icon.center span:nth-child(3) { width: 100%; }

/* 오른쪽 정렬 - 긴줄, 중간줄(오른쪽), 긴줄 */
.align-icon.right span:nth-child(1) { width: 100%; }
.align-icon.right span:nth-child(2) { width: 75%; margin-left: auto; }
.align-icon.right span:nth-child(3) { width: 100%; }

/* ══ 표 가져오기 모달 ══ */
#import-tables-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

#import-tables-modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

#btn-import-modal-cancel {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 4px 8px;
}

#btn-import-modal-cancel:hover {
  color: #333;
}

#import-tables-modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--primary);
}

#import-tables-modal-desc {
  color: #666;
  margin-bottom: 16px;
  font-size: 14px;
}

#import-chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-chapter-item {
  padding: 14px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}

.import-chapter-item:hover {
  border-color: var(--accent);
  background: #f8f9fa;
  transform: translateX(4px);
}

.import-chapter-item-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  font-size: 15px;
}

.import-chapter-item-info {
  font-size: 13px;
  color: #666;
}

/* 표 가져오기 - 뒤로가기 버튼 */
.import-back-btn {
  padding: 10px 14px;
  background: #f0f0f0;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 12px;
  font-weight: 500;
  color: var(--primary);
  transition: all 0.2s;
}

.import-back-btn:hover {
  background: #e0e0e0;
}

/* 표 가져오기 - 개별 표 아이템 */
.import-table-item {
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.import-table-item:hover {
  border-color: var(--accent);
  background: #f8f9fa;
  transform: translateX(4px);
}

.import-table-preview {
  font-weight: 600;
  color: var(--primary);
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-table-info {
  font-size: 12px;
  color: #999;
  margin-left: 12px;
}

/* 표 가져오기 - 카테고리 헤더 */
.import-category-header {
  font-size: 14px;
  font-weight: 700;
  color: #666;
  margin-top: 16px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e0e0e0;
}

.import-category-header:first-child {
  margin-top: 0;
}

/* 표 가져오기 - 전체 가져오기 버튼 */
.import-all-btn {
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 16px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(46, 134, 222, 0.3);
}

.import-all-btn:hover {
  background: #1e6fb8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 134, 222, 0.4);
}

.import-all-btn:active {
  transform: translateY(0);
}


/* ══ 진도 체크 화면 ══ */
#progress-screen {
  position: absolute;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0;
  margin: 0;
  background: #fff;
  overflow-y: auto;
}

#progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--card);
  border-bottom: 2px solid var(--border);
}

#progress-header h2 {
  font-size: 24px;
  color: var(--primary);
  margin: 0;
}

#user-selector {
  display: flex;
  gap: 8px;
}

.user-btn {
  padding: 10px 20px;
  border: 2px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.user-btn:hover {
  background: #f0f8ff;
}

.user-btn.active {
  background: var(--accent);
  color: #fff;
}

#progress-stats {
  background: var(--card);
  padding: 24px;
  border-bottom: 2px solid var(--border);
}

#progress-chart {
  min-height: 600px;
}

#progress-table-wrap {
  padding: 24px;
  overflow-x: auto;
}

#progress-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

#progress-table thead {
  background: var(--table-head);
  color: #fff;
}

#progress-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

#progress-table th:nth-child(1) { width: 20%; }
#progress-table th:nth-child(2) { width: 50%; }
#progress-table th:nth-child(3) { width: 10%; text-align: center; }
#progress-table th:nth-child(4) { width: 20%; text-align: center; }

#progress-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

#progress-table tbody tr:hover {
  background: #f8f9fa;
}

#progress-table td {
  padding: 12px 16px;
}

.progress-title {
  font-weight: 600;
  color: var(--primary);
}

.progress-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.progress-date-tag {
  padding: 4px 10px;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 4px;
  font-size: 12px;
  color: #1976d2;
  white-space: nowrap;
}

.progress-count-cell {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.progress-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.progress-action-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.progress-action-btn.check {
  background: #4caf50;
  color: #fff;
}

.progress-action-btn.check:hover {
  background: #45a049;
}

.progress-action-btn.reset {
  background: #f44336;
  color: #fff;
}

.progress-action-btn.reset:hover {
  background: #da190b;
}

/* 날짜 드롭다운 */
.progress-dates-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-date-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-delete-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: #f44336;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.date-delete-btn:hover {
  background: #da190b;
  transform: scale(1.1);
}

.progress-dates-dropdown {
  margin-top: 6px;
}

.progress-dates-dropdown summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  user-select: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.progress-dates-dropdown summary:hover {
  background: #f0f8ff;
}

.progress-dates-old {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 이미지 크기 선택 드롭다운 */
#image-size-dropdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1001;
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#image-size-select {
  padding: 10px 12px;
  border: 2px solid #4CAF50;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: white;
  min-width: 200px;
}

#image-size-select:hover {
  border-color: #45a049;
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.2);
}

#image-size-select option {
  padding: 8px;
  border: none;
}

/* 병명 버튼 스타일 */
.disease-name-btn {
  display: inline-block !important;
  background: #e74c3c !important;
  color: #fff !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  margin: 0 2px !important;
}

.disease-name-btn a {
  color: #fff !important;
  text-decoration: none !important;
}

.disease-name-btn a:hover {
  color: #fff !important;
  text-decoration: none !important;
}

/* 증례 버튼 스타일 */
.case-name-btn {
  display: inline-block !important;
  background: #2980b9 !important;
  color: #fff !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  margin: 0 2px !important;
}

.case-name-btn a {
  color: #fff !important;
  text-decoration: none !important;
}

.case-name-btn a:hover {
  color: #fff !important;
  text-decoration: none !important;
}

/* 대본 버튼 스타일 */
.script-name-btn {
  display: inline-block !important;
  background: #222 !important;
  color: #fff !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  margin: 0 2px !important;
}

.script-name-btn a {
  color: #fff !important;
  text-decoration: none !important;
}

.script-name-btn a:hover {
  color: #fff !important;
  text-decoration: none !important;
}

/* GPT 버튼 스타일 */
.gpt-name-btn {
  display: inline-block !important;
  background: #27ae60 !important;
  color: #fff !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  margin: 0 2px !important;
}

.gpt-name-btn a {
  color: #fff !important;
  text-decoration: none !important;
}

.gpt-name-btn a:hover {
  color: #fff !important;
  text-decoration: none !important;
}

/* CPX 증례 sub-sidebar-2 */
#sub-sidebar-2 {
  position: absolute;
  right: 0;
  top: 0;
  width: 300px;
  height: 100%;
  background: #f5f5f5;
  border-left: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  z-index: 1001;
}

/* CPX 증례 페이지 화면 */
#case-page-screen {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

#case-page-header {
  background: #fff;
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #ddd;
  margin-bottom: 20px;
}

#case-page-header h2 {
  margin: 0 0 16px 0;
  font-size: 24px;
  color: #333;
}

#case-page-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* 증례 탭 바 */
#case-tab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
  border-bottom: 1.5px solid #e5e9f0;
  margin-bottom: 16px;
}

#case-content-area {
  width: 100%;
}
/* 증례 탭 번호 버튼 — CPX 카드 스타일 */
.case-tab-btn {
  width: 36px;
  height: 36px;
  background: #2e86de;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(46,134,222,.3);
}
.case-tab-btn:hover {
  background: #1f6fbf;
  transform: translateY(-1px);
}
.case-tab-btn.active {
  background: #1abc9c;
  box-shadow: 0 2px 6px rgba(26,188,156,.4);
}
/* 증례 추가 버튼 */
.case-tab-add-btn {
  padding: 0 14px;
  height: 36px;
  background: #fff;
  color: #2e86de;
  border: 2px solid #2e86de;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
  margin-left: 4px;
}
.case-tab-add-btn:hover {
  background: #2e86de;
  color: #fff;
}
/* 증례 삭제 버튼 */
.case-tab-del-btn {
  padding: 0 14px;
  height: 36px;
  background: #fff;
  color: #e74c3c;
  border: 2px solid #e74c3c;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
  margin-left: 2px;
}
.case-tab-del-btn:hover {
  background: #e74c3c;
  color: #fff;
}

#case-page-content {
  background: #fff;
  padding: 20px;
  border-radius: 6px;
  border: 1px solid #ddd;
  min-height: 400px;
}

#case-page-content img {
  max-width: 100%;
  height: auto;
  margin: 12px 0;
}

.case-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.case-table td {
  border: 1px solid #ddd;
  padding: 8px;
}

.case-table th {
  background: #f5f5f5;
  border: 1px solid #ddd;
  padding: 8px;
  font-weight: 600;
}

/* 진도체크 메뉴 숨김 (로직은 그대로, 표시만 제거) */
#btn-progress { display: none !important; }

/* 3차모의 메뉴 숨김 (로직·mock3rdChapters 유지, 표시만 제거) */
.cat-btn[data-cat="3rd-mock"] { display: none !important; }
