:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --ink: #1d2230;
  --muted: #667085;
  --line: #e2e5ec;
  --accent: #2d51ad;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefb;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --warn: #a15c00;
  --warn-soft: #fff3e0;
  --err: #b42318;
  --err-soft: #fdecea;
  --radius: 12px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a; --panel: #1b1e26; --ink: #e8eaf0; --muted: #9aa1b2; --line: #2c313d;
    --accent: #7d9cf0; --accent-ink: #0d1430; --accent-soft: #232c45;
    --ok: #6fd3a0; --ok-soft: #173326; --warn: #f1b45a; --warn-soft: #3a2b12; --err: #ff8a80; --err-soft: #3d1a17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141a; --panel: #1b1e26; --ink: #e8eaf0; --muted: #9aa1b2; --line: #2c313d;
  --accent: #7d9cf0; --accent-ink: #0d1430; --accent-soft: #232c45;
  --ok: #6fd3a0; --ok-soft: #173326; --warn: #f1b45a; --warn-soft: #3a2b12; --err: #ff8a80; --err-soft: #3d1a17;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; padding-bottom: 88px; }
button, input { font: inherit; color: inherit; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }

.top { padding: 22px 24px 8px; max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.brand h1 { font-size: 22px; }
.brand p { margin: 4px 0 0; color: var(--muted); }

.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; padding: 12px 24px; max-width: 1400px; margin: 0 auto; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; padding: 12px 16px; } .top { padding: 18px 16px 4px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.count { color: var(--muted); font-weight: 500; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.empty { color: var(--muted); margin: 8px 0; }

.editor { min-height: 320px; max-height: 60vh; overflow: auto; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; background: color-mix(in srgb, var(--panel) 92%, var(--bg)); outline: none; font-size: 14px; }
.editor:focus { border-color: var(--accent); border-style: solid; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor p { margin: 0 0 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; cursor: pointer; }

button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; font-size: 14px; }
button:hover { border-color: var(--accent); }
button.ghost { background: transparent; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; padding: 10px 22px; font-size: 15px; }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.small { padding: 3px 9px; font-size: 13px; }
button.danger:hover { border-color: var(--err); color: var(--err); }
a.btn { display: inline-block; text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; font-size: 13px; color: inherit; background: var(--panel); }
a.btn:hover { border-color: var(--accent); }

.colors { display: flex; flex-direction: column; gap: 8px; }
.color-row { display: grid; grid-template-columns: 28px 1fr auto auto auto; align-items: center; gap: 10px; font-size: 14px; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); }
.color-row code { font-size: 13px; color: var(--muted); }
.color-row input[type=color] { width: 40px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.color-sample { font-weight: 700; }

.slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.slide-card { display: flex; flex-direction: column; gap: 6px; }
.slide { position: relative; aspect-ratio: 16 / 9; background: #ddd url(sermon-bg.jpg) center / cover; border-radius: 6px; overflow: hidden; container-type: inline-size; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.slide .box { position: absolute; font-weight: 700; color: #333; text-align: left; line-height: 1.2; font-family: "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
.slide .box p { margin: 0; min-height: 1.2em; }
.slide-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }

.songs { display: flex; flex-direction: column; gap: 10px; }
.song { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.song.ready { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.song-head { display: flex; gap: 8px; align-items: center; }
.song-head .num { font-weight: 700; color: var(--muted); min-width: 24px; }
.song-head input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; background: transparent; font-weight: 600; }
.song .hints { font-size: 13px; color: var(--muted); margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 3px 9px; border-radius: 999px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.miss { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.song-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.link-row { display: flex; gap: 6px; }
.link-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; background: transparent; font-size: 13px; }
.drop { display: flex; align-items: center; justify-content: center; text-align: center; border: 1.5px dashed var(--line); border-radius: 10px; padding: 12px; color: var(--muted); font-size: 13px; cursor: pointer; }
.drop.small { padding: 16px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop input { display: none; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.results li { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px; }
.results .r-title { font-weight: 600; }
.results .r-desc { color: var(--muted); }

.bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.status { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.fname { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.fname input { width: 160px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: transparent; color: var(--ink); }
@media (max-width: 700px) { .bar { flex-wrap: wrap; padding: 10px 16px; } .fname input { width: 120px; } .status { flex-basis: 100%; } }

.library { width: min(640px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 18px; }
.library::backdrop { background: rgba(0,0,0,.35); }
.lib-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.lib-list li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 14px; }
.lib-list li .t { flex: 1; min-width: 0; font-weight: 600; }
.lib-list li .m { color: var(--muted); font-size: 12px; }

.login { width: min(400px, calc(100vw - 32px)); }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login input { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: transparent; }
.login-error { color: var(--err); font-size: 13px; margin: 0; min-height: 1em; }

.opts { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 10px; }
.opts .check { margin-top: 0; }
.font-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.font-opt select { width: 220px; max-width: 60vw; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; background: var(--panel); color: var(--ink); }
.slide .pic { position: absolute; object-fit: contain; display: grid; place-items: center; font-size: 11px; color: #666; background: rgba(255,255,255,.4); }
.slide img.pic { background: none; }
.slide-tools { display: inline-flex; gap: 6px; align-items: center; }
.slide-tools select, .img-item select, .img-target select { border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; background: var(--panel); font-size: 12px; max-width: 100%; }
.img-target { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.img-target label { display: flex; gap: 8px; align-items: center; min-width: 0; flex: 1; }
.img-target select { flex: 1; min-width: 0; font-size: 13px; padding: 5px 8px; }
.img-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.img-list:empty { display: none; }
.img-item { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.img-item .thumb { width: 84px; height: 56px; border-radius: 6px; overflow: hidden; background: var(--bg); display: grid; place-items: center; }
.img-item .thumb img { width: 100%; height: 100%; object-fit: contain; }
.img-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.err-text { color: var(--err); }
.editor img { max-width: 220px; max-height: 140px; border-radius: 6px; vertical-align: middle; outline: 2px solid var(--accent-soft); }
.slide-meta { flex-wrap: wrap; gap: 4px; }
.slide-meta button { white-space: nowrap; }

.slide-fmt { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.slide-fmt select, .all-valign select { border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; background: var(--panel); font-size: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 3px 9px; font-size: 12px; background: var(--panel); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.all-valign { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.warn-text { color: var(--warn); font-weight: 600; }

.lib-search { width: 100%; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: transparent; color: var(--ink); }
.cands { gap: 6px; }
.cand { background: var(--accent-soft); border-color: transparent; }

.who { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.login a { color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 4px; }
.tabs button { border: 0; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.login form[hidden] { display: none; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }

.notice { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; }
.login-ok { color: var(--ok); font-size: 13px; margin: 0; }
.login-ok:empty { display: none; }
.pill { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; }
.admin { width: min(760px, calc(100vw - 32px)); }
.adm-list li { flex-wrap: wrap; }
.adm-list li .t { flex: 1 1 160px; }
.adm-list li .m { flex: 1 1 220px; }
.adm-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.role { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.role-owner { background: var(--accent); color: var(--accent-ink); }
button.primary-sm { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill[hidden], .who button[hidden] { display: none; }
