/* ── 리셋 & 기본 ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
}

:root {
  --sidebar-w: 220px;
  --bg: #f5f6fa;
  --card: #fff;
  --border: #e0e0e0;
  --primary: #2e1bb8;
  --primary-light: #ede9ff;
  --accent: #0f92cd;
  --off: #e22143;
  --part: #0f92cd;
  --on: #2e1bb8;
  --text: #1a1a2e;
  --muted: #888;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .08);
}

body {
  display: flex;
  height: 100vh;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ── 사이드바 ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

#sidebar-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
}

#sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

#sidebar-title-row h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

#btn-all-groups {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0;
}

#btn-all-groups:hover {
  color: var(--primary);
}

#search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

#search {
  flex: 1;
  min-width: 0;
  padding: 0 28px 0 10px;
  height: 34px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

#search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* 돋보기 버튼 (오른쪽) */
#search-icon {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 4px;
  transition: background .15s;
}

#search-icon:hover {
  background: var(--border);
}

#search-icon::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

#search-icon::after {
  content: '';
  display: block;
  width: 4px;
  height: 2px;
  background: var(--muted);
  border-radius: 1px;
  margin-left: -2px;
  margin-top: 6px;
  transform: rotate(45deg);
}

#search-wrap.has-value #search-icon {
  display: none;
}

#search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  display: none;
  line-height: 1;
  transition: color .15s, background .15s;
}

#search-clear:hover {
  color: var(--text);
  background: var(--border);
}

#search-count {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  min-height: 0;
  line-height: 1.2;
}

#sidebar-month-label {
  padding: 8px 14px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

#status-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 8px 0;
}

.status-tab {
  flex: 1;
  padding: 4px 0;
  border: none;
  border-radius: 4px;
  background: none;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  transition: background .1s, color .1s;
}

.status-tab:hover {
  background: var(--bg);
  color: var(--text);
}

.status-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.hosp-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hosp-status-emoji {
  font-size: 13px;
  flex-shrink: 0;
}

#hospital-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 8px 0;
}

#hospital-list li {
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 6px;
  margin: 2px 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s;
}

#hospital-list li.search-empty {
  cursor: default;
  color: var(--muted);
  font-size: 12px;
  justify-content: center;
  padding: 20px 0;
  flex-direction: column;
  gap: 4px;
}

#hospital-list li.search-empty::before {
  content: '검색 결과 없음';
  font-size: 13px;
}

mark {
  background: #fff3b0;
  color: var(--text);
  border-radius: 2px;
  padding: 0 1px;
}

#hospital-list li:hover {
  background: var(--bg);
}

#hospital-list li.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.group-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
}

#btn-add-hospital {
  margin: 10px;
  padding: 10px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  transition: all .2s;
}

#btn-add-hospital:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── 메인 ── */
#main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
}

#empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--muted);
  font-size: 16px;
}

#editor {
  display: flex;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ─ 편집 패널 ─ */
#edit-panel {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
}

/* ─ 패널 리사이저 ─ */
#panel-resizer {
  width: 5px;
  min-width: 5px;
  cursor: col-resize;
  background: var(--border);
  flex-shrink: 0;
  transition: background .15s;
  position: relative;
  z-index: 10;
}

#panel-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -4px;
}

#panel-resizer:hover,
#panel-resizer.dragging {
  background: var(--primary);
}

/* ─ 미리보기 패널 ─ */
#preview-panel {
  flex: 1; /* 가변 너비로 변경 */
  min-width: 400px;
  min-height: 0;
  border-left: none;
  background: #e8e8ee;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#info-panel {
  flex: 0 0 320px;
  min-width: 250px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#preview-header {
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  gap: 6px;
}

#preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#btn-open-preview {
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0;
}

#btn-open-preview:hover {
  color: var(--primary);
}

#preview-size-btns {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.btn-size {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  cursor: pointer;
  transition: all .15s;
}

.btn-size.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

