/* 워십 스코어 메이커 — 밝은/어두운 화면을 같은 토큰으로 */

:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --surface-3: #e8eaf3;
  --border: #dde0ea;
  --border-strong: #c7cbd9;
  --text: #1a1c28;
  --text-2: #474c5f;
  --muted: #767b8f;
  --accent: #4648d4;
  --accent-hover: #3a3cbc;
  --accent-soft: #ecebff;
  --accent-ink: #ffffff;
  --chorus: #e6efff;
  --chorus-ink: #1d4fa8;
  --bridge: #fff0dd;
  --bridge-ink: #8a4b06;
  --verse: #eef1f6;
  --other: #f2eefb;
  --danger: #c8373a;
  --danger-soft: #fdecec;
  --ok: #1d7f47;
  --ok-soft: #e5f5ec;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --mark: #b3141a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 20, 40, .05), 0 6px 20px rgba(18, 20, 40, .06);
  --shadow-lg: 0 20px 60px rgba(18, 20, 40, .25);
  --font: "Pretendard", "Pretendard Variable", "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111218;
  --surface: #1a1c25;
  --surface-2: #22252f;
  --surface-3: #2b2e3a;
  --border: #2f3240;
  --border-strong: #3d4152;
  --text: #eceef6;
  --text-2: #b8bccb;
  --muted: #8b90a3;
  --accent: #8587ff;
  --accent-hover: #9d9fff;
  --accent-soft: #272a52;
  --accent-ink: #0f1020;
  --chorus: #1f2c48;
  --chorus-ink: #9cc0ff;
  --bridge: #3a2a14;
  --bridge-ink: #ffc98a;
  --verse: #262a35;
  --other: #2b2638;
  --danger: #ff6b6e;
  --danger-soft: #3a1f22;
  --ok: #5fd08f;
  --ok-soft: #173325;
  --warn: #f2bf5a;
  --warn-soft: #3a2f16;
  --mark: #ff6b70;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #111218;
    --surface: #1a1c25;
    --surface-2: #22252f;
    --surface-3: #2b2e3a;
    --border: #2f3240;
    --border-strong: #3d4152;
    --text: #eceef6;
    --text-2: #b8bccb;
    --muted: #8b90a3;
    --accent: #8587ff;
    --accent-hover: #9d9fff;
    --accent-soft: #272a52;
    --accent-ink: #0f1020;
    --chorus: #1f2c48;
    --chorus-ink: #9cc0ff;
    --bridge: #3a2a14;
    --bridge-ink: #ffc98a;
    --verse: #262a35;
    --other: #2b2638;
    --danger: #ff6b6e;
    --danger-soft: #3a1f22;
    --ok: #5fd08f;
    --ok-soft: #173325;
    --warn: #f2bf5a;
    --warn-soft: #3a2f16;
    --mark: #ff6b70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- 머리 */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1320px) / 2));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand-text { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-text strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.mode-badge.desktop { background: var(--ok-soft); color: var(--ok); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.lang-select {
  height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 0 8px;
}
@media (max-width: 720px) {
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand-text strong { display: none; }
  .top-actions { gap: 2px; }
  #libraryBtn .label, #quitBtn .label { display: none; }
  #libraryBtn, #quitBtn { padding: 0 9px; }
  .lang-select { max-width: 92px; }
}
.boot-error {
  margin: 16px; padding: 12px; background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius); white-space: pre-wrap; font-size: 12px;
}

/* ---------------------------------------------------------------- 배치 */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  align-items: start;
}
.main-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.panel-title { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.output-panel { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; }
.output-panel .panel-title { margin-bottom: 0; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 96px; }
  .output-panel { position: static; }
}