#preview-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

#preview-week-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #f97316;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 14px;
  border-radius: 100px;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(249,115,22,.4);
}

#preview-wrap.week-focused #preview-scaler {
  outline: 2px solid #f97316;
  outline-offset: 2px;
}

#preview-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
}

#preview-footer #btn-generate {
  font-size: 16px;
  padding: 14px;
  border-radius: 12px;
  width: 95%;
}

#preview-scaler {
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .18);
}

#preview-frame {
  display: block;
  border: none;
  background: transparent;
  transform-origin: top left;
  overflow: hidden;
}

/* ── 에디터 헤더 ── */
#editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

#editor-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

#editor-title h1 {
  font-size: 20px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 4px;
  margin: 0 -4px;
  outline: none;
  cursor: text;
}

#editor-title h1:hover {
  background: var(--bg);
}

#editor-title h1:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--primary-light);
}

#editor-title #hospital-group {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

#editor-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

#save-status {
  margin-right: 6px;
}

#btn-save,
#btn-delete-hospital {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

#btn-save:hover {
  border-color: var(--primary);
  color: var(--primary);
}

#btn-delete-hospital:hover {
  border-color: var(--off);
  color: var(--off);
}

/* ── 이미지 설정 ── */
.image-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.image-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.image-block-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  width: 60px;
  flex-shrink: 0;
}

.image-preview-wrap {
  width: 56px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  flex-shrink: 0;
}

.img-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.img-placeholder {
  font-size: 10px;
  color: var(--muted);
}

.btn-upload {
  font-size: 12px;
  padding: 0 12px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  transition: border-color .15s, color .15s, transform .1s;
}

.btn-upload input[type="file"] {
  display: none;
}

.btn-upload:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-img-del {
  font-size: 12px;
  padding: 0 12px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--off);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color .15s, background .15s, transform .1s;
}

.btn-img-del:hover {
  border-color: var(--off);
  background: #fff0f0;
}

.image-block-options {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-block-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.image-block-options input[type="number"] {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
}

.image-showon {
  display: flex;
  align-items: center; /* 세로 중앙 정렬 */
  gap: 6px;
  font-size: 12px;
  margin-top: 8px;
}

.image-showon span,
.image-showon .opt-label {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: normal;
}

.showon-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.opt-group {
  display: flex;
  align-items: center;
  gap: 16px; /* 항목 사이 여백 늘림 */
  flex-wrap: wrap;
  font-size: 12px;
}

.opt-label {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

#preview-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 16px;
  position: relative;
}

#preview-scaler {
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .18);
}

#btn-generate {
  flex-shrink: 0;
  font-size: 15px;
  padding: 12px 30px;
  border-radius: 10px;
  width: auto;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ── 병원 사이드바 (정보 패널 내부) ── */
#hospital-sidebar {
  flex: 1;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── CSS 조절 패널 ── */
#css-tuning-panel {
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
}

.tuning-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.tuning-panel-header > span {
  font-weight: 600;
  font-size: 13px;
}

.tuning-size-label {
  font-weight: 400;
  font-size: 11px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}


.tuning-preview-mode { display: flex; gap: 4px; margin-left: auto; }

.btn-preview-mode {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg);
}

.btn-preview-mode.active {
  background: #555;
  color: #fff;
  border-color: #555;
}

#tuning-week-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.btn-tuning-week {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg);
}

.btn-tuning-week.active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

/* 해당 주차에 저장된 값이 있을 때 오렌지 점 표시 */
.btn-tuning-week.has-week-data::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f97316;
  margin-left: 3px;
  vertical-align: middle;
  position: relative;
  top: -1px;
}
.btn-tuning-week.active.has-week-data::after {
  background: #fed7aa;
}

/* 슬라이더 행 라벨 내 주차별 뱃지 */


.tuning-element-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 4px 6px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

#tuning-sliders { display: flex; flex-direction: column; gap: 8px; }

.tuning-slider-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tuning-slider-row label {
  width: 90px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.tuning-slider-row input[type="range"] {
  flex: 1;
  height: 4px;
  cursor: pointer;
}

.tuning-slider-row .tuning-val-input {
  width: 52px;
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-align: right;
}

.tuning-slider-row .tuning-text-input {
  flex: 1;
  width: auto;
  text-align: left;
  font-size: 11px;
}

.tuning-toggle-group { display: flex; gap: 6px; }

.btn-small.active {
  background: #4f46e5;
  color: #fff;
}

.tuning-actions { margin-top: 10px; }

.tuning-save-row { display: flex; gap: 6px; margin-bottom: 6px; }

.btn-tuning-save {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg);
}

.btn-tuning-save.accent {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.tuning-restore-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.tuning-restore-row button {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  background: var(--bg);
}

.tuning-history-wrap { position: relative; }

#tuning-history-list {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  min-width: 160px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#tuning-history-list li {
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

#tuning-history-list li:hover { background: var(--hover, #f0f0f0); }

.sidebar-homepage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sidebar-homepage-row #btn-homepage {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  background: var(--bg);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-homepage-row #btn-homepage:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.sidebar-homepage-row #homepage-url {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg);
}

/* ── 메모 & 투두 ── */
.todo-section-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  margin-top: 4px;
}

.todo-section-header span {
  font-weight: 400;
  color: var(--muted);
}

#hospital-memo,
#request-memo {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 10px;
}

.todo-group {
  margin-top: 10px;
}

.todo-group+.todo-group {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.todo-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

#hospital-todos,
#global-todos {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.todo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
}

.todo-item label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex: 1;
}

.todo-item span.done {
  text-decoration: line-through;
  color: var(--muted);
}

.btn-todo-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 11px;
}

.btn-todo-del:hover {
  color: var(--off);
}

.todo-add-row {
  display: flex;
  gap: 5px;
}

.todo-add-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.todo-add-row button {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
}

#generate-group {
  display: flex;
  gap: 6px;
}

#generate-size {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

/* ── 버튼 ── */
.btn-primary,
.btn-secondary,
.btn-accent,
.btn-small {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color .15s, opacity .15s, transform .1s, box-shadow .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  opacity: .88;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

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

.btn-accent:hover {
  opacity: .88;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-accent:disabled,
.btn-small:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 28px;
}

/* ── 패널 섹션 (공통 카드) ── */
.panel-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
  padding-left: 8px;
  line-height: 1;
}

.section-header-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-with-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.settings-row {
  display: flex;
  align-items: flex-start; /* 무조건 상단 기준 정렬 */
  flex-wrap: wrap;
  gap: 16px;
}

.label-with-hint {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  height: 30px; /* 레이블 높이를 고정해서 옆 항목들과 라인을 맞춤 */
}

.panel-section select {
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  cursor: pointer;
  height: 34px;
  transition: border-color .15s, box-shadow .15s;
}

.panel-section .checkbox-label {
  font-weight: 500;
}