/* ---------------------------------------------------------------- 입력 요소 */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; }
input[type="text"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px 11px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { padding-right: 28px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.big { min-height: 48px; font-size: 16px; }
.btn.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.xs { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.link-btn {
  display: inline-flex; align-items: center; gap: 3px;
  border: 0; background: none; padding: 2px 4px; color: var(--accent);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; border-radius: 6px;
}
.link-btn:hover { background: var(--accent-soft); }

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check.sm { font-size: 13px; align-items: center; }
.check.sm input { width: 16px; height: 16px; margin: 0; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 18px; font-weight: 600; font-size: 14px; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  background: var(--surface-3); color: var(--text-2);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.notice { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text-2); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 예배 정보 */

.meta-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 14px; }
.date-row { display: flex; gap: 6px; }
.date-row input { flex: 1; min-width: 0; }
@media (max-width: 760px) { .meta-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- 순서 목록 */

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-input { flex: 1 1 280px; min-height: 44px !important; font-size: 16px; }
.add-row .btn { min-height: 44px; }
.drop-hint {
  display: none; margin-top: 10px; padding: 16px; text-align: center; font-weight: 600;
  border: 2px dashed var(--accent); border-radius: var(--radius); color: var(--accent); background: var(--accent-soft);
}
body.file-dragging .drop-hint { display: block; }

.item-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.card.active { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); box-shadow: 0 0 0 3px var(--accent-soft); }
.card.dragging { opacity: .5; }
.card.drop-before::before, .card.drop-after::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 3px; border-radius: 3px; background: var(--accent);
}
.card.drop-before::before { top: -8px; }
.card.drop-after::after { bottom: -8px; }
.card.file-over { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }

.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px; }
.grip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 32px; border: 0; background: none; color: var(--muted); cursor: grab; border-radius: 6px; flex: none;
}
.grip:hover { background: var(--surface-2); }
.grip:active { cursor: grabbing; }
.num {
  flex: none; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 99px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px;
}
.num.elem { background: var(--surface-3); color: var(--muted); }
.title-input { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 16px !important; }
.key-select { width: 134px !important; flex: none; font-weight: 700; }
.kind-select { width: 190px !important; flex: none; font-weight: 700; }
.head-actions { display: flex; gap: 2px; flex: none; }
.collapse-btn { flex: none; margin-left: -6px; }
.collapse-btn svg { transition: transform .15s; }
.card.collapsed .collapse-btn svg { transform: rotate(-90deg); }

.card-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 14px 0 104px; font-size: 13px; color: var(--text-2); min-height: 4px; }
.card-sub:empty { display: none; }
.sub-item { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sub-item.notice { padding: 3px 8px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); }
.sub-item.muted { color: var(--muted); }

.card-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.card-body.compact { padding-top: 0; padding-left: 76px; }
.card.collapsed .card-body { display: none; }
.card.collapsed .card-sub { padding-bottom: 10px; }