/* 폼 요소 확장 */
.field-stacked {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.muted-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.input-full {
  width: 100%;
  padding: 0 10px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.input-full:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.nday-row {
  flex-direction: column;
  align-items: flex-start !important;
  gap: 10px !important;
}

#nday-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-section input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ── 공지 문구 (구조화 행) ── */

.notice-actions,
.field-actions {
  display: flex;
  gap: 4px;
}

/* 공지 섹션: 타이틀 아래 바로 리스트가 오므로 여백 축소 */
.panel-section:has(#notice-list) .section-title {
  margin-bottom: 6px;
}

.notice-actions button,
.field-actions button {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  font-size: 12px;
  cursor: pointer;
  transition: background .1s;
}

.notice-actions button:hover,
.field-actions button:hover {
  background: var(--primary-light);
}

.field-actions button.btn-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.field-actions button.btn-active:hover {
  background: var(--primary-dark, #1a5fc7);
}

.notice-action-icon {
  padding: 2px 6px !important;
  color: var(--muted);
}

.notice-action-icon.active {
  background: var(--primary-light) !important;
  border-color: var(--primary-light) !important;
  color: var(--primary) !important;
}

#notice-fmt-panel {
  margin-bottom: 6px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#notice-fmt-panel label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

#notice-fmt-panel input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.fmt-hint {
  font-size: 10px;
  color: #bbb;
  width: 100%;
  padding-left: 2px;
}

#notice-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#notice-add-row {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

#notice-add-row #notice-add {
  padding: 4px 24px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

#notice-add-row #notice-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.notice-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.notice-auto-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  flex-shrink: 0;
}

.notice-row-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── 스타일 토글 버튼 ── */
.notice-style-btns {
  display: flex;
  gap: 2px;
  flex: 1;
}

.nsb {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  cursor: pointer;
  background: var(--card);
  color: var(--muted);
  white-space: nowrap;
  transition: border-color .1s, background .1s, color .1s;
}

.nsb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.12);
}

.nsb-none .nsb-dot {
  background: #fff;
  border-style: dashed;
  border-color: #bbb;
}

.nsb.active {
  border-color: #888;
  background: #f0f0f0;
  color: var(--text);
}

/* ── 미니 서식 툴바 (포커스 시 노출) ── */
.notice-mini-toolbar {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.notice-row:focus-within .notice-mini-toolbar {
  display: flex;
}

.notice-fmt-btn {
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card);
  cursor: pointer;
  color: var(--text);
}

.notice-fmt-btn:hover { background: var(--primary-light); }

.notice-del-btn {
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.notice-del-btn:hover {
  background: #fff0f2;
  border-color: var(--off);
  color: var(--off);
}

/* ── 공지 텍스트 (contenteditable) ── */
.notice-row-text {
  min-height: 22px;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 13px;
  outline: none;
  cursor: text;
  line-height: 1.5;
}

.notice-row-text:empty::before {
  content: attr(data-placeholder);
  color: #bbb;
  pointer-events: none;
}

.notice-row-text:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--primary-light);
  border-radius: 3px;
}

/* ── 일정 선택 피커 ── */
#notice-schedule-picker {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  overflow: hidden;
  font-size: 12px;
}

.nsp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-weight: 700;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.nsp-header button {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card);
  font-size: 11px;
  cursor: pointer;
  color: var(--muted);
}

.nsp-list {
  list-style: none;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nsp-item label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nsp-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.nsp-badge {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
}

.nsp-badge.em-part { background: #e8f7ff; color: var(--part); }
.nsp-badge.em-off  { background: #fff0f2; color: var(--off); }

.nsp-empty {
  padding: 12px 10px;
  color: var(--muted);
  text-align: center;
}

.nsp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.nsp-footer button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card);
  font-size: 12px;
  cursor: pointer;
}

.nsp-footer .nsp-confirm {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.nsp-footer .nsp-confirm:hover { opacity: .88; }

.format-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.format-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── 월 네비게이션 ── */
#month-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

.month-nav-center {
  display: flex;
  align-items: center;
  gap: 20px;
}

.month-nav-side {
  display: flex;
  justify-content: flex-end;
}

#month-nav button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}

#month-nav button:hover {
  background: var(--primary-light);
}

#month-nav #btn-this-month {
  width: auto;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  border-color: var(--primary);
}

#current-month-label {
  font-size: 18px;
  font-weight: 700;
  min-width: 100px;
  text-align: center;
}

/* ── 달력 편집 테이블 ── */
#calendar-editor {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

#edit-table {
  width: 100%;
  border-collapse: collapse;
}

#edit-table th {
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
}

#edit-table th.sun {
  color: #ffb3b3;
}

#edit-table th.sat {
  color: #b3d4ff;
}