.score-row { display: flex; flex-direction: column; gap: 10px; }
.pages-wrap { position: relative; }
.pages { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.page-tile {
  position: relative; flex: none; width: 118px; aspect-ratio: 0.72;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; overflow: hidden;
  scroll-snap-align: start;
}
.page-tile.loading { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.page-tile.broken::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 28px; }
.tile-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.tile-open img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile-no {
  position: absolute; left: 5px; top: 5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px;
  background: rgba(20, 22, 40, .72); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.tile-marks {
  position: absolute; left: 5px; bottom: 5px; display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 99px; background: var(--mark); color: #fff; font-size: 11px; font-weight: 700;
}
.tile-actions {
  position: absolute; right: 4px; top: 4px; display: flex; gap: 2px;
  opacity: 0; transition: opacity .15s;
}
.tile-actions .icon-btn { background: rgba(255, 255, 255, .92); color: #333; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.page-tile:hover .tile-actions, .page-tile:focus-within .tile-actions { opacity: 1; }
@media (hover: none) { .tile-actions { opacity: 1; } }
.add-tile {
  flex: none; width: 118px; aspect-ratio: 0.72;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-2); cursor: pointer; text-align: center;
}
.add-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.add-tile strong { font-size: 13px; }
.add-tile small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.busy {
  position: absolute; inset: 0 0 6px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px; color: var(--text-2);
}
.score-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.form-row { display: flex; flex-direction: column; gap: 8px; }
.row-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  border-radius: 99px; padding: 5px 11px; font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.2;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.part-chorus { background: var(--chorus); color: var(--chorus-ink); border-color: transparent; }
.chip.part-bridge { background: var(--bridge); color: var(--bridge-ink); border-color: transparent; }
.sequence {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
}
.sequence .hint { font-size: 13px; color: var(--muted); }
.sequence .arrow { color: var(--muted); font-size: 13px; }
.pill {
  display: inline-flex; align-items: center; border-radius: 99px; overflow: hidden; cursor: grab;
  background: var(--surface); border: 1px solid var(--border-strong); font-weight: 700; font-size: 14px;
}
.pill.part-chorus { background: var(--chorus); color: var(--chorus-ink); border-color: transparent; }
.pill.part-bridge { background: var(--bridge); color: var(--bridge-ink); border-color: transparent; }
.pill.part-verse { background: var(--verse); }
.pill.part-prayer, .pill.part-tag, .pill.part-interlude { background: var(--other); }
.pill-label { border: 0; background: none; padding: 4px 4px 4px 11px; font-weight: 700; cursor: pointer; }
.pill-x { border: 0; background: none; padding: 4px 8px 4px 4px; color: inherit; opacity: .6; cursor: pointer; display: inline-flex; }
.pill-x:hover { opacity: 1; }

.fields-row { display: flex; gap: 10px; flex-wrap: wrap; }
.fields-row .field.sm { width: 96px; }
.fields-row .field.grow { flex: 1 1 260px; }

.empty { margin-top: 18px; padding: 26px 20px; text-align: center; border: 2px dashed var(--border); border-radius: var(--radius); }
.empty h3 { margin: 0 0 14px; font-size: 18px; }
.steps { list-style: none; margin: 0 auto; padding: 0; max-width: 520px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.steps li { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); }
.step-no {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 13px;
}

@media (max-width: 640px) {
  .panel { padding: 14px; }
  .card-head { flex-wrap: wrap; }
  .title-input { flex-basis: calc(100% - 80px); order: 1; }
  .grip { order: 0; }
  .num { order: 0; }
  .key-select, .kind-select { order: 2; flex: 1 !important; width: auto !important; }
  .head-actions { order: 3; }
  .card-sub, .card-body.compact { padding-left: 14px; }
  .page-tile, .add-tile { width: 96px; }
}

/* ---------------------------------------------------------------- 출력 */

.options { display: flex; flex-direction: column; gap: 10px; }
.out-actions { display: flex; flex-direction: column; gap: 8px; }
.out-actions .btn { width: 100%; }
.mobile-bar { display: none; }
@media (max-width: 1000px) {
  .mobile-bar {
    display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .mobile-bar .btn { flex: 1; min-height: 46px; }
}
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }

.progress {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-weight: 600;
}

/* ---------------------------------------------------------------- 알림 */

.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100vw - 32px));
  pointer-events: none;
}
@media (max-width: 1000px) { .toasts { bottom: 86px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: #23253a; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: toast-in .2s ease-out; transition: opacity .25s, transform .25s;
}
.toast-error { background: #9e2327; }
.toast-warn { background: #7a5200; }
.toast-ok { background: #17663a; }
.toast.leaving { opacity: 0; transform: translateY(8px); }
.toast-action { border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; border-radius: 6px; padding: 4px 10px; font-weight: 700; cursor: pointer; flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- 대화상자·메뉴 */

.modal-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(10, 12, 24, .55);
}
.modal {
  width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.confirm-text { margin: 0; font-size: 15px; }

.menu-pop {
  position: absolute; z-index: 80; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; text-align: left; cursor: pointer; color: var(--text); text-decoration: none; font-size: 14px;
}
.menu-item:hover, .menu-item:focus { background: var(--surface-2); outline: none; }

/* 웹 악보 찾기 */
.search-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-bar .grow { flex: 1 1 260px; }
.search-bar .field.inline select { width: 120px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.grid-msg { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 30px; color: var(--muted); }
.grid-msg.error { color: var(--danger); }
.result-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.result-card.is-store { opacity: .85; }
.result-thumb { aspect-ratio: .75; background: #fff; display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.result-thumb img { width: 100%; height: 100%; object-fit: contain; }
.result-thumb img.broken { visibility: hidden; }
.result-meta { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 4px; }
.result-title { font-size: 13px; font-weight: 700; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.result-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.result-actions .btn { flex: 1; }

/* 악보 위 송폼 표시 */
.marker-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.marker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.marker-custom { width: 180px !important; }
.marker-scroll { overflow: auto; max-height: 70vh; text-align: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px; }
.marker-stage { position: relative; display: inline-block; cursor: crosshair; min-width: 200px; min-height: 200px; }
.marker-stage.loading { background: var(--surface-3); }
.marker-stage img { display: block; max-height: 66vh; width: auto; background: #fff; box-shadow: var(--shadow); user-select: none; -webkit-user-select: none; }
.marker-layer { position: absolute; inset: 0; pointer-events: none; }
.marker {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto;
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 3px 2px 7px;
  background: #fff; color: var(--mark); border: 2px solid var(--mark); border-radius: 6px;
  font-weight: 800; font-size: 14px; cursor: move; touch-action: none; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.marker.view { padding: 2px 7px; cursor: default; }
.marker-x { border: 0; background: none; color: var(--mark); padding: 2px; cursor: pointer; display: inline-flex; }

.batch-text { min-height: 180px; }

/* 콘티 목록 */
.library-top { display: flex; gap: 8px; flex-wrap: wrap; }
.library-list { display: flex; flex-direction: column; gap: 8px; }
.library-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.library-row.current { border-color: var(--accent); background: var(--accent-soft); }
.library-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.library-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.help-section h3 { margin: 4px 0 6px; font-size: 15px; }
.help-section p, .help-section ol { margin: 0 0 6px; color: var(--text-2); }
.help-section ol { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- 보면대 모드 */

body.stand-open { overflow: hidden; }
.stand { position: fixed; inset: 0; z-index: 100; background: #2a2b31; color: #fff; display: flex; flex-direction: column; }
.stand-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: #1c1d22; z-index: 2; }
.stand-bar .btn { background: #2f3139; color: #fff; border-color: #444754; }
.stand-bar .btn.on { background: #4648d4; border-color: #4648d4; }
.stand-bar .icon-btn { color: #ddd; }
.stand-info { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stand-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.stand-count { font-variant-numeric: tabular-nums; color: #bbb; margin-right: 4px; font-size: 14px; }
.stand-stage { flex: 1; display: flex; gap: 8px; padding: 8px; min-height: 0; justify-content: center; }
.stand-page { flex: 1; min-width: 0; max-width: 100%; display: flex; flex-direction: column; background: #fff; color: #111; border-radius: 4px; overflow: hidden; }
.stand-stage.two .stand-page { max-width: 50%; }
.stand-head { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; padding: 6px 12px; background: #f1f2f8; border-bottom: 1px solid #dde0ea; font-size: 14px; }
.stand-head strong { font-size: 16px; }
.stand-head.compact { color: #555; font-size: 13px; }
.stand-form { color: #1d4fa8; font-weight: 700; }
.stand-memo { color: #555; }
.stand-frame { position: relative; flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
.stand-frame img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.stand-frame .marker-layer { position: absolute; inset: auto; }
.stand-page.empty { align-items: center; justify-content: center; text-align: center; padding: 20px; }
.stand-empty { margin: auto; color: #ccc; }
.stand-zone { position: absolute; top: 56px; bottom: 0; width: 22%; border: 0; background: transparent; cursor: pointer; z-index: 1; }
.stand-zone.left { left: 0; }
.stand-zone.right { right: 0; }
.stand.night .stand-page { background: #000; }
.stand.night .stand-frame img { filter: invert(1) hue-rotate(180deg); }
.stand.night .stand-head { background: #111; color: #ddd; border-color: #333; }

.quit-screen { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 8px; padding: 20px; }

@media print {
  .topbar, .output-panel, .mobile-bar, .toasts { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