#edit-table td {
  width: 14.28%;
  height: 96px;
  border: 1px solid var(--border);
  vertical-align: top;
  padding: 6px 4px 4px;
  cursor: pointer;
  transition: background .1s;
  position: relative;
  text-align: center;
}

.cell-actions {
  display: none;
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  gap: 2px;
  background: rgba(255,255,255,.92);
  border-radius: 4px;
  padding: 1px 2px;
}

#edit-table td:hover .cell-actions {
  display: flex;
}

.cell-btn-edit,
.cell-btn-del {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  color: var(--muted);
}

.cell-btn-edit:hover { color: var(--primary); background: var(--primary-light); }
.cell-btn-del:hover  { color: var(--off);     background: #fff0f2; }

#edit-table td:hover {
  background: #f0f0ff;
}

#edit-table td.other-month {
  opacity: .35;
}

#edit-table td.day-sunday .day-num {
  color: var(--off);
}

#edit-table td.day-saturday .day-num {
  color: var(--on);
}

.day-num {
  font-size: 16px;
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

.day-name {
  display: block;
  font-size: 10px;
  color: #555;
  font-weight: 600;
  margin-bottom: 2px;
  cursor: pointer;
  line-height: 1.3;
}

.day-name:hover {
  color: var(--primary);
  text-decoration: underline;
}

.day-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  display: inline-block;
}

/* 상태별 셀 색상 */
td.state-off {
  background: #fff0f2;
}

td.state-off .day-tag {
  background: var(--off);
  color: #fff;
}

td.state-on {
  background: #f0f0ff;
}

td.state-on .day-tag {
  background: var(--on);
  color: #fff;
}

td.state-part {
  background: #e8f7ff;
}

td.state-part .day-tag {
  background: var(--part);
  color: #fff;
}

/* 국경일 표시 */
td.is-holiday .day-num::after {
  content: '●';
  font-size: 6px;
  color: var(--off);
  position: absolute;
  top: 4px;
  right: 4px;
}

/* ── 범례 ── */
#legend {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legend-item {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
}

.legend-item.normal {
  background: #f0f0f0;
  color: var(--text);
}

.legend-item.off {
  background: var(--off);
  color: #fff;
}

.legend-item.part {
  background: var(--part);
  color: #fff;
}

.legend-item.on {
  background: var(--on);
  color: #fff;
}

.legend-tip {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

/* ── 커스텀 일정 패널 ── */
#custom-schedule-panel h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#schedule-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.schedule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
}

.schedule-item .schedule-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.schedule-type {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  background: #eee;
  color: #555;
}

.schedule-type.override {
  background: #fff0f2;
  color: var(--off);
}

.schedule-type.batch {
  background: #fff8e0;
  color: #b8860b;
}

.btn-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

.btn-remove:hover {
  color: var(--off);
}

.schedule-notice-hint {
  font-size: 11px;
  color: var(--accent);
  background: #e8f7ff;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

/* ── 모달 ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 24px 24px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
}

.modal-box h3 {
  margin-bottom: 16px;
  font-size: 16px;
}

.modal-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.modal-box input,
.modal-box select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── 저장 상태 ── */
#save-status {
  font-size: 12px;
  font-weight: 700;
  transition: opacity .3s;
}

#save-status.dirty {
  color: #e67e22;
}

#save-status.saved {
  color: #2e8b57;
}

/* ── 병원 삭제 버튼 ── */
.btn-delete-hospital {
  opacity: 0;
  pointer-events: none;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity .15s;
}

#hospital-list li:hover .btn-delete-hospital {
  opacity: 1;
  pointer-events: auto;
}

.btn-delete-hospital:hover {
  color: var(--off);
}

/* ── 미리보기 탭 비활성화 ── */
.btn-size.tab-disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ── 일정 수정 버튼 ── */
.btn-edit {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
}

.btn-edit:hover {
  color: var(--primary);
}

.schedule-actions {
  display: flex;
  gap: 2px;
}

/* ── 토스트 ── */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 22px;
  border-radius: 100px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  z-index: 2000;
}

#toast.show {
  opacity: 1;
}

.tuning-section-header {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.tuning-section-header:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* ── BG 이미지 업로드 존 ─────────────────────────────────── */
.bg-upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 14px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.8;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.bg-upload-zone:hover,
.bg-upload-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.bg-upload-zone-icon {
  font-size: 1.3rem;
  display: block;
  margin-bottom: 2px;
}
.bg-upload-zone.has-image {
  border-style: solid;
  border-color: var(--accent);
  padding: 0;
  overflow: hidden;
}
.bg-upload-preview {
  height: 60px;
  background-size: cover;
  background-position: center;
  cursor: pointer;
}
.bg-upload-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: var(--surface-2);
  font-size: 0.68rem;
}
.bg-upload-bar-name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.bg-upload-bar-remove {
  color: #e55;
  cursor: pointer;
  flex-shrink: 0;
}
.bg-upload-bar-remove:hover { text-decoration: underline; }

/* ── BG 라이브러리 토글 + 그리드 ────────────────────────── */
.bg-library-toggle {
  text-align: right;
  margin-top: 5px;
  font-size: 0.68rem;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}
.bg-library-toggle:hover { text-decoration: underline; }
.bg-library-grid {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-top: 5px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.bg-library-item {
  border-radius: 5px;
  border: 1.5px solid var(--border);
  height: 38px;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  position: relative;
  transition: border-color 0.1s;
}
.bg-library-item:hover { border-color: var(--accent); }
.bg-library-item.selected { border: 2px solid var(--accent); }
.bg-library-item.selected::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 3px;
  background: var(--accent);
  border-radius: 50%;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  color: #fff;
}
.bg-library-add {
  border: 1.5px dashed var(--border);
  border-radius: 5px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.bg-library-add:hover { border-color: var(--accent); color: var(--accent); }

/* ── BG 존 하단 푸터 (그룹 정보 + 링크) ─────────────────── */
.bg-upload-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.68rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.bg-upload-footer-label {
  color: var(--muted);
  position: relative;
  cursor: default;
}
.bg-upload-footer-label .bg-tooltip {
  display: none;
  position: absolute;
  bottom: 18px;
  left: 0;
  background: #333;
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 20;
  pointer-events: none;
}
.bg-upload-footer-label:hover .bg-tooltip { display: block; }
.bg-upload-footer-action {
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.bg-upload-footer-action:hover { text-decoration: underline; }
.bg-upload-footer-action.danger { color: #e55; }

/* ── 병원 오버라이드 상태 ────────────────────────────────── */
.bg-upload-zone.override-mode {
  border-color: var(--accent);
  border-style: solid;
  border-width: 2px;
}
.bg-override-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── 인터랙션: Focus-visible & Active ─────────────────────── */

/* 메인 버튼 포커스 */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-accent:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 메인 버튼 액티브 */
.btn-primary:active,
.btn-accent:active {
  opacity: .75;
  transform: scale(0.97);
}

.btn-secondary:active {
  background: var(--border);
  transform: scale(0.97);
}

/* small 버튼 */
.btn-small:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-small:active {
  opacity: .75;
  transform: scale(0.96);
}

/* 업로드·삭제 버튼 */
.btn-upload:focus-visible,
.btn-img-del:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-upload:active {
  transform: scale(0.96);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-img-del:active {
  transform: scale(0.96);
}

/* 미리보기 모드 / 튜닝 주차 버튼 */
.btn-preview-mode:focus-visible,
.btn-tuning-week:focus-visible,
.btn-tuning-save:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-preview-mode:active,
.btn-tuning-week:active,
.btn-tuning-save:active {
  transform: scale(0.95);
}

/* Select 포커스 */
.panel-section select:focus,
.panel-section select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* 검색 액티브 */
#search:focus-visible {
  outline: none; /* box-shadow로 대체 */
}
